* Some code cleanup
authorRob Church <robchurch@users.mediawiki.org>
Mon, 16 Jan 2006 18:55:45 +0000 (18:55 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 16 Jan 2006 18:55:45 +0000 (18:55 +0000)
* Deprecate OutputPage::developerRequired()

includes/SpecialLockdb.php
includes/SpecialUnlockdb.php

index a07c1d8..652549a 100644 (file)
  */
 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;
        }
 }
 
index 6ff28c7..7050e0d 100644 (file)
  */
 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( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
+       function showForm( $error = false ) {
+               global $wgOut, $wgUser;
+               $wgOut->setPagetitle( wfMsg( 'unlockdb' ) );
+               $wgOut->addWikiText( wfMsg( 'unlockdbtext' ) );
+               
+               if( $error ) {
+                       $wgOut->setSubtitle( wfMsg( 'formerror' ) );
+                       $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $error ) . "</p>\n" );
                }
+       
                $lc = htmlspecialchars( wfMsg( "unlockconfirm" ) );
                $lb = htmlspecialchars( wfMsg( "unlockbtn" ) );
                $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );