4 * Implements Special:Unlockdb
8 class SpecialUnlockdb
extends SpecialPage
{
10 public function __construct() {
11 parent
::__construct( 'Unlockdb', 'siteadmin' );
14 public function execute( $par ) {
15 global $wgUser, $wgOut, $wgRequest;
19 if( !$wgUser->isAllowed( 'siteadmin' ) ) {
20 $wgOut->permissionRequired( 'siteadmin' );
24 $this->outputHeader();
26 $action = $wgRequest->getVal( 'action' );
28 if ( $action == 'success' ) {
30 } else if ( $action == 'submit' && $wgRequest->wasPosted() &&
31 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
38 private function showForm( $err = '' ) {
39 global $wgOut, $wgUser;
41 global $wgReadOnlyFile;
42 if( !file_exists( $wgReadOnlyFile ) ) {
43 $wgOut->addWikiMsg( 'databasenotlocked' );
47 $wgOut->addWikiMsg( 'unlockdbtext' );
50 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
51 $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
55 Html
::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST',
56 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . "
59 " . Html
::openElement( 'td', array( 'style' => 'text-align:right' ) ) . "
60 " . Html
::input( 'wpLockConfirm', null, 'checkbox' ) . "
62 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) .
63 wfMsgHtml( 'unlockconfirm' ) . "</td>
67 " . Html
::openElement( 'td', array( 'style' => 'text-align:left' ) ) . "
68 " . Html
::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
72 Html
::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" .
73 Html
::closeElement( 'form' )
78 private function doSubmit() {
79 global $wgOut, $wgRequest, $wgReadOnlyFile;
81 $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' );
82 if ( !$wpLockConfirm ) {
83 $this->showForm( wfMsg( 'locknoconfirm' ) );
86 if ( @!unlink( $wgReadOnlyFile ) ) {
87 $wgOut->showFileDeleteError( $wgReadOnlyFile );
91 $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) );
94 private function showSuccess() {
97 $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) );
98 $wgOut->addWikiMsg( 'unlockdbsuccesstext' );