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 track a search query they're already subscribed to.
         $channel->error($cur, sprintf(_m('You are already tracking the search "%s".'), $this->keyword));
         return;
     }
     try {
         SearchSub::start($cur->getProfile(), $this->keyword);
     } catch (Exception $e) {
         // TRANS: Message given having failed to set up a search subscription by track command.
         $channel->error($cur, sprintf(_m('Could not start a search subscription for query "%s".'), $this->keyword));
         return;
     }
     // TRANS: Message given having added a search subscription by track command.
     $channel->output($cur, sprintf(_m('You are subscribed to the search "%s".'), $this->keyword));
 }
Exemplo n.º 2
0
 /**
  * Handle request
  *
  * Does the subscription and returns results.
  *
  * @param Array $args unused.
  *
  * @return void
  */
 function handle($args)
 {
     // Throws exception on error
     SearchSub::start($this->user->getProfile(), $this->search);
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Page title when search subscription succeeded.
         $this->element('title', null, _m('Subscribed'));
         $this->elementEnd('head');
         $this->elementStart('body');
         $unsubscribe = new SearchUnsubForm($this, $this->search);
         $unsubscribe->show();
         $this->elementEnd('body');
         $this->endHTML();
     } else {
         $url = common_local_url('search', array('search' => $this->search));
         common_redirect($url, 303);
     }
 }