function handle($channel)
 {
     $cur = $this->user;
     $all = new SearchSub();
     $all->profile_id = $cur->id;
     $all->find();
     if ($all->N == 0) {
         // TRANS: Error text shown a user tries to disable all a search subscriptions with track off command, but has none.
         $channel->error($cur, _m('You are not tracking any searches.'));
         return;
     }
     $profile = $cur->getProfile();
     while ($all->fetch()) {
         try {
             SearchSub::cancel($profile, $all->search);
         } catch (Exception $e) {
             // TRANS: Message given having failed to cancel one of the search subs with 'track off' command.
             // TRANS: %s is the search for which the subscription removal failed.
             $channel->error($cur, sprintf(_m('Error disabling search subscription for query "%s".'), $all->search));
             return;
         }
     }
     // TRANS: Message given having disabled all search subscriptions with 'track off'.
     $channel->output($cur, _m('Disabled all your search subscriptions.'));
 }
Example #2
0
 /**
  * Handle request
  *
  * Does the subscription and returns results.
  *
  * @param Array $args unused.
  *
  * @return void
  */
 function handle($args)
 {
     // Throws exception on error
     SearchSub::cancel($this->user->getProfile(), $this->search);
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Page title when search unsubscription succeeded.
         $this->element('title', null, _m('Unsubscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $subscribe = new SearchSubForm($this, $this->search);
         $subscribe->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         $url = common_local_url('search', array('search' => $this->search));
         common_redirect($url, 303);
     }
 }
 function handle($channel)
 {
     $cur = $this->user;
     $searchsub = SearchSub::pkeyGet(array('search' => $this->keyword, 'profile_id' => $cur->id));
     if (!$searchsub) {
         // TRANS: Error text shown a user tries to untrack a search query they're not subscribed to.
         // TRANS: %s is the keyword for the search.
         $channel->error($cur, sprintf(_m('You are not tracking the search "%s".'), $this->keyword));
         return;
     }
     try {
         SearchSub::cancel($cur->getProfile(), $this->keyword);
     } catch (Exception $e) {
         // TRANS: Message given having failed to cancel a search subscription by untrack command.
         // TRANS: %s is the keyword for the query.
         $channel->error($cur, sprintf(_m('Could not end a search subscription for query "%s".'), $this->keyword));
         return;
     }
     // TRANS: Message given having removed a search subscription by untrack command.
     // TRANS: %s is the keyword for the search.
     $channel->output($cur, sprintf(_m('You are no longer subscribed to the search "%s".'), $this->keyword));
 }