r50519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50518‎ | r50519 | r50520 >
Date:15:59, 12 May 2009
Author:ialex
Status:deferred
Tags:
Comment:
Updated OpenID to use the new preferences system
Modified paths:
  • /trunk/extensions/OpenID/OpenID.hooks.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.i18n.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenID.i18n.php
@@ -92,7 +92,7 @@
9393
9494 There are many [http://openid.net/get/ OpenID providers], and you may already have an OpenID-enabled account on another service.',
9595 'openidupdateuserinfo' => 'Update my personal information',
96 - 'openid-prefs' => 'OpenID',
 96+ 'prefs-openid' => 'OpenID',
9797 'openid-prefstext' => '[http://openid.net/ OpenID] preferences',
9898 'openid-pref-hide' => 'Hide your OpenID URL on your user page, if you log in with OpenID.',
9999 'openid-pref-update-userinfo-on-login' => 'Update my information from OpenID persona every time I login',
@@ -119,7 +119,7 @@
120120 'openidlanguage' => '{{Identical|Language}}',
121121 'openidchoosepassword' => '{{Identical|Password}}',
122122 'openidalreadyloggedin' => '$1 is a user name.',
123 - 'openid-prefs' => '{{optional}}
 123+ 'prefs-openid' => '{{optional}}
124124 OpenID preferences tab title',
125125 'openid-prefstext' => 'OpenID preferences tab text above the list of preferences',
126126 'openid-pref-hide' => 'OpenID preference label (Hide your OpenID URL on your user page, if you log in with OpenID)',
@@ -229,7 +229,7 @@
230230
231231 يوجد العديد من [http://wiki.openid.net/Public_OpenID_providers موفري الهوية المفتوحة العلنيين]، وربما يكون لديك حسابك بهوية مفتوحة على خدمة أخرى.',
232232 'openidupdateuserinfo' => 'تحديث معلوماتي الشخصية',
233 - 'openid-prefs' => 'هوية مفتوحة',
 233+ 'prefs-openid' => 'هوية مفتوحة',
234234 'openid-prefstext' => 'تفضيلات [http://openid.net/ OpenID]',
235235 'openid-pref-hide' => 'أخف هويتك <a href="http://openid.net/">هويتك المفتوحة</a> على صفحتك الشخصية، لو سجلت الدخول بالهوية المفتوحة.',
236236 'openid-pref-update-userinfo-on-login' => 'حدث معلوماتي من شخصية الهوية المفتوحة كل مرة أسجل الدخول',
Index: trunk/extensions/OpenID/OpenID.hooks.php
@@ -104,64 +104,25 @@
105105 return true;
106106 }
107107
108 - # list of preferences used by extension
109 - private static $oidPrefs = array( 'hide', 'update-userinfo-on-login' );
110 -
111 - public static function onInitPreferencesForm( $prefs, $request ) {
112 - foreach ( self::$oidPrefs as $oidPref )
113 - {
114 - $prefs->mToggles['openid-' . $oidPref]
115 - = $request->getCheck( "wpOpOpenID-" . $oidPref ) ? 1 : 0;
116 - }
117 -
118 - return true;
119 - }
120 -
121 - public static function onRenderPreferencesForm( $prefs, $out ) {
 108+ public static function onGetPreferences( $user, &$preferences ) {
122109 wfLoadExtensionMessages( 'OpenID' );
 110+
 111+ $preferences['openid-hide'] =
 112+ array(
 113+ 'type' => 'toggle',
 114+ 'section' => 'openid',
 115+ 'label-message' => 'openid-pref-hide',
 116+ );
123117
124 - $out->addHTML( "\n<fieldset>\n<legend>" . wfMsgHtml( 'openid-prefs' ) . "</legend>\n" );
 118+ $preferences['openid-update-userinfo-on-login'] =
 119+ array(
 120+ 'type' => 'toggle',
 121+ 'section' => 'openid',
 122+ 'label-message' => 'openid-pref-update-userinfo-on-login',
 123+ );
125124
126 - $out->addWikiText( wfMsg( 'openid-prefstext' ) );
127 -
128 - foreach ( self::$oidPrefs as $oidPref )
129 - {
130 - $out->addHTML( '<div class="toggle"><input type="checkbox" value="1" ' .
131 - 'id="openid-' . $oidPref . '" name="wpOpOpenID-' . $oidPref . '"' .
132 - ( $prefs->mToggles['openid-' . $oidPref] == 1 ? ' checked="checked"' : '' ) .
133 - '/> ' .
134 - '<span class="toggletext">' .
135 - '<label for="openid-' . $oidPref . '">' . wfMsg( 'openid-pref-' . $oidPref ) . '</label>' .
136 - "</span></div>\n" );
137 - }
138 -
139 - $out->addHTML( "</fieldset>\n\n" );
140 -
141125 return true;
142126 }
143 -
144 - public static function onSavePreferences( $prefs, $user, &$message, $old )
145 - {
146 - foreach ( self::$oidPrefs as $oidPref )
147 - {
148 - $user->setOption( 'openid-' . $oidPref, $prefs->mToggles['openid-' . $oidPref] );
149 - wfDebugLog( 'OpenID', 'Setting user preferences: ' . print_r( $user, true ) );
150 - }
151 -
152 - $user->saveSettings();
153 -
154 - return true;
155 - }
156 -
157 - public static function onResetPreferences( $prefs, $user )
158 - {
159 - foreach ( self::$oidPrefs as $oidPref ) {
160 - $prefs->mToggles['openid-' . $oidPref] = $user->getOption( 'openid-' . $oidPref );
161 - }
162 -
163 - return true;
164 - }
165 -
166127 public static function onLoadExtensionSchemaUpdates() {
167128 global $wgDBtype, $wgExtNewTables;
168129
Index: trunk/extensions/OpenID/OpenID.setup.php
@@ -155,9 +155,6 @@
156156 $wgHooks['ArticleViewHeader'][] = 'OpenIDHooks::onArticleViewHeader';
157157 $wgHooks['SpecialPage_initList'][] = 'OpenIDHooks::onSpecialPage_initList';
158158 $wgHooks['LoadExtensionSchemaUpdates'][] = 'OpenIDHooks::onLoadExtensionSchemaUpdates';
159 -$wgHooks['RenderPreferencesForm'][] = 'OpenIDHooks::onRenderPreferencesForm';
160 -$wgHooks['InitPreferencesForm'][] = 'OpenIDHooks::onInitPreferencesForm';
161 -$wgHooks['ResetPreferences'][] = 'OpenIDHooks::onResetPreferences';
162 -$wgHooks['SavePreferences'][] = 'OpenIDHooks::onSavePreferences';
 159+$wgHooks['GetPreferences'][] = 'OpenIDHooks::onGetPreferences';
163160 # FIXME, function does not exist
164161 # $wgHooks['UserLoginForm'][] = 'OpenIDHooks::onUserLoginForm';

Follow-up revisions

RevisionCommit summaryAuthorDate
r50520Oops, update Translate per r50519ialex16:01, 12 May 2009

Status & tagging log