From e419436ad227e82d215c947310f4182db089e063 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 16 Jan 2006 18:55:45 +0000 Subject: [PATCH] * Some code cleanup * Deprecate OutputPage::developerRequired() --- includes/SpecialLockdb.php | 24 +++++++++------------ includes/SpecialUnlockdb.php | 42 ++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/includes/SpecialLockdb.php b/includes/SpecialLockdb.php index a07c1d8d2b..652549a6ca 100644 --- a/includes/SpecialLockdb.php +++ b/includes/SpecialLockdb.php @@ -10,21 +10,17 @@ */ function wfSpecialLockdb() { global $wgUser, $wgOut, $wgRequest; - - if ( ! $wgUser->isAllowed('siteadmin') ) { - $wgOut->developerRequired(); - return; - } - $action = $wgRequest->getVal( 'action' ); - $f = new DBLockForm(); - - if ( 'success' == $action ) { - $f->showSuccess(); - } else if ( 'submit' == $action && $wgRequest->wasPosted() && - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $f->doSubmit(); + if( $wgUser->isAllowed( 'siteadmin' ) ) { + $form = new DBLockForm(); + if( $action == 'success' ) { + $form->showSuccess(); + } else if( $action == 'submit' && wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + $form->doSubmit(); + } else { + $form->showForm(); } else { - $f->showForm( '' ); + $wgOut->permissionRequired( 'siteadmin' ); + return; } } diff --git a/includes/SpecialUnlockdb.php b/includes/SpecialUnlockdb.php index 6ff28c7902..7050e0daf3 100644 --- a/includes/SpecialUnlockdb.php +++ b/includes/SpecialUnlockdb.php @@ -10,21 +10,17 @@ */ function wfSpecialUnlockdb() { global $wgUser, $wgOut, $wgRequest; - - if ( ! $wgUser->isAllowed('siteadmin') ) { - $wgOut->developerRequired(); - return; - } - $action = $wgRequest->getVal( 'action' ); - $f = new DBUnlockForm(); - - if ( "success" == $action ) { - $f->showSuccess(); - } else if ( "submit" == $action && $wgRequest->wasPosted() && - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $f->doSubmit(); + if( $wgUser->isAllowed( 'siteadmin' ) ) { + $form = new DBUnlockForm(); + if( $action == 'success' ) { + $form->showSuccess(); + } else if( $action == 'submit' && wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + $form->doSubmit(); + } else { + $form->showForm(); } else { - $f->showForm( "" ); + $wgOut->permissionRequired( 'siteadmin' ); + return; } } @@ -34,17 +30,17 @@ function wfSpecialUnlockdb() { * @subpackage SpecialPage */ class DBUnlockForm { - function showForm( $err ) - { - global $wgOut, $wgUser; - - $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); - $wgOut->addWikiText( wfMsg( "unlockdbtext" ) ); - if ( "" != $err ) { - $wgOut->setSubtitle( wfMsg( "formerror" ) ); - $wgOut->addHTML( '

' . htmlspecialchars( $err ) . "

\n" ); + function showForm( $error = false ) { + global $wgOut, $wgUser; + $wgOut->setPagetitle( wfMsg( 'unlockdb' ) ); + $wgOut->addWikiText( wfMsg( 'unlockdbtext' ) ); + + if( $error ) { + $wgOut->setSubtitle( wfMsg( 'formerror' ) ); + $wgOut->addHTML( '

' . htmlspecialchars( $error ) . "

\n" ); } + $lc = htmlspecialchars( wfMsg( "unlockconfirm" ) ); $lb = htmlspecialchars( wfMsg( "unlockbtn" ) ); $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" ); -- 2.20.1