r45563 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45562‎ | r45563 | r45564 >
Date:14:02, 8 January 2009
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
(bug 2164) Add a "reset to site defaults" link to Special:Preferences
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1909,6 +1909,13 @@
19101910 }
19111911 $this->mOptions[$oname] = $val;
19121912 }
 1913+
 1914+ /**
 1915+ * Reset all options to the site defaults
 1916+ */
 1917+ function restoreOptions() {
 1918+ $this->mOptions = User::getDefaultOptions();
 1919+ }
19131920
19141921 /**
19151922 * Get the user's preferred date format.
Index: trunk/phase3/includes/specials/SpecialPreferences.php
@@ -32,7 +32,7 @@
3333 * Constructor
3434 * Load some values
3535 */
36 - function PreferencesForm( &$request ) {
 36+ function __construct( &$request ) {
3737 global $wgContLang, $wgUser, $wgAllowRealName;
3838
3939 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
@@ -60,6 +60,7 @@
6161 $this->mUnderline = $request->getInt( 'wpOpunderline' );
6262 $this->mAction = $request->getVal( 'action' );
6363 $this->mReset = $request->getCheck( 'wpReset' );
 64+ $this->mRestoreprefs = $request->getCheck( 'wpRestore' );
6465 $this->mPosted = $request->wasPosted();
6566 $this->mSuccess = $request->getCheck( 'success' );
6667 $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
@@ -117,6 +118,8 @@
118119 $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) );
119120 } else if ( $this->mSaveprefs ) {
120121 $this->savePreferences();
 122+ } else if ( $this->mRestoreprefs ) {
 123+ $this->restorePreferences();
121124 } else {
122125 $this->resetPrefs();
123126 $this->mainPrefsForm( '' );
@@ -435,6 +438,17 @@
436439
437440 wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) );
438441 }
 442+
 443+ /**
 444+ * @access private
 445+ */
 446+ function restorePreferences() {
 447+ global $wgUser;
 448+ $wgUser->restoreOptions();
 449+ $wgUser->setCookies();
 450+ $wgUser->saveSettings();
 451+ $this->mainPrefsForm( 'success' );
 452+ }
439453
440454 /**
441455 * @access private
@@ -1192,13 +1206,13 @@
11931207 $skin = $wgUser->getSkin();
11941208 $wgOut->addHTML( "
11951209 <div id='prefsubmit'>
1196 - <div>
1197 - <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . '"'.$skin->tooltipAndAccesskey('save')." />
 1210+ <input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) .
 1211+ '"'.$skin->tooltipAndAccesskey('save')." />
11981212 <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" />
 1213+ <input type='submit' name='wpRestore' class='btnSavePrefs' style='float:right;' value=\"" .
 1214+ wfMsgHtml( 'restoreprefs' ) . "\" />
11991215 </div>
12001216
1201 - </div>
1202 -
12031217 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
12041218 </div></form>\n" );
12051219
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1535,6 +1535,7 @@
15361536 'prefs-resetpass' => 'Change password',
15371537 'saveprefs' => 'Save',
15381538 'resetprefs' => 'Clear unsaved changes',
 1539+'restoreprefs' => 'Restore all default settings',
15391540 'textboxsize' => 'Editing',
15401541 'prefs-edit-boxsize' => 'Size of the edit window.',
15411542 'rows' => 'Rows:',

Comments

#Comment by Raymond (talk | contribs)   14:03, 9 January 2009

At least the restore does not work for the tabs "Skin, TeX, Files, Date/Time, Search".

#Comment by Aaron Schulz (talk | contribs)   14:21, 9 January 2009

Skin works for me

#Comment by Aaron Schulz (talk | contribs)   14:24, 9 January 2009

Actually, they all work fine. The first reloading of the page sometimes shows the old ones though..

#Comment by Aaron Schulz (talk | contribs)   14:26, 9 January 2009

Fixed in r45602

#Comment by Brion VIBBER (talk | contribs)   21:42, 13 January 2009

This explicit float right is pretty bad for RTL. :)

#Comment by Raymond (talk | contribs)   21:47, 13 January 2009

A tabindex should be added to the buttons too.

#Comment by Aaron Schulz (talk | contribs)   13:43, 16 January 2009

Uses a table in r45761

Status & tagging log