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 ) {
36 global $wgUser, $wgOut, $wgRequest;
40 if( !$wgUser->isAllowed( 'siteadmin' ) ) {
41 $wgOut->permissionRequired( 'siteadmin' );
45 $this->outputHeader();
47 $action = $wgRequest->getVal( 'action' );
49 if ( $action == 'success' ) {
51 } else if ( $action == 'submit' && $wgRequest->wasPosted() &&
52 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
59 private function showForm( $err = '' ) {
60 global $wgOut, $wgUser;
62 global $wgReadOnlyFile;
63 if( !file_exists( $wgReadOnlyFile ) ) {
64 $wgOut->addWikiMsg( 'databasenotlocked' );
68 $wgOut->addWikiMsg( 'unlockdbtext' );
71 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
72 $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
76 Html
::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST',
77 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . "
80 " . Html
::openElement( 'td', array( 'style' => 'text-align:right' ) ) . "
81 " . Html
::input( 'wpLockConfirm', null, 'checkbox' ) . "
83 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) .
84 wfMsgHtml( 'unlockconfirm' ) . "</td>
88 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) . "
89 " . Html
::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
93 Html
::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" .
94 Html
::closeElement( 'form' )
99 private function doSubmit() {
100 global $wgOut, $wgRequest, $wgReadOnlyFile;
102 $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' );
103 if ( !$wpLockConfirm ) {
104 $this->showForm( wfMsg( 'locknoconfirm' ) );
107 if ( @!unlink( $wgReadOnlyFile ) ) {
108 $wgOut->showFileDeleteError( $wgReadOnlyFile );
112 $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) );
115 private function showSuccess() {
118 $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) );
119 $wgOut->addWikiMsg( 'unlockdbsuccesstext' );