MediaWiki  1.23.15
SpecialUnlockdb.php
Go to the documentation of this file.
1 <?php
30 
31  public function __construct() {
32  parent::__construct( 'Unlockdb', 'siteadmin' );
33  }
34 
35  public function requiresWrite() {
36  return false;
37  }
38 
39  public function checkExecutePermissions( User $user ) {
40  global $wgReadOnlyFile;
41 
42  parent::checkExecutePermissions( $user );
43  # If the lock file isn't writable, we can do sweet bugger all
44  if ( !file_exists( $wgReadOnlyFile ) ) {
45  throw new ErrorPageError( 'lockdb', 'databasenotlocked' );
46  }
47  }
48 
49  protected function getFormFields() {
50  return array(
51  'Confirm' => array(
52  'type' => 'toggle',
53  'label-message' => 'unlockconfirm',
54  ),
55  );
56  }
57 
58  protected function alterForm( HTMLForm $form ) {
59  $form->setWrapperLegend( false );
60  $form->setHeaderText( $this->msg( 'unlockdbtext' )->parseAsBlock() );
61  $form->setSubmitTextMsg( 'unlockbtn' );
62  }
63 
64  public function onSubmit( array $data ) {
65  global $wgReadOnlyFile;
66 
67  if ( !$data['Confirm'] ) {
68  return Status::newFatal( 'locknoconfirm' );
69  }
70 
72  $res = unlink( $wgReadOnlyFile );
74 
75  if ( $res ) {
76  return Status::newGood();
77  } else {
78  return Status::newFatal( 'filedeleteerror', $wgReadOnlyFile );
79  }
80  }
81 
82  public function onSuccess() {
83  $out = $this->getOutput();
84  $out->addSubtitle( $this->msg( 'unlockdbsuccesssub' ) );
85  $out->addWikiMsg( 'unlockdbsuccesstext' );
86  }
87 
88  protected function getGroupName() {
89  return 'wiki';
90  }
91 }
SpecialUnlockdb
Implements Special:Unlockdb.
Definition: SpecialUnlockdb.php:29
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
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2584
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2434
Status\newGood
static newGood( $value=null)
Factory function for good results.
Definition: Status.php:77
FormSpecialPage
Special page which uses an HTMLForm to handle processing.
Definition: FormSpecialPage.php:31
SpecialUnlockdb\__construct
__construct()
Definition: SpecialUnlockdb.php:31
SpecialUnlockdb\alterForm
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
Definition: SpecialUnlockdb.php:58
$out
$out
Definition: UtfNormalGenerate.php:167
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2464
SpecialUnlockdb\onSuccess
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
Definition: SpecialUnlockdb.php:82
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
SpecialUnlockdb\requiresWrite
requiresWrite()
Whether this action requires the wiki not to be locked.
Definition: SpecialUnlockdb.php:35
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:609
$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
SpecialUnlockdb\getFormFields
getFormFields()
Get an HTMLForm descriptor array.
Definition: SpecialUnlockdb.php:49
SpecialUnlockdb\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUnlockdb.php:88
SpecialUnlockdb\checkExecutePermissions
checkExecutePermissions(User $user)
Called from execute() to check if the given user can perform this action.
Definition: SpecialUnlockdb.php:39
SpecialUnlockdb\onSubmit
onSubmit(array $data)
Process the form on POST submission.
Definition: SpecialUnlockdb.php:64
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
$res
$res
Definition: database.txt:21
Status\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: Status.php:63
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:100