Paladox has uploaded a new change for review. https://gerrit.wikimedia.org/r/255941
Change subject: Update to match changes done in SpecialPreferences ...................................................................... Update to match changes done in SpecialPreferences This also replaces deprecated use of wfMsg* Bug: T70750 Change-Id: Ic2764145db31f676bb3b5d2c7441cdb27381ff78 --- M EditUserPreferencesForm.php M EditUser_body.php 2 files changed, 75 insertions(+), 20 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EditUser refs/changes/41/255941/1 diff --git a/EditUserPreferencesForm.php b/EditUserPreferencesForm.php index d5b6ee0..0bb61a7 100644 --- a/EditUserPreferencesForm.php +++ b/EditUserPreferencesForm.php @@ -6,13 +6,16 @@ } function getButtons() { + $attrs = array( 'id' => 'mw-prefs-restoreprefs' ); + $html = HTMLForm::getButtons(); $url = SpecialPage::getTitleFor( 'EditUser' )->getFullURL( array( 'reset' => 1, 'username' => $this->getModifiedUser()->getName() ) ); - $html .= "\n" . Xml::element( 'a', array( 'href'=> $url ), wfMsgHtml( 'restoreprefs' ) ); + $html .= "\n" . Xml::element( 'a', array( 'href'=> $url ), $this->msg( 'restoreprefs' )->escaped(), + Html::buttonAttributes( $attrs, array( 'mw-ui-quiet' ) ) ); $html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html ); diff --git a/EditUser_body.php b/EditUser_body.php index 172c6e6..190f0b7 100644 --- a/EditUser_body.php +++ b/EditUser_body.php @@ -1,12 +1,38 @@ <?php -/* Shamelessly copied and modified from /includes/specials/SpecialPreferences.php v1.16.1 */ -class EditUser extends SpecialPage { +/* Shamelessly copied and modified from /includes/specials/SpecialPreferences.php v1.27alpha */ +/** + * Implements Special:Preferences + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup SpecialPage + */ +/** + * A special page that allows users to change their preferences + * + * @ingroup SpecialPage + */ +class EditUser extends SpecialPage { function __construct() { parent::__construct( 'EditUser', 'edituser' ); } - function execute( $par ) { + public function execute( $par ) { $user = $this->getUser(); $out = $this->getOutput(); @@ -39,33 +65,51 @@ $this->outputHeader(); $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. - if ( wfReadOnly() ) { - $out->readOnlyPage(); - return; - } + $this->checkReadOnly(); if ( $request->getCheck( 'reset' ) ) { $this->showResetForm(); + return; } $out->addModules( 'mediawiki.special.preferences' ); + $out->addModuleStyles( 'mediawiki.special.preferences.styles' ); // $this->loadGlobals( $this->target ); $out->addHtml( $this->makeSearchForm() . '<br />' ); # End EditUser additions - if ( $request->getCheck( 'success' ) ) { + if ( $this->getRequest()->getCheck( 'success' ) ) { $out->wrapWikiMsg( - "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>", + Html::rawElement( + 'div', + array( + 'class' => 'mw-preferences-messagebox successbox', + 'id' => 'mw-preferences-success' + ), + Html::element( 'p', array(), '$1' ) + ), 'savedprefs' ); } - if ( $request->getCheck( 'eauth' ) ) { - $out->wrapWikiMsg( "<div class='error' style='clear: both;'>\n$1\n</div>", - 'eauthentsent', $this->target ); + if ( $this->getRequest()->getCheck( 'eauth' ) ) { + $out->wrapWikiMsg( + Html::rawElement( + 'div', + array( + 'class' => 'error', + 'style' => 'clear: both;' + ), + Html::element( 'p', array(), '$1' ) + ), + 'eauthentsent', + $this->target + ); } + + $this->addHelpLink( 'Help:Preferences' ); $htmlForm = Preferences::getFormObject( $targetuser, $this->getContext(), 'EditUserPreferencesForm', array( 'password' ) ); @@ -75,12 +119,16 @@ $htmlForm->show(); } - function showResetForm() { + private function showResetForm() { + if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) { + throw new PermissionsError( 'editmyoptions' ); + } + $this->getOutput()->addWikiMsg( 'prefs-reset-intro' ); $htmlForm = new HTMLForm( array(), $this->getContext(), 'prefs-restore' ); - $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) ); + $htmlForm->setSubmitTextMsg( 'restoreprefs' ); $htmlForm->addHiddenField( 'username', $this->target ); $htmlForm->addHiddenField( 'reset', '1' ); $htmlForm->setSubmitCallback( array( $this, 'submitReset' ) ); @@ -89,18 +137,22 @@ $htmlForm->show(); } - function submitReset( $formData ) { - $this->targetuser->resetOptions(); + public function submitReset( $formData ) { + if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) { + throw new PermissionsError( 'editmyoptions' ); + } + + $this->targetuser->resetOptions( 'all', $this->getContext() ); $this->targetuser->saveSettings(); - $url = $this->getTitle()->getFullURL( array( 'success' => 1, 'username'=>$this->target ) ); + $url = $this->getTitle()->getFullURL( array( 'success' => 1, 'username' => $this->target ) ); $this->getOutput()->redirect( $url ); return true; } - function makeSearchForm() { + public function makeSearchForm() { global $wgScript; $fields = array(); @@ -114,7 +166,7 @@ return $form; } - function getGroupName() { + protected function getGroupName() { return 'users'; } } -- To view, visit https://gerrit.wikimedia.org/r/255941 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic2764145db31f676bb3b5d2c7441cdb27381ff78 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/EditUser Gerrit-Branch: master Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits