MediaWiki
REL1_20
|
00001 <?php 00029 class SpecialPreferences extends SpecialPage { 00030 function __construct() { 00031 parent::__construct( 'Preferences' ); 00032 } 00033 00034 public function execute( $par ) { 00035 $this->setHeaders(); 00036 $this->outputHeader(); 00037 $out = $this->getOutput(); 00038 $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. 00039 00040 $user = $this->getUser(); 00041 if ( $user->isAnon() ) { 00042 throw new ErrorPageError( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) ); 00043 } 00044 $this->checkReadOnly(); 00045 00046 if ( $par == 'reset' ) { 00047 $this->showResetForm(); 00048 return; 00049 } 00050 00051 $out->addModules( 'mediawiki.special.preferences' ); 00052 00053 if ( $this->getRequest()->getCheck( 'success' ) ) { 00054 $out->wrapWikiMsg( 00055 "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>", 00056 'savedprefs' 00057 ); 00058 } 00059 00060 $htmlForm = Preferences::getFormObject( $user, $this->getContext() ); 00061 $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) ); 00062 00063 $htmlForm->show(); 00064 } 00065 00066 private function showResetForm() { 00067 $this->getOutput()->addWikiMsg( 'prefs-reset-intro' ); 00068 00069 $htmlForm = new HTMLForm( array(), $this->getContext(), 'prefs-restore' ); 00070 00071 $htmlForm->setSubmitTextMsg( 'restoreprefs' ); 00072 $htmlForm->setTitle( $this->getTitle( 'reset' ) ); 00073 $htmlForm->setSubmitCallback( array( $this, 'submitReset' ) ); 00074 $htmlForm->suppressReset(); 00075 00076 $htmlForm->show(); 00077 } 00078 00079 public function submitReset( $formData ) { 00080 $user = $this->getUser(); 00081 $user->resetOptions(); 00082 $user->saveSettings(); 00083 00084 $url = $this->getTitle()->getFullURL( 'success' ); 00085 00086 $this->getOutput()->redirect( $url ); 00087 00088 return true; 00089 } 00090 }