r62766 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62765‎ | r62766 | r62767 >
Date:12:32, 21 February 2010
Author:ashley
Status:ok
Tags:
Comment:
ApiBlock.php: spacing & coding style tweaks, more braces, fixed copyright symbol
Modified paths:
  • /trunk/phase3/includes/api/ApiBlock.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBlock.php
@@ -1,10 +1,10 @@
22 <?php
33
4 -/*
 4+/**
55 * Created on Sep 4, 2007
66 * API for MediaWiki 1.8+
77 *
8 - * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
 8+ * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
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 /**
@@ -39,7 +39,7 @@
4040 * Std ctor.
4141 */
4242 public function __construct( $main, $action ) {
43 - parent :: __construct( $main, $action );
 43+ parent::__construct( $main, $action );
4444 }
4545
4646 /**
@@ -52,21 +52,24 @@
5353 global $wgUser, $wgBlockAllowsUTEdit;
5454 $params = $this->extractRequestParams();
5555
56 - if ( $params['gettoken'] )
57 - {
 56+ if ( $params['gettoken'] ) {
5857 $res['blocktoken'] = $wgUser->editToken();
5958 $this->getResult()->addValue( null, $this->getModuleName(), $res );
6059 return;
6160 }
6261
63 - if ( is_null( $params['user'] ) )
 62+ if ( is_null( $params['user'] ) ) {
6463 $this->dieUsageMsg( array( 'missingparam', 'user' ) );
65 - if ( !$wgUser->isAllowed( 'block' ) )
 64+ }
 65+ if ( !$wgUser->isAllowed( 'block' ) ) {
6666 $this->dieUsageMsg( array( 'cantblock' ) );
67 - if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) )
 67+ }
 68+ if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) {
6869 $this->dieUsageMsg( array( 'canthide' ) );
69 - if ( $params['noemail'] && !IPBlockForm::canBlockEmail( $wgUser ) )
 70+ }
 71+ if ( $params['noemail'] && !IPBlockForm::canBlockEmail( $wgUser ) ) {
7072 $this->dieUsageMsg( array( 'cantblock-email' ) );
 73+ }
7174
7275 $form = new IPBlockForm( '' );
7376 $form->BlockAddress = $params['user'];
@@ -84,26 +87,33 @@
8588
8689 $userID = $expiry = null;
8790 $retval = $form->doBlock( $userID, $expiry );
88 - if ( count( $retval ) )
 91+ if ( count( $retval ) ) {
8992 // We don't care about multiple errors, just report one of them
9093 $this->dieUsageMsg( $retval );
 94+ }
9195
9296 $res['user'] = $params['user'];
9397 $res['userID'] = intval( $userID );
9498 $res['expiry'] = ( $expiry == Block::infinity() ? 'infinite' : wfTimestamp( TS_ISO_8601, $expiry ) );
9599 $res['reason'] = $params['reason'];
96 - if ( $params['anononly'] )
 100+ if ( $params['anononly'] ) {
97101 $res['anononly'] = '';
98 - if ( $params['nocreate'] )
 102+ }
 103+ if ( $params['nocreate'] ) {
99104 $res['nocreate'] = '';
100 - if ( $params['autoblock'] )
 105+ }
 106+ if ( $params['autoblock'] ) {
101107 $res['autoblock'] = '';
102 - if ( $params['noemail'] )
 108+ }
 109+ if ( $params['noemail'] ) {
103110 $res['noemail'] = '';
104 - if ( $params['hidename'] )
 111+ }
 112+ if ( $params['hidename'] ) {
105113 $res['hidename'] = '';
106 - if ( $params['allowusertalk'] )
 114+ }
 115+ if ( $params['allowusertalk'] ) {
107116 $res['allowusertalk'] = '';
 117+ }
108118
109119 $this->getResult()->addValue( null, $this->getModuleName(), $res );
110120 }
@@ -117,7 +127,7 @@
118128 }
119129
120130 public function getAllowedParams() {
121 - return array (
 131+ return array(
122132 'user' => null,
123133 'token' => null,
124134 'gettoken' => false,
@@ -134,7 +144,7 @@
135145 }
136146
137147 public function getParamDescription() {
138 - return array (
 148+ return array(
139149 'user' => 'Username, IP address or IP range you want to block',
140150 'token' => 'A block token previously obtained through the gettoken parameter or prop=info',
141151 'gettoken' => 'If set, a block token will be returned, and no other action will be taken',
@@ -162,7 +172,7 @@
163173 array( 'cantblock' ),
164174 array( 'canthide' ),
165175 array( 'cantblock-email' ),
166 - ) );
 176+ ) );
167177 }
168178
169179 public function getTokenSalt() {
@@ -170,7 +180,7 @@
171181 }
172182
173183 protected function getExamples() {
174 - return array (
 184+ return array(
175185 'api.php?action=block&user=123.5.5.12&expiry=3%20days&reason=First%20strike',
176186 'api.php?action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate&autoblock&noemail'
177187 );

Status & tagging log