]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/userauthorization.php
better page numbers
[quix0rs-gnu-social.git] / actions / userauthorization.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 class UserauthorizationAction extends Action {
23         function handle($args) {
24                 parent::handle($args);
25                 
26                 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
27                         $this->send_authorization();
28                 } else {
29                         try {
30                                 $req = $this->get_request();
31                                 $server = common_oauth_server();
32                                 list($consumer, $token) = $server->verify_request($req);
33                         } catch (OAuthException $e) {
34                                 $this->clear_request();
35                                 common_server_error($e->getMessage());
36                                 return;
37                         }
38                         
39                         if (common_logged_in()) {
40                                 $this->show_form($req);
41                         } else {
42                                 common_return_to(common_local_url('userauthorization'));
43                                 common_redirect(common_local_url('login'));
44                         }
45                 }
46         }
47         
48         function store_request($req) {
49                 common_ensure_session();
50                 $_SESSION['userauthorizationrequest'] = $req;
51         }
52         
53         function get_request() {
54                 common_ensure_session();                
55                 $req = $_SESSION['userauthorizationrequest'];
56                 if (!$req) {
57                         # XXX: may have an uncaught exception
58                         $req = OAuthRequest::from_request();
59                         $this->store_request($req);
60                 }
61                 return $req;
62         }
63         
64         function show_form($req) {
65                 common_show_header(_t('Authorize subscription'));
66
67                 common_show_footer();
68         }
69         
70         function send_authorization() {
71                 $req = $this->get_request();
72                 if (!$req) {
73                         common_user_error(_t('No authorization request!'));
74                         return;
75                 }
76                 
77                 if ($this->boolean('authorize')) {
78                         
79                 }
80         }
81 }