(Bug 19725) Do not include suppressed edits in the "View X deleted edits" message...
[lhc/web/wiklou.git] / includes / specials / SpecialPreferences.php
1 <?php
2 /**
3 * Implements Special:Preferences
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * A special page that allows users to change their preferences
26 *
27 * @ingroup SpecialPage
28 */
29 class SpecialPreferences extends SpecialPage {
30 function __construct() {
31 parent::__construct( 'Preferences' );
32 }
33
34 function execute( $par ) {
35 global $wgOut, $wgUser, $wgRequest;
36
37 $this->setHeaders();
38 $this->outputHeader();
39 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
40
41 if ( $wgUser->isAnon() ) {
42 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
43 return;
44 }
45 if ( wfReadOnly() ) {
46 $wgOut->readOnlyPage();
47 return;
48 }
49
50 if ( $par == 'reset' ) {
51 $this->showResetForm();
52 return;
53 }
54
55 $wgOut->addModules( 'mediawiki.special.preferences' );
56
57 if ( $wgRequest->getCheck( 'success' ) ) {
58 $wgOut->wrapWikiMsg(
59 "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>",
60 'savedprefs'
61 );
62 }
63
64 if ( $wgRequest->getCheck( 'eauth' ) ) {
65 $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>\n$1\n</div>",
66 'eauthentsent', $wgUser->getName() );
67 }
68
69 $htmlForm = Preferences::getFormObject( $wgUser );
70 $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
71
72 $htmlForm->show();
73 }
74
75 function showResetForm() {
76 global $wgOut;
77
78 $wgOut->addWikiMsg( 'prefs-reset-intro' );
79
80 $htmlForm = new HTMLForm( array(), $this->getContext(), 'prefs-restore' );
81
82 $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) );
83 $htmlForm->setTitle( $this->getTitle( 'reset' ) );
84 $htmlForm->setSubmitCallback( array( __CLASS__, 'submitReset' ) );
85 $htmlForm->suppressReset();
86
87 $htmlForm->show();
88 }
89
90 static function submitReset( $formData ) {
91 global $wgUser, $wgOut;
92 $wgUser->resetOptions();
93 $wgUser->saveSettings();
94
95 $url = SpecialPage::getTitleFor( 'Preferences' )->getFullURL( 'success' );
96
97 $wgOut->redirect( $url );
98
99 return true;
100 }
101 }