Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / specials / SpecialUnlockdb.php
blobe3becbf002adb22e45bd9bd83282650b051a7eb1
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
21 namespace MediaWiki\Specials;
23 use ErrorPageError;
24 use MediaWiki\HTMLForm\HTMLForm;
25 use MediaWiki\MainConfigNames;
26 use MediaWiki\SpecialPage\FormSpecialPage;
27 use MediaWiki\Status\Status;
28 use MediaWiki\User\User;
29 use Wikimedia\AtEase\AtEase;
31 /**
32 * Implements Special:Unlockdb
34 * @see SpecialLockDb
35 * @ingroup SpecialPage
37 class SpecialUnlockdb extends FormSpecialPage {
39 public function __construct() {
40 parent::__construct( 'Unlockdb', 'siteadmin' );
43 public function doesWrites() {
44 return false;
47 public function requiresWrite() {
48 return false;
51 public function checkExecutePermissions( User $user ) {
52 parent::checkExecutePermissions( $user );
53 # If the lock file isn't writable, we can do sweet bugger all
54 if ( !file_exists( $this->getConfig()->get( MainConfigNames::ReadOnlyFile ) ) ) {
55 throw new ErrorPageError( 'lockdb', 'databasenotlocked' );
59 protected function getFormFields() {
60 return [
61 'Confirm' => [
62 'type' => 'toggle',
63 'label-message' => 'unlockconfirm',
68 protected function alterForm( HTMLForm $form ) {
69 $form->setWrapperLegend( false )
70 ->setHeaderHtml( $this->msg( 'unlockdbtext' )->parseAsBlock() )
71 ->setSubmitTextMsg( 'unlockbtn' );
74 public function onSubmit( array $data ) {
75 if ( !$data['Confirm'] ) {
76 return Status::newFatal( 'locknoconfirm' );
79 $readOnlyFile = $this->getConfig()->get( MainConfigNames::ReadOnlyFile );
80 AtEase::suppressWarnings();
81 $res = unlink( $readOnlyFile );
82 AtEase::restoreWarnings();
84 if ( $res ) {
85 return Status::newGood();
86 } else {
87 return Status::newFatal( 'filedeleteerror', $readOnlyFile );
91 public function onSuccess() {
92 $out = $this->getOutput();
93 $out->addSubtitle( $this->msg( 'unlockdbsuccesssub' ) );
94 $out->addWikiMsg( 'unlockdbsuccesstext' );
97 protected function getDisplayFormat() {
98 return 'ooui';
101 protected function getGroupName() {
102 return 'wiki';
107 * Retain the old class name for backwards compatibility.
108 * @deprecated since 1.41
110 class_alias( SpecialUnlockdb::class, 'SpecialUnlockdb' );