r62823 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62822‎ | r62823 | r62824 >
Date:12:20, 22 February 2010
Author:ashley
Status:ok
Tags:
Comment:
ApiEmailUser.php: fix copyright symbol, spacing and coding style tweaks, spaces -> tabs, trimmed off trailing whitespace
Modified paths:
  • /trunk/phase3/includes/api/ApiEmailUser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEmailUser.php
@@ -1,10 +1,10 @@
22 <?php
33
4 -/*
 4+/**
55 * Created on June 1, 2008
66 * API for MediaWiki 1.8+
77 *
8 - * Copyright (C) 2008 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
 8+ * Copyright © 2008 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
99 *
1010 * This program is free software; you can redistribute it and/or modify
1111 * it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
2525
2626 if ( !defined( 'MEDIAWIKI' ) ) {
2727 // Eclipse helper - will be ignored in production
28 - require_once ( "ApiBase.php" );
 28+ require_once( "ApiBase.php" );
2929 }
3030
3131 /**
@@ -33,43 +33,51 @@
3434 class ApiEmailUser extends ApiBase {
3535
3636 public function __construct( $main, $action ) {
37 - parent :: __construct( $main, $action );
 37+ parent::__construct( $main, $action );
3838 }
3939
4040 public function execute() {
4141 global $wgUser;
4242 // Check whether email is enabled
43 - if ( !EmailUserForm::userEmailEnabled() )
 43+ if ( !EmailUserForm::userEmailEnabled() ) {
4444 $this->dieUsageMsg( array( 'usermaildisabled' ) );
 45+ }
4546
4647 $params = $this->extractRequestParams();
4748 // Check required parameters
48 - if ( !isset( $params['target'] ) )
 49+ if ( !isset( $params['target'] ) ) {
4950 $this->dieUsageMsg( array( 'missingparam', 'target' ) );
50 - if ( !isset( $params['text'] ) )
 51+ }
 52+ if ( !isset( $params['text'] ) ) {
5153 $this->dieUsageMsg( array( 'missingparam', 'text' ) );
52 -
53 - // Validate target
 54+ }
 55+
 56+ // Validate target
5457 $targetUser = EmailUserForm::validateEmailTarget( $params['target'] );
55 - if ( !( $targetUser instanceof User ) )
 58+ if ( !( $targetUser instanceof User ) ) {
5659 $this->dieUsageMsg( array( $targetUser ) );
57 -
 60+ }
 61+
5862 // Check permissions
5963 $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] );
60 - if ( $error )
 64+ if ( $error ) {
6165 $this->dieUsageMsg( array( $error ) );
 66+ }
6267
6368 $form = new EmailUserForm( $targetUser, $params['text'], $params['subject'], $params['ccme'] );
6469 $retval = $form->doSubmit();
65 - if ( is_null( $retval ) )
 70+ if ( is_null( $retval ) ) {
6671 $result = array( 'result' => 'Success' );
67 - else
68 - $result = array( 'result' => 'Failure',
69 - 'message' => $retval->getMessage() );
70 -
 72+ } else {
 73+ $result = array(
 74+ 'result' => 'Failure',
 75+ 'message' => $retval->getMessage()
 76+ );
 77+ }
 78+
7179 $this->getResult()->addValue( null, $this->getModuleName(), $result );
7280 }
73 -
 81+
7482 public function mustBePosted() {
7583 return true;
7684 }
@@ -79,7 +87,7 @@
8088 }
8189
8290 public function getAllowedParams() {
83 - return array (
 91+ return array(
8492 'target' => null,
8593 'subject' => null,
8694 'text' => null,
@@ -89,7 +97,7 @@
9098 }
9199
92100 public function getParamDescription() {
93 - return array (
 101+ return array(
94102 'target' => 'User to send email to',
95103 'subject' => 'Subject header',
96104 'text' => 'Mail body',
@@ -103,21 +111,21 @@
104112 'Email a user.'
105113 );
106114 }
107 -
108 - public function getPossibleErrors() {
 115+
 116+ public function getPossibleErrors() {
109117 return array_merge( parent::getPossibleErrors(), array(
110118 array( 'usermaildisabled' ),
111119 array( 'missingparam', 'target' ),
112120 array( 'missingparam', 'text' ),
113 - ) );
 121+ ) );
114122 }
115 -
 123+
116124 public function getTokenSalt() {
117125 return '';
118126 }
119127
120128 protected function getExamples() {
121 - return array (
 129+ return array(
122130 'api.php?action=emailuser&target=WikiSysop&text=Content'
123131 );
124132 }
@@ -126,4 +134,3 @@
127135 return __CLASS__ . ': $Id$';
128136 }
129137 }
130 -
\ No newline at end of file

Status & tagging log