3 * Implements Special:Preferences
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * A special page that allows users to change their preferences
27 * @ingroup SpecialPage
29 class SpecialPreferences
extends SpecialPage
{
30 function __construct() {
31 parent
::__construct( 'Preferences' );
34 function execute( $par ) {
35 global $wgOut, $wgUser, $wgRequest;
38 $this->outputHeader();
39 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
41 if ( $wgUser->isAnon() ) {
42 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
46 $wgOut->readOnlyPage();
50 if ( $par == 'reset' ) {
51 $this->showResetForm();
55 $wgOut->addModules( 'mediawiki.legacy.prefs' );
57 if ( $wgRequest->getCheck( 'success' ) ) {
59 "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>",
64 if ( $wgRequest->getCheck( 'eauth' ) ) {
65 $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>\n$1\n</div>",
66 'eauthentsent', $wgUser->getName() );
69 $htmlForm = Preferences
::getFormObject( $wgUser );
70 $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
75 function showResetForm() {
78 $wgOut->addWikiMsg( 'prefs-reset-intro' );
80 $htmlForm = new HTMLForm( array(), 'prefs-restore' );
82 $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) );
83 $htmlForm->setTitle( $this->getTitle( 'reset' ) );
84 $htmlForm->setSubmitCallback( array( __CLASS__
, 'submitReset' ) );
85 $htmlForm->suppressReset();
90 static function submitReset( $formData ) {
91 global $wgUser, $wgOut;
92 $wgUser->resetOptions();
93 $wgUser->saveSettings();
95 $url = SpecialPage
::getTitleFor( 'Preferences' )->getFullURL( 'success' );
97 $wgOut->redirect( $url );