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, $wgRequest;
41 if( !$this->userCanExecute( $wgUser ) ) {
42 $this->displayRestrictionError();
46 $this->outputHeader();
48 $action = $wgRequest->getVal( 'action' );
50 if ( $action == 'success' ) {
52 } elseif ( $action == 'submit' && $wgRequest->wasPosted() &&
53 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
60 private function showForm( $err = '' ) {
61 global $wgOut, $wgUser;
63 global $wgReadOnlyFile;
64 if( !file_exists( $wgReadOnlyFile ) ) {
65 $wgOut->addWikiMsg( 'databasenotlocked' );
69 $wgOut->addWikiMsg( 'unlockdbtext' );
72 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
73 $wgOut->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' ) . "
84 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) .
85 wfMsgHtml( 'unlockconfirm' ) . "</td>
89 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) . "
90 " . Html
::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
94 Html
::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" .
95 Html
::closeElement( 'form' )
100 private function doSubmit() {
101 global $wgOut, $wgRequest, $wgReadOnlyFile;
103 $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' );
104 if ( !$wpLockConfirm ) {
105 $this->showForm( wfMsg( 'locknoconfirm' ) );
109 wfSuppressWarnings();
110 $res = unlink( $wgReadOnlyFile );
114 $wgOut->showFileDeleteError( $wgReadOnlyFile );
118 $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) );
121 private function showSuccess() {
124 $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) );
125 $wgOut->addWikiMsg( 'unlockdbsuccesstext' );