3 class FavCommand extends Command
7 function __construct($user, $other)
9 parent::__construct($user);
10 $this->other = $other;
13 function handle($channel)
15 $notice = $this->getNotice($this->other);
18 $fave->user_id = $this->user->id;
19 $fave->notice_id = $notice->id;
23 // TRANS: Error message text shown when a favorite could not be set because it has already been favorited.
24 $channel->error($this->user, _('Could not create favorite: Already favorited.'));
29 $fave = Fave::addNew($this->user->getProfile(), $notice);
30 } catch (Exception $e) {
31 $channel->error($this->user, $e->getMessage());
35 // @fixme favorite notification should be triggered
38 $other = User::getKV('id', $notice->profile_id);
40 if ($other && $other->id != $this->user->id && !empty($other->email)) {
41 require_once INSTALLDIR.'/lib/mail.php';
43 mail_notify_fave($other, $this->user->getProfile(), $notice);
46 Fave::blowCacheForProfileId($this->user->id);
48 // TRANS: Text shown when a notice has been marked as favourite successfully.
49 $channel->output($this->user, _('Notice marked as fave.'));