From: Jack Phoenix Date: Mon, 22 Feb 2010 12:20:54 +0000 (+0000) Subject: ApiEmailUser.php: fix copyright symbol, spacing and coding style tweaks, spaces ... X-Git-Tag: 1.31.0-rc.0~37648 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=582afa7e2a6ed62f19a6c52d11dcbb49a10974a4;p=lhc%2Fweb%2Fwiklou.git ApiEmailUser.php: fix copyright symbol, spacing and coding style tweaks, spaces -> tabs, trimmed off trailing whitespace --- diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 0c29c6fb25..65da13f0d7 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -1,10 +1,10 @@ + * Copyright © 2008 Bryan Tong Minh * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { // Eclipse helper - will be ignored in production - require_once ( "ApiBase.php" ); + require_once( "ApiBase.php" ); } /** @@ -33,43 +33,51 @@ if ( !defined( 'MEDIAWIKI' ) ) { class ApiEmailUser extends ApiBase { public function __construct( $main, $action ) { - parent :: __construct( $main, $action ); + parent::__construct( $main, $action ); } public function execute() { global $wgUser; // Check whether email is enabled - if ( !EmailUserForm::userEmailEnabled() ) + if ( !EmailUserForm::userEmailEnabled() ) { $this->dieUsageMsg( array( 'usermaildisabled' ) ); + } $params = $this->extractRequestParams(); // Check required parameters - if ( !isset( $params['target'] ) ) + if ( !isset( $params['target'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'target' ) ); - if ( !isset( $params['text'] ) ) + } + if ( !isset( $params['text'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'text' ) ); - - // Validate target + } + + // Validate target $targetUser = EmailUserForm::validateEmailTarget( $params['target'] ); - if ( !( $targetUser instanceof User ) ) + if ( !( $targetUser instanceof User ) ) { $this->dieUsageMsg( array( $targetUser ) ); - + } + // Check permissions $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] ); - if ( $error ) + if ( $error ) { $this->dieUsageMsg( array( $error ) ); + } $form = new EmailUserForm( $targetUser, $params['text'], $params['subject'], $params['ccme'] ); $retval = $form->doSubmit(); - if ( is_null( $retval ) ) + if ( is_null( $retval ) ) { $result = array( 'result' => 'Success' ); - else - $result = array( 'result' => 'Failure', - 'message' => $retval->getMessage() ); - + } else { + $result = array( + 'result' => 'Failure', + 'message' => $retval->getMessage() + ); + } + $this->getResult()->addValue( null, $this->getModuleName(), $result ); } - + public function mustBePosted() { return true; } @@ -79,7 +87,7 @@ class ApiEmailUser extends ApiBase { } public function getAllowedParams() { - return array ( + return array( 'target' => null, 'subject' => null, 'text' => null, @@ -89,7 +97,7 @@ class ApiEmailUser extends ApiBase { } public function getParamDescription() { - return array ( + return array( 'target' => 'User to send email to', 'subject' => 'Subject header', 'text' => 'Mail body', @@ -103,21 +111,21 @@ class ApiEmailUser extends ApiBase { 'Email a user.' ); } - - public function getPossibleErrors() { + + public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'usermaildisabled' ), array( 'missingparam', 'target' ), array( 'missingparam', 'text' ), - ) ); + ) ); } - + public function getTokenSalt() { return ''; } protected function getExamples() { - return array ( + return array( 'api.php?action=emailuser&target=WikiSysop&text=Content' ); } @@ -126,4 +134,3 @@ class ApiEmailUser extends ApiBase { return __CLASS__ . ': $Id$'; } } - \ No newline at end of file