]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SearchSub/searchsubuntrackcommand.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into prefillbookmark
[quix0rs-gnu-social.git] / plugins / SearchSub / searchsubuntrackcommand.php
1 <?php
2
3 class SearchSubUntrackCommand 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 untrack a search query they're not subscribed to.
21             $channel->error($cur, sprintf(_m('You are not tracking the search "%s".'), $this->keyword));
22             return;
23         }
24
25         try {
26             SearchSub::cancel($cur->getProfile(), $this->keyword);
27         } catch (Exception $e) {
28             // TRANS: Message given having failed to cancel a search subscription by untrack command.
29             $channel->error($cur, sprintf(_m('Could not end a search subscription for query "%s".'),
30                                           $this->keyword));
31             return;
32         }
33
34         // TRANS: Message given having removed a search subscription by untrack command.
35         $channel->output($cur, sprintf(_m('You are no longer subscribed to the search "%s".'),
36                                               $this->keyword));
37     }
38 }