From 133ca0ef6b13d4d693c2e03b831cc75517f89227 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 14 Nov 2009 13:10:47 -0800 Subject: Fix regression from 9f372da3da4bd445175eda9155fa7fdd13d3c85e: typo in refactoring caused fatal error on unrecognized message source --- lib/mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mailbox.php b/lib/mailbox.php index e1d384a06..90a58b4c4 100644 --- a/lib/mailbox.php +++ b/lib/mailbox.php @@ -282,7 +282,7 @@ class MailboxAction extends CurrentUserDesignAction $ns->name); $this->elementEnd('span'); } else { - $this->out->element('span', 'device', $source_name); + $this->element('span', 'device', $source_name); } break; } -- cgit v1.2.3-54-g00ecf From f04dbc8fa21d86bae5c34ece2637c3c345e29927 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 16 Nov 2009 00:19:47 -0500 Subject: Add "followers" and "following" commands --- lib/command.php | 40 ++++++++++++++++++++++++++++++++++++++++ lib/commandinterpreter.php | 12 ++++++++++++ 2 files changed, 52 insertions(+) (limited to 'lib') diff --git a/lib/command.php b/lib/command.php index 2ec3320de..c4a4f7cf4 100644 --- a/lib/command.php +++ b/lib/command.php @@ -605,6 +605,44 @@ class LoginCommand extends Command } } +class FollowingCommand extends Command +{ + function execute($channel) + { + $profile = $this->user->getSubscriptions(0); + $nicknames=array(); + while ($profile->fetch()) { + $nicknames[]=$profile->nickname; + } + if(count($nicknames)==0){ + $out=_('You are not subscribed to anyone.'); + }else{ + $out=_('You are subscribed to these people: '); + $out.=implode(', ',$nicknames); + } + $channel->output($this->user,$out); + } +} + +class FollowersCommand extends Command +{ + function execute($channel) + { + $profile = $this->user->getSubscribers(); + $nicknames=array(); + while ($profile->fetch()) { + $nicknames[]=$profile->nickname; + } + if(count($nicknames)==0){ + $out=_('No one is subscribed to you.'); + }else{ + $out=_('These people are subscribed to you: '); + $out.=implode(', ',$nicknames); + } + $channel->output($this->user,$out); + } +} + class HelpCommand extends Command { function execute($channel) @@ -615,6 +653,8 @@ class HelpCommand extends Command "off - turn off notifications\n". "help - show this help\n". "follow - subscribe to user\n". + "following - list the people you follow\n". + "followers - list the people that follow you\n". "leave - unsubscribe from user\n". "d - direct message to user\n". "get - get last notice from user\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index d878fe268..ecc08f101 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -47,6 +47,18 @@ class CommandInterpreter } else { return new LoginCommand($user); } + case 'followers': + if ($arg) { + return null; + } else { + return new FollowersCommand($user); + } + case 'following': + if ($arg) { + return null; + } else { + return new FollowingCommand($user); + } case 'on': if ($arg) { list($other, $extra) = $this->split_arg($arg); -- cgit v1.2.3-54-g00ecf From 73b4d770a2551018ea17d115d980972dc5f0865a Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 16 Nov 2009 11:17:14 -0500 Subject: Changed to StatusNet consistent terminology --- lib/command.php | 8 ++++---- lib/commandinterpreter.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/command.php b/lib/command.php index c4a4f7cf4..247ea4475 100644 --- a/lib/command.php +++ b/lib/command.php @@ -605,7 +605,7 @@ class LoginCommand extends Command } } -class FollowingCommand extends Command +class SubscriptionsCommand extends Command { function execute($channel) { @@ -624,7 +624,7 @@ class FollowingCommand extends Command } } -class FollowersCommand extends Command +class SubscribersCommand extends Command { function execute($channel) { @@ -653,8 +653,8 @@ class HelpCommand extends Command "off - turn off notifications\n". "help - show this help\n". "follow - subscribe to user\n". - "following - list the people you follow\n". - "followers - list the people that follow you\n". + "subscriptions - list the people you follow\n". + "subscribers - list the people that follow you\n". "leave - unsubscribe from user\n". "d - direct message to user\n". "get - get last notice from user\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index ecc08f101..c39fafb62 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -47,17 +47,17 @@ class CommandInterpreter } else { return new LoginCommand($user); } - case 'followers': + case 'subscribers': if ($arg) { return null; } else { - return new FollowersCommand($user); + return new SubscribersCommand($user); } - case 'following': + case 'subscriptions': if ($arg) { return null; } else { - return new FollowingCommand($user); + return new SubscriptionsCommand($user); } case 'on': if ($arg) { -- cgit v1.2.3-54-g00ecf From 0e7dd81a6cf38c879f24f476411104d67b9eb177 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 16 Nov 2009 11:23:00 -0500 Subject: Added a "groups" command --- lib/command.php | 20 ++++++++++++++++++++ lib/commandinterpreter.php | 6 ++++++ 2 files changed, 26 insertions(+) (limited to 'lib') diff --git a/lib/command.php b/lib/command.php index 247ea4475..0c98c94ac 100644 --- a/lib/command.php +++ b/lib/command.php @@ -643,6 +643,25 @@ class SubscribersCommand extends Command } } +class GroupsCommand extends Command +{ + function execute($channel) + { + $group = $this->user->getGroups(); + $groups=array(); + while ($group->fetch()) { + $groups[]=$group->nickname; + } + if(count($groups)==0){ + $out=_('You are not a member of any groups.'); + }else{ + $out=_('You are a member of these groups: '); + $out.=implode(', ',$groups); + } + $channel->output($this->user,$out); + } +} + class HelpCommand extends Command { function execute($channel) @@ -653,6 +672,7 @@ class HelpCommand extends Command "off - turn off notifications\n". "help - show this help\n". "follow - subscribe to user\n". + "groups - lists the groups you have joined\n". "subscriptions - list the people you follow\n". "subscribers - list the people that follow you\n". "leave - unsubscribe from user\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index c39fafb62..665015afc 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -59,6 +59,12 @@ class CommandInterpreter } else { return new SubscriptionsCommand($user); } + case 'groups': + if ($arg) { + return null; + } else { + return new GroupsCommand($user); + } case 'on': if ($arg) { list($other, $extra) = $this->split_arg($arg); -- cgit v1.2.3-54-g00ecf From a373d07ae00b878f47970f2e4a7d86c6ec3a65cf Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 16 Nov 2009 15:24:25 -0500 Subject: Allow plugin DB_DataObject classes to not have to use the .ini file by overriding keys(), table(), and sequenceKey() for them --- classes/Plugin_DataObject.php | 195 ++++++++++++++++++++++++ classes/statusnet.ini | 31 ---- lib/schema.php | 41 ++++- plugins/Authentication/AuthenticationPlugin.php | 11 +- plugins/Authentication/User_username.php | 22 ++- plugins/OpenID/OpenIDPlugin.php | 23 +-- plugins/OpenID/User_openid.php | 22 ++- plugins/OpenID/User_openid_trustroot.php | 20 ++- plugins/UserFlag/UserFlagPlugin.php | 11 +- plugins/UserFlag/User_flag_profile.php | 21 ++- 10 files changed, 318 insertions(+), 79 deletions(-) create mode 100644 classes/Plugin_DataObject.php (limited to 'lib') diff --git a/classes/Plugin_DataObject.php b/classes/Plugin_DataObject.php new file mode 100644 index 000000000..d5cecf0f7 --- /dev/null +++ b/classes/Plugin_DataObject.php @@ -0,0 +1,195 @@ +. + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } + +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; + +abstract class Plugin_DataObject extends Memcached_DataObject +{ + function table() { + static $table = null; + if($table == null) { + $table = array(); + $DB = $this->getDatabaseConnection(); + $dbtype = $DB->phptype; + $tableDef = $this->tableDef(); + foreach($tableDef->columns as $columnDef){ + switch(strtoupper($columnDef->type)) { + /*shamelessly copied from DB_DataObject_Generator*/ + case 'INT': + case 'INT2': // postgres + case 'INT4': // postgres + case 'INT8': // postgres + case 'SERIAL4': // postgres + case 'SERIAL8': // postgres + case 'INTEGER': + case 'TINYINT': + case 'SMALLINT': + case 'MEDIUMINT': + case 'BIGINT': + $type = DB_DATAOBJECT_INT; + if ($columnDef->size == 1) { + $type += DB_DATAOBJECT_BOOL; + } + break; + + case 'REAL': + case 'DOUBLE': + case 'DOUBLE PRECISION': // double precision (firebird) + case 'FLOAT': + case 'FLOAT4': // real (postgres) + case 'FLOAT8': // double precision (postgres) + case 'DECIMAL': + case 'MONEY': // mssql and maybe others + case 'NUMERIC': + case 'NUMBER': // oci8 + $type = DB_DATAOBJECT_INT; // should really by FLOAT!!! / MONEY... + break; + + case 'YEAR': + $type = DB_DATAOBJECT_INT; + break; + + case 'BIT': + case 'BOOL': + case 'BOOLEAN': + + $type = DB_DATAOBJECT_BOOL; + // postgres needs to quote '0' + if ($dbtype == 'pgsql') { + $type += DB_DATAOBJECT_STR; + } + break; + + case 'STRING': + case 'CHAR': + case 'VARCHAR': + case 'VARCHAR2': + case 'TINYTEXT': + + case 'ENUM': + case 'SET': // not really but oh well + + case 'POINT': // mysql geometry stuff - not really string - but will do.. + + case 'TIMESTAMPTZ': // postgres + case 'BPCHAR': // postgres + case 'INTERVAL': // postgres (eg. '12 days') + + case 'CIDR': // postgres IP net spec + case 'INET': // postgres IP + case 'MACADDR': // postgress network Mac address. + + case 'INTEGER[]': // postgres type + case 'BOOLEAN[]': // postgres type + + $type = DB_DATAOBJECT_STR; + break; + + case 'TEXT': + case 'MEDIUMTEXT': + case 'LONGTEXT': + + $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT; + break; + + + case 'DATE': + $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE; + break; + + case 'TIME': + $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TIME; + break; + + + case 'DATETIME': + + $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME; + break; + + case 'TIMESTAMP': // do other databases use this??? + + $type = ($dbtype == 'mysql') ? + DB_DATAOBJECT_MYSQLTIMESTAMP : + DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME; + break; + + + case 'BLOB': /// these should really be ignored!!!??? + case 'TINYBLOB': + case 'MEDIUMBLOB': + case 'LONGBLOB': + + case 'CLOB': // oracle character lob support + + case 'BYTEA': // postgres blob support.. + $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_BLOB; + break; + + default: + throw new Exception("Cannot handle datatype: $columnDef->type"); + } + if(! $columnDef->nullable) { + $type+=DB_DATAOBJECT_NOTNULL; + } + $table[$columnDef->name]=$type; + } + } + return $table; + } + + function keys() { + static $keys = null; + if($keys == null) { + $keys = array(); + $tableDef = $this->tableDef(); + foreach($tableDef->columns as $columnDef){ + if($columnDef->key != null){ + $keys[] = $columnDef->name; + } + } + } + return $keys; + } + + function sequenceKey() { + static $sequenceKey = null; + if($sequenceKey == null) { + $sequenceKey = array(false,false); + $tableDef = $this->tableDef(); + foreach($tableDef->columns as $columnDef){ + if($columnDef->key == 'PRI' && $columnDef->auto_increment){ + $sequenceKey=array($columnDef->name,true); + } + } + } + return $sequenceKey; + } + + /** + * Get the TableDef object that represents the table backing this class + * Ideally, this function would a static function, but PHP doesn't allow + * abstract static functions + * @return TableDef TableDef instance + */ + abstract function tableDef(); +} + diff --git a/classes/statusnet.ini b/classes/statusnet.ini index 19ab7bf97..8572ea8ac 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -526,27 +526,6 @@ modified = 384 [user_group__keys] id = N -[user_openid] -canonical = 130 -display = 130 -user_id = 129 -created = 142 -modified = 384 - -[user_openid__keys] -canonical = K -display = U - -[user_openid_trustroot] -trustroot = 130 -user_id = 129 -created = 142 -modified = 384 - -[user_openid__keys] -trustroot = K -user_id = K - [user_role] user_id = 129 role = 130 @@ -566,13 +545,3 @@ modified = 384 user_id = K token = K -[user_username] -user_id = 129 -provider_name = 130 -username = 130 -created = 142 -modified = 384 - -[user_username__keys] -provider_name = K -username = K diff --git a/lib/schema.php b/lib/schema.php index 1e0c1f3e9..560884d9f 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -372,6 +372,26 @@ class Schema return true; } + /** + * Ensures that the table that backs a given + * Plugin_DataObject class exists. + * + * If the table does not yet exist, it will + * create the table. If it does exist, it will + * alter the table to match the column definitions. + * + * @param Plugin_DataObject $dataObjectClass + * + * @return boolean success flag + */ + + public function ensureDataObject($dataObjectClass) + { + $obj = new $dataObjectClass(); + $tableDef = $obj->tableDef(); + return $this->ensureTable($tableDef->name,$tableDef->columns); + } + /** * Ensures that a table exists with the given * name and the given column definitions. @@ -544,6 +564,19 @@ class TableDef public $name; /** array of ColumnDef objects for the columns. */ public $columns; + + /** + * Constructor. + * + * @param string $name name of the table + * @param array $columns columns in the table + */ + + function __construct($name=null,$columns=null) + { + $this->name = $name; + $this->columns = $columns; + } } /** @@ -576,6 +609,8 @@ class ColumnDef /** 'extra' stuff. Returned by MySQL, largely * unused. */ public $extra; + /** auto increment this field if no value is specific for it during an insert **/ + public $auto_increment; /** * Constructor. @@ -591,7 +626,7 @@ class ColumnDef function __construct($name=null, $type=null, $size=null, $nullable=true, $key=null, $default=null, - $extra=null) + $extra=null, $auto_increment=false) { $this->name = strtolower($name); $this->type = strtolower($type); @@ -600,6 +635,7 @@ class ColumnDef $this->key = $key; $this->default = $default; $this->extra = $extra; + $this->auto_increment = $auto_increment; } /** @@ -617,7 +653,8 @@ class ColumnDef $this->_typeMatch($other) && $this->_defaultMatch($other) && $this->_nullMatch($other) && - $this->key == $other->key); + $this->key == $other->key && + $this->auto_increment == $other->auto_increment); } /** diff --git a/plugins/Authentication/AuthenticationPlugin.php b/plugins/Authentication/AuthenticationPlugin.php index a76848b04..a80da901c 100644 --- a/plugins/Authentication/AuthenticationPlugin.php +++ b/plugins/Authentication/AuthenticationPlugin.php @@ -204,16 +204,7 @@ abstract class AuthenticationPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureTable('user_username', - array(new ColumnDef('provider_name', 'varchar', - '255', false, 'PRI'), - new ColumnDef('username', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); + $schema->ensureDataObject(User_username); return true; } diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php index f30f60d83..6826f2681 100644 --- a/plugins/Authentication/User_username.php +++ b/plugins/Authentication/User_username.php @@ -2,9 +2,9 @@ /** * Table Definition for user_username */ -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; +require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; -class User_username extends Memcached_DataObject +class User_username extends Plugin_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,4 +43,22 @@ class User_username extends Memcached_DataObject return false; } } + + /** + * Get the TableDef object that represents the table backing this class + * @return TableDef TableDef instance + */ + function tableDef() + { + return new TableDef($this->__table, + array(new ColumnDef('provider_name', 'varchar', + '255', false, 'PRI'), + new ColumnDef('username', 'varchar', + '255', false, 'PRI'), + new ColumnDef('user_id', 'integer', + null, false), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); + } } diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index 55c0eadaf..88e23ea3e 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -156,6 +156,9 @@ class OpenIDPlugin extends Plugin case 'User_openid': require_once(INSTALLDIR.'/plugins/OpenID/User_openid.php'); return false; + case 'User_openid_trustroot': + require_once(INSTALLDIR.'/plugins/OpenID/User_openid_trustroot.php'); + return false; default: return true; } @@ -278,24 +281,8 @@ class OpenIDPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureTable('user_openid', - array(new ColumnDef('canonical', 'varchar', - '255', false, 'PRI'), - new ColumnDef('display', 'varchar', - '255', false), - new ColumnDef('user_id', 'integer', - null, false, 'MUL'), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - $schema->ensureTable('user_openid_trustroot', - array(new ColumnDef('trustroot', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false, 'PRI'), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); + $schema->ensureDataObject(User_openid); + $schema->ensureDataObject(User_openid_trustroot); return true; } diff --git a/plugins/OpenID/User_openid.php b/plugins/OpenID/User_openid.php index 338e0f6e9..c3624118e 100644 --- a/plugins/OpenID/User_openid.php +++ b/plugins/OpenID/User_openid.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid */ -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; +require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; -class User_openid extends Memcached_DataObject +class User_openid extends Plugin_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -33,4 +33,22 @@ class User_openid extends Memcached_DataObject return ($cnt > 0); } + + /** + * Get the TableDef object that represents the table backing this class + * @return TableDef TableDef instance + */ + function tableDef() + { + return new TableDef($this->__table, + array(new ColumnDef('canonical', 'varchar', + '255', false, 'PRI'), + new ColumnDef('display', 'varchar', + '255', false), + new ColumnDef('user_id', 'integer', + null, false, 'MUL'), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); + } } diff --git a/plugins/OpenID/User_openid_trustroot.php b/plugins/OpenID/User_openid_trustroot.php index 4654b72df..b208dddfd 100644 --- a/plugins/OpenID/User_openid_trustroot.php +++ b/plugins/OpenID/User_openid_trustroot.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid_trustroot */ -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; +require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; -class User_openid_trustroot extends Memcached_DataObject +class User_openid_trustroot extends Plugin_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -26,4 +26,20 @@ class User_openid_trustroot extends Memcached_DataObject { return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv); } + + /** + * Get the TableDef object that represents the table backing this class + * @return TableDef TableDef instance + */ + function tableDef() + { + return new TableDef($this->__table, + array(new ColumnDef('trustroot', 'varchar', + '255', false, 'PRI'), + new ColumnDef('user_id', 'integer', + null, false, 'PRI'), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); + } } diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index 6410ee1ce..df7eac7a2 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -48,16 +48,7 @@ class UserFlagPlugin extends Plugin $schema = Schema::get(); // For storing user-submitted flags on profiles - - $schema->ensureTable('user_flag_profile', - array(new ColumnDef('profile_id', 'integer', null, - false, 'PRI'), - new ColumnDef('user_id', 'integer', null, - false, 'PRI'), - new ColumnDef('created', 'datetime', null, - false, 'MUL'), - new ColumnDef('cleared', 'datetime', null, - true, 'MUL'))); + $schema->ensureDataObject(User_flag_profile); return true; } diff --git a/plugins/UserFlag/User_flag_profile.php b/plugins/UserFlag/User_flag_profile.php index 30bd4ae68..2fb27912d 100644 --- a/plugins/UserFlag/User_flag_profile.php +++ b/plugins/UserFlag/User_flag_profile.php @@ -21,9 +21,9 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; +require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; -class User_flag_profile extends Memcached_DataObject +class User_flag_profile extends Plugin_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -65,4 +65,21 @@ class User_flag_profile extends Memcached_DataObject return !empty($ufp); } + + /** + * Get the TableDef object that represents the table backing this class + * @return TableDef TableDef instance + */ + function tableDef() + { + return new TableDef($this->__table, + array(new ColumnDef('profile_id', 'integer', null, + false, 'PRI'), + new ColumnDef('user_id', 'integer', null, + false, 'PRI'), + new ColumnDef('created', 'datetime', null, + false, 'MUL'), + new ColumnDef('cleared', 'datetime', null, + true, 'MUL'))); + } } -- cgit v1.2.3-54-g00ecf From a99198ba94766dcfb58d4cc16358dc1438df422a Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 16 Nov 2009 15:57:57 -0500 Subject: Do proper translations for plurals --- lib/command.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/command.php b/lib/command.php index 0c98c94ac..7e98156b6 100644 --- a/lib/command.php +++ b/lib/command.php @@ -617,8 +617,11 @@ class SubscriptionsCommand extends Command if(count($nicknames)==0){ $out=_('You are not subscribed to anyone.'); }else{ - $out=_('You are subscribed to these people: '); - $out.=implode(', ',$nicknames); + $out = ngettext('You are subscribed to this person:', + 'You are subscribed to these people:', + count($nicknames)); + $out .= ' '; + $out .= implode(', ',$nicknames); } $channel->output($this->user,$out); } @@ -636,8 +639,11 @@ class SubscribersCommand extends Command if(count($nicknames)==0){ $out=_('No one is subscribed to you.'); }else{ - $out=_('These people are subscribed to you: '); - $out.=implode(', ',$nicknames); + $out = ngettext('This person is subscribed to you:', + 'These people are subscribed to you:', + count($nicknames)); + $out .= ' '; + $out .= implode(', ',$nicknames); } $channel->output($this->user,$out); } @@ -655,7 +661,9 @@ class GroupsCommand extends Command if(count($groups)==0){ $out=_('You are not a member of any groups.'); }else{ - $out=_('You are a member of these groups: '); + $out = ngettext('You are a member of this group:', + 'You are a member of these groups:', + count($nicknames)); $out.=implode(', ',$groups); } $channel->output($this->user,$out); -- cgit v1.2.3-54-g00ecf From 8ab40e70518402071f50263ebae8cf9633500405 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 16 Nov 2009 15:35:16 -0800 Subject: Cleanup for bug 1813: workaround sometimes-missing dl() in PHP 5.3 by defining our own bogus function rather than attempting to patch upstream libs. This keeps our fix across upstream versions (or when loading upstream library from outside extlib) Note that fixes to OpenID libraries in commit fe9473ac7810d317e001a0fec19cbacaafc0c909 were lost in just such an update. --- extlib/PEAR.php | 2 +- lib/common.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/extlib/PEAR.php b/extlib/PEAR.php index fcefa964a..4c24c6006 100644 --- a/extlib/PEAR.php +++ b/extlib/PEAR.php @@ -746,7 +746,7 @@ class PEAR { if (!extension_loaded($ext)) { // if either returns true dl() will produce a FATAL error, stop that - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1) || !function_exists('dl')) { + if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { return false; } if (OS_WINDOWS) { diff --git a/lib/common.php b/lib/common.php index 4524d50fa..063d7d9d9 100644 --- a/lib/common.php +++ b/lib/common.php @@ -45,6 +45,14 @@ define('FOREIGN_FRIEND_RECV', 2); set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib/'); +# To protect against upstream libraries which haven't updated +# for PHP 5.3 where dl() function may not be present... +if (!function_exists('dl')) { + function dl($library) { + return false; + } +} + # global configuration object require_once('PEAR.php'); -- cgit v1.2.3-54-g00ecf