From 7058f802a2a915ccb8f0a7a4ed6dd3bdf0ec86a8 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Thu, 29 Jan 2009 19:27:44 +0000 Subject: [PATCH] Kill code duplication & other style tweaks --- includes/api/ApiEmailUser.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 338e96eaaa..bcec9f7968 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -52,21 +52,21 @@ class ApiEmailUser extends ApiBase { $this->dieUsageMsg( array( 'missingparam', 'target' ) ); // Validate target $targetUser = EmailUserForm::validateEmailTarget( $params['target'] ); - if( isset( $params['check'] ) ) - if($targetUser instanceof User) { + if ( isset( $params['check'] ) ) { + // Only a check was requested; don't actually send a mail + if ( $targetUser instanceof User ) $result = array( 'result' => 'Enabled' ); - $this->getResult()->addValue( null, $this->getModuleName(), $result ); - return; - } - else { + else $result = array( 'result' => 'Disabled' ); - $this->getResult()->addValue( null, $this->getModuleName(), $result ); - return; - } + + $this->getResult()->addValue( null, $this->getModuleName(), $result ); + return; + } + // If $targetUser is not a User it represents an error message if ( !( $targetUser instanceof User ) ) $this->dieUsageMsg( array( $targetUser ) ); - //Check more parameters + // Check more parameters if ( !isset( $params['text'] ) ) $this->dieUsageMsg( array( 'missingparam', 'text' ) ); if ( !isset( $params['token'] ) ) @@ -110,7 +110,7 @@ class ApiEmailUser extends ApiBase { 'text' => 'Mail body', 'token' => 'A token previously acquired via prop=info', 'ccme' => 'Send a copy of this mail to me', - 'check' => 'Check if the user has email enabled', + 'check' => 'Only check whether the user has email enabled', ); } -- 2.20.1