r43509 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43508‎ | r43509 | r43510 >
Date:23:05, 14 November 2008
Author:skizzerz
Status:deferred
Tags:
Comment:
* final fixes for this extension (updated current branch for updated Prefs, actually fixed the fatal error glitch when using maintenance scripts)
Modified paths:
  • /trunk/extensions/EditUser/1.14/EditUser_body.php (modified) (history)
  • /trunk/extensions/EditUser/EditUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EditUser/1.14/EditUser_body.php
@@ -1,13 +1,12 @@
22 <?php
33 /* Shamelessly copied and modified from /includes/specials/SpecialPreferences.php v1.14 */
44 class EditUser extends SpecialPage {
5 - var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
 5+ var $mQuickbar, $mNewpass, $mRetypePass, $mStubs;
66 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
77 var $mUserLanguage, $mUserVariant;
88 var $mSearch, $mRecent, $mRecentDays, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
99 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
1010 var $mUnderline, $mWatchlistEdits;
11 - var $user, $target;
1211
1312 function __construct() {
1413 SpecialPage::SpecialPage('EditUser', 'edituser');
@@ -23,11 +22,11 @@
2423 $this->user->load();
2524 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
2625 $this->mNewpass = $request->getVal( 'wpNewpass' );
27 - $this->mRetypePass = $request->getVal( 'wpRetypePass' );
 26+ $this->mRetypePass =$request->getVal( 'wpRetypePass' );
2827 $this->mStubs = $request->getVal( 'wpStubs' );
2928 $this->mRows = $request->getVal( 'wpRows' );
3029 $this->mCols = $request->getVal( 'wpCols' );
31 - $this->mSkin = $request->getVal( 'wpSkin' );
 30+ $this->mSkin = Skin::normalizeKey( $request->getVal( 'wpSkin' ) );
3231 $this->mMath = $request->getVal( 'wpMath' );
3332 $this->mDate = $request->getVal( 'wpDate' );
3433 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
@@ -52,9 +51,10 @@
5352 $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
5453 $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
5554 $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' );
 55+
5656 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
5757 $this->mPosted &&
58 - $this->user->matchEditToken( $request->getVal( 'wpEditToken' ) );
 58+ $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
5959
6060 # User toggles (the big ugly unsorted list of checkboxes)
6161 $this->mToggles = array();
@@ -217,7 +217,7 @@
218218 global $wgAuth, $wgEmailConfirmToEdit;
219219
220220
221 - if ( $this->mNewpass !== '' && $wgAuth->allowPasswordChange() ) {
 221+ if ( ($this->mNewpass !== '' || $this->mOldpass !== '' ) && $wgAuth->allowPasswordChange() ) {
222222 if ( $this->mNewpass != $this->mRetypePass ) {
223223 wfRunHooks( 'PrefsPasswordAudit', array( $this->user, $this->mNewpass, 'badretype' ) );
224224 $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) );
@@ -266,7 +266,10 @@
267267 $this->user->setOption( 'variant', $this->mUserVariant );
268268 $this->user->setOption( 'nickname', $this->mNick );
269269 $this->user->setOption( 'quickbar', $this->mQuickbar );
270 - $this->user->setOption( 'skin', $this->mSkin );
 270+ global $wgAllowUserSkin;
 271+ if( $wgAllowUserSkin ) {
 272+ $this->user->setOption( 'skin', $this->mSkin );
 273+ }
271274 global $wgUseTeX;
272275 if( $wgUseTeX ) {
273276 $this->user->setOption( 'math', $this->mMath );
@@ -627,7 +630,7 @@
628631 );
629632
630633 if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) {
631 - $wgOut->addHtml( $userInformationHtml );
 634+ $wgOut->addHTML( $userInformationHtml );
632635 }
633636
634637 if ( $wgAllowRealName ) {
@@ -712,7 +715,7 @@
713716 }
714717
715718 if(count($variantArray) > 1) {
716 - $wgOut->addHtml(
 719+ $wgOut->addHTML(
717720 $this->tableRow(
718721 Xml::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ),
719722 Xml::tags( 'select',
@@ -724,7 +727,7 @@
725728 }
726729
727730 if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
728 - $wgOut->addHtml(
 731+ $wgOut->addHTML(
729732 Xml::tags( 'tr', null,
730733 Xml::tags( 'td', array( 'colspan' => '2' ),
731734 $this->getToggle( "noconvertlink" )
@@ -799,46 +802,48 @@
800803 # Quickbar
801804 #
802805 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
803 - $wgOut->addHtml( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
 806+ $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" );
804807 for ( $i = 0; $i < count( $qbs ); ++$i ) {
805808 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
806809 else { $checked = ""; }
807810 $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
808811 }
809 - $wgOut->addHtml( "</fieldset>\n\n" );
 812+ $wgOut->addHTML( "</fieldset>\n\n" );
810813 } else {
811814 # Need to output a hidden option even if the relevant skin is not in use,
812815 # otherwise the preference will get reset to 0 on submit
813 - $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar ) );
 816+ $wgOut->addHTML( wfHidden( 'wpQuickbar', $this->mQuickbar ) );
814817 }
815818
816819 # Skin
817820 #
818 - $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
819 - $mptitle = Title::newMainPage();
820 - $previewtext = wfMsg('skin-preview');
821 - # Only show members of Skin::getSkinNames() rather than
822 - # $skinNames (skins is all skin names from Language.php)
823 - $validSkinNames = Skin::getUsableSkins();
824 - # Sort by UI skin name. First though need to update validSkinNames as sometimes
825 - # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
826 - foreach ($validSkinNames as $skinkey => & $skinname ) {
827 - if ( isset( $skinNames[$skinkey] ) ) {
828 - $skinname = $skinNames[$skinkey];
 821+ global $wgAllowUserSkin;
 822+ if( $wgAllowUserSkin ) {
 823+ $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n" );
 824+ $mptitle = Title::newMainPage();
 825+ $previewtext = wfMsg('skin-preview');
 826+ # Only show members of Skin::getSkinNames() rather than
 827+ # $skinNames (skins is all skin names from Language.php)
 828+ $validSkinNames = Skin::getUsableSkins();
 829+ # Sort by UI skin name. First though need to update validSkinNames as sometimes
 830+ # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
 831+ foreach ($validSkinNames as $skinkey => & $skinname ) {
 832+ if ( isset( $skinNames[$skinkey] ) ) {
 833+ $skinname = $skinNames[$skinkey];
 834+ }
829835 }
 836+ asort($validSkinNames);
 837+ foreach ($validSkinNames as $skinkey => $sn ) {
 838+ $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
 839+ $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
 840+ $previewlink = $wgAllowUserSkin ? "(<a target='_blank' href=\"$mplink\">$previewtext</a>)" : '';
 841+ if( $skinkey == $wgDefaultSkin )
 842+ $sn .= ' (' . wfMsg( 'default' ) . ')';
 843+ $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
 844+ }
 845+ $wgOut->addHTML( "</fieldset>\n\n" );
830846 }
831 - asort($validSkinNames);
832 - foreach ($validSkinNames as $skinkey => $sn ) {
833 - $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
834847
835 - $mplink = htmlspecialchars($mptitle->getLocalURL("useskin=$skinkey"));
836 - $previewlink = "(<a target='_blank' href=\"$mplink\">$previewtext</a>)";
837 - if( $skinkey == $wgDefaultSkin )
838 - $sn .= ' (' . wfMsg( 'default' ) . ')';
839 - $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink<br />\n" );
840 - }
841 - $wgOut->addHTML( "</fieldset>\n\n" );
842 -
843848 # Math
844849 #
845850 global $wgUseTeX;
@@ -977,11 +982,12 @@
978983 'externaldiff',
979984 $wgLivePreview ? 'uselivepreview' : false,
980985 'forceeditsummary',
981 - ) ) . '</fieldset>'
982 - );
 986+ ) ) );
 987+
 988+ $wgOut->addHTML( '</fieldset>' );
983989
984990 # Recent changes
985 - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
 991+ $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
986992
987993 $rc = '<table><tr>';
988994 $rc .= '<td>' . Xml::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>';
@@ -990,42 +996,42 @@
991997 $rc .= '<td>' . Xml::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>';
992998 $rc .= '<td>' . Xml::input( 'wpRecent', 3, $this->mRecent, array( 'id' => 'wpRecent' ) ) . '</td>';
993999 $rc .= '</tr></table>';
994 - $wgOut->addHtml( $rc );
 1000+ $wgOut->addHTML( $rc );
9951001
996 - $wgOut->addHtml( '<br />' );
 1002+ $wgOut->addHTML( '<br />' );
9971003
9981004 $toggles[] = 'hideminor';
9991005 if( $wgRCShowWatchingUsers )
10001006 $toggles[] = 'shownumberswatching';
10011007 $toggles[] = 'usenewrc';
1002 - $wgOut->addHtml( $this->getToggles( $toggles ) );
 1008+ $wgOut->addHTML( $this->getToggles( $toggles ) );
10031009
1004 - $wgOut->addHtml( '</fieldset>' );
 1010+ $wgOut->addHTML( '</fieldset>' );
10051011
10061012 # Watchlist
1007 - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
 1013+ $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
10081014
1009 - $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) );
1010 - $wgOut->addHtml( '<br /><br />' );
 1015+ $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) );
 1016+ $wgOut->addHTML( '<br /><br />' );
10111017
1012 - $wgOut->addHtml( $this->getToggle( 'extendwatchlist' ) );
1013 - $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) );
1014 - $wgOut->addHtml( '<br /><br />' );
 1018+ $wgOut->addHTML( $this->getToggle( 'extendwatchlist' ) );
 1019+ $wgOut->addHTML( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) );
 1020+ $wgOut->addHTML( '<br /><br />' );
10151021
1016 - $wgOut->addHtml( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) );
 1022+ $wgOut->addHTML( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) );
10171023
10181024 if( $this->user->isAllowed( 'createpage' ) || $this->user->isAllowed( 'createtalk' ) )
1019 - $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
 1025+ $wgOut->addHTML( $this->getToggle( 'watchcreations' ) );
10201026 foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) {
10211027 if( $this->user->isAllowed( $action ) )
1022 - $wgOut->addHtml( $this->getToggle( $toggle ) );
 1028+ $wgOut->addHTML( $this->getToggle( $toggle ) );
10231029 }
10241030 $this->mUsedToggles['watchcreations'] = true;
10251031 $this->mUsedToggles['watchdefault'] = true;
10261032 $this->mUsedToggles['watchmoves'] = true;
10271033 $this->mUsedToggles['watchdeletion'] = true;
10281034
1029 - $wgOut->addHtml( '</fieldset>' );
 1035+ $wgOut->addHTML( '</fieldset>' );
10301036
10311037 # Search
10321038 $mwsuggest = $wgEnableMWSuggest ?
@@ -1069,8 +1075,8 @@
10701076 # Misc
10711077 #
10721078 $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
1073 - $wgOut->addHtml( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label>&nbsp;' );
1074 - $wgOut->addHtml( Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) );
 1079+ $wgOut->addHTML( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label>&nbsp;' );
 1080+ $wgOut->addHTML( Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) );
10751081 $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) );
10761082 $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) );
10771083 $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) );
@@ -1089,9 +1095,13 @@
10901096
10911097 foreach ( $togs as $tname ) {
10921098 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
1093 - $wgOut->addHTML( $this->getToggle( $tname ) );
 1099+ if( $tname == 'norollbackdiff' && $this->user->isAllowed( 'rollback' ) )
 1100+ $wgOut->addHTML( $this->getToggle( $tname ) );
 1101+ else
 1102+ $wgOut->addHTML( $this->getToggle( $tname ) );
10941103 }
10951104 }
 1105+
10961106 $wgOut->addHTML( '</fieldset>' );
10971107
10981108 wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
@@ -1108,10 +1118,9 @@
11091119 </div>
11101120
11111121 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
1112 - <input type='hidden' name='username' value=\"{$this->target}\" />
11131122 </div></form>\n" );
11141123
1115 - $wgOut->addHtml( Xml::tags( 'div', array( 'class' => "prefcache" ),
 1124+ $wgOut->addHTML( Xml::tags( 'div', array( 'class' => "prefcache" ),
11161125 wfMsgExt( 'clearyourcache', 'parseinline' ) )
11171126 );
11181127 }
Index: trunk/extensions/EditUser/EditUser.php
@@ -10,8 +10,11 @@
1111
1212 $dir = dirname(__FILE__) . '/';
1313
14 -if(!file_exists($dir . substr($wgVersion, 0, 4) . 'EditUser_body.php')) {
15 - wfErrorLog("Your MediaWiki version \"$wgVersion\" is not supported by the EditUser extension");
 14+#in case we're running a maintenance script and GlobalFunctions.php isn't loaded...
 15+require_once("$IP/includes/GlobalFunctions.php");
 16+
 17+if(!file_exists($dir . substr($wgVersion, 0, 4) . '/EditUser_body.php')) {
 18+ wfDebug("Your MediaWiki version \"$wgVersion\" is not supported by the EditUser extension");
1619 return;
1720 }
1821
@@ -26,7 +29,7 @@
2730
2831 $wgExtensionMessagesFiles['EditUser'] = $dir . 'EditUser.i18n.php';
2932 $wgExtensionAliasesFiles['EditUser'] = $dir . 'EditUser.alias.php';
30 -$wgAutoloadClasses['EditUser'] = $dir . substr($wgVersion, 0, 4) . 'EditUser_body.php';
 33+$wgAutoloadClasses['EditUser'] = $dir . substr($wgVersion, 0, 4) . '/EditUser_body.php';
3134 $wgSpecialPages['EditUser'] = 'EditUser';
3235 $wgAvailableRights[] = 'edituser';
3336 $wgAvaliableRights[] = 'edituser-exempt';

Follow-up revisions

RevisionCommit summaryAuthorDate
r88943Remove stray require_once of GlobalFunctions.php from EditUser extension's se...brion22:50, 26 May 2011

Status & tagging log