Index: trunk/extensions/EditUser/1.14/EditUser_body.php |
— | — | @@ -1,13 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | /* Shamelessly copied and modified from /includes/specials/SpecialPreferences.php v1.14 */ |
4 | 4 | class EditUser extends SpecialPage { |
5 | | - var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs; |
| 5 | + var $mQuickbar, $mNewpass, $mRetypePass, $mStubs; |
6 | 6 | var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick; |
7 | 7 | var $mUserLanguage, $mUserVariant; |
8 | 8 | var $mSearch, $mRecent, $mRecentDays, $mHourDiff, $mSearchLines, $mSearchChars, $mAction; |
9 | 9 | var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize; |
10 | 10 | var $mUnderline, $mWatchlistEdits; |
11 | | - var $user, $target; |
12 | 11 | |
13 | 12 | function __construct() { |
14 | 13 | SpecialPage::SpecialPage('EditUser', 'edituser'); |
— | — | @@ -23,11 +22,11 @@ |
24 | 23 | $this->user->load(); |
25 | 24 | $this->mQuickbar = $request->getVal( 'wpQuickbar' ); |
26 | 25 | $this->mNewpass = $request->getVal( 'wpNewpass' ); |
27 | | - $this->mRetypePass = $request->getVal( 'wpRetypePass' ); |
| 26 | + $this->mRetypePass =$request->getVal( 'wpRetypePass' ); |
28 | 27 | $this->mStubs = $request->getVal( 'wpStubs' ); |
29 | 28 | $this->mRows = $request->getVal( 'wpRows' ); |
30 | 29 | $this->mCols = $request->getVal( 'wpCols' ); |
31 | | - $this->mSkin = $request->getVal( 'wpSkin' ); |
| 30 | + $this->mSkin = Skin::normalizeKey( $request->getVal( 'wpSkin' ) ); |
32 | 31 | $this->mMath = $request->getVal( 'wpMath' ); |
33 | 32 | $this->mDate = $request->getVal( 'wpDate' ); |
34 | 33 | $this->mUserEmail = $request->getVal( 'wpUserEmail' ); |
— | — | @@ -52,9 +51,10 @@ |
53 | 52 | $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' ); |
54 | 53 | $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' ); |
55 | 54 | $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' ); |
| 55 | + |
56 | 56 | $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) && |
57 | 57 | $this->mPosted && |
58 | | - $this->user->matchEditToken( $request->getVal( 'wpEditToken' ) ); |
| 58 | + $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) ); |
59 | 59 | |
60 | 60 | # User toggles (the big ugly unsorted list of checkboxes) |
61 | 61 | $this->mToggles = array(); |
— | — | @@ -217,7 +217,7 @@ |
218 | 218 | global $wgAuth, $wgEmailConfirmToEdit; |
219 | 219 | |
220 | 220 | |
221 | | - if ( $this->mNewpass !== '' && $wgAuth->allowPasswordChange() ) { |
| 221 | + if ( ($this->mNewpass !== '' || $this->mOldpass !== '' ) && $wgAuth->allowPasswordChange() ) { |
222 | 222 | if ( $this->mNewpass != $this->mRetypePass ) { |
223 | 223 | wfRunHooks( 'PrefsPasswordAudit', array( $this->user, $this->mNewpass, 'badretype' ) ); |
224 | 224 | $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) ); |
— | — | @@ -266,7 +266,10 @@ |
267 | 267 | $this->user->setOption( 'variant', $this->mUserVariant ); |
268 | 268 | $this->user->setOption( 'nickname', $this->mNick ); |
269 | 269 | $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 | + } |
271 | 274 | global $wgUseTeX; |
272 | 275 | if( $wgUseTeX ) { |
273 | 276 | $this->user->setOption( 'math', $this->mMath ); |
— | — | @@ -627,7 +630,7 @@ |
628 | 631 | ); |
629 | 632 | |
630 | 633 | if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) { |
631 | | - $wgOut->addHtml( $userInformationHtml ); |
| 634 | + $wgOut->addHTML( $userInformationHtml ); |
632 | 635 | } |
633 | 636 | |
634 | 637 | if ( $wgAllowRealName ) { |
— | — | @@ -712,7 +715,7 @@ |
713 | 716 | } |
714 | 717 | |
715 | 718 | if(count($variantArray) > 1) { |
716 | | - $wgOut->addHtml( |
| 719 | + $wgOut->addHTML( |
717 | 720 | $this->tableRow( |
718 | 721 | Xml::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ), |
719 | 722 | Xml::tags( 'select', |
— | — | @@ -724,7 +727,7 @@ |
725 | 728 | } |
726 | 729 | |
727 | 730 | if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) { |
728 | | - $wgOut->addHtml( |
| 731 | + $wgOut->addHTML( |
729 | 732 | Xml::tags( 'tr', null, |
730 | 733 | Xml::tags( 'td', array( 'colspan' => '2' ), |
731 | 734 | $this->getToggle( "noconvertlink" ) |
— | — | @@ -799,46 +802,48 @@ |
800 | 803 | # Quickbar |
801 | 804 | # |
802 | 805 | 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" ); |
804 | 807 | for ( $i = 0; $i < count( $qbs ); ++$i ) { |
805 | 808 | if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; } |
806 | 809 | else { $checked = ""; } |
807 | 810 | $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" ); |
808 | 811 | } |
809 | | - $wgOut->addHtml( "</fieldset>\n\n" ); |
| 812 | + $wgOut->addHTML( "</fieldset>\n\n" ); |
810 | 813 | } else { |
811 | 814 | # Need to output a hidden option even if the relevant skin is not in use, |
812 | 815 | # otherwise the preference will get reset to 0 on submit |
813 | | - $wgOut->addHtml( wfHidden( 'wpQuickbar', $this->mQuickbar ) ); |
| 816 | + $wgOut->addHTML( wfHidden( 'wpQuickbar', $this->mQuickbar ) ); |
814 | 817 | } |
815 | 818 | |
816 | 819 | # Skin |
817 | 820 | # |
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 | + } |
829 | 835 | } |
| 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" ); |
830 | 846 | } |
831 | | - asort($validSkinNames); |
832 | | - foreach ($validSkinNames as $skinkey => $sn ) { |
833 | | - $checked = $skinkey == $this->mSkin ? ' checked="checked"' : ''; |
834 | 847 | |
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 | | - |
843 | 848 | # Math |
844 | 849 | # |
845 | 850 | global $wgUseTeX; |
— | — | @@ -977,11 +982,12 @@ |
978 | 983 | 'externaldiff', |
979 | 984 | $wgLivePreview ? 'uselivepreview' : false, |
980 | 985 | 'forceeditsummary', |
981 | | - ) ) . '</fieldset>' |
982 | | - ); |
| 986 | + ) ) ); |
| 987 | + |
| 988 | + $wgOut->addHTML( '</fieldset>' ); |
983 | 989 | |
984 | 990 | # Recent changes |
985 | | - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' ); |
| 991 | + $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' ); |
986 | 992 | |
987 | 993 | $rc = '<table><tr>'; |
988 | 994 | $rc .= '<td>' . Xml::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . '</td>'; |
— | — | @@ -990,42 +996,42 @@ |
991 | 997 | $rc .= '<td>' . Xml::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . '</td>'; |
992 | 998 | $rc .= '<td>' . Xml::input( 'wpRecent', 3, $this->mRecent, array( 'id' => 'wpRecent' ) ) . '</td>'; |
993 | 999 | $rc .= '</tr></table>'; |
994 | | - $wgOut->addHtml( $rc ); |
| 1000 | + $wgOut->addHTML( $rc ); |
995 | 1001 | |
996 | | - $wgOut->addHtml( '<br />' ); |
| 1002 | + $wgOut->addHTML( '<br />' ); |
997 | 1003 | |
998 | 1004 | $toggles[] = 'hideminor'; |
999 | 1005 | if( $wgRCShowWatchingUsers ) |
1000 | 1006 | $toggles[] = 'shownumberswatching'; |
1001 | 1007 | $toggles[] = 'usenewrc'; |
1002 | | - $wgOut->addHtml( $this->getToggles( $toggles ) ); |
| 1008 | + $wgOut->addHTML( $this->getToggles( $toggles ) ); |
1003 | 1009 | |
1004 | | - $wgOut->addHtml( '</fieldset>' ); |
| 1010 | + $wgOut->addHTML( '</fieldset>' ); |
1005 | 1011 | |
1006 | 1012 | # Watchlist |
1007 | | - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' ); |
| 1013 | + $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' ); |
1008 | 1014 | |
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 />' ); |
1011 | 1017 | |
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 />' ); |
1015 | 1021 | |
1016 | | - $wgOut->addHtml( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) ); |
| 1022 | + $wgOut->addHTML( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) ); |
1017 | 1023 | |
1018 | 1024 | if( $this->user->isAllowed( 'createpage' ) || $this->user->isAllowed( 'createtalk' ) ) |
1019 | | - $wgOut->addHtml( $this->getToggle( 'watchcreations' ) ); |
| 1025 | + $wgOut->addHTML( $this->getToggle( 'watchcreations' ) ); |
1020 | 1026 | foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) { |
1021 | 1027 | if( $this->user->isAllowed( $action ) ) |
1022 | | - $wgOut->addHtml( $this->getToggle( $toggle ) ); |
| 1028 | + $wgOut->addHTML( $this->getToggle( $toggle ) ); |
1023 | 1029 | } |
1024 | 1030 | $this->mUsedToggles['watchcreations'] = true; |
1025 | 1031 | $this->mUsedToggles['watchdefault'] = true; |
1026 | 1032 | $this->mUsedToggles['watchmoves'] = true; |
1027 | 1033 | $this->mUsedToggles['watchdeletion'] = true; |
1028 | 1034 | |
1029 | | - $wgOut->addHtml( '</fieldset>' ); |
| 1035 | + $wgOut->addHTML( '</fieldset>' ); |
1030 | 1036 | |
1031 | 1037 | # Search |
1032 | 1038 | $mwsuggest = $wgEnableMWSuggest ? |
— | — | @@ -1069,8 +1075,8 @@ |
1070 | 1076 | # Misc |
1071 | 1077 | # |
1072 | 1078 | $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>'); |
1073 | | - $wgOut->addHtml( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label> ' ); |
1074 | | - $wgOut->addHtml( Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) ); |
| 1079 | + $wgOut->addHTML( '<label for="wpStubs">' . wfMsg( 'stub-threshold' ) . '</label> ' ); |
| 1080 | + $wgOut->addHTML( Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) ); |
1075 | 1081 | $msgUnderline = htmlspecialchars( wfMsg ( 'tog-underline' ) ); |
1076 | 1082 | $msgUnderlinenever = htmlspecialchars( wfMsg ( 'underline-never' ) ); |
1077 | 1083 | $msgUnderlinealways = htmlspecialchars( wfMsg ( 'underline-always' ) ); |
— | — | @@ -1089,9 +1095,13 @@ |
1090 | 1096 | |
1091 | 1097 | foreach ( $togs as $tname ) { |
1092 | 1098 | 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 ) ); |
1094 | 1103 | } |
1095 | 1104 | } |
| 1105 | + |
1096 | 1106 | $wgOut->addHTML( '</fieldset>' ); |
1097 | 1107 | |
1098 | 1108 | wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) ); |
— | — | @@ -1108,10 +1118,9 @@ |
1109 | 1119 | </div> |
1110 | 1120 | |
1111 | 1121 | <input type='hidden' name='wpEditToken' value=\"{$token}\" /> |
1112 | | - <input type='hidden' name='username' value=\"{$this->target}\" /> |
1113 | 1122 | </div></form>\n" ); |
1114 | 1123 | |
1115 | | - $wgOut->addHtml( Xml::tags( 'div', array( 'class' => "prefcache" ), |
| 1124 | + $wgOut->addHTML( Xml::tags( 'div', array( 'class' => "prefcache" ), |
1116 | 1125 | wfMsgExt( 'clearyourcache', 'parseinline' ) ) |
1117 | 1126 | ); |
1118 | 1127 | } |
Index: trunk/extensions/EditUser/EditUser.php |
— | — | @@ -10,8 +10,11 @@ |
11 | 11 | |
12 | 12 | $dir = dirname(__FILE__) . '/'; |
13 | 13 | |
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"); |
16 | 19 | return; |
17 | 20 | } |
18 | 21 | |
— | — | @@ -26,7 +29,7 @@ |
27 | 30 | |
28 | 31 | $wgExtensionMessagesFiles['EditUser'] = $dir . 'EditUser.i18n.php'; |
29 | 32 | $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'; |
31 | 34 | $wgSpecialPages['EditUser'] = 'EditUser'; |
32 | 35 | $wgAvailableRights[] = 'edituser'; |
33 | 36 | $wgAvaliableRights[] = 'edituser-exempt'; |