]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
New "desktop" mode for the OAuth authorization page. If mode=deskstop
authorZach Copley <zach@status.net>
Thu, 21 Oct 2010 19:23:04 +0000 (12:23 -0700)
committerZach Copley <zach@status.net>
Thu, 21 Oct 2010 19:23:04 +0000 (12:23 -0700)
is specified in the request the page is probably meant to be displayed
in a small webview of another application, so suppress header, aside
and footer.

actions/apioauthauthorize.php

index 013cca029e71360d521cdf0dae996c3ebe824f5d..8bbe0d737fd90583febc89ad5ea6b02d3ed38649 100644 (file)
@@ -68,11 +68,12 @@ class ApiOauthAuthorizeAction extends Action
     {
         parent::prepare($args);
 
-        $this->nickname         = $this->trimmed('nickname');
-        $this->password         = $this->arg('password');
-        $this->oauthTokenParam  = $this->arg('oauth_token');
-        $this->callback         = $this->arg('oauth_callback');
-        $this->store            = new ApiStatusNetOAuthDataStore();
+        $this->nickname        = $this->trimmed('nickname');
+        $this->password        = $this->arg('password');
+        $this->oauthTokenParam = $this->arg('oauth_token');
+        $this->callback        = $this->arg('oauth_callback');
+        $this->mode            = $this->arg('mode');
+        $this->store           = new ApiStatusNetOAuthDataStore();
 
         try {
             $this->app = $this->store->getAppByRequestToken($this->oauthTokenParam);
@@ -429,6 +430,51 @@ class ApiOauthAuthorizeAction extends Action
         // NOP
     }
 
+    /*
+     * Checks to see if a the "mode" parameter is present in the request
+     * and set to "desktop". If it is, the page is meant to be displayed in
+     * a small frame of another application, and we should  suppress the
+     * header, aside, and footer.
+     */
+    function desktopMode()
+    {
+        if (isset($this->mode) && $this->mode == 'desktop') {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /*
+     * Override - suppress output in "desktop" mode
+     */
+    function showHeader()
+    {
+        if ($this->desktopMode() == false) {
+            parent::showHeader();
+        }
+    }
+
+    /*
+     * Override - suppress output in "desktop" mode
+     */
+    function showAside()
+    {
+        if ($this->desktopMode() == false) {
+            parent::showHeader();
+        }
+    }
+
+    /*
+     * Override - suppress output in "desktop" mode
+     */
+    function showFooter()
+    {
+        if ($this->desktopMode() == false) {
+            parent::showHeader();
+        }
+    }
+
     /**
      * Show site notice.
      *