/** * End a search subscription! * * @param profile $profile subscriber * @param string $search subscribee */ static function cancel(Profile $profile, $search) { $ts = SearchSub::pkeyGet(array('search' => $search, 'profile_id' => $profile->id)); if ($ts) { $ts->delete(); self::blow('searchsub:by_profile:%d', $profile->id); } }
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)); }
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)); }
/** * * @param NoticeSearchAction $action * @param string $q * @param Notice $notice * @return boolean hook result */ function onStartNoticeSearchShowResults($action, $q, $notice) { $user = common_current_user(); if ($user) { $search = $q; $searchsub = SearchSub::pkeyGet(array('search' => $search, 'profile_id' => $user->id)); if ($searchsub) { $form = new SearchUnsubForm($action, $search); } else { $form = new SearchSubForm($action, $search); } $action->elementStart('div', 'entity_actions'); $action->elementStart('ul'); $action->elementStart('li', 'entity_subscribe'); $form->show(); $action->elementEnd('li'); $action->elementEnd('ul'); $action->elementEnd('div'); } return true; }