r88972 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88971‎ | r88972 | r88973 >
Date:15:57, 27 May 2011
Author:happy-melon
Status:resolved (Comments)
Tags:
Comment:
A couple of tweaks to SecurePoll:
* Implement must-be-registered-before as a simple condition
* Standardise format of list view table, with navigation links both above and below the table
* Parse wikitext in radio-range column labels
These have been sitting as core hacks on one of my production wikis for about two years now... :-)
Modified paths:
  • /trunk/extensions/SecurePoll/SecurePoll.i18n.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/ballots/RadioRangeBallot.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/entities/Election.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/pages/ListPage.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/user/Auth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SecurePoll/SecurePoll.i18n.php
@@ -74,6 +74,7 @@
7575 'securepoll-api-token-mismatch' => 'Security token mismatch, cannot log in.',
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.',
 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.',
7879 'securepoll-blocked' => 'Sorry, you cannot vote in this election if you are currently blocked from editing.',
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.',
Index: trunk/extensions/SecurePoll/includes/user/Auth.php
@@ -213,7 +213,8 @@
214214 'bot' => $user->isAllowed( 'bot' ),
215215 'language' => $user->getOption( 'language' ),
216216 'groups' => $user->getGroups(),
217 - 'lists' => $this->getLists( $user )
 217+ 'lists' => $this->getLists( $user ),
 218+ 'registration' => $user->getRegistration(),
218219 )
219220 );
220221 wfRunHooks( 'SecurePoll_GetUserParams', array( $this, $user, &$params ) );
Index: trunk/extensions/SecurePoll/includes/pages/ListPage.php
@@ -32,7 +32,8 @@
3333
3434 $pager = new SecurePoll_ListPager( $this );
3535 $wgOut->addHTML(
36 - $pager->getLimitForm() . '<br />' .
 36+ $pager->getLimitForm() .
 37+ $pager->getNavigationBar() .
3738 $pager->getBody() .
3839 $pager->getNavigationBar()
3940 );
Index: trunk/extensions/SecurePoll/includes/ballots/RadioRangeBallot.php
@@ -67,7 +67,7 @@
6868 if ( $useMessageLabels ) {
6969 foreach ( $scores as $score ) {
7070 $signedScore = $this->addSign( $question, $score );
71 - $labels[$score] = $question->getMessage( "column$signedScore" );
 71+ $labels[$score] = $question->parseMessage( "column$signedScore" );
7272 }
7373 } else {
7474 global $wgLang;
@@ -113,7 +113,7 @@
114114 "<tr>\n" .
115115 "<th>&#160;</th>\n";
116116 foreach ( $labels as $label ) {
117 - $s .= Xml::element( 'th', array(), $label ) . "\n";
 117+ $s .= Html::rawElement( 'th', array(), $label ) . "\n";
118118 }
119119 $s .= "</tr>\n";
120120 $defaultScore = $question->getProperty( 'default-score' );
Index: trunk/extensions/SecurePoll/includes/entities/Election.php
@@ -17,6 +17,8 @@
1818 * Election
1919 * min-edits
2020 * Minimum number of edits needed to be qualified
 21+ * max-registration
 22+ * Latest acceptable registration date
2123 * not-blocked
2224 * True if voters need to not be blocked
2325 * not-bot
@@ -163,6 +165,17 @@
164166 $status->fatal( 'securepoll-too-few-edits', $minEdits, $edits );
165167 }
166168
 169+ # Registration date
 170+ $maxDate = $this->getProperty( 'max-registration' );
 171+ $date = isset( $props['registration'] ) ? $props['registration'] : 0;
 172+ if ( $maxDate && $date > $maxDate ) {
 173+ global $wgLang;
 174+ $status->fatal(
 175+ 'securepoll-too-new',
 176+ $wgLang->timeanddate( $maxDate ),
 177+ $wgLang->timeanddate( $date )
 178+ );
 179+ }
167180 # Blocked
168181 $notBlocked = $this->getProperty( 'not-blocked' );
169182 $isBlocked = !empty( $props['blocked'] );

Sign-offs

UserFlagDate
Werdnainspected07:08, 28 May 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r95476Improve i18n per CR comment on r88972.siebrand11:15, 25 August 2011

Comments

#Comment by Raymond (talk | contribs)   18:30, 27 May 2011

I suggest to split timeanddate into time and date for better i18n.

#Comment by Siebrand (talk | contribs)   11:16, 25 August 2011

Addressed in r95476.

Status & tagging log