Index: trunk/extensions/SecurePoll/SecurePoll.i18n.php |
— | — | @@ -76,6 +76,7 @@ |
77 | 77 | 'securepoll-too-few-edits' => 'Sorry, you cannot vote. You need to have made at least $1 {{PLURAL:$1|edit|edits}} to vote in this election, you have made $2.', |
78 | 78 | 'securepoll-too-new' => 'Sorry, you cannot vote. Your account needs to have been registered before $1 to vote in this election, you registered on $2.', |
79 | 79 | 'securepoll-blocked' => 'Sorry, you cannot vote in this election if you are currently blocked from editing.', |
| 80 | + 'securepoll-blocked-centrally' => 'Sorry, you cannot vote in this election if you are blocked on $1 or more {{PLURAL:$1|wiki|wikis}}.', |
80 | 81 | 'securepoll-bot' => 'Sorry, accounts with the bot flag are not allowed to vote in this election.', |
81 | 82 | 'securepoll-not-in-group' => 'Only members of the "$1" group can vote in this election.', |
82 | 83 | 'securepoll-not-in-list' => 'Sorry, you are not in the predetermined list of users authorised to vote in this election.', |
Index: trunk/extensions/SecurePoll/includes/entities/Election.php |
— | — | @@ -33,6 +33,10 @@ |
34 | 34 | * True if a voter is not allowed to change their vote |
35 | 35 | * encrypt-type |
36 | 36 | * The encryption module name |
| 37 | + * not-centrally-blocked |
| 38 | + * True if voters need to not be blocked on more than X projects |
| 39 | + * central-block-threshold |
| 40 | + * Number of blocks across projects that disqualify a user from voting. |
37 | 41 | * |
38 | 42 | * See the other module for documentation of the following. |
39 | 43 | * |
— | — | @@ -183,6 +187,14 @@ |
184 | 188 | if ( $notBlocked && $isBlocked ) { |
185 | 189 | $status->fatal( 'securepoll-blocked' ); |
186 | 190 | } |
| 191 | + |
| 192 | + # Centrally blocked on more than X projects |
| 193 | + $notCentrallyBlocked = $this->getProperty( 'not-centrally-blocked' ); |
| 194 | + $centralBlockCount = isset( $props['central-block-count'] ) ? $props['central-block-count'] : 0; |
| 195 | + $centralBlockThreshold = $this->getProperty( 'central-block-threshold', 1 ); |
| 196 | + if ( $centralBlockCount >= $centralBlockThreshold ) { |
| 197 | + $status->fatal( 'securepoll-blocked-centrally', $centralBlockThreshold ); |
| 198 | + } |
187 | 199 | |
188 | 200 | # Bot |
189 | 201 | $notBot = $this->getProperty( 'not-bot' ); |
— | — | @@ -212,6 +224,7 @@ |
213 | 225 | $status = Status::newFatal( 'securepoll-custom-unqualified', $errorMsg ); |
214 | 226 | } |
215 | 227 | } |
| 228 | + |
216 | 229 | return $status; |
217 | 230 | } |
218 | 231 | |
Index: trunk/extensions/SecurePoll/includes/user/Auth.php |
— | — | @@ -209,6 +209,7 @@ |
210 | 210 | 'properties' => array( |
211 | 211 | 'wiki' => wfWikiID(), |
212 | 212 | 'blocked' => $user->isBlocked(), |
| 213 | + 'central-block-count' => $this->getCentralBlockCount( $user ), |
213 | 214 | 'edit-count' => $user->getEditCount(), |
214 | 215 | 'bot' => $user->isAllowed( 'bot' ), |
215 | 216 | 'language' => $user->getOption( 'language' ), |
— | — | @@ -217,6 +218,7 @@ |
218 | 219 | 'registration' => $user->getRegistration(), |
219 | 220 | ) |
220 | 221 | ); |
| 222 | + |
221 | 223 | wfRunHooks( 'SecurePoll_GetUserParams', array( $this, $user, &$params ) ); |
222 | 224 | return $params; |
223 | 225 | } |
— | — | @@ -240,6 +242,30 @@ |
241 | 243 | } |
242 | 244 | return $lists; |
243 | 245 | } |
| 246 | + |
| 247 | + /** |
| 248 | + * Checks how many central wikis the user is blocked on |
| 249 | + * @param $user User |
| 250 | + * @return Integer the number of wikis the user is blocked on. |
| 251 | + */ |
| 252 | + function getCentralBlockCount( $user ) { |
| 253 | + if ( ! class_exists( 'CentralAuthUser' ) ) { |
| 254 | + return 0; |
| 255 | + } |
| 256 | + |
| 257 | + $centralUser = new CentralAuthUser( $user ); |
| 258 | + |
| 259 | + $attached = $centralUser->queryAttached(); |
| 260 | + $blockCount = 0; |
| 261 | + |
| 262 | + foreach( $attached as $wiki => $data ) { |
| 263 | + if ( $data['blocked'] ) { |
| 264 | + $blockCount++; |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + return $blockCount; |
| 269 | + } |
244 | 270 | } |
245 | 271 | |
246 | 272 | /** |