X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnewapplication.php;h=5032bb74951a8f05a8096ec9115999a33b2f8b33;hb=df46f123dd656545c80821931f0a384f7dc5d608;hp=ad71aaad0ac5cfb0869ae2714232de47ad67b96f;hpb=220b51d8be61e9bd316567f3ad03fffdbc4b7526;p=quix0rs-gnu-social.git diff --git a/actions/newapplication.php b/actions/newapplication.php index ad71aaad0a..5032bb7495 100644 --- a/actions/newapplication.php +++ b/actions/newapplication.php @@ -28,9 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Add a new application @@ -43,7 +41,7 @@ if (!defined('STATUSNET')) { * @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() { @@ -51,13 +49,12 @@ class NewApplicationAction extends FormAction 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(); } @@ -65,30 +62,18 @@ class NewApplicationAction extends FormAction $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'); @@ -153,7 +138,7 @@ class NewApplicationAction extends FormAction $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; @@ -181,6 +166,7 @@ class NewApplicationAction extends FormAction 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.')); } @@ -191,9 +177,9 @@ class NewApplicationAction extends FormAction 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 {