Wikinaut has submitted this change and it was merged.
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
bump version 3.03
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, 114 insertions(+), 47 deletions(-)
Approvals:
Wikinaut: Verified; Looks good to me, approved
diff --git a/CHANGES b/CHANGES
index 9da2937..8bb91d1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,9 @@
CHANGES
=======
-3.02 20130309 fix bug45928 change deprecated wgAllowRealName to
wgHiddenPrefs checks
+3.03 20130310 fix bug45928 change deprecated wgAllowRealName to
wgHiddenPrefs checks
+3.02 20130309 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.01 20130309 fixed a regression which stopped optional userinfo updating
from OpenID
3.00 20130308 delegate /User:Username to /Special:OpenIDIdentifier/<userid>
2.06 20130305 fix bug45515 OpenID server lost trust information when
Preferences were saved
diff --git a/OpenID.hooks.php b/OpenID.hooks.php
index bb8de30..1607dea 100644
--- a/OpenID.hooks.php
+++ b/OpenID.hooks.php
@@ -69,7 +69,7 @@
$user = User::newFromName( $nt->getText() );
if ( $user && ( $user->getID() != 0 ) ) {
- SpecialOpenID::outputIdentifier( $user, true );
+ SpecialOpenID::showOpenIDIdentifier( $user,
true );
}
}
@@ -181,7 +181,7 @@
);
$info .= Linker::link(
SpecialPage::getTitleFor( 'OpenIDConvert' ),
- wfMessage( 'openid-add-url' )->text()
+ wfMessage( 'openid-add-url' )->escaped()
);
return $info;
}
@@ -221,16 +221,40 @@
* @return bool
*/
public static function onGetPreferences( $user, &$preferences ) {
- global $wgOpenIDShowUrlOnUserPage, $wgHiddenPrefs;
- global $wgAuth, $wgUser, $wgLang, $wgOpenIDOnlyClient;
+ global $wgOpenIDShowUrlOnUserPage, $wgHiddenPrefs,
+ $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;
+
}
// setting up user_properties up_property database key names
@@ -270,6 +294,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 . " " .
SpecialOpenIDServer::getLocalIdentityLink( $user ),
+ 'raw' => true,
+ );
+
$preferences['openid-trusted-sites'] =
array(
'section' =>
'openid/openid-trusted-sites',
@@ -284,7 +319,7 @@
if ( $wgAuth->allowPasswordChange() ) {
$resetlink = Linker::link(
SpecialPage::getTitleFor( 'PasswordReset' ),
- wfMessage( 'passwordreset' )->text(),
+ wfMessage( 'passwordreset' )->escaped(),
array(),
array( 'returnto' => SpecialPage::getTitleFor(
'Preferences' ) )
);
@@ -373,7 +408,7 @@
wfDebug( "OpenID: transferred OpenID(s) of
$fromUsername ($fromUserID) => $toUsername ($toUserID)\n" );
} 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 4443cc7..419972a 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' => 'User profile information
fields which will be automatically updated from OpenID persona every time when
you 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',
@@ -228,6 +232,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)',
@@ -240,6 +245,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 5d93648..4e9bf3e 100644
--- a/OpenID.php
+++ b/OpenID.php
@@ -29,7 +29,7 @@
exit( 1 );
}
-define( 'MEDIAWIKI_OPENID_VERSION', '3.02 20130309' );
+define( 'MEDIAWIKI_OPENID_VERSION', '3.03 20130310' );
$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 4a2381f..a6ec8c6 100644
--- a/SpecialOpenID.body.php
+++ b/SpecialOpenID.body.php
@@ -37,25 +37,27 @@
* @param $user User
* @param $delegate bool
*/
- public static function outputIdentifier( $user, $delegate = false ) {
- global $wgOut, $wgOpenIDClientOnly,
$wgOpenIDAllowServingOpenIDUserAccounts, $wgOpenIDIdentifiersURL;
+ public static function showOpenIDIdentifier( $user, $delegate = false )
{
+ global $wgOut, $wgUser, $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
@@ -66,12 +68,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 ) );
}
@@ -81,6 +78,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 82c165f..595126a 100644
--- a/SpecialOpenIDLogin.body.php
+++ b/SpecialOpenIDLogin.body.php
@@ -254,7 +254,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"
);
@@ -277,7 +277,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"
);
@@ -307,7 +307,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 e3a9804..d513791 100644
--- a/SpecialOpenIDServer.body.php
+++ b/SpecialOpenIDServer.body.php
@@ -233,6 +233,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.
@@ -420,14 +453,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: merged
Gerrit-Change-Id: I6ce233264e1eeccc76ee47adf33b77e80494bf66
Gerrit-PatchSet: 14
Gerrit-Project: mediawiki/extensions/OpenID
Gerrit-Branch: master
Gerrit-Owner: Wikinaut <[email protected]>
Gerrit-Reviewer: Ryan Lane <[email protected]>
Gerrit-Reviewer: Wikinaut <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits