3 * Implements Special:Unlockdb
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * Implements Special:Unlockdb
27 * @ingroup SpecialPage
29 class SpecialUnlockdb
extends SpecialPage
{
31 public function __construct() {
32 parent
::__construct( 'Unlockdb', 'siteadmin' );
35 public function execute( $par ) {
39 if( !$this->userCanExecute( $this->getUser() ) ) {
40 $this->displayRestrictionError();
44 $this->outputHeader();
46 $request = $this->getRequest();
47 $action = $request->getVal( 'action' );
49 if ( $action == 'success' ) {
51 } elseif ( $action == 'submit' && $request->wasPosted() &&
52 $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
59 private function showForm( $err = '' ) {
60 global $wgReadOnlyFile;
62 $out = $this->getOutput();
64 if( !file_exists( $wgReadOnlyFile ) ) {
65 $out->addWikiMsg( 'databasenotlocked' );
69 $out->addWikiMsg( 'unlockdbtext' );
72 $out->setSubtitle( wfMsg( 'formerror' ) );
73 $out->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
77 Html
::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST',
78 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . "
81 " . Html
::openElement( 'td', array( 'style' => 'text-align:right' ) ) . "
82 " . Html
::input( 'wpLockConfirm', null, 'checkbox', array( 'id' => 'mw-input-wpunlockconfirm' ) ) . "
84 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) .
85 Html
::openElement( 'label', array( 'for' => 'mw-input-wpunlockconfirm' ) ) .
86 wfMsgHtml( 'unlockconfirm' ) . "</label>
91 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) . "
92 " . Html
::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
96 Html
::hidden( 'wpEditToken', $this->getUser()->editToken() ) . "\n" .
97 Html
::closeElement( 'form' )
102 private function doSubmit() {
103 global $wgReadOnlyFile;
105 if ( !$this->getRequest()->getCheck( 'wpLockConfirm' ) ) {
106 $this->showForm( wfMsg( 'locknoconfirm' ) );
110 wfSuppressWarnings();
111 $res = unlink( $wgReadOnlyFile );
115 $this->getOutput()->redirect( $this->getTitle()->getFullURL( 'action=success' ) );
117 $this->getOutput()->addWikiMsg( 'filedeleteerror', $wgReadOnlyFile );
121 private function showSuccess() {
122 $out = $this->getOutput();
123 $out->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) );
124 $out->addWikiMsg( 'unlockdbsuccesstext' );