3 * StatusNet, the distributed open-source microblogging tool
5 * List the OAuth applications that a user has registered with this instance
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2008-2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 * Show a user's registered OAuth applications
39 * @author Zach Copley <zach@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
46 class OauthappssettingsAction extends SettingsAction
50 function prepare($args)
52 parent::prepare($args);
53 $this->page = ($this->arg('page')) ? ($this->arg('page') + 0) : 1;
55 if (!common_logged_in()) {
56 // TRANS: Message displayed to an anonymous user trying to view OAuth application list.
57 $this->clientError(_('You must be logged in to list your applications.'));
67 * @return string Title of the page
72 // TRANS: Page title for OAuth applications
73 return _('OAuth applications');
77 * Instructions for use
79 * @return instructions for use
82 function getInstructions()
84 // TRANS: Page instructions for OAuth applications
85 return _('Applications you have registered');
89 * Content area of the page
94 function showContent()
96 $user = common_current_user();
98 $offset = ($this->page - 1) * APPS_PER_PAGE;
99 $limit = APPS_PER_PAGE + 1;
101 $application = new Oauth_application();
102 $application->owner = $user->id;
103 $application->whereAdd("name != 'anonymous'");
104 $application->limit($offset, $limit);
105 $application->orderBy('created DESC');
106 $application->find();
111 $al = new ApplicationList($application, $user, $this);
114 $this->showEmptyListMessage();
118 $this->elementStart('p', array('id' => 'application_register'));
120 array('href' => common_local_url('newapplication'),
123 // TRANS: Link description to add a new OAuth application.
124 'Register a new application');
125 $this->elementEnd('p');
129 $cnt > APPS_PER_PAGE,
135 function showEmptyListMessage()
137 // TRANS: Empty list message on page with OAuth applications.
138 $message = sprintf(_('You have not registered any applications yet.'));
140 $this->elementStart('div', 'guide');
141 $this->raw(common_markup_to_html($message));
142 $this->elementEnd('div');
146 * Handle posts to this form
148 * Based on the button that was pressed, muxes out to other functions
149 * to do the actual task requested.
151 * All sub-functions reload the form with a message -- success or failure.
156 function handlePost()
160 $token = $this->trimmed('token');
161 if (!$token || $token != common_session_token()) {
162 $this->showForm(_('There was a problem with your session token. '.
163 'Try again, please.'));