Per 46512#c1554, moving check to before required params, returns a result rather...
authorX! <soxred93@users.mediawiki.org>
Thu, 29 Jan 2009 03:23:25 +0000 (03:23 +0000)
committerX! <soxred93@users.mediawiki.org>
Thu, 29 Jan 2009 03:23:25 +0000 (03:23 +0000)
RELEASE-NOTES
includes/api/ApiEmailUser.php

index e36f354..fc8fceb 100644 (file)
@@ -128,6 +128,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 15949) Add undo functionality to action=edit
 * (bug 16483) Kill filesort in ApiQueryBacklinks caused by missing parentheses.
   Building query properly now using makeList()
+* Add "check" parameter to action=email
 
 === Languages updated in 1.15 ===
 
index 6cfbd7b..91e2ad6 100644 (file)
@@ -50,18 +50,28 @@ class ApiEmailUser extends ApiBase {
                // Check required parameters
                if ( !isset( $params['target'] ) )
                        $this->dieUsageMsg( array( 'missingparam', 'target' ) );
-               if ( !isset( $params['text'] ) )
-                       $this->dieUsageMsg( array( 'missingparam', 'text' ) );
-               if ( !isset( $params['token'] ) )
-                       $this->dieUsageMsg( array( 'missingparam', 'token' ) ); 
-               
                // Validate target 
                $targetUser = EmailUserForm::validateEmailTarget( $params['target'] );
                if( isset( $params['check'] ) ) 
-                       ($targetUser instanceof User)? $this->dieUsageMsg( array( 'usermailenabled' ) ) : $this->dieUsageMsg( array( 'usermaildisabled' ) );
+                       if($targetUser instanceof User) {
+                               $result = array( 'result' => 'Enabled' );
+                               $this->getResult()->addValue( null, $this->getModuleName(), $result );
+                               return;
+                       }
+                       else {
+                               $result = array( 'result' => 'Disabled' );
+                               $this->getResult()->addValue( null, $this->getModuleName(), $result );
+                               return;
+                       } //$this->dieUsageMsg( array( 'usermailenabled' ) ) : $this->dieUsageMsg( array( 'usermaildisabled' ) );
                if ( !( $targetUser instanceof User ) )
                        $this->dieUsageMsg( array( $targetUser ) );
                
+               //Check more parameters
+               if ( !isset( $params['text'] ) )
+                       $this->dieUsageMsg( array( 'missingparam', 'text' ) );
+               if ( !isset( $params['token'] ) )
+                       $this->dieUsageMsg( array( 'missingparam', 'token' ) ); 
+               
                
                // Check permissions
                $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] );
@@ -80,7 +90,7 @@ class ApiEmailUser extends ApiBase {
                $this->getResult()->addValue( null, $this->getModuleName(), $result );
        }
        
-       //public function mustBePosted() { return true; }
+       public function mustBePosted() { return true; }
 
        public function getAllowedParams() {
                return array (