Move things along the DROP TABLE.
[mediawiki.git] / includes / specials / SpecialPreferences.php
blob720d5164ffb3e087c9016268bcea84ebad5617d6
1 <?php
2 /**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
20 class SpecialPreferences extends SpecialPage {
21 function __construct() {
22 parent::__construct( 'Preferences' );
25 function execute( $par ) {
26 global $wgOut, $wgUser, $wgRequest;
28 $this->setHeaders();
29 $this->outputHeader();
30 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
32 if ( $wgUser->isAnon() ) {
33 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
34 return;
36 if ( wfReadOnly() ) {
37 $wgOut->readOnlyPage();
38 return;
41 if ( $par == 'reset' ) {
42 $this->showResetForm();
43 return;
46 $wgOut->addScriptFile( 'prefs.js' );
48 if ( $wgRequest->getCheck( 'success' ) ) {
49 $wgOut->wrapWikiMsg(
50 "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>",
51 'savedprefs'
55 if ( $wgRequest->getCheck( 'eauth' ) ) {
56 $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>\n$1\n</div>",
57 'eauthentsent', $wgUser->getName() );
60 $htmlForm = Preferences::getFormObject( $wgUser );
61 $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
63 $htmlForm->show();
66 function showResetForm() {
67 global $wgOut;
69 $wgOut->addWikiMsg( 'prefs-reset-intro' );
71 $htmlForm = new HTMLForm( array(), 'prefs-restore' );
73 $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) );
74 $htmlForm->setTitle( $this->getTitle( 'reset' ) );
75 $htmlForm->setSubmitCallback( array( __CLASS__, 'submitReset' ) );
76 $htmlForm->suppressReset();
78 $htmlForm->show();
81 static function submitReset( $formData ) {
82 global $wgUser, $wgOut;
83 $wgUser->resetOptions();
84 $wgUser->saveSettings();
86 $url = SpecialPage::getTitleFor( 'Preferences' )->getFullURL( 'success' );
88 $wgOut->redirect( $url );
90 return true;