]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SearchSub/lib/searchsubtrackcommand.php
plugins onAutoload now only overloads if necessary (extlibs etc.)
[quix0rs-gnu-social.git] / plugins / SearchSub / lib / searchsubtrackcommand.php
1 <?php
2
3 class SearchSubTrackCommand extends Command
4 {
5     var $keyword = null;
6
7     function __construct($user, $keyword)
8     {
9         parent::__construct($user);
10         $this->keyword = $keyword;
11     }
12
13     function handle($channel)
14     {
15         $cur = $this->user;
16         $searchsub = SearchSub::pkeyGet(array('search' => $this->keyword,
17                                               'profile_id' => $cur->id));
18
19         if ($searchsub) {
20             // TRANS: Error text shown a user tries to track a search query they're already subscribed to.
21             $channel->error($cur, sprintf(_m('You are already tracking the search "%s".'), $this->keyword));
22             return;
23         }
24
25         try {
26             SearchSub::start($cur->getProfile(), $this->keyword);
27         } catch (Exception $e) {
28             // TRANS: Message given having failed to set up a search subscription by track command.
29             $channel->error($cur, sprintf(_m('Could not start a search subscription for query "%s".'),
30                                           $this->keyword));
31             return;
32         }
33
34         // TRANS: Message given having added a search subscription by track command.
35         $channel->output($cur, sprintf(_m('You are subscribed to the search "%s".'),
36                                               $this->keyword));
37     }
38 }