Set values from query params (bug 12750)
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 6 Sep 2008 07:20:13 +0000 (07:20 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 6 Sep 2008 07:20:13 +0000 (07:20 +0000)
includes/ProtectionForm.php

index aa682bf..4b3eaff 100644 (file)
@@ -64,25 +64,23 @@ class ProtectionForm {
                        ? array( 'disabled' => 'disabled' )
                        : array();
 
-               if( $wgRequest->wasPosted() ) {
-                       $this->mReason = $wgRequest->getText( 'mwProtect-reason' );
-                       $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
-                       $this->mExpiry = $wgRequest->getText( 'mwProtect-expiry' );
-
-                       foreach( $this->mApplicableTypes as $action ) {
-                               $val = $wgRequest->getVal( "mwProtect-level-$action" );
-                               if( isset( $val ) && in_array( $val, $wgRestrictionLevels ) ) {
-                                       //prevent users from setting levels that they cannot later unset
-                                       if( $val == 'sysop' ) {
-                                               //special case, rewrite sysop to either protect and editprotected
-                                               if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') )
-                                                       continue;
-                                       } else {
-                                               if( !$wgUser->isAllowed($val) )
-                                                       continue;
-                                       }
-                                       $this->mRestrictions[$action] = $val;
+               $this->mReason = $wgRequest->getText( 'mwProtect-reason' );
+               $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
+               $this->mExpiry = $wgRequest->getText( 'mwProtect-expiry', 'infinite' );
+
+               foreach( $this->mApplicableTypes as $action ) {
+                       $val = $wgRequest->getVal( "mwProtect-level-$action" );
+                       if( isset( $val ) && in_array( $val, $wgRestrictionLevels ) ) {
+                               // Prevent users from setting levels that they cannot later unset
+                               if( $val == 'sysop' ) {
+                                       // Special case, rewrite sysop to either protect and editprotected
+                                       if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') )
+                                               continue;
+                               } else {
+                                       if( !$wgUser->isAllowed($val) )
+                                               continue;
                                }
+                               $this->mRestrictions[$action] = $val;
                        }
                }
        }