MediaWiki  1.23.2
SpecialPreferences.php
Go to the documentation of this file.
1 <?php
30  function __construct() {
31  parent::__construct( 'Preferences' );
32  }
33 
34  public function execute( $par ) {
35  $this->setHeaders();
36  $this->outputHeader();
37  $out = $this->getOutput();
38  $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
39 
40  $this->requireLogin( 'prefsnologintext2' );
41  $this->checkReadOnly();
42 
43  if ( $par == 'reset' ) {
44  $this->showResetForm();
45 
46  return;
47  }
48 
49  $out->addModules( 'mediawiki.special.preferences' );
50 
51  if ( $this->getRequest()->getCheck( 'success' ) ) {
52  $out->wrapWikiMsg(
53  "<div class=\"successbox\">\n$1\n</div>",
54  'savedprefs'
55  );
56  }
57 
58  $htmlForm = Preferences::getFormObject( $this->getUser(), $this->getContext() );
59  $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
60 
61  $htmlForm->show();
62  }
63 
64  private function showResetForm() {
65  if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
66  throw new PermissionsError( 'editmyoptions' );
67  }
68 
69  $this->getOutput()->addWikiMsg( 'prefs-reset-intro' );
70 
71  $context = new DerivativeContext( $this->getContext() );
72  $context->setTitle( $this->getPageTitle( 'reset' ) ); // Reset subpage
73  $htmlForm = new HTMLForm( array(), $context, 'prefs-restore' );
74 
75  $htmlForm->setSubmitTextMsg( 'restoreprefs' );
76  $htmlForm->setSubmitCallback( array( $this, 'submitReset' ) );
77  $htmlForm->suppressReset();
78 
79  $htmlForm->show();
80  }
81 
82  public function submitReset( $formData ) {
83  if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
84  throw new PermissionsError( 'editmyoptions' );
85  }
86 
87  $user = $this->getUser();
88  $user->resetOptions( 'all', $this->getContext() );
89  $user->saveSettings();
90 
91  $url = $this->getPageTitle()->getFullURL( 'success' );
92 
93  $this->getOutput()->redirect( $url );
94 
95  return true;
96  }
97 
98  protected function getGroupName() {
99  return 'users';
100  }
101 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:488
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
SpecialPreferences
A special page that allows users to change their preferences.
Definition: SpecialPreferences.php:29
SpecialPreferences\execute
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: SpecialPreferences.php:34
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition: PermissionsError.php:28
SpecialPage\requireLogin
requireLogin( $reasonMsg=null, $titleMsg=null)
If the user is not logged in, throws UserNotLoggedIn error.
Definition: SpecialPage.php:321
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:32
Preferences\getFormObject
static getFormObject( $user, IContextSource $context, $formClass='PreferencesForm', array $remove=array())
Definition: Preferences.php:1226
$out
$out
Definition: UtfNormalGenerate.php:167
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:508
user
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:33
etc
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add etc
Definition: design.txt:12
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:525
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
scripts
The package scripts
Definition: README.txt:1
from
Please log in again after you receive it</td >< td > s a saved copy from
Definition: All_system_messages.txt:3297
SpecialPreferences\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialPreferences.php:98
SpecialPage\checkReadOnly
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Definition: SpecialPage.php:300
SpecialPreferences\submitReset
submitReset( $formData)
Definition: SpecialPreferences.php:82
SpecialPreferences\showResetForm
showResetForm()
Definition: SpecialPreferences.php:64
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:443
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:100
SpecialPreferences\__construct
__construct()
Definition: SpecialPreferences.php:30