]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apioauthauthorize.php
Make page titles more consistent: no title case in four cases.
[quix0rs-gnu-social.git] / actions / apioauthauthorize.php
index cdf9cb7df37c243e12617be4743fd162d5126b18..19128bdcefe5798580c0b1b5cfdb75bb432c08e9 100644 (file)
@@ -74,42 +74,11 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
         $this->oauth_token = $this->arg('oauth_token');
         $this->callback    = $this->arg('oauth_callback');
         $this->store       = new ApiStatusNetOAuthDataStore();
+        $this->app         = $this->store->getAppByRequestToken($this->oauth_token);
 
         return true;
     }
 
-    function getApp()
-    {
-        // Look up the full req token
-
-        $req_token = $this->store->lookup_token(null,
-                                                'request',
-                                                $this->oauth_token);
-
-        if (empty($req_token)) {
-
-            common_debug("Couldn't find request token!");
-
-            $this->clientError(_('Bad request.'));
-            return;
-        }
-
-        // Look up the app
-
-        $app = new Oauth_application();
-        $app->consumer_key = $req_token->consumer_key;
-        $result = $app->find(true);
-
-        if (!empty($result)) {
-            $this->app = $app;
-            return true;
-
-        } else {
-            common_debug("couldn't find the app!");
-            return false;
-        }
-    }
-
     /**
      * Handle input, produce output
      *
@@ -140,7 +109,8 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
                 return;
             }
 
-            if (!$this->getApp()) {
+            if (empty($this->app)) {
+                common_debug('No app for that token.');
                 $this->clientError(_('Bad request.'));
                 return;
             }
@@ -166,11 +136,6 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
             return;
         }
 
-        if (!$this->getApp()) {
-            $this->clientError(_('Bad request.'));
-            return;
-        }
-
         // check creds
 
         $user = null;
@@ -308,27 +273,6 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
         return _('An application would like to connect to your account');
     }
 
-    /**
-     * Show page notice
-     *
-     * Display a notice for how to use the page, or the
-     * error if it exists.
-     *
-     * @return void
-     */
-
-    function showPageNotice()
-    {
-        if ($this->error) {
-            $this->element('p', 'error', $this->error);
-        } else {
-            $instr  = $this->getInstructions();
-            $output = common_markup_to_html($instr);
-
-            $this->raw($output);
-        }
-    }
-
     /**
      * Shows the authorization form.
      *
@@ -338,44 +282,42 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
     function showContent()
     {
         $this->elementStart('form', array('method' => 'post',
-                                          'id' => 'form_login',
+                                          'id' => 'form_apioauthauthorize',
                                           'class' => 'form_settings',
                                           'action' => common_local_url('apioauthauthorize')));
+        $this->elementStart('fieldset');
+        $this->element('legend', array('id' => 'apioauthauthorize_allowdeny'),
+                                 _('Allow or deny access'));
 
         $this->hidden('token', common_session_token());
         $this->hidden('oauth_token', $this->oauth_token);
         $this->hidden('oauth_callback', $this->callback);
 
-        $this->elementStart('fieldset');
-
-        $this->elementStart('ul');
+        $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
+        $this->elementStart('p');
         if (!empty($this->app->icon)) {
             $this->element('img', array('src' => $this->app->icon));
         }
-        $this->elementEnd('li');
-        $this->elementStart('li');
 
         $access = ($this->app->access_type & Oauth_application::$writeAccess) ?
           'access and update' : 'access';
 
-        $msg = _("The application <b>%s</b> by <b>%s</b> would like " .
-                 "the ability to <b>%s</b> your account data.");
+        $msg = _("The application <strong>%1$s</strong> by <strong>%2$s</strong> would like " .
+                 "the ability to <strong>%3$s</strong> your account data.");
 
         $this->raw(sprintf($msg,
                            $this->app->name,
                            $this->app->organization,
                            $access));
-
+        $this->elementEnd('p');
         $this->elementEnd('li');
         $this->elementEnd('ul');
 
-        $this->elementEnd('fieldset');
-
         if (!common_logged_in()) {
 
             $this->elementStart('fieldset');
-            $this->element('legend', null, _('Login'));
+            $this->element('legend', null, _('Account'));
             $this->elementStart('ul', 'form_data');
             $this->elementStart('li');
             $this->input('nickname', _('Nickname'));
@@ -390,17 +332,18 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
         }
 
         $this->element('input', array('id' => 'deny_submit',
-                                      'class' => 'submit',
+                                      'class' => 'submit submit form_action-primary',
                                       'name' => 'deny',
                                       'type' => 'submit',
                                       'value' => _('Deny')));
 
         $this->element('input', array('id' => 'allow_submit',
-                                      'class' => 'submit',
+                                      'class' => 'submit submit form_action-secondary',
                                       'name' => 'allow',
                                       'type' => 'submit',
                                       'value' => _('Allow')));
 
+        $this->elementEnd('fieldset');
         $this->elementEnd('form');
     }
 
@@ -416,7 +359,6 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
     function getInstructions()
     {
         return _('Allow or deny access to your account information.');
-
     }
 
     /**