]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/command.php
Fix misnamed unique constraint
[quix0rs-gnu-social.git] / lib / command.php
index 084c61fd1a119ad5dbb082535a15750e73856b04..efe917fb11895d03a2cf443008f02c7a0753a245 100644 (file)
@@ -23,7 +23,6 @@ require_once(INSTALLDIR.'/lib/channel.php');
 
 class Command
 {
-
     var $user = null;
 
     function __construct($user=null)
@@ -49,7 +48,6 @@ class Command
         }
     }
 
-    
     /**
      * Override this with the meat!
      *
@@ -80,15 +78,16 @@ class Command
 
                 $notice = Notice::staticGet(substr($arg,1));
                 if (!$notice) {
-                    throw new CommandException(_('Notice with that id does not exist'));
+                    // TRANS: Command exception text shown when a notice ID is requested that does not exist.
+                    throw new CommandException(_('Notice with that id does not exist.'));
                 }
             }
-            
+
             if (Validate::uri($this->other)) {
                 // A specific notice by URI lookup
                 $notice = Notice::staticGet('uri', $arg);
             }
-            
+
             if (!$notice) {
                 // Local or remote profile name to get their last notice.
                 // May throw an exception and report 'no such user'
@@ -96,13 +95,15 @@ class Command
 
                 $notice = $recipient->getCurrentNotice();
                 if (!$notice) {
-                    throw new CommandException(_('User has no last notice'));
+                    // TRANS: Command exception text shown when a last user notice is requested and it does not exist.
+                    throw new CommandException(_('User has no last notice.'));
                 }
             }
         }
         Event::handle('EndCommandGetNotice', array($this, $arg, &$notice));
         if (!$notice) {
-            throw new CommandException(_('Notice with that id does not exist'));
+            // TRANS: Command exception text shown when a notice ID is requested that does not exist.
+            throw new CommandException(_('Notice with that id does not exist.'));
         }
         return $notice;
     }
@@ -122,7 +123,9 @@ class Command
         }
         Event::handle('EndCommandGetProfile', array($this, $arg, &$profile));
         if (!$profile) {
-            throw new CommandException(sprintf(_('Could not find a user with nickname %s'), $arg));
+            // TRANS: Message given requesting a profile for a non-existing user.
+            // TRANS: %s is the nickname of the user for which the profile could not be found.
+            throw new CommandException(sprintf(_('Could not find a user with nickname %s.'), $arg));
         }
         return $profile;
     }
@@ -140,7 +143,9 @@ class Command
         }
         Event::handle('EndCommandGetUser', array($this, $arg, &$user));
         if (!$user){
-            throw new CommandException(sprintf(_('Could not find a local user with nickname %s'),
+            // TRANS: Message given getting a non-existing user.
+            // TRANS: %s is the nickname of the user that could not be found.
+            throw new CommandException(sprintf(_('Could not find a local user with nickname %s.'),
                                $arg));
         }
         return $user;
@@ -159,6 +164,7 @@ class Command
         }
         Event::handle('EndCommandGetGroup', array($this, $arg, &$group));
         if (!$group) {
+            // TRANS: Command exception text shown when a group is requested that does not exist.
             throw new CommandException(_('No such group.'));
         }
         return $group;
@@ -173,6 +179,7 @@ class UnimplementedCommand extends Command
 {
     function handle($channel)
     {
+        // TRANS: Error text shown when an unimplemented command is given.
         $channel->error($this->user, _("Sorry, this command is not yet implemented."));
     }
 }
@@ -218,6 +225,7 @@ class NudgeCommand extends Command
     {
         $recipient = $this->getUser($this->other);
         if ($recipient->id == $this->user->id) {
+            // TRANS: Command exception text shown when a user tries to nudge themselves.
             throw new CommandException(_('It does not make a lot of sense to nudge yourself!'));
         } else {
             if ($recipient->email && $recipient->emailnotifynudge) {
@@ -225,7 +233,9 @@ class NudgeCommand extends Command
             }
             // XXX: notify by IM
             // XXX: notify by SMS
-            $channel->output($this->user, sprintf(_('Nudge sent to %s'),
+            // TRANS: Message given having nudged another user.
+            // TRANS: %s is the nickname of the user that was nudged.
+            $channel->output($this->user, sprintf(_('Nudge sent to %s.'),
                            $recipient->nickname));
         }
     }
@@ -251,6 +261,10 @@ class StatsCommand extends Command
         $subbed_count = $profile->subscriberCount();
         $notice_count = $profile->noticeCount();
 
+        // TRANS: User statistics text.
+        // TRANS: %1$s is the number of other user the user is subscribed to.
+        // TRANS: %2$s is the number of users that are subscribed to the user.
+        // TRANS: %3$s is the number of notices the user has sent.
         $channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
                                    "Subscribers: %2\$s\n".
                                    "Notices: %3\$s"),
@@ -276,6 +290,7 @@ class FavCommand extends Command
         $fave = Fave::addNew($this->user->getProfile(), $notice);
 
         if (!$fave) {
+            // TRANS: Error message text shown when a favorite could not be set.
             $channel->error($this->user, _('Could not create favorite.'));
             return;
         }
@@ -293,9 +308,9 @@ class FavCommand extends Command
 
         $this->user->blowFavesCache();
 
+        // TRANS: Text shown when a notice has been marked as favourite successfully.
         $channel->output($this->user, _('Notice marked as fave.'));
     }
-
 }
 
 class JoinCommand extends Command
@@ -314,10 +329,12 @@ class JoinCommand extends Command
         $cur   = $this->user;
 
         if ($cur->isMember($group)) {
-            $channel->error($cur, _('You are already a member of that group'));
+            // TRANS: Error text shown a user tries to join a group they already are a member of.
+            $channel->error($cur, _('You are already a member of that group.'));
             return;
         }
         if (Group_block::isBlocked($group, $cur->getProfile())) {
+            // TRANS: Error text shown when a user tries to join a group they are blocked from joining.
           $channel->error($cur, _('You have been blocked from that group by the admin.'));
             return;
         }
@@ -328,17 +345,21 @@ class JoinCommand extends Command
                 Event::handle('EndJoinGroup', array($group, $cur));
             }
         } catch (Exception $e) {
-            $channel->error($cur, sprintf(_('Could not join user %s to group %s'),
+            // TRANS: Message given having failed to add a user to a group.
+            // TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
+            $channel->error($cur, sprintf(_('Could not join user %1$s to group %2$s.'),
                                           $cur->nickname, $group->nickname));
             return;
         }
 
-        $channel->output($cur, sprintf(_('%s joined group %s'),
+        // TRANS: Message given having added a user to a group.
+        // TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
+        $channel->output($cur, sprintf(_('%1$s joined group %2$s.'),
                                               $cur->nickname,
                                               $group->nickname));
     }
-
 }
+
 class DropCommand extends Command
 {
     var $other = null;
@@ -355,11 +376,13 @@ class DropCommand extends Command
         $cur   = $this->user;
 
         if (!$group) {
+            // TRANS: Error text shown when trying to leave a group that does not exist.
             $channel->error($cur, _('No such group.'));
             return;
         }
 
         if (!$cur->isMember($group)) {
+            // TRANS: Error text shown when trying to leave an existing group the user is not a member of.
             $channel->error($cur, _('You are not a member of that group.'));
             return;
         }
@@ -370,16 +393,19 @@ class DropCommand extends Command
                 Event::handle('EndLeaveGroup', array($group, $cur));
             }
         } catch (Exception $e) {
-            $channel->error($cur, sprintf(_('Could not remove user %s to group %s'),
+            // TRANS: Message given having failed to remove a user from a group.
+            // TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
+            $channel->error($cur, sprintf(_('Could not remove user %1$s from group %2$s.'),
                                           $cur->nickname, $group->nickname));
             return;
         }
 
-        $channel->output($cur, sprintf(_('%s left group %s'),
+        // TRANS: Message given having removed a user from a group.
+        // TRANS: %1$s is the nickname of the user, %2$s is the nickname of the group.
+        $channel->output($cur, sprintf(_('%1$s left group %2$s.'),
                                               $cur->nickname,
                                               $group->nickname));
     }
-
 }
 
 class WhoisCommand extends Command
@@ -395,18 +421,24 @@ class WhoisCommand extends Command
     {
         $recipient = $this->getProfile($this->other);
 
+        // TRANS: Whois output.
+        // TRANS: %1$s nickname of the queried user, %2$s is their profile URL.
         $whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
                          $recipient->profileurl);
         if ($recipient->fullname) {
+            // TRANS: Whois output. %s is the full name of the queried user.
             $whois .= "\n" . sprintf(_('Fullname: %s'), $recipient->fullname);
         }
         if ($recipient->location) {
+            // TRANS: Whois output. %s is the location of the queried user.
             $whois .= "\n" . sprintf(_('Location: %s'), $recipient->location);
         }
         if ($recipient->homepage) {
+            // TRANS: Whois output. %s is the homepage of the queried user.
             $whois .= "\n" . sprintf(_('Homepage: %s'), $recipient->homepage);
         }
         if ($recipient->bio) {
+            // TRANS: Whois output. %s is the bio information of the queried user.
             $whois .= "\n" . sprintf(_('About: %s'), $recipient->bio);
         }
         $channel->output($this->user, $whois);
@@ -434,12 +466,15 @@ class MessageCommand extends Command
             } catch (CommandException $f) {
                 throw $e;
             }
+            // TRANS: Command exception text shown when trying to send a direct message to a remote user (a user not registered at the current server).
+            // TRANS: %s is a remote profile.
             throw new CommandException(sprintf(_('%s is a remote profile; you can only send direct messages to users on the same server.'), $this->other));
         }
 
         $len = mb_strlen($this->text);
 
         if ($len == 0) {
+            // TRANS: Command exception text shown when trying to send a direct message to another user without content.
             $channel->error($this->user, _('No content!'));
             return;
         }
@@ -447,26 +482,35 @@ class MessageCommand extends Command
         $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'),
+            // XXX: i18n. Needs plural support.
+            // TRANS: Message given if content is too long.
+            // TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters.
+            $channel->error($this->user, sprintf(_('Message too long - maximum is %1$d characters, you sent %2$d.'),
                                                  Message::maxContent(), mb_strlen($this->text)));
             return;
         }
 
         if (!$other) {
+            // TRANS: Error text shown when trying to send a direct message to a user that does not exist.
             $channel->error($this->user, _('No such user.'));
             return;
         } else if (!$this->user->mutuallySubscribed($other)) {
+            // TRANS: Error text shown when trying to send a direct message to a user without a mutual subscription (each user must be subscribed to the other).
             $channel->error($this->user, _('You can\'t send a message to this user.'));
             return;
         } else if ($this->user->id == $other->id) {
+            // TRANS: Error text shown when trying to send a direct message to self.
             $channel->error($this->user, _('Don\'t send a message to yourself; just say it to yourself quietly instead.'));
             return;
         }
         $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
         if ($message) {
             $message->notify();
-            $channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
+            // TRANS: Message given have sent a direct message to another user.
+            // TRANS: %s is the name of the other user.
+            $channel->output($this->user, sprintf(_('Direct message to %s sent.'), $this->other));
         } else {
+            // TRANS: Error text shown sending a direct message fails with an unknown reason.
             $channel->error($this->user, _('Error sending direct message.'));
         }
     }
@@ -487,12 +531,14 @@ class RepeatCommand extends Command
 
         if($this->user->id == $notice->profile_id)
         {
-            $channel->error($this->user, _('Cannot repeat your own notice'));
+            // TRANS: Error text shown when trying to repeat an own notice.
+            $channel->error($this->user, _('Cannot repeat your own notice.'));
             return;
         }
 
         if ($this->user->getProfile()->hasRepeated($notice->id)) {
-            $channel->error($this->user, _('Already repeated that notice'));
+            // TRANS: Error text shown when trying to repeat an notice that was already repeated by the user.
+            $channel->error($this->user, _('Already repeated that notice.'));
             return;
         }
 
@@ -500,8 +546,11 @@ class RepeatCommand extends Command
 
         if ($repeat) {
 
-            $channel->output($this->user, sprintf(_('Notice from %s repeated'), $recipient->nickname));
+            // TRANS: Message given having repeated a notice from another user.
+            // TRANS: %s is the name of the user for which the notice was repeated.
+            $channel->output($this->user, sprintf(_('Notice from %s repeated.'), $recipient->nickname));
         } else {
+            // TRANS: Error text shown when repeating a notice fails with an unknown reason.
             $channel->error($this->user, _('Error repeating notice.'));
         }
     }
@@ -526,6 +575,7 @@ class ReplyCommand extends Command
         $len = mb_strlen($this->text);
 
         if ($len == 0) {
+            // TRANS: Command exception text shown when trying to reply to a notice without providing content for the reply.
             $channel->error($this->user, _('No content!'));
             return;
         }
@@ -533,7 +583,10 @@ class ReplyCommand extends Command
         $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'),
+            // XXX: i18n. Needs plural support.
+            // TRANS: Message given if content of a notice for a reply is too long.
+            // TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters.
+            $channel->error($this->user, sprintf(_('Notice too long - maximum is %1$d characters, you sent %2$d.'),
                                                  Notice::maxContent(), mb_strlen($this->text)));
             return;
         }
@@ -542,8 +595,11 @@ class ReplyCommand extends Command
                                   array('reply_to' => $notice->id));
 
         if ($notice) {
-            $channel->output($this->user, sprintf(_('Reply to %s sent'), $recipient->nickname));
+            // TRANS: Text shown having sent a reply to a notice successfully.
+            // TRANS: %s is the nickname of the user of the notice the reply was sent to.
+            $channel->output($this->user, sprintf(_('Reply to %s sent.'), $recipient->nickname));
         } else {
+            // TRANS: Error text shown when a reply to a notice fails with an unknown reason.
             $channel->error($this->user, _('Error saving notice.'));
         }
 
@@ -552,7 +608,6 @@ class ReplyCommand extends Command
 
 class GetCommand extends Command
 {
-
     var $other = null;
 
     function __construct($user, $other)
@@ -567,7 +622,8 @@ class GetCommand extends Command
 
         $notice = $target->getCurrentNotice();
         if (!$notice) {
-            $channel->error($this->user, _('User has no last notice'));
+            // TRANS: Error text shown when a last user notice is requested and it does not exist.
+            $channel->error($this->user, _('User has no last notice.'));
             return;
         }
         $notice_content = $notice->content;
@@ -578,7 +634,6 @@ class GetCommand extends Command
 
 class SubCommand extends Command
 {
-
     var $other = null;
 
     function __construct($user, $other)
@@ -591,7 +646,8 @@ class SubCommand extends Command
     {
 
         if (!$this->other) {
-            $channel->error($this->user, _('Specify the name of the user to subscribe to'));
+            // TRANS: Error text shown when no username was provided when issuing a subscribe command.
+            $channel->error($this->user, _('Specify the name of the user to subscribe to.'));
             return;
         }
 
@@ -599,13 +655,16 @@ class SubCommand extends Command
 
         $remote = Remote_profile::staticGet('id', $target->id);
         if ($remote) {
+            // TRANS: Command exception text shown when trying to subscribe to an OMB profile using the subscribe command.
             throw new CommandException(_("Can't subscribe to OMB profiles by command."));
         }
 
         try {
             Subscription::start($this->user->getProfile(),
                                 $target);
-            $channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
+            // TRANS: Text shown after having subscribed to another user successfully.
+            // TRANS: %s is the name of the user the subscription was requested for.
+            $channel->output($this->user, sprintf(_('Subscribed to %s.'), $this->other));
         } catch (Exception $e) {
             $channel->error($this->user, $e->getMessage());
         }
@@ -614,7 +673,6 @@ class SubCommand extends Command
 
 class UnsubCommand extends Command
 {
-
     var $other = null;
 
     function __construct($user, $other)
@@ -626,7 +684,8 @@ class UnsubCommand extends Command
     function handle($channel)
     {
         if(!$this->other) {
-            $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
+            // TRANS: Error text shown when no username was provided when issuing an unsubscribe command.
+            $channel->error($this->user, _('Specify the name of the user to unsubscribe from.'));
             return;
         }
 
@@ -635,7 +694,9 @@ class UnsubCommand extends Command
         try {
             Subscription::cancel($this->user->getProfile(),
                                  $target);
-            $channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
+            // TRANS: Text shown after having unsubscribed from another user successfully.
+            // TRANS: %s is the name of the user the unsubscription was requested for.
+            $channel->output($this->user, sprintf(_('Unsubscribed from %s.'), $this->other));
         } catch (Exception $e) {
             $channel->error($this->user, $e->getMessage());
         }
@@ -645,6 +706,7 @@ class UnsubCommand extends Command
 class OffCommand extends Command
 {
     var $other = null;
+
     function __construct($user, $other=null)
     {
         parent::__construct($user);
@@ -653,11 +715,14 @@ class OffCommand extends Command
     function handle($channel)
     {
         if ($this->other) {
+            // TRANS: Error text shown when issuing the command "off" with a setting which has not yet been implemented.
             $channel->error($this->user, _("Command not yet implemented."));
         } else {
             if ($channel->off($this->user)) {
+                // TRANS: Text shown when issuing the command "off" successfully.
                 $channel->output($this->user, _('Notification off.'));
             } else {
+                // TRANS: Error text shown when the command "off" fails for an unknown reason.
                 $channel->error($this->user, _('Can\'t turn off notification.'));
             }
         }
@@ -676,11 +741,14 @@ class OnCommand extends Command
     function handle($channel)
     {
         if ($this->other) {
+            // TRANS: Error text shown when issuing the command "on" with a setting which has not yet been implemented.
             $channel->error($this->user, _("Command not yet implemented."));
         } else {
             if ($channel->on($this->user)) {
+                // TRANS: Text shown when issuing the command "on" successfully.
                 $channel->output($this->user, _('Notification on.'));
             } else {
+                // TRANS: Error text shown when the command "on" fails for an unknown reason.
                 $channel->error($this->user, _('Can\'t turn on notification.'));
             }
         }
@@ -694,7 +762,8 @@ class LoginCommand extends Command
         $disabled = common_config('logincommand','disabled');
         $disabled = isset($disabled) && $disabled;
         if($disabled) {
-            $channel->error($this->user, _('Login command is disabled'));
+            // TRANS: Error text shown when issuing the login command while login is disabled.
+            $channel->error($this->user, _('Login command is disabled.'));
             return;
         }
 
@@ -705,7 +774,9 @@ class LoginCommand extends Command
         }
 
         $channel->output($this->user,
-            sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'),
+            // TRANS: Text shown after issuing the login command successfully.
+            // TRANS: %s is a logon link..
+            sprintf(_('This link is useable only once and is valid for only 2 minutes: %s.'),
                     common_local_url('otp',
                         array('user_id' => $login_token->user_id, 'token' => $login_token->token))));
     }
@@ -713,7 +784,6 @@ class LoginCommand extends Command
 
 class LoseCommand extends Command
 {
-
     var $other = null;
 
     function __construct($user, $other)
@@ -725,14 +795,17 @@ class LoseCommand extends Command
     function execute($channel)
     {
         if(!$this->other) {
-            $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
+            // TRANS: Error text shown when no username was provided when issuing the command.
+            $channel->error($this->user, _('Specify the name of the user to unsubscribe from.'));
             return;
         }
 
         $result = Subscription::cancel($this->getProfile($this->other), $this->user->getProfile());
 
         if ($result) {
-            $channel->output($this->user, sprintf(_('Unsubscribed  %s'), $this->other));
+            // TRANS: Text shown after issuing the lose command successfully (stop another user from following the current user).
+            // TRANS: %s is the name of the user the unsubscription was requested for.
+            $channel->output($this->user, sprintf(_('Unsubscribed %s.'), $this->other));
         } else {
             $channel->error($this->user, $result);
         }
@@ -749,8 +822,12 @@ class SubscriptionsCommand extends Command
             $nicknames[]=$profile->nickname;
         }
         if(count($nicknames)==0){
+            // TRANS: Text shown after requesting other users a user is subscribed to without having any subscriptions.
             $out=_('You are not subscribed to anyone.');
         }else{
+            // TRANS: Text shown after requesting other users a user is subscribed to.
+            // TRANS: This message supports plural forms. This message is followed by a
+            // TRANS: hard coded space and a comma separated list of subscribed users.
             $out = ngettext('You are subscribed to this person:',
                 'You are subscribed to these people:',
                 count($nicknames));
@@ -771,8 +848,13 @@ class SubscribersCommand extends Command
             $nicknames[]=$profile->nickname;
         }
         if(count($nicknames)==0){
+            // TRANS: Text shown after requesting other users that are subscribed to a user
+            // TRANS: (followers) without having any subscribers.
             $out=_('No one is subscribed to you.');
         }else{
+            // TRANS: Text shown after requesting other users that are subscribed to a user (followers).
+            // TRANS: This message supports plural forms. This message is followed by a
+            // TRANS: hard coded space and a comma separated list of subscribing users.
             $out = ngettext('This person is subscribed to you:',
                 'These people are subscribed to you:',
                 count($nicknames));
@@ -793,8 +875,13 @@ class GroupsCommand extends Command
             $groups[]=$group->nickname;
         }
         if(count($groups)==0){
+            // TRANS: Text shown after requesting groups a user is subscribed to without having
+            // TRANS: any group subscriptions.
             $out=_('You are not a member of any groups.');
         }else{
+            // TRANS: Text shown after requesting groups a user is subscribed to.
+            // TRANS: This message supports plural forms. This message is followed by a
+            // TRANS: hard coded space and a comma separated list of subscribed groups.
             $out = ngettext('You are a member of this group:',
                 'You are a member of these groups:',
                 count($nicknames));
@@ -809,6 +896,7 @@ class HelpCommand extends Command
     function handle($channel)
     {
         $channel->output($this->user,
+                         // TRANS: Help text for commands. Do not translate the command names themselves; they are fixed strings.
                          _("Commands:\n".
                            "on - turn on notifications\n".
                            "off - turn off notifications\n".