Index: trunk/extensions/SecurePoll/SecurePoll.i18n.php |
— | — | @@ -100,6 +100,8 @@ |
101 | 101 | 'securepoll-strike-error' => 'Error performing strike/unstrike: $1', |
102 | 102 | 'securepoll-strike-token-mismatch' => 'Session data lost', |
103 | 103 | 'securepoll-details-link' => 'Details', |
| 104 | + 'securepoll-votername-local' => '[[User:$1|$1]]', |
| 105 | + 'securepoll-votername-remote' => '$1', |
104 | 106 | |
105 | 107 | # Details page |
106 | 108 | # Mostly for admins |
— | — | @@ -133,6 +135,7 @@ |
134 | 136 | 'securepoll-submit-select-lang' => 'Translate', |
135 | 137 | |
136 | 138 | # Entry page |
| 139 | + 'securepoll-entry-text' => 'Below is the list of polls.', |
137 | 140 | 'securepoll-header-title' => 'Name', |
138 | 141 | 'securepoll-header-start-date' => 'Start date', |
139 | 142 | 'securepoll-header-end-date' => 'End date', |
Index: trunk/extensions/SecurePoll/includes/pages/VotePage.php |
— | — | @@ -67,6 +67,10 @@ |
68 | 68 | $this->showJumpForm(); |
69 | 69 | return; |
70 | 70 | } |
| 71 | + |
| 72 | + // This is when it starts getting all serious; disable JS |
| 73 | + // that might be used to sniff cookies or log voting data. |
| 74 | + $wgOut->disallowUserJs(); |
71 | 75 | |
72 | 76 | // Show welcome |
73 | 77 | if ( $this->voter->isRemote() ) { |
Index: trunk/extensions/SecurePoll/includes/pages/EntryPage.php |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | function execute( $params ) { |
13 | 13 | global $wgOut; |
14 | 14 | $pager = new SecurePoll_ElectionPager( $this ); |
| 15 | + $wgOut->addWikiMsg( 'securepoll-entry-text' ); |
15 | 16 | $wgOut->addHTML( |
16 | 17 | $pager->getBody() . |
17 | 18 | $pager->getNavigationBar() |
— | — | @@ -29,13 +30,6 @@ |
30 | 31 | * Pager for an election list. See TablePager documentation. |
31 | 32 | */ |
32 | 33 | class SecurePoll_ElectionPager extends TablePager { |
33 | | - var $subpages = array( |
34 | | - 'vote', |
35 | | - 'translate', |
36 | | - 'list', |
37 | | - 'dump', |
38 | | - 'tally' |
39 | | - ); |
40 | 34 | var $fields = array( |
41 | 35 | 'el_title', |
42 | 36 | 'el_start_date', |
— | — | @@ -63,6 +57,18 @@ |
64 | 58 | 'el_title', 'el_start_date', 'el_end_date' |
65 | 59 | ) ); |
66 | 60 | } |
| 61 | + |
| 62 | + /** |
| 63 | + * Add classes based on whether the poll is open or closed |
| 64 | + * @param $row database object |
| 65 | + * @return String |
| 66 | + * @see TablePager::getRowClass() |
| 67 | + */ |
| 68 | + function getRowClass( $row ){ |
| 69 | + return $row->el_end_date > wfTimestampNow( TS_DB ) |
| 70 | + ? 'securepoll-election-open' |
| 71 | + : 'securepoll-election-closed'; |
| 72 | + } |
67 | 73 | |
68 | 74 | function formatValue( $name, $value ) { |
69 | 75 | global $wgLang; |
— | — | @@ -76,20 +82,47 @@ |
77 | 83 | return htmlspecialchars( $value ); |
78 | 84 | } |
79 | 85 | } |
| 86 | + |
| 87 | + function formatRow( $row ){ |
| 88 | + global $wgUser; |
| 89 | + $id = $row->el_entity; |
| 90 | + $this->election = $this->entryPage->context->getElection( $id ); |
| 91 | + if( !$this->election ) { |
| 92 | + $this->isAdmin = false; |
| 93 | + } else { |
| 94 | + $this->isAdmin = $this->election->isAdmin( $wgUser ); |
| 95 | + } |
| 96 | + return parent::formatRow( $row ); |
| 97 | + } |
80 | 98 | |
81 | 99 | function getLinks() { |
82 | 100 | global $wgUser; |
83 | 101 | $id = $this->mCurrentRow->el_entity; |
| 102 | + |
| 103 | + $links = array( |
| 104 | + # visible to non-admins |
| 105 | + # visible after election is closed |
| 106 | + 'vote' => array( true, false ), |
| 107 | + 'translate' => array( false, false ), |
| 108 | + 'list' => array( true, true ), |
| 109 | + 'dump' => array( false, true ), |
| 110 | + 'tally' => array( false, true ), |
| 111 | + ); |
| 112 | + |
84 | 113 | $s = ''; |
85 | 114 | $sep = wfMsg( 'pipe-separator' ); |
86 | 115 | $skin = $wgUser->getSkin(); |
87 | | - foreach ( $this->subpages as $subpage ) { |
88 | | - $title = $this->entryPage->parent->getTitle( "$subpage/$id" ); |
89 | | - $linkText = wfMsg( "securepoll-subpage-$subpage" ); |
90 | | - if ( $s !== '' ) { |
91 | | - $s .= $sep; |
| 116 | + foreach ( $links as $subpage => $criteria ) { |
| 117 | + if( ( $this->isAdmin || $criteria[0] ) |
| 118 | + && ( !$this->election->isFinished() || $criteria[1] ) |
| 119 | + ){ |
| 120 | + $title = $this->entryPage->parent->getTitle( "$subpage/$id" ); |
| 121 | + $linkText = wfMsgExt( "securepoll-subpage-$subpage", 'parseinline' ); |
| 122 | + if ( $s !== '' ) { |
| 123 | + $s .= $sep; |
| 124 | + } |
| 125 | + $s .= $skin->makeKnownLinkObj( $title, $linkText ); |
92 | 126 | } |
93 | | - $s .= $skin->makeKnownLinkObj( $title, $linkText ); |
94 | 127 | } |
95 | 128 | return $s; |
96 | 129 | } |
Index: trunk/extensions/SecurePoll/includes/pages/ListPage.php |
— | — | @@ -175,7 +175,6 @@ |
176 | 176 | var $listPage, $isAdmin, $election; |
177 | 177 | |
178 | 178 | static $publicFields = array( |
179 | | - 'details', |
180 | 179 | 'vote_timestamp', |
181 | 180 | 'vote_voter_name', |
182 | 181 | 'vote_voter_domain', |
— | — | @@ -220,10 +219,14 @@ |
221 | 220 | } |
222 | 221 | |
223 | 222 | function formatValue( $name, $value ) { |
224 | | - global $wgLang; |
225 | | - $critical = Xml::element( 'img', |
226 | | - array( 'src' => $GLOBALS['wgScriptPath'] . '/extensions/SecurePoll/resources/critical-32.png' ) |
| 223 | + global $wgLang, $wgScriptPath; |
| 224 | + $critical = Xml::element( 'img', array( |
| 225 | + 'src' => "$wgScriptPath/extensions/SecurePoll/resources/critical-32.png" ) |
227 | 226 | ); |
| 227 | + $voter = SecurePoll_Voter::newFromId( |
| 228 | + $this->listPage->context, |
| 229 | + $this->mCurrentRow->vote_voter |
| 230 | + ); |
228 | 231 | |
229 | 232 | switch ( $name ) { |
230 | 233 | case 'vote_timestamp': |
— | — | @@ -264,6 +267,15 @@ |
265 | 268 | 'value' => $label, |
266 | 269 | 'onclick' => "securepoll_strike_popup(event, $action, $voteId)" |
267 | 270 | ) ); |
| 271 | + case 'vote_voter_name': |
| 272 | + $msg = $voter->isRemote() |
| 273 | + ? 'securepoll-votername-remote' |
| 274 | + : 'securepoll-votername-local'; |
| 275 | + return wfMsgExt( |
| 276 | + $msg, |
| 277 | + 'parseinline', |
| 278 | + array( $value ) |
| 279 | + ); |
268 | 280 | default: |
269 | 281 | return htmlspecialchars( $value ); |
270 | 282 | } |
Index: trunk/extensions/SecurePoll/includes/main/Base.php |
— | — | @@ -1,5 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * The page that's initially called by MediaWiki when navigating to |
| 6 | + * Special:SecurePoll. The actual pages are not actually subclasses of |
| 7 | + * this or of SpecialPage, they're subclassed from SecurePoll_Page. |
| 8 | + */ |
4 | 9 | class SecurePoll_BasePage extends UnlistedSpecialPage { |
5 | 10 | static $pages = array( |
6 | 11 | 'details' => 'SecurePoll_DetailsPage', |
— | — | @@ -31,8 +36,6 @@ |
32 | 37 | public function execute( $paramString ) { |
33 | 38 | global $wgOut, $wgUser, $wgRequest, $wgScriptPath; |
34 | 39 | |
35 | | - wfLoadExtensionMessages( 'SecurePoll' ); |
36 | | - |
37 | 40 | $this->setHeaders(); |
38 | 41 | $wgOut->addLink( array( |
39 | 42 | 'rel' => 'stylesheet', |
Index: trunk/extensions/SecurePoll/resources/SecurePoll.css |
— | — | @@ -94,3 +94,6 @@ |
95 | 95 | .securepoll-error-jump { |
96 | 96 | margin-right: 0.5em; |
97 | 97 | } |
| 98 | +.securepoll-election-closed { |
| 99 | + color: #aaa; |
| 100 | +} |