]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/SearchSub/actions/searchunsub.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / SearchSub / actions / searchunsub.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008-2011, StatusNet, Inc.
5  *
6  * Search subscription action.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Affero General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  * PHP version 5
22  *
23  * @category  Action
24  * @package   StatusNet
25  * @author    Brion Vibber <brion@status.net>
26  * @author    Evan Prodromou <evan@status.net>
27  * @copyright 2008-2010 StatusNet, Inc.
28  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
29  * @link      http://status.net/
30  */
31
32 if (!defined('STATUSNET')) {
33     exit(1);
34 }
35
36 /**
37  * Search unsubscription action
38  *
39  * Takes parameters:
40  *
41  *    - token: session token to prevent CSRF attacks
42  *    - ajax: boolean; whether to return Ajax or full-browser results
43  *
44  * Only works if the current user is logged in.
45  *
46  * @category  Action
47  * @package   StatusNet
48  * @author    Evan Prodromou <evan@status.net>
49  * @author    Brion Vibber <brion@status.net>
50  * @copyright 2008-2011 StatusNet, Inc.
51  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
52  * @link      http://status.net/
53  */
54 class SearchunsubAction extends SearchsubAction
55 {
56     /**
57      * Handle request
58      *
59      * Does the subscription and returns results.
60      *
61      * @param Array $args unused.
62      *
63      * @return void
64      */
65     function handle(array $args=array())
66     {
67         // Throws exception on error
68
69         SearchSub::cancel($this->user->getProfile(),
70                        $this->search);
71
72         if ($this->boolean('ajax')) {
73             $this->startHTML('text/xml;charset=utf-8');
74             $this->elementStart('head');
75             // TRANS: Page title when search unsubscription succeeded.
76             $this->element('title', null, _m('Unsubscribed'));
77             $this->elementEnd('head');
78             $this->elementStart('body');
79             $subscribe = new SearchSubForm($this, $this->search);
80             $subscribe->show();
81             $this->elementEnd('body');
82             $this->endHTML();
83         } else {
84             $url = common_local_url('search',
85                                     array('search' => $this->search));
86             common_redirect($url, 303);
87         }
88     }
89 }