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