]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OpenID/OpenIDPlugin.php
Merge branch '1.0.x' into feedsub-wizard
[quix0rs-gnu-social.git] / plugins / OpenID / OpenIDPlugin.php
index 87eab94a20a1463ceed5331aa6df6048d2578c69..6089777eb9342a520bbe8f3d4bff43e48f67e97a 100644 (file)
@@ -80,7 +80,7 @@ class OpenIDPlugin extends Plugin
         $m->connect('index.php?action=finishaddopenid',
                     array('action' => 'finishaddopenid'));
         $m->connect('main/openidserver', array('action' => 'openidserver'));
-        $m->connect('admin/openid', array('action' => 'openidadminpanel'));
+        $m->connect('panel/openid', array('action' => 'openidadminpanel'));
 
         return true;
     }
@@ -248,11 +248,11 @@ class OpenIDPlugin extends Plugin
      *
      * If we're in openidOnly mode, we disable the menu for all other login.
      *
-     * @param Action &$action Action being executed
+     * @param Action $action Action being executed
      *
      * @return boolean hook return
      */
-    function onStartLoginGroupNav(&$action)
+    function onStartLoginGroupNav($action)
     {
         if (common_config('site', 'openidonly')) {
             $this->showOpenIDLoginTab($action);
@@ -268,11 +268,11 @@ class OpenIDPlugin extends Plugin
     /**
      * Menu item for login
      *
-     * @param Action &$action Action being executed
+     * @param Action $action Action being executed
      *
      * @return boolean hook return
      */
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         $this->showOpenIDLoginTab($action);
 
@@ -318,11 +318,11 @@ class OpenIDPlugin extends Plugin
     /**
      * Menu item for OpenID settings
      *
-     * @param Action &$action Action being executed
+     * @param Action $action Action being executed
      *
      * @return boolean hook return
      */
-    function onEndAccountSettingsNav(&$action)
+    function onEndAccountSettingsNav($action)
     {
         $action_name = $action->trimmed('action');
 
@@ -613,6 +613,28 @@ class OpenIDPlugin extends Plugin
         return true;
     }
 
+    /**
+     * Add OpenID information to the Account Management Control Document
+     * Event supplied by the Account Manager plugin
+     *
+     * @param array &$amcd Array that expresses the AMCD
+     *
+     * @return boolean hook value
+     */
+
+    function onEndAccountManagementControlDocument(&$amcd)
+    {
+        $amcd['auth-methods']['openid'] = array(
+            'connect' => array(
+                'method' => 'POST',
+                'path' => common_local_url('openidlogin'),
+                'params' => array(
+                    'identity' => 'openid_url'
+                )
+            )
+        );
+    }
+
     /**
      * Add our version information to output
      *
@@ -713,8 +735,14 @@ class OpenIDPlugin extends Plugin
             require_once dirname(__FILE__) . '/openid.php';
             oid_assert_allowed($openid_url);
 
-            $returnto = common_local_url('apioauthauthorize', array(),
-                    array('oauth_token' => $action->arg('oauth_token')));
+            $returnto = common_local_url(
+                'ApiOauthAuthorize',
+                array(),
+                array(
+                    'oauth_token' => $action->arg('oauth_token'),
+                   'mode'        => $action->arg('mode')
+                )
+            );
             common_set_returnto($returnto);
 
             // This will redirect if functional...
@@ -729,4 +757,29 @@ class OpenIDPlugin extends Plugin
 
         return true;
     }
+
+    /**
+     * Add link in user's XRD file to allow OpenID login.
+     * 
+     * This link in the XRD should let users log in with their
+     * Webfinger identity to services that support it. See
+     * http://webfinger.org/login for an example.
+     *
+     * @param XRD  &$xrd Currently-displaying XRD object
+     * @param User $user The user that it's for
+     * 
+     * @return boolean hook value (always true)
+     */
+
+    function onEndXrdActionLinks(&$xrd, $user)
+    {
+        $profile = $user->getProfile();
+       
+        if (!empty($profile)) {
+            $xrd->links[] = array('rel' => 'http://specs.openid.net/auth/2.0/provider',
+                                  'href' => $profile->profileurl);
+        }
+       
+        return true;
+    }
 }