+++ /dev/null
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * List the OAuth applications that a user has registered with this instance
- *
- * PHP version 5
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category Settings
- * @package StatusNet
- * @author Zach Copley <zach@status.net>
- * @copyright 2008-2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once INSTALLDIR . '/lib/settingsaction.php';
-require_once INSTALLDIR . '/lib/applicationlist.php';
-
-/**
- * Show a user's registered OAuth applications
- *
- * @category Settings
- * @package StatusNet
- * @author Zach Copley <zach@status.net>
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- *
- * @see SettingsAction
- */
-
-class AppsAction extends SettingsAction
-{
- var $page = 0;
-
- function prepare($args)
- {
- parent::prepare($args);
- $this->page = ($this->arg('page')) ? ($this->arg('page') + 0) : 1;
-
- if (!common_logged_in()) {
- $this->clientError(_('You must be logged in to list your applications.'));
- return false;
- }
-
- return true;
- }
-
- /**
- * Title of the page
- *
- * @return string Title of the page
- */
-
- function title()
- {
- return _('OAuth applications');
- }
-
- /**
- * Instructions for use
- *
- * @return instructions for use
- */
-
- function getInstructions()
- {
- return _('Applications you have registered');
- }
-
- /**
- * Content area of the page
- *
- * @return void
- */
-
- function showContent()
- {
- $user = common_current_user();
-
- $offset = ($this->page - 1) * APPS_PER_PAGE;
- $limit = APPS_PER_PAGE + 1;
-
- $application = new Oauth_application();
- $application->owner = $user->id;
- $application->limit($offset, $limit);
- $application->orderBy('created DESC');
- $application->find();
-
- $cnt = 0;
-
- if ($application) {
- $al = new ApplicationList($application, $user, $this);
- $cnt = $al->show();
- if (0 == $cnt) {
- $this->showEmptyListMessage();
- }
- }
-
- $this->elementStart('p', array('id' => 'application_register'));
- $this->element('a',
- array('href' => common_local_url(
- 'newapplication',
- array('nickname' => $user->nickname)
- ),
- 'class' => 'more'
- ),
- 'Register a new application');
- $this->elementEnd('p');
-
- $this->pagination(
- $this->page > 1,
- $cnt > APPS_PER_PAGE,
- $this->page,
- 'apps',
- array('nickname' => $user->nickname)
- );
- }
-
- function showEmptyListMessage()
- {
- $message = sprintf(_('You have not registered any applications yet.'));
-
- $this->elementStart('div', 'guide');
- $this->raw(common_markup_to_html($message));
- $this->elementEnd('div');
- }
-
- /**
- * Handle posts to this form
- *
- * Based on the button that was pressed, muxes out to other functions
- * to do the actual task requested.
- *
- * All sub-functions reload the form with a message -- success or failure.
- *
- * @return void
- */
-
- function handlePost()
- {
- // CSRF protection
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
- $this->showForm(_('There was a problem with your session token. '.
- 'Try again, please.'));
- return;
- }
-
- }
-
-}
if ($this->arg('cancel')) {
common_redirect(common_local_url('showapplication',
- array(
- 'nickname' => $cur->nickname,
- 'id' => $this->app->id)
- ), 303);
+ array('id' => $this->app->id)), 303);
} elseif ($this->arg('save')) {
$this->trySave();
} else {
$this->app->uploadLogo();
- common_redirect(common_local_url('apps',
- array('nickname' => $cur->nickname)), 303);
+ common_redirect(common_local_url('oauthappssettings'), 303);
}
}
$cur = common_current_user();
if ($this->arg('cancel')) {
- common_redirect(common_local_url('apps',
- array('nickname' => $cur->nickname)), 303);
+ common_redirect(common_local_url('oauthappssettings'), 303);
} elseif ($this->arg('save')) {
$this->trySave();
} else {
function trySave()
{
- $name = $this->trimmed('name');
+ $name = $this->trimmed('name');
$description = $this->trimmed('description');
$source_url = $this->trimmed('source_url');
$organization = $this->trimmed('organization');
$app->query('COMMIT');
- common_redirect(common_local_url('apps',
- array('nickname' => $cur->nickname)), 303);
+ common_redirect(common_local_url('oauthappssettings'), 303);
}
--- /dev/null
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * List the OAuth applications that a user has registered with this instance
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Settings
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/settingsaction.php';
+require_once INSTALLDIR . '/lib/applicationlist.php';
+
+/**
+ * Show a user's registered OAuth applications
+ *
+ * @category Settings
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ * @see SettingsAction
+ */
+
+class OauthappssettingsAction extends SettingsAction
+{
+ var $page = 0;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $this->page = ($this->arg('page')) ? ($this->arg('page') + 0) : 1;
+
+ if (!common_logged_in()) {
+ $this->clientError(_('You must be logged in to list your applications.'));
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Title of the page
+ *
+ * @return string Title of the page
+ */
+
+ function title()
+ {
+ return _('OAuth applications');
+ }
+
+ /**
+ * Instructions for use
+ *
+ * @return instructions for use
+ */
+
+ function getInstructions()
+ {
+ return _('Applications you have registered');
+ }
+
+ /**
+ * Content area of the page
+ *
+ * @return void
+ */
+
+ function showContent()
+ {
+ $user = common_current_user();
+
+ $offset = ($this->page - 1) * APPS_PER_PAGE;
+ $limit = APPS_PER_PAGE + 1;
+
+ $application = new Oauth_application();
+ $application->owner = $user->id;
+ $application->limit($offset, $limit);
+ $application->orderBy('created DESC');
+ $application->find();
+
+ $cnt = 0;
+
+ if ($application) {
+ $al = new ApplicationList($application, $user, $this);
+ $cnt = $al->show();
+ if (0 == $cnt) {
+ $this->showEmptyListMessage();
+ }
+ }
+
+ $this->elementStart('p', array('id' => 'application_register'));
+ $this->element('a',
+ array('href' => common_local_url('newapplication'),
+ 'class' => 'more'
+ ),
+ 'Register a new application');
+ $this->elementEnd('p');
+
+ $this->pagination(
+ $this->page > 1,
+ $cnt > APPS_PER_PAGE,
+ $this->page,
+ 'oauthappssettings'
+ );
+ }
+
+ function showEmptyListMessage()
+ {
+ $message = sprintf(_('You have not registered any applications yet.'));
+
+ $this->elementStart('div', 'guide');
+ $this->raw(common_markup_to_html($message));
+ $this->elementEnd('div');
+ }
+
+ /**
+ * Handle posts to this form
+ *
+ * Based on the button that was pressed, muxes out to other functions
+ * to do the actual task requested.
+ *
+ * All sub-functions reload the form with a message -- success or failure.
+ *
+ * @return void
+ */
+
+ function handlePost()
+ {
+ // CSRF protection
+
+ $token = $this->trimmed('token');
+ if (!$token || $token != common_session_token()) {
+ $this->showForm(_('There was a problem with your session token. '.
+ 'Try again, please.'));
+ return;
+ }
+
+ }
+
+}
$this->elementStart('p');
$this->raw(_('Developers can edit the registration settings for their applications '));
$this->element('a',
- array('href' => common_local_url('apps', array('nickname' => $cur->nickname))),
+ array('href' => common_local_url('oauthappssettings')),
'here.');
$this->elementEnd('p');
}
$this->elementStart('ul');
$this->elementStart('li', 'entity_edit');
$this->element('a',
- array('href' =>
- common_local_url(
- 'editapplication',
- array(
- 'nickname' => $this->owner->nickname,
- 'id' => $this->application->id
- )
- )
- ), 'Edit');
+ array('href' => common_local_url('editapplication',
+ array('id' => $this->application->id))),
+ 'Edit');
$this->elementEnd('li');
$this->elementStart('li', 'entity_reset_keysecret');
'class' => 'form_reset_key',
'method' => 'POST',
'action' => common_local_url('showapplication',
- array('nickname' => $cur->nickname,
- 'id' => $this->application->id))));
+ array('id' => $this->application->id))));
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
$this->elementStart('p', array('id' => 'application_action'));
$this->element('a',
- array(
- 'href' => common_local_url(
- 'apps',
- array('nickname' => $this->owner->nickname)),
- 'class' => 'more'
- ),
- 'View your applications');
+ array('href' => common_local_url('oauthappssettings'),
+ 'class' => 'more'),
+ 'View your applications');
$this->elementEnd('p');
}
if (!empty($this->application)) {
return common_local_url('editapplication',
- array('id' => $this->application->id,
- 'nickname' => $cur->nickname)
- );
+ array('id' => $this->application->id));
} else {
- return common_local_url('newapplication',
- array('nickname' => $cur->nickname));
+ return common_local_url('newapplication');
}
}
{
if ($this->application) {
$id = $this->application->id;
- $icon = $this->application->icon;
+ $icon = $this->application->icon;
$name = $this->application->name;
$description = $this->application->description;
$source_url = $this->application->source_url;
$this->access_type = $this->application->access_type;
} else {
$id = '';
- $icon = '';
+ $icon = '';
$name = '';
$description = '';
$source_url = '';
$this->access_type = '';
}
- $this->out->hidden('token', common_session_token());
+ $this->out->hidden('token', common_session_token());
$this->out->elementStart('ul', 'form_data');
- $this->out->elementStart('li', array('id' => 'application_icon'));
+ $this->out->elementStart('li', array('id' => 'application_icon'));
- if (!empty($icon)) {
- $this->out->element('img', array('src' => $icon));
- }
+ if (!empty($icon)) {
+ $this->out->element('img', array('src' => $icon));
+ }
- $this->out->element('label', array('for' => 'app_icon'),
- _('Icon'));
+ $this->out->element('label', array('for' => 'app_icon'),
+ _('Icon'));
$this->out->element('input', array('name' => 'app_icon',
- 'type' => 'file',
- 'id' => 'app_icon'));
+ 'type' => 'file',
+ 'id' => 'app_icon'));
$this->out->element('p', 'form_guide', _('Icon for this application'));
$this->out->element('input', array('name' => 'MAX_FILE_SIZE',
- 'type' => 'hidden',
- 'id' => 'MAX_FILE_SIZE',
- 'value' => ImageFile::maxFileSizeInt()));
+ 'type' => 'hidden',
+ 'id' => 'MAX_FILE_SIZE',
+ 'value' => ImageFile::maxFileSizeInt()));
$this->out->elementEnd('li');
$this->out->elementStart('li');
$maxDesc = Oauth_application::maxDesc();
if ($maxDesc > 0) {
$descInstr = sprintf(_('Describe your application in %d chars'),
- $maxDesc);
+ $maxDesc);
} else {
$descInstr = _('Describe your application');
}
$this->out->textarea('description', _('Description'),
($this->out->arg('description')) ? $this->out->arg('description') : $description,
- $descInstr);
+ $descInstr);
$this->out->elementEnd('li');
$this->out->element('input', $attrs);
$this->out->element('label', array('for' => 'app_type-browser',
- 'class' => 'radio'),
- _('Browser'));
+ 'class' => 'radio'),
+ _('Browser'));
$attrs = array('name' => 'app_type',
'type' => 'radio',
$this->out->element('input', $attrs);
$this->out->element('label', array('for' => 'app_type-desktop',
- 'class' => 'radio'),
- _('Desktop'));
+ 'class' => 'radio'),
+ _('Desktop'));
$this->out->element('p', 'form_guide', _('Type of application, browser or desktop'));
$this->out->elementEnd('li');
$this->out->element('input', $attrs);
$this->out->element('label', array('for' => 'default_access_type-ro',
- 'class' => 'radio'),
- _('Read-only'));
+ 'class' => 'radio'),
+ _('Read-only'));
$attrs = array('name' => 'default_access_type',
'type' => 'radio',
if ($this->application->access_type & Oauth_application::$readAccess
&& $this->application->access_type & Oauth_application::$writeAccess
- ) {
+ ) {
$attrs['checked'] = 'checked';
}
$this->out->element('input', $attrs);
$this->out->element('label', array('for' => 'default_access_type-rw',
- 'class' => 'radio'),
- _('Read-write'));
+ 'class' => 'radio'),
+ _('Read-write'));
$this->out->element('p', 'form_guide', _('Default access for this application: read-only, or read-write'));
$this->out->elementEnd('li');
function formActions()
{
$this->out->submit('cancel', _('Cancel'), 'submit form_action-primary',
- 'cancel', _('Cancel'));
+ 'cancel', _('Cancel'));
$this->out->submit('save', _('Save'), 'submit form_action-secondary',
- 'save', _('Save'));
+ 'save', _('Save'));
}
}
$this->application = $application;
$this->owner = $owner;
$this->action = $action;
- $this->connections = $connections;
+ $this->connections = $connections;
}
function show()
$this->out->elementStart('span', 'vcard author');
if (!$this->connections) {
$this->out->elementStart('a',
- array('href' => common_local_url('showapplication',
- array('nickname' => $user->nickname,
- 'id' => $this->application->id)),
- 'class' => 'url'));
+ array('href' => common_local_url('showapplication',
+ array('id' => $this->application->id)),
+ 'class' => 'url'));
} else {
$this->out->elementStart('a', array('href' => $this->application->source_url,
return;
}
- function highlight($text)
- {
- return htmlspecialchars($text);
- }
}
// settings
foreach (array('profile', 'avatar', 'password', 'im', 'oauthconnections',
- 'email', 'sms', 'userdesign', 'other') as $s) {
+ 'oauthapps', 'email', 'sms', 'userdesign', 'other') as $s) {
$m->connect('settings/'.$s, array('action' => $s.'settings'));
}
// user stuff
foreach (array('subscriptions', 'subscribers',
- 'nudge', 'all', 'foaf', 'xrds', 'apps',
+ 'nudge', 'all', 'foaf', 'xrds',
'replies', 'inbox', 'outbox', 'microsummary') as $a) {
$m->connect(':nickname/'.$a,
array('action' => $a),
array('nickname' => '[a-zA-Z0-9]{1,64}'));
}
- $m->connect(':nickname/apps',
- array('action' => 'apps'),
- array('nickname' => '['.NICKNAME_FMT.']{1,64}'));
- $m->connect(':nickname/apps/show/:id',
+ $m->connect('settings/oauthapps/show/:id',
array('action' => 'showapplication'),
- array('nickname' => '['.NICKNAME_FMT.']{1,64}',
- 'id' => '[0-9]+')
+ array('id' => '[0-9]+')
);
- $m->connect(':nickname/apps/new',
- array('action' => 'newapplication'),
- array('nickname' => '['.NICKNAME_FMT.']{1,64}'));
- $m->connect(':nickname/apps/edit/:id',
+ $m->connect('settings/oauthapps/new',
+ array('action' => 'newapplication')
+ );
+ $m->connect('settings/oauthapps/edit/:id',
array('action' => 'editapplication'),
- array('nickname' => '['.NICKNAME_FMT.']{1,64}',
- 'id' => '[0-9]+')
+ array('id' => '[0-9]+')
);
$m->connect('api/oauth/request_token',