/** * 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); } }
/** * * @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; }