r25690 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25689‎ | r25690 | r25691 >
Date:16:38, 9 September 2007
Author:evan
Status:old
Tags:
Comment:
Add a configuration variable to let the admin set a policy on showing
OpenID identity URLs in user pages. Possible values are 'always',
'never', and 'user', to let the user whose page it is decide.

If the config variable is 'user', shows a toggle in user preferences
to let the user hide the OpenID identity URL.
Modified paths:
  • /trunk/extensions/OpenID/OpenID.php (modified) (history)
  • /trunk/extensions/OpenID/README (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenID.php
@@ -46,8 +46,16 @@
4747 # Whether to hide the "Login with OpenID link" link; set to true if you already have this link in your skin.
4848
4949 $wgHideOpenIDLoginLink = false;
 50+
 51+ # Location of the OpenID login logo. You can copy this to your server if you want.
 52+
5053 $wgOpenIDLoginLogoUrl = 'http://www.openid.net/login-bg.gif';
5154
 55+ # Whether to show the OpenID identity URL on a user's home page. Possible values are 'always', 'never', or 'user'
 56+ # 'user' lets the user decide.
 57+
 58+ $wgOpenIDShowUrlOnUserPage = 'user';
 59+
5260 function setupOpenID() {
5361 global $wgMessageCache, $wgOut, $wgRequest, $wgHooks;
5462
@@ -93,6 +101,7 @@
94102 'openidconvertyourstext' => 'That is already your OpenID.',
95103 'openidconvertothertext' => 'That is someone else\'s OpenID.',
96104 'openidalreadyloggedin' => '<strong>User $1, you are already logged in!</strong>',
 105+ 'tog-hideopenid' => 'Hide your <a href="http://openid.net/">OpenID</a> on your user page, if you log in with OpenID.',
97106 ));
98107
99108 SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDLogin'));
@@ -102,6 +111,8 @@
103112 SpecialPage::AddPage(new UnlistedSpecialPage('OpenIDXRDS'));
104113
105114 $wgHooks['PersonalUrls'][] = 'OpenIDPersonalUrls';
 115+ $wgHooks['UserToggles'][] = 'OpenIDUserToggles';
 116+
106117 $wgOut->addHeadItem('openidloginstyle', OpenIDLoginStyle());
107118
108119 $action = $wgRequest->getText('action', 'view');
@@ -139,12 +150,20 @@
140151 if ($user && $user->getID() != 0) {
141152 $openid = OpenIdGetUserUrl($user);
142153 if (isset($openid) && strlen($openid) != 0) {
143 - $url = OpenIDToUrl($openid);
144 - $disp = htmlspecialchars($openid);
145 - $wgOut->setSubtitle("<span class='subpages'>" .
146 - "<img src='http://openid.net/login-bg.gif' alt='OpenID' />" .
147 - "<a href='$url'>$disp</a>" .
148 - "</span>");
 154+ global $wgOpenIDShowUrlOnUserPage;
 155+
 156+ if ($wgOpenIDShowUrlOnUserPage == 'always' ||
 157+ ($wgOpenIDShowUrlOnUserPage == 'user' && !$user->getOption('hideopenid')))
 158+ {
 159+ global $wgOpenIDLoginLogoUrl;
 160+
 161+ $url = OpenIDToUrl($openid);
 162+ $disp = htmlspecialchars($openid);
 163+ $wgOut->setSubtitle("<span class='subpages'>" .
 164+ "<img src='$wgOpenIDLoginLogoUrl' alt='OpenID' />" .
 165+ "<a href='$url'>$disp</a>" .
 166+ "</span>");
 167+ }
149168 } else {
150169 $wgOut->addLink(array('rel' => 'openid.server',
151170 'href' => OpenIDServerUrl()));
@@ -229,6 +248,10 @@
230249 return true;
231250 }
232251
 252+ function OpenIDUserToggles(&$extraToggles) {
 253+ $extraToggles[] = 'hideopenid';
 254+ }
 255+
233256 function OpenIDLoginStyle() {
234257 global $wgOpenIDLoginLogoUrl;
235258 return <<<EOS
Index: trunk/extensions/OpenID/README
@@ -266,7 +266,11 @@
267267 'http://www.openid.net/login-bg.gif', but you may want to move it to
268268 a local URL, or an URL on a CDN, if that kind of thing floats your
269269 boat.
270 -
 270+
 271+* $wgOpenIDShowUrlOnUserPage -- whether to show the OpenID identity URL
 272+ on a user's home page. Possible values are 'always', 'never', or 'user'
 273+ (lets the user decide). Default is 'user'.
 274+
271275 == Skins ==
272276
273277 If you are customizing a skin, and you want to show the OpenID

Status & tagging log