123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- defined('GNUSOCIAL') || die();
- class SearchsubAction extends Action
- {
- public $user;
- public $search;
-
- public function prepare(array $args = [])
- {
- parent::prepare($args);
- if ($this->boolean('ajax')) {
- GNUsocial::setApi(true);
- }
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-
-
- $this->clientError(_m('This action only accepts POST requests.'));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_m('There was a problem with your session token.' .
- ' Try again, please.'));
- }
-
- $this->user = common_current_user();
- if (empty($this->user)) {
-
- $this->clientError(_m('Not logged in.'));
- }
-
- $this->search = $this->arg('search');
- if (empty($this->search)) {
-
- $this->clientError(_m('No such profile.'));
- }
- return true;
- }
-
- public function handle()
- {
-
- SearchSub::start(
- $this->user->getProfile(),
- $this->search
- );
- if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
- $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);
- }
- }
- }
|