From eb309f788bc9e52fd7108e024e58594b425de426 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 21 Aug 2009 07:21:29 -0400 Subject: correctly check Message length for d-commands --- lib/command.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/command.php') diff --git a/lib/command.php b/lib/command.php index 4e2280bc8..371386dc5 100644 --- a/lib/command.php +++ b/lib/command.php @@ -211,16 +211,20 @@ class MessageCommand extends Command function execute($channel) { $other = User::staticGet('nickname', common_canonical_nickname($this->other)); + $len = mb_strlen($this->text); + if ($len == 0) { $channel->error($this->user, _('No content!')); return; - } else if ($len > 140) { - $content = common_shorten_links($content); - if (mb_strlen($content) > 140) { - $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len)); - return; - } + } + + $this->text = common_shorten_links($this->text); + + if (Message::contentTooLong($this->text)) { + $channel->error($this->user, sprintf(_('Message too long - maximum is %d characters, you sent %d'), + Message::maxContent(), mb_strlen($this->text))); + return; } if (!$other) { -- cgit v1.2.3-54-g00ecf From 922ee7b3b292689806b0b94a9eb94fe08a204751 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 27 Oct 2009 21:48:56 -0400 Subject: Implemented reply # command, allowing users to favorite specific notices by the notice id --- lib/command.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'lib/command.php') diff --git a/lib/command.php b/lib/command.php index 11d40b8e1..6ece01b96 100644 --- a/lib/command.php +++ b/lib/command.php @@ -124,18 +124,30 @@ class FavCommand extends Command function execute($channel) { + if(substr($this->other,0,1)=='#'){ + //replying to a specific notice_id - $recipient = - common_relative_profile($this->user, common_canonical_nickname($this->other)); + $notice = Notice::staticGet(substr($this->other,1)); + if (!$notice) { + $channel->error($this->user, _('Notice with that id does not exist')); + return; + } + $recipient = $notice->getProfile(); + }else{ + //replying to a given user's last notice - if (!$recipient) { - $channel->error($this->user, _('No such user.')); - return; - } - $notice = $recipient->getCurrentNotice(); - if (!$notice) { - $channel->error($this->user, _('User has no last notice')); - return; + $recipient = + common_relative_profile($this->user, common_canonical_nickname($this->other)); + + if (!$recipient) { + $channel->error($this->user, _('No such user.')); + return; + } + $notice = $recipient->getCurrentNotice(); + if (!$notice) { + $channel->error($this->user, _('User has no last notice')); + return; + } } $fave = Fave::addNew($this->user, $notice); @@ -497,6 +509,7 @@ class HelpCommand extends Command "get - get last notice from user\n". "whois - get profile info on user\n". "fav - add user's last notice as a 'fave'\n". + "fav # - add notice with the given id as a 'fave'\n". "join - join group\n". "drop - leave group\n". "stats - get your stats\n". -- cgit v1.2.3-54-g00ecf From da16dc05a81e2fcc1ed89fe16717f2652265f23a Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 27 Oct 2009 22:30:21 -0400 Subject: Added a new "reply" command --- lib/command.php | 71 ++++++++++++++++++++++++++++++++++++++++++++-- lib/commandinterpreter.php | 11 +++++++ 2 files changed, 80 insertions(+), 2 deletions(-) (limited to 'lib/command.php') diff --git a/lib/command.php b/lib/command.php index 6ece01b96..d7ae11361 100644 --- a/lib/command.php +++ b/lib/command.php @@ -125,7 +125,7 @@ class FavCommand extends Command function execute($channel) { if(substr($this->other,0,1)=='#'){ - //replying to a specific notice_id + //favoriting a specific notice_id $notice = Notice::staticGet(substr($this->other,1)); if (!$notice) { @@ -134,7 +134,7 @@ class FavCommand extends Command } $recipient = $notice->getProfile(); }else{ - //replying to a given user's last notice + //favoriting a given user's last notice $recipient = common_relative_profile($this->user, common_canonical_nickname($this->other)); @@ -359,6 +359,71 @@ class MessageCommand extends Command } } +class ReplyCommand extends Command +{ + var $other = null; + var $text = null; + function __construct($user, $other, $text) + { + parent::__construct($user); + $this->other = $other; + $this->text = $text; + } + + function execute($channel) + { + if(substr($this->other,0,1)=='#'){ + //replying to a specific notice_id + + $notice = Notice::staticGet(substr($this->other,1)); + if (!$notice) { + $channel->error($this->user, _('Notice with that id does not exist')); + return; + } + $recipient = $notice->getProfile(); + }else{ + //replying to a given user's last notice + + $recipient = + common_relative_profile($this->user, common_canonical_nickname($this->other)); + + if (!$recipient) { + $channel->error($this->user, _('No such user.')); + return; + } + $notice = $recipient->getCurrentNotice(); + if (!$notice) { + $channel->error($this->user, _('User has no last notice')); + return; + } + } + + $len = mb_strlen($this->text); + + if ($len == 0) { + $channel->error($this->user, _('No content!')); + return; + } + + $this->text = common_shorten_links($this->text); + + if (Notice::contentTooLong($this->text)) { + $channel->error($this->user, sprintf(_('Notice too long - maximum is %d characters, you sent %d'), + Notice::maxContent(), mb_strlen($this->text))); + return; + } + + $notice = Notice::saveNew($this->user->id, $this->text, $channel->source(), 1, + $notice->id); + if ($notice) { + $channel->output($this->user, sprintf(_('Reply to %s sent'), $recipient->nickname)); + } else { + $channel->error($this->user, _('Error saving notice.')); + } + common_broadcast_notice($notice); + } +} + class GetCommand extends Command { @@ -510,6 +575,8 @@ class HelpCommand extends Command "whois - get profile info on user\n". "fav - add user's last notice as a 'fave'\n". "fav # - add notice with the given id as a 'fave'\n". + "reply # - reply to notice with a given id\n". + "reply - reply to the last notice from user\n". "join - join group\n". "drop - leave group\n". "stats - get your stats\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 60fc4c3c4..b921a17cc 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -134,6 +134,17 @@ class CommandInterpreter } else { return new MessageCommand($user, $other, $extra); } + case 'r': + case 'reply': + if (!$arg) { + return null; + } + list($other, $extra) = $this->split_arg($arg); + if (!$extra) { + return null; + } else { + return new ReplyCommand($user, $other, $extra); + } case 'whois': if (!$arg) { return null; -- cgit v1.2.3-54-g00ecf From 5f42023f97fca2c3b5fbd0da2d5e333e4cc2f109 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 27 Oct 2009 22:45:00 -0400 Subject: implement the nudge command --- lib/command.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'lib/command.php') diff --git a/lib/command.php b/lib/command.php index d7ae11361..9efa40696 100644 --- a/lib/command.php +++ b/lib/command.php @@ -73,7 +73,7 @@ class UntrackCommand extends UnimplementedCommand } } -class NudgeCommand extends UnimplementedCommand +class NudgeCommand extends Command { var $other = null; function __construct($user, $other) @@ -81,6 +81,26 @@ class NudgeCommand extends UnimplementedCommand parent::__construct($user); $this->other = $other; } + function execute($channel) + { + $recipient = User::staticGet('nickname', $this->other); + if(! $recipient){ + $channel->error($this->user, sprintf(_('Could not find a user with nickname %s'), + $this->other)); + }else{ + if ($recipient->id == $this->user->id) { + $channel->error($this->user, _('It does not make a lot of sense to nudge yourself!')); + }else{ + if ($recipient->email && $recipient->emailnotifynudge) { + mail_notify_nudge($this->user, $recipient); + } + // XXX: notify by IM + // XXX: notify by SMS + $channel->output($this->user, sprintf(_('Nudge sent to %s'), + $recipient->nickname)); + } + } + } } class InviteCommand extends UnimplementedCommand @@ -587,7 +607,7 @@ class HelpCommand extends Command "last - same as 'get'\n". "on - not yet implemented.\n". "off - not yet implemented.\n". - "nudge - not yet implemented.\n". + "nudge - remind a user to update.\n". "invite - not yet implemented.\n". "track - not yet implemented.\n". "untrack - not yet implemented.\n". -- cgit v1.2.3-54-g00ecf From b9d40f723bce8e01ddcbbb989bd7035b92cd9af8 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 2 Nov 2009 18:40:18 -0500 Subject: Added 'login' command that gives you a link that can be used to login to the website --- actions/login.php | 55 ++++++++++++++++++++++++++++++++++------------ classes/Login_token.php | 42 +++++++++++++++++++++++++++++++++++ classes/statusnet.ini | 11 ++++++++++ db/08to09.sql | 10 +++++++++ db/08to09_pg.sql | 10 +++++++++ db/statusnet.sql | 10 +++++++++ db/statusnet_pg.sql | 10 +++++++++ lib/command.php | 27 +++++++++++++++++++++++ lib/commandinterpreter.php | 6 +++++ lib/router.php | 2 ++ 10 files changed, 169 insertions(+), 14 deletions(-) create mode 100644 classes/Login_token.php (limited to 'lib/command.php') diff --git a/actions/login.php b/actions/login.php index f6d016310..ad57dd667 100644 --- a/actions/login.php +++ b/actions/login.php @@ -79,6 +79,8 @@ class LoginAction extends Action $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->checkLogin(); + } else if (isset($args['user_id']) && isset($args['token'])){ + $this->checkLogin($args['user_id'],$args['token']); } else { common_ensure_session(); $this->showForm(); @@ -95,23 +97,48 @@ class LoginAction extends Action * @return void */ - function checkLogin() + function checkLogin($user_id=null, $token=null) { - // XXX: login throttle - - // CSRF protection - token set in NoticeForm - $token = $this->trimmed('token'); - if (!$token || $token != common_session_token()) { - $this->clientError(_('There was a problem with your session token. '. - 'Try again, please.')); - return; + if(isset($token) && isset($user_id)){ + //Token based login (from the LoginCommand) + $login_token = Login_token::staticGet('user_id',$user_id); + if($login_token && $login_token->token == $token){ + if($login_token->modified > time()+2*60){ + //token has expired + //delete the token as it is useless + $login_token->delete(); + $this->showForm(_('Invalid or expired token.')); + return; + }else{ + //delete the token so it cannot be reused + $login_token->delete(); + //it's a valid token - let them log in + $user = User::staticGet('id', $user_id); + //$user = User::staticGet('nickname', "candrews"); + } + }else{ + $this->showForm(_('Invalid or expired token.')); + return; + } + }else{ + // Regular form submission login + + // XXX: login throttle + + // CSRF protection - token set in NoticeForm + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->clientError(_('There was a problem with your session token. '. + 'Try again, please.')); + return; + } + + $nickname = common_canonical_nickname($this->trimmed('nickname')); + $password = $this->arg('password'); + + $user = common_check_user($nickname, $password); } - $nickname = common_canonical_nickname($this->trimmed('nickname')); - $password = $this->arg('password'); - - $user = common_check_user($nickname, $password); - if (!$user) { $this->showForm(_('Incorrect username or password.')); return; diff --git a/classes/Login_token.php b/classes/Login_token.php new file mode 100644 index 000000000..bd6381f90 --- /dev/null +++ b/classes/Login_token.php @@ -0,0 +1,42 @@ +. + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } + +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; + +class Login_token extends Memcached_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + public $__table = 'login_token'; // table name + public $user_id; // int(4) primary_key not_null + public $token; // char(32) not_null + public $created; // datetime() not_null + public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Login_token',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/classes/statusnet.ini b/classes/statusnet.ini index 623790b10..912d05cdf 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -555,3 +555,14 @@ created = 142 [user_role__keys] user_id = K role = K + +[login_token] +user_id = 129 +token = 130 +created = 142 +modified = 384 + +[login_token__keys] +user_id = K +token = K + diff --git a/db/08to09.sql b/db/08to09.sql index 953e0e5f4..a0e37f0f1 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -32,3 +32,13 @@ create table user_role ( constraint primary key (user_id, role) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table login_token ( + user_id integer not null comment 'user owning this token' references user (id), + token char(32) not null comment 'token useable for logging in', + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified', + + constraint primary key (user_id) +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 9e37314aa..197fcabfd 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -38,3 +38,13 @@ create table user_role ( primary key (user_id, role) ); + +create table login_token ( + user_id integer not null /* comment 'user owning this token'*/ references user (id), + token char(32) not null /* comment 'token useable for logging in'*/, + created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, + modified timestamp /* comment 'date this record was modified'*/, + + constraint primary key (user_id) +); + diff --git a/db/statusnet.sql b/db/statusnet.sql index 1524d8395..3ed4e2c48 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -575,3 +575,13 @@ create table location_namespace ( modified timestamp comment 'date this record was modified' ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table login_token ( + user_id integer not null comment 'user owning this token' references user (id), + token char(32) not null comment 'token useable for logging in', + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified', + + constraint primary key (user_id) +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 672877ddf..0e5e96c32 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -569,3 +569,13 @@ create table user_role ( primary key (user_id, role) ); + +create table login_token ( + user_id integer not null /* comment 'user owning this token'*/ references user (id), + token char(32) not null /* comment 'token useable for logging in'*/, + created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, + modified timestamp /* comment 'date this record was modified'*/, + + constraint primary key (user_id) +); + diff --git a/lib/command.php b/lib/command.php index 9efa40696..2ec3320de 100644 --- a/lib/command.php +++ b/lib/command.php @@ -579,6 +579,32 @@ class OnCommand extends Command } } +class LoginCommand extends Command +{ + function execute($channel) + { + $login_token = Login_token::staticGet('user_id',$this->user->id); + if($login_token){ + $login_token->delete(); + } + $login_token = new Login_token(); + $login_token->user_id = $this->user->id; + $login_token->token = common_good_rand(16); + $login_token->created = common_sql_now(); + $result = $login_token->insert(); + if (!$result) { + common_log_db_error($login_token, 'INSERT', __FILE__); + $channel->error($this->user, sprintf(_('Could not create login token for %s'), + $this->user->nickname)); + return; + } + $channel->output($this->user, + sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'), + common_local_url('login', + array('user_id'=>$login_token->user_id, 'token'=>$login_token->token)))); + } +} + class HelpCommand extends Command { function execute($channel) @@ -598,6 +624,7 @@ class HelpCommand extends Command "reply # - reply to notice with a given id\n". "reply - reply to the last notice from user\n". "join - join group\n". + "login - Get a link to login to the web interface\n". "drop - leave group\n". "stats - get your stats\n". "stop - same as 'off'\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index b921a17cc..d878fe268 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -41,6 +41,12 @@ class CommandInterpreter return null; } return new HelpCommand($user); + case 'login': + if ($arg) { + return null; + } else { + return new LoginCommand($user); + } case 'on': if ($arg) { list($other, $extra) = $this->split_arg($arg); diff --git a/lib/router.php b/lib/router.php index 888cbdd20..0ddda473c 100644 --- a/lib/router.php +++ b/lib/router.php @@ -88,6 +88,8 @@ class Router $m->connect('doc/:title', array('action' => 'doc')); + $m->connect('main/login?user_id=:user_id&token=:token', array('action'=>'login'), array('user_id'=> '[0-9]+', 'token'=>'.+')); + // main stuff is repetitive $main = array('login', 'logout', 'register', 'subscribe', -- 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/command.php') 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/command.php') 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/command.php') 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 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/command.php') 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