Index: trunk/phase3/includes/api/ApiBlock.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -/* |
| 4 | +/** |
5 | 5 | * Created on Sep 4, 2007 |
6 | 6 | * API for MediaWiki 1.8+ |
7 | 7 | * |
8 | | - * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl |
| 8 | + * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl |
9 | 9 | * |
10 | 10 | * This program is free software; you can redistribute it and/or modify |
11 | 11 | * it under the terms of the GNU General Public License as published by |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | |
26 | 26 | if ( !defined( 'MEDIAWIKI' ) ) { |
27 | 27 | // Eclipse helper - will be ignored in production |
28 | | - require_once ( "ApiBase.php" ); |
| 28 | + require_once( "ApiBase.php" ); |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | * Std ctor. |
41 | 41 | */ |
42 | 42 | public function __construct( $main, $action ) { |
43 | | - parent :: __construct( $main, $action ); |
| 43 | + parent::__construct( $main, $action ); |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
— | — | @@ -52,21 +52,24 @@ |
53 | 53 | global $wgUser, $wgBlockAllowsUTEdit; |
54 | 54 | $params = $this->extractRequestParams(); |
55 | 55 | |
56 | | - if ( $params['gettoken'] ) |
57 | | - { |
| 56 | + if ( $params['gettoken'] ) { |
58 | 57 | $res['blocktoken'] = $wgUser->editToken(); |
59 | 58 | $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
60 | 59 | return; |
61 | 60 | } |
62 | 61 | |
63 | | - if ( is_null( $params['user'] ) ) |
| 62 | + if ( is_null( $params['user'] ) ) { |
64 | 63 | $this->dieUsageMsg( array( 'missingparam', 'user' ) ); |
65 | | - if ( !$wgUser->isAllowed( 'block' ) ) |
| 64 | + } |
| 65 | + if ( !$wgUser->isAllowed( 'block' ) ) { |
66 | 66 | $this->dieUsageMsg( array( 'cantblock' ) ); |
67 | | - if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) |
| 67 | + } |
| 68 | + if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) { |
68 | 69 | $this->dieUsageMsg( array( 'canthide' ) ); |
69 | | - if ( $params['noemail'] && !IPBlockForm::canBlockEmail( $wgUser ) ) |
| 70 | + } |
| 71 | + if ( $params['noemail'] && !IPBlockForm::canBlockEmail( $wgUser ) ) { |
70 | 72 | $this->dieUsageMsg( array( 'cantblock-email' ) ); |
| 73 | + } |
71 | 74 | |
72 | 75 | $form = new IPBlockForm( '' ); |
73 | 76 | $form->BlockAddress = $params['user']; |
— | — | @@ -84,26 +87,33 @@ |
85 | 88 | |
86 | 89 | $userID = $expiry = null; |
87 | 90 | $retval = $form->doBlock( $userID, $expiry ); |
88 | | - if ( count( $retval ) ) |
| 91 | + if ( count( $retval ) ) { |
89 | 92 | // We don't care about multiple errors, just report one of them |
90 | 93 | $this->dieUsageMsg( $retval ); |
| 94 | + } |
91 | 95 | |
92 | 96 | $res['user'] = $params['user']; |
93 | 97 | $res['userID'] = intval( $userID ); |
94 | 98 | $res['expiry'] = ( $expiry == Block::infinity() ? 'infinite' : wfTimestamp( TS_ISO_8601, $expiry ) ); |
95 | 99 | $res['reason'] = $params['reason']; |
96 | | - if ( $params['anononly'] ) |
| 100 | + if ( $params['anononly'] ) { |
97 | 101 | $res['anononly'] = ''; |
98 | | - if ( $params['nocreate'] ) |
| 102 | + } |
| 103 | + if ( $params['nocreate'] ) { |
99 | 104 | $res['nocreate'] = ''; |
100 | | - if ( $params['autoblock'] ) |
| 105 | + } |
| 106 | + if ( $params['autoblock'] ) { |
101 | 107 | $res['autoblock'] = ''; |
102 | | - if ( $params['noemail'] ) |
| 108 | + } |
| 109 | + if ( $params['noemail'] ) { |
103 | 110 | $res['noemail'] = ''; |
104 | | - if ( $params['hidename'] ) |
| 111 | + } |
| 112 | + if ( $params['hidename'] ) { |
105 | 113 | $res['hidename'] = ''; |
106 | | - if ( $params['allowusertalk'] ) |
| 114 | + } |
| 115 | + if ( $params['allowusertalk'] ) { |
107 | 116 | $res['allowusertalk'] = ''; |
| 117 | + } |
108 | 118 | |
109 | 119 | $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
110 | 120 | } |
— | — | @@ -117,7 +127,7 @@ |
118 | 128 | } |
119 | 129 | |
120 | 130 | public function getAllowedParams() { |
121 | | - return array ( |
| 131 | + return array( |
122 | 132 | 'user' => null, |
123 | 133 | 'token' => null, |
124 | 134 | 'gettoken' => false, |
— | — | @@ -134,7 +144,7 @@ |
135 | 145 | } |
136 | 146 | |
137 | 147 | public function getParamDescription() { |
138 | | - return array ( |
| 148 | + return array( |
139 | 149 | 'user' => 'Username, IP address or IP range you want to block', |
140 | 150 | 'token' => 'A block token previously obtained through the gettoken parameter or prop=info', |
141 | 151 | 'gettoken' => 'If set, a block token will be returned, and no other action will be taken', |
— | — | @@ -162,7 +172,7 @@ |
163 | 173 | array( 'cantblock' ), |
164 | 174 | array( 'canthide' ), |
165 | 175 | array( 'cantblock-email' ), |
166 | | - ) ); |
| 176 | + ) ); |
167 | 177 | } |
168 | 178 | |
169 | 179 | public function getTokenSalt() { |
— | — | @@ -170,7 +180,7 @@ |
171 | 181 | } |
172 | 182 | |
173 | 183 | protected function getExamples() { |
174 | | - return array ( |
| 184 | + return array( |
175 | 185 | 'api.php?action=block&user=123.5.5.12&expiry=3%20days&reason=First%20strike', |
176 | 186 | 'api.php?action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate&autoblock&noemail' |
177 | 187 | ); |