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.')); }
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; } $list = array(); while ($all->fetch()) { $list[] = $all->search; } // TRANS: Separator for list of tracked searches. $separator = _m('SEPARATOR', '", "'); // TRANS: Message given having disabled all search subscriptions with 'track off'. // TRANS: %s is a list of searches. Separator default is '", "'. $channel->output($cur, sprintf(_m('You are tracking searches for: "%s".'), implode($separator, $list))); }
function showContent() { if (Event::handle('StartShowTagSubscriptionsContent', array($this))) { parent::showContent(); $offset = ($this->page - 1) * PROFILES_PER_PAGE; $limit = PROFILES_PER_PAGE + 1; $cnt = 0; $searchsub = new SearchSub(); $searchsub->profile_id = $this->getTarget()->getID(); $searchsub->limit($limit, $offset); $searchsub->find(); if ($searchsub->N) { $list = new SearchSubscriptionsList($searchsub, $this->getTarget(), $this); $cnt = $list->show(); if (0 == $cnt) { $this->showEmptyListMessage(); } } else { $this->showEmptyListMessage(); } $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'searchsubs', array('nickname' => $this->getTarget()->getNickname())); Event::handle('EndShowTagSubscriptionsContent', array($this)); } }
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)); }
/** * 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)); }
static function forProfile(Profile $profile) { $searches = array(); $keypart = sprintf('searchsub:by_profile:%d', $profile->id); $searchstring = self::cacheGet($keypart); if ($searchstring !== false && !empty($searchstring)) { $searches = explode(',', $searchstring); } else { $searchsub = new SearchSub(); $searchsub->profile_id = $profile->id; if ($searchsub->find()) { while ($searchsub->fetch()) { if (!empty($searchsub->search)) { $searches[] = $searchsub->search; } } } self::cacheSet($keypart, implode(',', $searches)); } return $searches; }
function onEndDefaultLocalNav($menu, $user) { $user = common_current_user(); if (!empty($user)) { $searches = SearchSub::forProfile($user->getProfile()); if (!empty($searches) && count($searches) > 0) { $searchSubMenu = new SearchSubMenu($menu->out, $user, $searches); // TRANS: Sub menu for searches. $menu->submenu(_m('MENU', 'Searches'), $searchSubMenu); } } return true; }