r89023 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89022‎ | r89023 | r89024 >
Date:07:49, 28 May 2011
Author:werdna
Status:ok
Tags:
Comment:
Merge r89020
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/SecurePoll (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/SecurePoll/SecurePoll.i18n.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/SecurePoll/includes/entities/Election.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/SecurePoll/includes/user/Auth.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/SecurePoll/SecurePoll.i18n.php
@@ -75,6 +75,7 @@
7676 'securepoll-not-logged-in' => 'You must log in to vote in this election',
7777 '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.',
7878 'securepoll-blocked' => 'Sorry, you cannot vote in this election if you are currently blocked from editing.',
 79+ 'securepoll-blocked-centrally' => 'Sorry, you cannot vote in this election if you are blocked on $1 or more {{PLURAL:$1|wiki|wikis}}.',
7980 'securepoll-bot' => 'Sorry, accounts with the bot flag are not allowed to vote in this election.',
8081 'securepoll-not-in-group' => 'Only members of the "$1" group can vote in this election.',
8182 'securepoll-not-in-list' => 'Sorry, you are not in the predetermined list of users authorised to vote in this election.',
Index: branches/wmf/1.17wmf1/extensions/SecurePoll/includes/entities/Election.php
@@ -31,6 +31,10 @@
3232 * True if a voter is not allowed to change their vote
3333 * encrypt-type
3434 * The encryption module name
 35+ * not-centrally-blocked
 36+ * True if voters need to not be blocked on more than X projects
 37+ * central-block-threshold
 38+ * Number of blocks across projects that disqualify a user from voting.
3539 *
3640 * See the other module for documentation of the following.
3741 *
@@ -169,6 +173,14 @@
170174 if ( $notBlocked && $isBlocked ) {
171175 $status->fatal( 'securepoll-blocked' );
172176 }
 177+
 178+ # Centrally blocked on more than X projects
 179+ $notCentrallyBlocked = $this->getProperty( 'not-centrally-blocked' );
 180+ $centralBlockCount = isset( $props['central-block-count'] ) ? $props['central-block-count'] : 0;
 181+ $centralBlockThreshold = $this->getProperty( 'central-block-threshold', 1 );
 182+ if ( $centralBlockCount >= $centralBlockThreshold ) {
 183+ $status->fatal( 'securepoll-blocked-centrally', $centralBlockThreshold );
 184+ }
173185
174186 # Bot
175187 $notBot = $this->getProperty( 'not-bot' );
@@ -198,6 +210,7 @@
199211 $status = Status::newFatal( 'securepoll-custom-unqualified', $errorMsg );
200212 }
201213 }
 214+
202215 return $status;
203216 }
204217
Index: branches/wmf/1.17wmf1/extensions/SecurePoll/includes/user/Auth.php
@@ -209,6 +209,7 @@
210210 'properties' => array(
211211 'wiki' => wfWikiID(),
212212 'blocked' => $user->isBlocked(),
 213+ 'central-block-count' => $this->getCentralBlockCount( $user ),
213214 'edit-count' => $user->getEditCount(),
214215 'bot' => $user->isAllowed( 'bot' ),
215216 'language' => $user->getOption( 'language' ),
@@ -216,6 +217,7 @@
217218 'lists' => $this->getLists( $user )
218219 )
219220 );
 221+
220222 wfRunHooks( 'SecurePoll_GetUserParams', array( $this, $user, &$params ) );
221223 return $params;
222224 }
@@ -239,6 +241,30 @@
240242 }
241243 return $lists;
242244 }
 245+
 246+ /**
 247+ * Checks how many central wikis the user is blocked on
 248+ * @param $user User
 249+ * @return Integer the number of wikis the user is blocked on.
 250+ */
 251+ function getCentralBlockCount( $user ) {
 252+ if ( ! class_exists( 'CentralAuthUser' ) ) {
 253+ return 0;
 254+ }
 255+
 256+ $centralUser = new CentralAuthUser( $user );
 257+
 258+ $attached = $centralUser->queryAttached();
 259+ $blockCount = 0;
 260+
 261+ foreach( $attached as $wiki => $data ) {
 262+ if ( $data['blocked'] ) {
 263+ $blockCount++;
 264+ }
 265+ }
 266+
 267+ return $blockCount;
 268+ }
243269 }
244270
245271 /**
Property changes on: branches/wmf/1.17wmf1/extensions/SecurePoll
___________________________________________________________________
Added: svn:mergeinfo
246272 Merged /branches/sqlite/extensions/SecurePoll:r58211-58321
247273 Merged /trunk/phase3/extensions/SecurePoll:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,80406,81833,83212,83590
248274 Merged /branches/new-installer/phase3/extensions/SecurePoll:r43664-66004
249275 Merged /branches/wmf-deployment/extensions/SecurePoll:r60970
250276 Merged /branches/REL1_15/phase3/extensions/SecurePoll:r51646
251277 Merged /branches/wmf/1.16wmf4/extensions/SecurePoll:r67177,69199,76243,77266
252278 Merged /trunk/extensions/SecurePoll:r89020

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89020Add support for detecting number of wikis a user is blocked on, and preventin...werdna07:23, 28 May 2011

Status & tagging log