* @link http://status.net/
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Add a new application
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-class NewApplicationAction extends FormAction
+class NewApplicationAction extends SettingsAction
{
function title()
{
return _('New application');
}
- protected function handlePost()
+ protected function doPost()
{
- parent::handlePost();
-
if ($this->arg('cancel')) {
common_redirect(common_local_url('oauthappssettings'), 303);
} elseif ($this->arg('save')) {
+ //trySave will never return, just throw exception or redirect
$this->trySave();
}
$this->clientError(_('Unexpected form submission.'));
}
- function showForm($msg=null)
- {
- $this->msg = $msg;
- $this->showPage();
- }
-
- function showContent()
+ protected function getForm()
{
- $form = new ApplicationEditForm($this);
- $form->show();
+ return new ApplicationEditForm($this);
}
- function showPageNotice()
+ protected function getInstructions()
{
- if ($this->msg) {
- $this->element('p', 'error', $this->msg);
- } else {
- $this->element('p', 'instructions',
- // TRANS: Form instructions for registering a new application.
- _('Use this form to register a new application.'));
- }
+ // TRANS: Form instructions for registering a new application.
+ return _('Use this form to register a new application.');
}
- private function trySave()
+ protected function trySave()
{
$name = $this->trimmed('name');
$description = $this->trimmed('description');
$app->query('BEGIN');
$app->name = $name;
- $app->owner = $this->scoped->id;
+ $app->owner = $this->scoped->getID();
$app->description = $description;
$app->source_url = $source_url;
$app->organization = $organization;
if (!$result) {
common_log_db_error($consumer, 'INSERT', __FILE__);
+ $app->query('ROLLBACK');
// TRANS: Server error displayed when an application could not be registered in the database through the "New application" form.
$this->serverError(_('Could not create application.'));
}
if (!$this->app_id) {
common_log_db_error($app, 'INSERT', __FILE__);
+ $app->query('ROLLBACK');
// TRANS: Server error displayed when an application could not be registered in the database through the "New application" form.
$this->serverError(_('Could not create application.'));
- $app->query('ROLLBACK');
}
try {