]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newapplication.php
Added new 'Scroller' plugin from @buttle which aims to replace the out-dated
[quix0rs-gnu-social.git] / actions / newapplication.php
index a9f3012771141e3f17fc84d80bc4c590c6ecc576..37bede0d72f3c547a3a4e3eb15bde6253c831d00 100644 (file)
@@ -28,9 +28,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Add a new application
@@ -51,10 +49,8 @@ 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')) {
@@ -65,27 +61,15 @@ 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()
@@ -122,12 +106,7 @@ class NewApplicationAction extends FormAction
         } elseif (empty($source_url)) {
             // TRANS: Validation error shown when not providing a source URL in the "New application" form.
             $this->clientError(_('Source URL is required.'));
-        } elseif ((strlen($source_url) > 0)
-            && !Validate::uri(
-                $source_url,
-                array('allowed_schemes' => array('http', 'https'))
-                )
-            ) {
+        } elseif ((strlen($source_url) > 0) && !common_valid_http_url($source_url)) {
             // TRANS: Validation error shown when providing an invalid source URL in the "New application" form.
             $this->clientError(_('Source URL is not valid.'));
         } elseif (empty($organization)) {
@@ -139,23 +118,13 @@ class NewApplicationAction extends FormAction
         } elseif (empty($homepage)) {
             // TRANS: Form validation error show when an organisation name has not been provided in the new application form.
             $this->clientError(_('Organization homepage is required.'));
-        } elseif ((strlen($homepage) > 0)
-            && !Validate::uri(
-                $homepage,
-                array('allowed_schemes' => array('http', 'https'))
-                )
-            ) {
+        } elseif ((strlen($homepage) > 0) && !common_valid_http_url($homepage)) {
             // TRANS: Validation error shown when providing an invalid homepage URL in the "New application" form.
             $this->clientError(_('Homepage is not a valid URL.'));
         } elseif (mb_strlen($callback_url) > 255) {
             // TRANS: Validation error shown when providing too long a callback URL in the "New application" form.
             $this->clientError(_('Callback is too long.'));
-        } elseif (strlen($callback_url) > 0
-            && !Validate::uri(
-                $source_url,
-                array('allowed_schemes' => array('http', 'https'))
-                )
-            ) {
+        } elseif (strlen($callback_url) > 0 && !common_valid_http_url($callback_url)) {
             // TRANS: Validation error shown when providing an invalid callback URL in the "New application" form.
             $this->clientError(_('Callback URL is not valid.'));
         }
@@ -196,6 +165,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.'));
         }
@@ -206,9 +176,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 {