2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2010-06-21 12:59:04 +00:00
|
|
|
/**
|
2010-08-15 07:16:58 +00:00
|
|
|
* Implements Special:Unlockdb
|
2010-06-21 12:59:04 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:16:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2010-06-21 12:59:04 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-15 07:16:58 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2010-06-21 12:59:04 +00:00
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-06-13 13:52:20 +00:00
|
|
|
* Implements Special:Unlockdb
|
2004-09-02 23:28:24 +00:00
|
|
|
*
|
2010-06-13 13:52:20 +00:00
|
|
|
* @ingroup SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-10-25 18:20:44 +00:00
|
|
|
class SpecialUnlockdb extends FormSpecialPage {
|
2006-01-18 00:04:30 +00:00
|
|
|
|
2010-06-13 13:52:20 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct( 'Unlockdb', 'siteadmin' );
|
2005-02-21 01:56:50 +00:00
|
|
|
}
|
2006-07-10 08:36:16 +00:00
|
|
|
|
2016-01-14 22:35:31 +00:00
|
|
|
public function doesWrites() {
|
2016-05-07 14:10:27 +00:00
|
|
|
return false;
|
2016-01-14 22:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 18:20:44 +00:00
|
|
|
public function requiresWrite() {
|
|
|
|
|
return false;
|
2006-01-18 00:04:30 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-10-26 06:22:25 +00:00
|
|
|
public function checkExecutePermissions( User $user ) {
|
|
|
|
|
parent::checkExecutePermissions( $user );
|
2011-10-25 18:20:44 +00:00
|
|
|
# If the lock file isn't writable, we can do sweet bugger all
|
2014-08-06 15:22:35 +00:00
|
|
|
if ( !file_exists( $this->getConfig()->get( 'ReadOnlyFile' ) ) ) {
|
2011-10-25 18:20:44 +00:00
|
|
|
throw new ErrorPageError( 'lockdb', 'databasenotlocked' );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2011-10-25 18:20:44 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-10-25 18:20:44 +00:00
|
|
|
protected function getFormFields() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
'Confirm' => [
|
2011-10-25 18:20:44 +00:00
|
|
|
'type' => 'toggle',
|
|
|
|
|
'label-message' => 'unlockconfirm',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
];
|
2011-10-25 18:20:44 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-10-25 18:20:44 +00:00
|
|
|
protected function alterForm( HTMLForm $form ) {
|
2016-05-03 19:51:04 +00:00
|
|
|
$form->setWrapperLegend( false )
|
|
|
|
|
->setHeaderText( $this->msg( 'unlockdbtext' )->parseAsBlock() )
|
|
|
|
|
->setSubmitTextMsg( 'unlockbtn' );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 18:20:44 +00:00
|
|
|
public function onSubmit( array $data ) {
|
|
|
|
|
if ( !$data['Confirm'] ) {
|
|
|
|
|
return Status::newFatal( 'locknoconfirm' );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2011-05-15 14:48:15 +00:00
|
|
|
|
2014-08-06 15:22:35 +00:00
|
|
|
$readOnlyFile = $this->getConfig()->get( 'ReadOnlyFile' );
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\suppressWarnings();
|
2014-08-06 15:22:35 +00:00
|
|
|
$res = unlink( $readOnlyFile );
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\restoreWarnings();
|
2011-05-15 14:48:15 +00:00
|
|
|
|
2011-08-14 19:54:04 +00:00
|
|
|
if ( $res ) {
|
2011-10-25 18:20:44 +00:00
|
|
|
return Status::newGood();
|
2011-08-14 19:54:04 +00:00
|
|
|
} else {
|
2014-08-06 15:22:35 +00:00
|
|
|
return Status::newFatal( 'filedeleteerror', $readOnlyFile );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-25 18:20:44 +00:00
|
|
|
public function onSuccess() {
|
2011-08-14 19:54:04 +00:00
|
|
|
$out = $this->getOutput();
|
2011-11-08 18:01:22 +00:00
|
|
|
$out->addSubtitle( $this->msg( 'unlockdbsuccesssub' ) );
|
2011-08-14 19:54:04 +00:00
|
|
|
$out->addWikiMsg( 'unlockdbsuccesstext' );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2013-03-07 20:15:54 +00:00
|
|
|
|
2016-05-03 19:51:04 +00:00
|
|
|
protected function getDisplayFormat() {
|
|
|
|
|
return 'ooui';
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 20:15:54 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
|
return 'wiki';
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|