8e432a1401a8639dab1c2634c26e83fc5895ee8f
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
21 * Implements Special:Unlockdb
23 * @ingroup SpecialPage
25 class SpecialUnlockdb
extends SpecialPage
{
27 public function __construct() {
28 parent
::__construct( 'Unlockdb', 'siteadmin' );
31 public function execute( $par ) {
32 global $wgUser, $wgOut, $wgRequest;
36 if( !$wgUser->isAllowed( 'siteadmin' ) ) {
37 $wgOut->permissionRequired( 'siteadmin' );
41 $this->outputHeader();
43 $action = $wgRequest->getVal( 'action' );
45 if ( $action == 'success' ) {
47 } else if ( $action == 'submit' && $wgRequest->wasPosted() &&
48 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
55 private function showForm( $err = '' ) {
56 global $wgOut, $wgUser;
58 global $wgReadOnlyFile;
59 if( !file_exists( $wgReadOnlyFile ) ) {
60 $wgOut->addWikiMsg( 'databasenotlocked' );
64 $wgOut->addWikiMsg( 'unlockdbtext' );
67 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
68 $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
72 Html
::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST',
73 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . "
76 " . Html
::openElement( 'td', array( 'style' => 'text-align:right' ) ) . "
77 " . Html
::input( 'wpLockConfirm', null, 'checkbox' ) . "
79 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) .
80 wfMsgHtml( 'unlockconfirm' ) . "</td>
84 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) . "
85 " . Html
::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
89 Html
::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" .
90 Html
::closeElement( 'form' )
95 private function doSubmit() {
96 global $wgOut, $wgRequest, $wgReadOnlyFile;
98 $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' );
99 if ( !$wpLockConfirm ) {
100 $this->showForm( wfMsg( 'locknoconfirm' ) );
103 if ( @!unlink( $wgReadOnlyFile ) ) {
104 $wgOut->showFileDeleteError( $wgReadOnlyFile );
108 $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) );
111 private function showSuccess() {
114 $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) );
115 $wgOut->addWikiMsg( 'unlockdbsuccesstext' );