We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 42550321 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x

parents 23a8645a 1ef8efe4
......@@ -81,7 +81,7 @@ class AllAction extends ProfileAction
function title()
{
if ($this->page > 1) {
return sprintf(_("%1$s and friends, page %2$d"), $this->user->nickname, $this->page);
return sprintf(_('%1$s and friends, page %2$d'), $this->user->nickname, $this->page);
} else {
return sprintf(_("%s and friends"), $this->user->nickname);
}
......
......@@ -303,8 +303,8 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
$access = ($this->app->access_type & Oauth_application::$writeAccess) ?
'access and update' : 'access';
$msg = _("The application <strong>%s</strong> by <strong>%s</strong> would like " .
"the ability to <strong>%s</strong> your account data.");
$msg = _("The application <strong>%1$s</strong> by <strong>%2$s</strong> would like " .
"the ability to <strong>%3$s</strong> your account data.");
$this->raw(sprintf($msg,
$this->app->name,
......
......@@ -72,7 +72,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
function prepare($args)
{
parent::prepare($args);
common_debug("api friends_timeline");
$this->user = $this->getTargetUser($this->arg('id'));
if (empty($this->user)) {
......
......@@ -141,7 +141,7 @@ class ConfirmaddressAction extends Action
function title()
{
return _('Confirm Address');
return _('Confirm address');
}
/**
......
......@@ -51,7 +51,7 @@ class EditApplicationAction extends OwnerDesignAction
function title()
{
return _('Edit Application');
return _('Edit application');
}
/**
......
......@@ -49,7 +49,7 @@ class NewApplicationAction extends OwnerDesignAction
function title()
{
return _('New Application');
return _('New application');
}
/**
......
......@@ -68,7 +68,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
function title()
{
return _('Connected Applications');
return _('Connected applications');
}
function isReadOnly($args)
......
......@@ -57,7 +57,7 @@ class OthersettingsAction extends AccountSettingsAction
function title()
{
return _('Other Settings');
return _('Other settings');
}
/**
......
......@@ -265,7 +265,7 @@ class ShowApplicationAction extends OwnerDesignAction
$this->elementEnd('dl');
$this->element('p', 'note',
_('Note: We support hmac-sha1 signatures. We do not support the plaintext signature method.'));
_('Note: We support HMAC-SHA1 signatures. We do not support the plaintext signature method.'));
$this->elementEnd('div');
$this->elementStart('p', array('id' => 'application_action'));
......@@ -325,4 +325,3 @@ class ShowApplicationAction extends OwnerDesignAction
}
}
......@@ -266,5 +266,6 @@ class VersionAction extends Action
'Craig Andrews',
'mEDI',
'Brett Taylor',
'Brigitte Schuster');
'Brigitte Schuster',
'Brion Vibber');
}
......@@ -154,17 +154,23 @@ class Inbox extends Memcached_DataObject
$ids = unpack('N*', $inbox->notice_ids);
if (!empty($since_id)) {
$i = array_search($since_id, $ids);
if ($i !== false) {
$ids = array_slice($ids, 0, $i - 1);
$newids = array();
foreach ($ids as $id) {
if ($id > $since_id) {
$newids[] = $id;
}
}
$ids = $newids;
}
if (!empty($max_id)) {
$i = array_search($max_id, $ids);
if ($i !== false) {
$ids = array_slice($ids, $i - 1);
$newids = array();
foreach ($ids as $id) {
if ($id <= $max_id) {
$newids[] = $id;
}
}
$ids = $newids;
}
$ids = array_slice($ids, $offset, $limit);
......
......@@ -203,7 +203,7 @@ class ApplicationEditForm extends Form
$maxDesc = Oauth_application::maxDesc();
if ($maxDesc > 0) {
$descInstr = sprintf(_('Describe your application in %d chars'),
$descInstr = sprintf(_('Describe your application in %d characters'),
$maxDesc);
} else {
$descInstr = _('Describe your application');
......
......@@ -92,6 +92,19 @@ abstract class AuthenticationPlugin extends Plugin
return false;
}
/**
* Given a username, suggest what the nickname should be
* Used during autoregistration
* Useful if your usernames are ugly, and you want to suggest
* nice looking nicknames when users initially sign on
* @param username
* @return string nickname
*/
function suggestNicknameForUsername($username)
{
return $username;
}
//------------Below are the methods that connect StatusNet to the implementing Auth plugin------------\\
function onInitializePlugin(){
if(!isset($this->provider_name)){
......@@ -108,10 +121,22 @@ abstract class AuthenticationPlugin extends Plugin
function onAutoRegister($nickname, $provider_name, &$user)
{
if($provider_name == $this->provider_name && $this->autoregistration){
$user = $this->autoregister($nickname);
if($user){
User_username::register($user,$nickname,$this->provider_name);
return false;
$suggested_nickname = $this->suggestNicknameForUsername($nickname);
$test_user = User::staticGet('nickname', $suggested_nickname);
if($test_user) {
//someone already exists with the suggested nickname, so used the passed nickname
$suggested_nickname = $nickname;
}
$test_user = User::staticGet('nickname', $suggested_nickname);
if($test_user) {
//someone already exists with the suggested nickname
//not much else we can do
}else{
$user = $this->autoregister($suggested_nickname);
if($user){
User_username::register($user,$nickname,$this->provider_name);
return false;
}
}
}
}
......@@ -122,23 +147,30 @@ abstract class AuthenticationPlugin extends Plugin
$user_username->username=$nickname;
$user_username->provider_name=$this->provider_name;
if($user_username->find() && $user_username->fetch()){
$username = $user_username->username;
$authenticated = $this->checkPassword($username, $password);
$authenticated = $this->checkPassword($user_username->username, $password);
if($authenticated){
$authenticatedUser = User::staticGet('id', $user_username->user_id);
return false;
}
}else{
$user = User::staticGet('nickname', $nickname);
//$nickname is the username used to login
//$suggested_nickname is the nickname the auth provider suggests for that username
$suggested_nickname = $this->suggestNicknameForUsername($nickname);
$user = User::staticGet('nickname', $suggested_nickname);
if($user){
//make sure a different provider isn't handling this nickname
//make sure this user isn't claimed
$user_username = new User_username();
$user_username->username=$nickname;
if(!$user_username->find()){
//no other provider claims this username, so it's safe for us to handle it
$user_username->user_id=$user->id;
$we_can_handle = false;
if($user_username->find()){
//either this provider, or another one, has already claimed this user
//so we cannot. Let another plugin try.
return;
}else{
//no other provider claims this user, so it's safe for us to handle it
$authenticated = $this->checkPassword($nickname, $password);
if($authenticated){
$authenticatedUser = User::staticGet('nickname', $nickname);
$authenticatedUser = $user;
User_username::register($authenticatedUser,$nickname,$this->provider_name);
return false;
}
......
......@@ -70,7 +70,7 @@ class IoMaster
$classes = array();
if (Event::handle('StartIoManagerClasses', array(&$classes))) {
$classes[] = 'QueueManager';
if (common_config('xmpp', 'enabled')) {
if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) {
$classes[] = 'XmppManager'; // handles pings/reconnects
$classes[] = 'XmppConfirmManager'; // polls for outgoing confirmations
}
......
......@@ -157,7 +157,7 @@ abstract class QueueManager extends IoManager
}
// XMPP output handlers...
if (common_config('xmpp', 'enabled')) {
if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) {
$this->connect('jabber', 'JabberQueueHandler');
$this->connect('public', 'PublicQueueHandler');
......
......@@ -66,10 +66,57 @@ class StompQueueManager extends QueueManager
*
* @fixme possibly actually do subscription here to save another
* loop over all sites later?
* @fixme possibly don't assume it's the current site
*/
public function addSite($server)
{
$this->sites[] = $server;
$this->initialize();
}
/**
* Instantiate the appropriate QueueHandler class for the given queue.
*
* @param string $queue
* @return mixed QueueHandler or null
*/
function getHandler($queue)
{
$handlers = $this->handlers[common_config('site', 'server')];
if (isset($handlers[$queue])) {
$class = $handlers[$queue];
if (class_exists($class)) {
return new $class();
} else {
common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'");
}
} else {
common_log(LOG_ERR, "Requested handler for unkown queue '$queue'");
}
return null;
}
/**
* Get a list of all registered queue transport names.
*
* @return array of strings
*/
function getQueues()
{
return array_keys($this->handlers[common_config('site', 'server')]);
}
/**
* Register a queue transport name and handler class for your plugin.
* Only registered transports will be reliably picked up!
*
* @param string $transport
* @param string $class
*/
public function connect($transport, $class)
{
$this->handlers[common_config('site', 'server')][$transport] = $class;
}
/**
......
......@@ -118,7 +118,11 @@ class XmppManager extends IoManager
*/
public function getSockets()
{
return array($this->conn->getSocket());
if ($this->conn) {
return array($this->conn->getSocket());
} else {
return array();
}
}
/**
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -153,6 +153,22 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
return false;
}
function suggestNicknameForUsername($username)
{
$entry = $this->ldap_get_user($username, $this->attributes);
if(!$entry){
//this really shouldn't happen
return $username;
}else{
$nickname = $entry->getValue($this->attributes['nickname'],'single');
if($nickname){
return $nickname;
}else{
return $username;
}
}
}
//---utility functions---//
function ldap_get_config(){
......
......@@ -165,20 +165,18 @@ class MemcachePlugin extends Plugin
$this->_conn = new Memcache();
if (is_array($this->servers)) {
foreach ($this->servers as $server) {
list($host, $port) = @explode(';', $server);
if (empty($port)) {
$port = 11211;
}
$this->_conn->addServer($host, $port, $this->persistent);
}
$servers = $this->servers;
} else {
$this->_conn->addServer($this->servers, $this->persistent);
list($host, $port) = explode(';', $this->servers);
if (empty($port)) {
$servers = array($this->servers);
}
foreach ($servers as $server) {
if (strpos($server, ':') !== false) {
list($host, $port) = explode(':', $server);
} else {
$host = $server;
$port = 11211;
}
$this->_conn->addServer($host, $port, $this->persistent);
}
......
......@@ -21,7 +21,7 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'fi:at:';
$longoptions = array('id=', 'foreground', 'all', 'threads=');
$longoptions = array('id=', 'foreground', 'all', 'threads=', 'skip-xmpp');
/**
* Attempts to get a count of the processors available on the current system
......@@ -260,6 +260,10 @@ if (!$threads) {
$daemonize = !(have_option('f') || have_option('--foreground'));
$all = have_option('a') || have_option('--all');
if (have_option('--skip-xmpp')) {
define('XMPP_EMERGENCY_FLAG', true);
}
$daemon = new QueueDaemon($id, $daemonize, $threads, $all);
$daemon->runOnce();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment