X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fcommand.php;h=02324280baec871a361c7700e591cb6d1c3f931b;hb=571ba1369b7598f7a5c3c154363f72c74b1ed1ad;hp=04c2e57ec8689b3372b3adf79ad39844e162c22d;hpb=fcba540a14fb227e5d455d12ff2d7311b25e7c2e;p=quix0rs-gnu-social.git diff --git a/lib/command.php b/lib/command.php index 04c2e57ec8..02324280ba 100644 --- a/lib/command.php +++ b/lib/command.php @@ -23,10 +23,12 @@ require_once(INSTALLDIR.'/lib/channel.php'); class Command { + protected $scoped = null; // The Profile of the user performing the command var $user = null; function __construct($user=null) { + $this->scoped = $user->getProfile(); $this->user = $user; } @@ -274,57 +276,6 @@ class StatsCommand extends Command } } -class FavCommand extends Command -{ - var $other = null; - - function __construct($user, $other) - { - parent::__construct($user); - $this->other = $other; - } - - function handle($channel) - { - $notice = $this->getNotice($this->other); - - $fave = new Fave(); - $fave->user_id = $this->user->id; - $fave->notice_id = $notice->id; - $fave->find(); - - if ($fave->fetch()) { - // TRANS: Error message text shown when a favorite could not be set because it has already been favorited. - $channel->error($this->user, _('Could not create favorite: Already favorited.')); - return; - } - - $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; - } - - // @fixme favorite notification should be triggered - // at a lower level - - $other = User::getKV('id', $notice->profile_id); - - if ($other && $other->id != $this->user->id) { - if ($other->email && $other->emailnotifyfav) { - mail_notify_fave($other, $this->user, $notice); - } - } - - $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 { var $other = null; @@ -586,7 +537,7 @@ class MessageCommand extends Command function handle($channel) { try { - $other = $this->getUser($this->other); + $other = $this->getUser($this->other)->getProfile(); } catch (CommandException $e) { try { $profile = $this->getProfile($this->other); @@ -619,7 +570,7 @@ class MessageCommand extends Command return; } - if (!$other) { + if (!$other instanceof Profile) { // 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; @@ -659,7 +610,7 @@ class RepeatCommand extends Command $notice = $this->getNotice($this->other); try { - $repeat = $notice->repeat($this->user->id, $channel->source()); + $repeat = $notice->repeat($this->scoped->id, $channel->source()); $recipient = $notice->getProfile(); // TRANS: Message given having repeated a notice from another user. @@ -980,7 +931,7 @@ class GroupsCommand extends Command { $group = $this->user->getGroups(); $groups=array(); - while ($group->fetch()) { + while ($group instanceof User_group && $group->fetch()) { $groups[]=$group->nickname; } if(count($groups)==0){ @@ -1034,10 +985,6 @@ class HelpCommand extends Command "whois " => _m('COMMANDHELP', "get profile info on user"), // TRANS: Help message for IM/SMS command "lose ". "lose " => _m('COMMANDHELP', "force user to stop following you"), - // TRANS: Help message for IM/SMS command "fav ". - "fav " => _m('COMMANDHELP', "add user's last notice as a 'fave'"), - // TRANS: Help message for IM/SMS command "fav #". - "fav #" => _m('COMMANDHELP', "add notice with the given id as a 'fave'"), // TRANS: Help message for IM/SMS command "repeat #". "repeat #" => _m('COMMANDHELP', "repeat a notice with a given id"), // TRANS: Help message for IM/SMS command "repeat ". @@ -1087,6 +1034,8 @@ class HelpCommand extends Command // Give plugins a chance to add or override... Event::handle('HelpCommandMessages', array($this, &$commands)); + + sort($commands); foreach ($commands as $command => $help) { $out[] = "$command - $help"; }