http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88972

Revision: 88972
Author:   happy-melon
Date:     2011-05-27 15:57:07 +0000 (Fri, 27 May 2011)
Log Message:
-----------
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
    trunk/extensions/SecurePoll/includes/ballots/RadioRangeBallot.php
    trunk/extensions/SecurePoll/includes/entities/Election.php
    trunk/extensions/SecurePoll/includes/pages/ListPage.php
    trunk/extensions/SecurePoll/includes/user/Auth.php

Modified: trunk/extensions/SecurePoll/SecurePoll.i18n.php
===================================================================
--- trunk/extensions/SecurePoll/SecurePoll.i18n.php     2011-05-27 15:22:36 UTC 
(rev 88971)
+++ trunk/extensions/SecurePoll/SecurePoll.i18n.php     2011-05-27 15:57:07 UTC 
(rev 88972)
@@ -74,6 +74,7 @@
        'securepoll-api-token-mismatch' => 'Security token mismatch, cannot log 
in.',
        'securepoll-not-logged-in' => 'You must log in to vote in this 
election',
        '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.',
+       '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.',
        'securepoll-blocked' => 'Sorry, you cannot vote in this election if you 
are currently blocked from editing.',
        'securepoll-bot' => 'Sorry, accounts with the bot flag are not allowed 
to vote in this election.',
        'securepoll-not-in-group' => 'Only members of the "$1" group can vote 
in this election.',

Modified: trunk/extensions/SecurePoll/includes/ballots/RadioRangeBallot.php
===================================================================
--- trunk/extensions/SecurePoll/includes/ballots/RadioRangeBallot.php   
2011-05-27 15:22:36 UTC (rev 88971)
+++ trunk/extensions/SecurePoll/includes/ballots/RadioRangeBallot.php   
2011-05-27 15:57:07 UTC (rev 88972)
@@ -67,7 +67,7 @@
                if ( $useMessageLabels ) {
                        foreach ( $scores as $score ) {
                                $signedScore = $this->addSign( $question, 
$score );
-                               $labels[$score] = $question->getMessage( 
"column$signedScore" );
+                               $labels[$score] = $question->parseMessage( 
"column$signedScore" );
                        }
                } else {
                        global $wgLang;
@@ -113,7 +113,7 @@
                        "<tr>\n" .
                        "<th>&#160;</th>\n";
                foreach ( $labels as $label ) {
-                       $s .= Xml::element( 'th', array(), $label ) . "\n";
+                       $s .= Html::rawElement( 'th', array(), $label ) . "\n";
                }
                $s .= "</tr>\n";
                $defaultScore = $question->getProperty( 'default-score' );

Modified: trunk/extensions/SecurePoll/includes/entities/Election.php
===================================================================
--- trunk/extensions/SecurePoll/includes/entities/Election.php  2011-05-27 
15:22:36 UTC (rev 88971)
+++ trunk/extensions/SecurePoll/includes/entities/Election.php  2011-05-27 
15:57:07 UTC (rev 88972)
@@ -17,6 +17,8 @@
  *      Election
  *          min-edits
  *              Minimum number of edits needed to be qualified
+ *          max-registration
+ *              Latest acceptable registration date
  *          not-blocked
  *              True if voters need to not be blocked
  *          not-bot
@@ -163,6 +165,17 @@
                        $status->fatal( 'securepoll-too-few-edits', $minEdits, 
$edits );
                }
 
+               # Registration date
+               $maxDate = $this->getProperty( 'max-registration' );
+               $date = isset( $props['registration'] ) ? 
$props['registration'] : 0;
+               if ( $maxDate && $date > $maxDate ) {
+                       global $wgLang;
+                       $status->fatal( 
+                               'securepoll-too-new', 
+                               $wgLang->timeanddate( $maxDate ), 
+                               $wgLang->timeanddate( $date )
+                       );
+               }
                # Blocked
                $notBlocked = $this->getProperty( 'not-blocked' );
                $isBlocked = !empty( $props['blocked'] );

Modified: trunk/extensions/SecurePoll/includes/pages/ListPage.php
===================================================================
--- trunk/extensions/SecurePoll/includes/pages/ListPage.php     2011-05-27 
15:22:36 UTC (rev 88971)
+++ trunk/extensions/SecurePoll/includes/pages/ListPage.php     2011-05-27 
15:57:07 UTC (rev 88972)
@@ -32,7 +32,8 @@
 
                $pager = new SecurePoll_ListPager( $this );
                $wgOut->addHTML( 
-                       $pager->getLimitForm() . '<br />' .
+                       $pager->getLimitForm() . 
+                       $pager->getNavigationBar() . 
                        $pager->getBody() . 
                        $pager->getNavigationBar()
                );

Modified: trunk/extensions/SecurePoll/includes/user/Auth.php
===================================================================
--- trunk/extensions/SecurePoll/includes/user/Auth.php  2011-05-27 15:22:36 UTC 
(rev 88971)
+++ trunk/extensions/SecurePoll/includes/user/Auth.php  2011-05-27 15:57:07 UTC 
(rev 88972)
@@ -213,7 +213,8 @@
                                'bot' => $user->isAllowed( 'bot' ),
                                'language' => $user->getOption( 'language' ),
                                'groups' => $user->getGroups(),
-                               'lists' => $this->getLists( $user )
+                               'lists' => $this->getLists( $user ),
+                               'registration' => $user->getRegistration(),
                        )
                );
                wfRunHooks( 'SecurePoll_GetUserParams', array( $this, $user, 
&$params ) );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to