Wikinaut has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/52776


Change subject: (bug 45322) Show OpenID "provider" identity instead of login 
"consumer" OpenID
......................................................................

(bug 45322) Show OpenID "provider" identity instead of login "consumer" OpenID

Show the own OpenID identity on the user's user page

+ when they visit their own user page
+ when the setting wgOpenIDShowUrlOnUserPage is "always" or "user"
+ and user did not opted out

Change-Id: I6ce233264e1eeccc76ee47adf33b77e80494bf66
---
M CHANGES
M OpenID.hooks.php
M OpenID.i18n.php
M OpenID.php
M README.OpenID-mediawiki-extension
M SpecialOpenID.body.php
M SpecialOpenIDIdentifier.body.php
M SpecialOpenIDLogin.body.php
M SpecialOpenIDServer.body.php
9 files changed, 113 insertions(+), 46 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenID 
refs/changes/76/52776/10

diff --git a/CHANGES b/CHANGES
index 9580ae9..c08b0c7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
 CHANGES
 =======
 
+3.01  20130308  when used as Provider, show the own OpenID in OpenID 
preference tab
+                fix bug 45322 show own OpenID as subtitle on own userpage 
(user option)
 3.00  20130308  delegate /User:Username to /Special:OpenIDIdentifier/<userid>
 2.06  20130305  fix bug45515 OpenID server lost trust information when 
Preferences were saved
 2.05  20130304  fix bug45586 preference tab got now section headers
diff --git a/OpenID.hooks.php b/OpenID.hooks.php
index bea3c70..85ffc48 100644
--- a/OpenID.hooks.php
+++ b/OpenID.hooks.php
@@ -64,7 +64,7 @@
                        $user = User::newFromName( $nt->getText() );
 
                        if ( $user && ( $user->getID() != 0 ) ) {
-                               SpecialOpenID::outputIdentifier( $user, True );
+                               SpecialOpenID::showOpenIDIdentifier( $user, 
true );
                        }
                }
 
@@ -139,7 +139,7 @@
                                ) .
                                Xml::tags( 'td',
                                        array(),
-                                       $sk->link( $delTitle, wfMessage( 
'openid-urls-delete' )->text(),
+                                       $sk->link( $delTitle, wfMessage( 
'openid-urls-delete' )->escaped(),
                                                array(),
                                                array( 'url' => 
$url_reg->uoi_openid ) 
                                        ) 
@@ -162,7 +162,7 @@
                );
                $info .= $sk->link(
                        SpecialPage::getTitleFor( 'OpenIDConvert' ),
-                       wfMessage( 'openid-add-url' )->text()
+                       wfMessage( 'openid-add-url' )->escaped()
                );
                return $info;
        }
@@ -200,15 +200,39 @@
 
        public static function onGetPreferences( $user, &$preferences ) {
                global $wgOpenIDShowUrlOnUserPage, $wgAllowRealName;
-               global $wgAuth, $wgUser, $wgLang, $wgOpenIDOnlyClient;
+               global $wgAuth, $wgUser, $wgLang, $wgOpenIDOnlyClient, 
$wgOpenIDLoginLogoUrl;
 
-               if ( $wgOpenIDShowUrlOnUserPage == 'user' ) {
+               switch ( $wgOpenIDShowUrlOnUserPage ) {
+
+               case 'user':
                        $preferences['openid-hide-openid'] =
                                array(
                                        'section' => 
'openid/openid-hide-openid',
                                        'type' => 'toggle',
                                        'label-message' => 
'openid-hide-openid-label',
                                );
+                       break;
+
+               case 'always':
+                       $preferences['openid-hide-openid'] =
+                               array(
+                                       'section' => 
'openid/openid-hide-openid',
+                                       'type' => 'info',
+                                       'label-message' => 
'openid-hide-openid-label',
+                                       'default' => wfMessage( 
'openid-show-openid-url-on-userpage-always' )->text(),
+                               );
+                       break;
+
+               case 'never':
+                       $preferences['openid-hide-openid'] =
+                               array(
+                                       'section' => 
'openid/openid-hide-openid',
+                                       'type' => 'info',
+                                       'label-message' => 
'openid-hide-openid-label',
+                                       'default' => wfMessage( 
'openid-show-openid-url-on-userpage-never' )->text(),
+                               );
+                       break;
+
                }
 
                $update = array();
@@ -244,6 +268,17 @@
 
                if ( !$wgOpenIDOnlyClient ) {
 
+                       $openIDLogo = Xml::element( 'img', array( 'src' => 
$wgOpenIDLoginLogoUrl, 'alt' => 'OpenID' ), '' );
+
+                       $preferences['openid-your-openid'] =
+                               array(
+                                       'section' => 
'openid/openid-local-identity',
+                                       'type' => 'info',
+                                       'label-message' => 
'openid-local-identity',
+                                       'default' => $openIDLogo . "&nbsp;" . 
SpecialOpenIDServer::getLocalIdentityLink( $user ),
+                                       'raw' => true,
+                               );
+
                        $preferences['openid-trusted-sites'] =
                                array(
                                        'section' => 
'openid/openid-trusted-sites',
@@ -259,7 +294,7 @@
 
                        $resetlink = $wgUser->getSkin()->link(
                                SpecialPage::getTitleFor( 'PasswordReset' ),
-                               wfMessage( 'passwordreset' )->text(),
+                               wfMessage( 'passwordreset' )->escaped(),
                                array(),
                                array( 'returnto' => SpecialPage::getTitleFor( 
'Preferences' ) )
                        );
@@ -342,7 +377,7 @@
 
                        } else {
 
-                               $wgOut->addHTML( wfMessage( 
'openid-openids-were-not-merged' )->text() . "<br />\n" );
+                               $wgOut->addHTML( wfMessage( 
'openid-openids-were-not-merged' )->escaped() . "<br />\n" );
                                wfDebug( "OpenID: OpenID(s) were not merged for 
merged users $fromUsername ($fromUserID) => $toUsername ($toUserID)\n" );
 
                        }
diff --git a/OpenID.i18n.php b/OpenID.i18n.php
index 60b0459..135bbc4 100644
--- a/OpenID.i18n.php
+++ b/OpenID.i18n.php
@@ -123,7 +123,10 @@
        'prefs-openid-userinfo-update-on-login' => 'OpenID user information 
update',
        'prefs-openid-associated-openids' => 'Your OpenIDs for login to 
{{SITENAME}}',
        'prefs-openid-trusted-sites' => 'Trusted sites',
+       'prefs-openid-local-identity' => 'Your OpenID for login to other sites',
        'openid-hide-openid-label' => 'Hide your OpenID URL on your user page, 
if you log in with OpenID.',
+       'openid-show-openid-url-on-userpage-always' => 'Your OpenID is always 
shown on your user page when you visit it.',
+       'openid-show-openid-url-on-userpage-never' => 'Your OpenID is never 
shown on your user page.',
        'openid-userinfo-update-on-login-label' => 'Update the following 
information from OpenID persona every time I log in:',
        'openid-associated-openids-label' => 'OpenIDs associated with your 
account:',
        'openid-urls-url' => 'URL',
@@ -134,6 +137,7 @@
        'openid-add-url' => 'Add a new OpenID to your account',
        'openid-trusted-sites-label' => 'Sites you trust and where you have 
used your OpenID for logging in:',
        'openid-trusted-sites-table-header' => 'Trusted sites',
+       'openid-local-identity' => 'Your OpenID:',
 
        'openid-login-or-create-account' => 'Log in or create a new account',
        'openid-provider-label-openid' => 'Enter your OpenID URL',
@@ -226,6 +230,7 @@
        'prefs-openid-associated-openids' => 'Your OpenIDs for login to this 
wiki (section header)',
        'prefs-openid-trusted-sites' => 'Trusted sites (section header).
 {{Identical|Trusted site}}',
+       'prefs-openid-local-identity' => 'Your OpenID for login to other sites 
(section header)',
        'openid-hide-openid-label' => 'Hide your OpenID URL on your user page 
(preference label)',
        'openid-userinfo-update-on-login-label' => 'Update the following 
information from OpenID persona every time the user logs in: (preference 
label)',
        'openid-associated-openids-label' => 'OpenIDs associated with your 
account: (preference label)',
@@ -238,6 +243,7 @@
        'openid-trusted-sites-label' => 'Sites you trust and where you have 
used your OpenID for logging in: (preference label)',
        'openid-trusted-sites-table-header' => 'Trusted sites (table header).
 {{Identical|Trusted site}}',
+       'openid-local-identity' => 'Your OpenID when used a identity to other 
sites (preference label)',
        'specialpages-group-openid' => 'Display group name for OpenID-extension 
related special pages for [[Special:SpecialPages]].',
        'right-openid-converter-access' => 
'{{doc-right|openid-converter-access}}
 {{doc-singularthey}}',
diff --git a/OpenID.php b/OpenID.php
index a9300cc..b2dd30b 100644
--- a/OpenID.php
+++ b/OpenID.php
@@ -29,7 +29,7 @@
        exit( 1 );
 }
 
-define( 'MEDIAWIKI_OPENID_VERSION', '3.00 20130308' );
+define( 'MEDIAWIKI_OPENID_VERSION', '3.01 20130308' );
 
 $path = dirname( __FILE__ );
 set_include_path( implode( PATH_SEPARATOR, array( $path ) ) . PATH_SEPARATOR . 
get_include_path() );
@@ -40,7 +40,7 @@
  * Whether to hide the "Login with OpenID link" link; set to true if you 
already
  * have this link in your skin.
  */
-$wgHideOpenIDLoginLink = false;
+$wgOpenIDHideOpenIDLoginLink = false;
 
 /**
  * Location of the OpenID login logo. You can copy this to your server if you
@@ -53,7 +53,7 @@
  * values are 'always', 'never' (default), or 'user'.
  * 'user' lets the user decide in their preferences.
  */
-$wgOpenIDShowUrlOnUserPage = 'never';
+$wgOpenIDShowUrlOnUserPage = 'user';
 
 /**
  * These are trust roots that we don't bother asking users whether the trust
diff --git a/README.OpenID-mediawiki-extension 
b/README.OpenID-mediawiki-extension
index 5d42196..e8cdc56 100644
--- a/README.OpenID-mediawiki-extension
+++ b/README.OpenID-mediawiki-extension
@@ -313,7 +313,7 @@
   respectively. The path will be automatically created if it doesn't
   exist at runtime.
 
-* $wgHideOpenIDLoginLink -- boolean that says whether or not to hide
+* $wgOpenIDHideOpenIDLoginLink -- boolean that says whether or not to hide
   the OpenID login link in the personal URLs. Typically you'd use this
   if you've already got some other method for showing the OpenID login
   link, like in your skin. Note that it will *not* prevent login if
diff --git a/SpecialOpenID.body.php b/SpecialOpenID.body.php
index 65f6304..c5d8078 100644
--- a/SpecialOpenID.body.php
+++ b/SpecialOpenID.body.php
@@ -33,25 +33,27 @@
 
 class SpecialOpenID extends SpecialPage {
 
-       static function outputIdentifier( $user, $delegate=False ) {
-               global $wgOut, $wgOpenIDClientOnly, 
$wgOpenIDAllowServingOpenIDUserAccounts, $wgOpenIDIdentifiersURL;
+       static function showOpenIDIdentifier( $user, $delegate = false ) {
+               global $wgOut, $wgUser, $wgArticle, $wgOpenIDClientOnly, 
$wgOpenIDShowUrlOnUserPage,
+                       $wgOpenIDAllowServingOpenIDUserAccounts, 
$wgOpenIDIdentifiersURL;
+
+               // show the own OpenID Url as a subtitle on the user page
+               // but only for the user when visiting their own page
+               // and when the options say so
+
+               if ( ( $user->getID() === $wgUser->getID() )
+                       && ( $user->getID() != 0 )
+                       && ( $wgOpenIDShowUrlOnUserPage === 'always'
+                               || ( ( $wgOpenIDShowUrlOnUserPage === 'user' ) 
&& !$wgUser->getOption( 'openid-hide-openid' ) ) ) ) {
+
+                       global $wgOpenIDLoginLogoUrl;
+                       $wgOut->setSubtitle( "<span class='subpages'>" .
+                               "<img src='$wgOpenIDLoginLogoUrl' alt='OpenID' 
/>" .
+                               SpecialOpenIDServer::getLocalIdentityLink( 
$wgUser ) .
+                               "</span>" );
+               }
 
                $openid = SpecialOpenID::getUserOpenIDInformation( $user );
-               if ( count( $openid ) && strlen( $openid[0]->uoi_openid ) != 0 
) {
-                       global $wgOpenIDShowUrlOnUserPage;
-
-                       if ( $wgOpenIDShowUrlOnUserPage == 'always'
-                               || ( ( $wgOpenIDShowUrlOnUserPage == 'user' ) 
&& !$user->getOption( 'openid-hide' ) ) ) {
-                               global $wgOpenIDLoginLogoUrl;
-
-                               $url = SpecialOpenID::OpenIDToUrl( 
$openid[0]->uoi_openid );
-                               $disp = htmlspecialchars( 
$openid[0]->uoi_openid );
-                               $wgOut->setSubtitle( "<span class='subpages'>" .
-                                       "<img src='$wgOpenIDLoginLogoUrl' 
alt='OpenID' />" .
-                                       "<a href='$url'>$disp</a>" .
-                                       "</span>" );
-                       }
-               }
 
                # Add OpenID data if its allowed
                if ( !$wgOpenIDClientOnly
@@ -62,12 +64,7 @@
                        $wgOut->addLink( array( 'rel' => 'openid.server', 
'href' => $serverUrl ) );
                        $wgOut->addLink( array( 'rel' => 'openid2.provider', 
'href' => $serverUrl ) );
                        if ( $delegate ) {
-                               if ( $wgOpenIDIdentifiersURL ) {
-                                       $local_identity = str_replace( '{ID}', 
$user->getID(), $wgOpenIDIdentifiersURL );
-                               } else {
-                                       $local_identity = 
SpecialPage::getTitleFor( 'OpenIDIdentifier', $user->getID() );
-                                       $local_identity = 
$local_identity->getFullURL();
-                               }
+                               $local_identity = 
SpecialOpenIDServer::getLocalIdentity( $user );
                                $wgOut->addLink( array( 'rel' => 
'openid.delegate', 'href' => $local_identity ) );
                                $wgOut->addLink( array( 'rel' => 
'openid2.local_id', 'href' => $local_identity ) );
                        }
@@ -77,6 +74,7 @@
                        header( 'X-XRDS-Location: ' . $xrdsUrl );
                }
                $wgOut->addWikiMsg( 'openid-identifier-page-text', 
$user->getName() );
+
        }
 
        function getOpenIDStore( $storeType, $prefix, $options ) {
diff --git a/SpecialOpenIDIdentifier.body.php b/SpecialOpenIDIdentifier.body.php
index 77cac9e..3d6a1f3 100644
--- a/SpecialOpenIDIdentifier.body.php
+++ b/SpecialOpenIDIdentifier.body.php
@@ -32,7 +32,7 @@
                $this->setHeaders();
                $user = User::newFromId( $par );
                if ( $user ) {
-                       SpecialOpenID::outputIdentifier( $user );
+                       SpecialOpenID::showOpenIDIdentifier( $user );
                }
        }
 }
diff --git a/SpecialOpenIDLogin.body.php b/SpecialOpenIDLogin.body.php
index 5df2a72..98a5837 100644
--- a/SpecialOpenIDLogin.body.php
+++ b/SpecialOpenIDLogin.body.php
@@ -252,7 +252,7 @@
                                                Xml::radio( 'wpNameChoice', 
'nick', !$def, array( 'id' => 'wpNameChoiceNick' ) )
                                        ) .
                                        Xml::tags( 'td', array( 'class' => 
'mw-input' ),
-                                               Xml::label( wfMessage( 
'openidchoosenick', $sreg['nickname'] )->text(), 'wpNameChoiceNick' )
+                                               Xml::label( wfMessage( 
'openidchoosenick', $sreg['nickname'] )->escaped(), 'wpNameChoiceNick' )
                                        ) .
                                        Xml::closeElement( 'tr' ) . "\n"
                                );
@@ -275,7 +275,7 @@
                                                Xml::radio( 'wpNameChoice', 
'full', !$def, array( 'id' => 'wpNameChoiceFull' ) )
                                        ) .
                                        Xml::tags( 'td', array( 'class' => 
'mw-input' ),
-                                               Xml::label( wfMessage( 
'openidchoosefull', $fullname )->text(), 'wpNameChoiceFull' )
+                                               Xml::label( wfMessage( 
'openidchoosefull', $fullname )->escaped(), 'wpNameChoiceFull' )
                                        ) .
                                        Xml::closeElement( 'tr' ) . "\n"
                                );
@@ -305,7 +305,7 @@
                                        Xml::radio( 'wpNameChoice', 'auto', 
!$def, array( 'id' => 'wpNameChoiceAuto' ) )
                                ) .
                                Xml::tags( 'td', array( 'class' => 'mw-input' ),
-                                       Xml::label( wfMessage( 
'openidchooseauto', $this->automaticName( $sreg ) )->text(), 'wpNameChoiceAuto' 
)
+                                       Xml::label( wfMessage( 
'openidchooseauto', $this->automaticName( $sreg ) )->escaped(), 
'wpNameChoiceAuto' )
                                ) .
                                        Xml::closeElement( 'tr' ) . "\n"
                                );
diff --git a/SpecialOpenIDServer.body.php b/SpecialOpenIDServer.body.php
index 88510d7..73a6f30 100644
--- a/SpecialOpenIDServer.body.php
+++ b/SpecialOpenIDServer.body.php
@@ -230,6 +230,39 @@
                return new Auth_OpenID_Server( $store, $this->serverUrl() );
        }
 
+
+       # respond with the authenticated local identity OpenID Url. Utility
+
+       /**
+        * @return getLocalIdentity
+        */
+       static function getLocalIdentity( $user ) {
+               global $wgOpenIDIdentifiersURL;
+
+               if ( $wgOpenIDIdentifiersURL ) {
+                       $local_identity = str_replace( '{ID}', $user->getID(), 
$wgOpenIDIdentifiersURL );
+               } else {
+                       $local_identity = SpecialPage::getTitleFor( 
'OpenIDIdentifier', $user->getID() );
+                       $local_identity = $local_identity->getFullURL();
+               }
+
+               return $local_identity;
+
+       }
+
+       /**
+        * @return getLocalIdentityLink
+        */
+       static function getLocalIdentityLink( $user ) {
+
+               return Xml::element( 'a',
+                               array( 'href' => ( 
SpecialOpenIDServer::getLocalIdentity( $user ) ) ),
+                               SpecialOpenIDServer::getLocalIdentity( $user )
+                       );
+
+       }
+
+
        # Checks a validation request. $imm means don't run any UI.
        # Fairly meticulous and step-by step, and uses assertions
        # to point out assumptions at each step.
@@ -418,14 +451,7 @@
 
                wfSuppressWarnings();
 
-               # respond with the authenticated local identity OpenID Url
-               if ( $wgOpenIDIdentifiersURL ) {
-                       $local_identity = str_replace( '{ID}', 
$wgUser->getID(), $wgOpenIDIdentifiersURL );
-               } else {
-                       $local_identity = SpecialPage::getTitleFor( 
'OpenIDIdentifier', $wgUser->getID() );
-                       $local_identity = $local_identity->getFullURL();
-               }
-               $response = $request->answer( true, $this->serverUrl(), 
$local_identity, null );
+               $response = $request->answer( true, $this->serverUrl(), 
$this->getLocalIdentity( $wgUser ), null );
                wfDebug( "OpenID: response: " . print_r( $response, true ) . 
"\n" );
 
                wfRestoreWarnings();

-- 
To view, visit https://gerrit.wikimedia.org/r/52776
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ce233264e1eeccc76ee47adf33b77e80494bf66
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/OpenID
Gerrit-Branch: master
Gerrit-Owner: Wikinaut <[email protected]>
Gerrit-Reviewer: Wikinaut <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to