Index: trunk/extensions/BoardVote/GoToBoardVote_body.php |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# Add messages |
| 5 | +global $wgMessageCache, $wgBoardVoteMessages; |
| 6 | +foreach( $wgBoardVoteMessages as $lang => $messages ) { |
| 7 | + $wgMessageCache->addMessages( $messages, $lang ); |
| 8 | +} |
| 9 | + |
| 10 | +class GoToBoardVotePage extends SpecialPage { |
| 11 | + function __construct() { |
| 12 | + SpecialPage::SpecialPage( "Go_to_board_vote" ); |
| 13 | + } |
| 14 | + |
| 15 | + function execute( $par ) { |
| 16 | + global $wgOut, $wgDBname, $site, $lang, $wgLang, $wgUser; |
| 17 | + global $wgBoardVoteEditCount, $wgBoardVoteCountDate, $wgBoardVoteFirstEdit; |
| 18 | + |
| 19 | + if ( $wgUser->isLoggedIn() ) { |
| 20 | + $url = 'https://secure.wikimedia.org/wikipedia/test/w/index.php?' . wfArrayToCGI( array( |
| 21 | + 'title' => 'Special:Boardvote' . ( $par ? "/$par" : '' ), |
| 22 | + 'sid' => session_id(), |
| 23 | + 'db' => $wgDBname, |
| 24 | + 'site' => $site, |
| 25 | + 'lang' => $lang, |
| 26 | + 'uselang' => $wgLang->getCode() |
| 27 | + ) ); |
| 28 | + $wgOut->redirect( $url ); |
| 29 | + } else { |
| 30 | + $this->setHeaders(); |
| 31 | + $wgOut->addWikiText( wfMsg( "boardvote_notloggedin", $wgBoardVoteEditCount, |
| 32 | + $wgLang->timeanddate( $wgBoardVoteCountDate ), |
| 33 | + $wgLang->timeanddate( $wgBoardVoteFirstEdit ) |
| 34 | + ) ); |
| 35 | + } |
| 36 | + |
| 37 | + } |
| 38 | +} |
| 39 | + |
Property changes on: trunk/extensions/BoardVote/GoToBoardVote_body.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 40 | + native |
Index: trunk/extensions/BoardVote/cacert-both.crt |
— | — | @@ -0,0 +1,77 @@ |
| 2 | +-----BEGIN CERTIFICATE-----
|
| 3 |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jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC
|
| 64 | +AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg
|
| 65 | +b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB
|
| 66 | +ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc
|
| 67 | +nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg
|
| 68 | +18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c
|
| 69 | +gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl
|
| 70 | +Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY
|
| 71 | +sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T
|
| 72 | +SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF
|
| 73 | +CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum
|
| 74 | +GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk
|
| 75 | +zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW
|
| 76 | +omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD
|
| 77 | +-----END CERTIFICATE-----
|
| 78 | +
|
Index: trunk/extensions/BoardVote/boardvote.sql |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | -- Board of Trustees vote |
3 | 3 | |
4 | | -CREATE TABLE log ( |
| 4 | +CREATE TABLE vote_log ( |
5 | 5 | log_id int(5) not null auto_increment, |
6 | 6 | log_user int(5) not null default 0, |
7 | 7 | log_user_text varchar(255) binary not null default '', |
— | — | @@ -20,4 +20,8 @@ |
21 | 21 | index log_user_key (log_user_key) |
22 | 22 | ); |
23 | 23 | |
| 24 | +CREATE TABLE voters ( |
| 25 | + user_key VARBINARY(255) not null, |
| 26 | + unique index (user_key) |
| 27 | +); |
24 | 28 | |
Index: trunk/extensions/BoardVote/BoardVote_body.php |
— | — | @@ -19,12 +19,85 @@ |
20 | 20 | SpecialPage::SpecialPage( "Boardvote" ); |
21 | 21 | } |
22 | 22 | |
23 | | - function execute( $par ) { |
24 | | - global $wgUser, $wgDBname, $wgInputEncoding, $wgRequest, |
25 | | - $wgBoardVoteEditCount, $wgBoardVoteEndDate, $wgBoardVoteStartDate, |
26 | | - $wgBoardVoteFirstEdit; |
| 23 | + function getUserFromRemote( $sid, $db, $site, $lang ) { |
| 24 | + $regex = '/^[\w.-]+$/'; |
| 25 | + if ( !preg_match( $regex, $sid ) || |
| 26 | + !preg_match( $regex, $db ) || |
| 27 | + !preg_match( $regex, $site ) || |
| 28 | + !preg_match( $regex, $lang ) |
| 29 | + ) { |
| 30 | + wfDebug( __METHOD__.": Invalid parameter\n" ); |
| 31 | + return array( false, false, false ); |
| 32 | + } |
27 | 33 | |
28 | | - $this->mUserKey = iconv( $wgInputEncoding, "UTF-8", $wgUser->getName() ) . "@$wgDBname"; |
| 34 | + $url = "https://secure.wikimedia.org/$site/$lang/w/query.php?what=userinfo&format=php"; |
| 35 | + #$url = "http://$lang.$site.org/w/query.php?what=userinfo&format=php"; |
| 36 | + #$url = "http://eva/w2/extensions/BotQuery/query.php?what=userinfo&format=php"; |
| 37 | + wfDebug( "Fetching URL $url\n" ); |
| 38 | + $c = curl_init( $url ); |
| 39 | + curl_setopt( $c, CURLOPT_CAINFO, dirname( __FILE__ ) . '/cacert-both.crt' ); |
| 40 | + curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
| 41 | + curl_setopt( $c, CURLOPT_COOKIE, "{$db}_session=" . urlencode( $sid ) ); |
| 42 | + curl_setopt( $c, CURLOPT_FOLLOWLOCATION, true ); |
| 43 | + curl_setopt( $c, CURLOPT_FAILONERROR, true ); |
| 44 | + $value = curl_exec( $c ); |
| 45 | + if ( !$value ) { |
| 46 | + wfDebug( __METHOD__.": No response from server\n" ); |
| 47 | + return array( false, false, false ); |
| 48 | + } |
| 49 | + |
| 50 | + $decoded = unserialize( $value ); |
| 51 | + if ( isset( $decoded['meta']['user']['anonymous'] ) ) { |
| 52 | + wfDebug( __METHOD__.": User is not logged in\n" ); |
| 53 | + return array( false, false, false ); |
| 54 | + } |
| 55 | + if ( !isset( $decoded['meta']['user']['name'] ) ) { |
| 56 | + wfDebug( __METHOD__.": No username in response\n" ); |
| 57 | + return array( false, false, false ); |
| 58 | + } |
| 59 | + wfDebug( __METHOD__." got response for user {$decoded['meta']['user']['name']}@$db\n" ); |
| 60 | + return array( |
| 61 | + $decoded['meta']['user']['name'] . '@' . $db, |
| 62 | + $db, |
| 63 | + isset( $decoded['meta']['user']['blocked'] ), |
| 64 | + ); |
| 65 | + } |
| 66 | + |
| 67 | + function init( $par ) { |
| 68 | + global $wgRequest; |
| 69 | + if( session_id() == '' ) { |
| 70 | + wfSetupSession(); |
| 71 | + } |
| 72 | + |
| 73 | + $this->mRemoteSession = $wgRequest->getVal( 'sid' ); |
| 74 | + $this->mRemoteDB = $wgRequest->getVal( 'db' ); |
| 75 | + $this->mRemoteSite = $wgRequest->getVal( 'site' ); |
| 76 | + $this->mRemoteLanguage = $wgRequest->getVal( 'lang' ); |
| 77 | + |
| 78 | + if ( $this->mRemoteSession ) { |
| 79 | + $info = $this->getUserFromRemote( |
| 80 | + $this->mRemoteSession, |
| 81 | + $this->mRemoteDB, |
| 82 | + $this->mRemoteSite, |
| 83 | + $this->mRemoteLanguage |
| 84 | + ); |
| 85 | + list( $this->mUserKey, $this->mDBname, $this->mBlocked ) = $info; |
| 86 | + list( $_SESSION['bvUserKey'], $_SESSION['bvDBname'], $_SESSION['bvBlocked'] ) = $info; |
| 87 | + if ( !is_null( $wgRequest->getVal( 'uselang' ) ) ) { |
| 88 | + $_SESSION['bvLang'] = $wgRequest->getVal( 'uselang' ); |
| 89 | + } else { |
| 90 | + $_SESSION['bvLang'] = $this->mRemoteLanguage; |
| 91 | + } |
| 92 | + } elseif ( isset( $_SESSION['bvUserKey'] ) ) { |
| 93 | + $this->mUserKey = $_SESSION['bvUserKey']; |
| 94 | + $this->mDBname = $_SESSION['bvDBname']; |
| 95 | + $this->mBlocked = $_SESSION['bvBlocked']; |
| 96 | + } else { |
| 97 | + $this->mUserKey = false; |
| 98 | + $this->mDBname = false; |
| 99 | + $this->mBlocked = false; |
| 100 | + } |
| 101 | + |
29 | 102 | $this->mPosted = $wgRequest->wasPosted(); |
30 | 103 | if ( method_exists( $wgRequest, 'getArray' ) ) { |
31 | 104 | $this->mVotedFor = $wgRequest->getArray( "votedfor", array() ); |
— | — | @@ -33,25 +106,39 @@ |
34 | 107 | } |
35 | 108 | $this->mId = $wgRequest->getInt( "id", 0 ); |
36 | 109 | |
37 | | - $this->mHasVoted = $this->hasVoted( $wgUser ); |
| 110 | + $this->mHasVoted = $this->hasVoted(); |
38 | 111 | |
39 | 112 | if ( $par ) { |
40 | 113 | $this->mAction = $par; |
41 | 114 | } else { |
42 | 115 | $this->mAction = $wgRequest->getText( "action" ); |
43 | 116 | } |
| 117 | + } |
44 | 118 | |
| 119 | + |
| 120 | + function execute( $par ) { |
| 121 | + global $wgBoardVoteEditCount, $wgBoardVoteEndDate, $wgBoardVoteStartDate, |
| 122 | + $wgBoardVoteFirstEdit, $wgOut; |
| 123 | + |
| 124 | + $this->init( $par ); |
45 | 125 | $this->setHeaders(); |
46 | 126 | |
47 | | - global $wgOut; |
48 | | - |
| 127 | + if ( $this->mRemoteSession ) { |
| 128 | + $wgOut->redirect( $this->getTitle( $par )->getFullUrl() ); |
| 129 | + return; |
| 130 | + } |
| 131 | + |
| 132 | + if ( $this->mUserKey ) { |
| 133 | + $wgOut->addWikiText( wfMsg( 'boardvote_welcome', wfEscapeWikiText( $this->mUserKey ) ) ); |
| 134 | + } |
| 135 | + |
49 | 136 | if ( wfTimestampNow() < $wgBoardVoteStartDate && !$this->isAdmin() ) { |
50 | 137 | $wgOut->addWikiText( wfMsg( 'boardvote_notstarted' ) ); |
51 | 138 | return; |
52 | 139 | } |
53 | 140 | |
54 | | - if ( $wgUser->isBlocked() ) { |
55 | | - $wgOut->blockedPage(); |
| 141 | + if ( $this->mBlocked ) { |
| 142 | + $wgOut->addWikiText( wfMsg( 'boardvote_blocked' ) ); |
56 | 143 | return; |
57 | 144 | } |
58 | 145 | |
— | — | @@ -75,14 +162,10 @@ |
76 | 163 | } elseif ( $this->mAction == "unstrike" ) { |
77 | 164 | $this->strike( $this->mId, true ); |
78 | 165 | } elseif( $this->mAction == "vote" && !$this->mFinished ) { |
79 | | - if ( !$wgUser->getID() ) { |
| 166 | + if ( !$this->mUserKey ) { |
80 | 167 | $this->notLoggedIn(); |
81 | 168 | } else { |
82 | | - $this->getQualifications( $wgUser ); |
83 | | - if ( !$this->isAdmin() && |
84 | | - ( $this->mUserEdits < $wgBoardVoteEditCount || |
85 | | - $this->mFirstEdit > $wgBoardVoteFirstEdit ) |
86 | | - ) { |
| 169 | + if ( !$this->isQualified( $this->mUserKey ) ) { |
87 | 170 | $this->notQualified(); |
88 | 171 | } elseif ( $this->mPosted ) { |
89 | 172 | $this->logVote(); |
— | — | @@ -114,9 +197,9 @@ |
115 | 198 | return $this->mDb; |
116 | 199 | } |
117 | 200 | |
118 | | - function hasVoted( &$user ) { |
| 201 | + function hasVoted() { |
119 | 202 | $dbr =& $this->getDB(); |
120 | | - $row = $dbr->selectRow( 'log', array( "1" ), |
| 203 | + $row = $dbr->selectRow( 'vote_log', array( "1" ), |
121 | 204 | array( "log_user_key" => $this->mUserKey ), "BoardVotePage::getUserVote" ); |
122 | 205 | if ( $row === false ) { |
123 | 206 | return false; |
— | — | @@ -126,7 +209,7 @@ |
127 | 210 | } |
128 | 211 | |
129 | 212 | function logVote() { |
130 | | - global $wgUser, $wgDBname, $wgIP, $wgOut, $wgGPGPubKey, $wgRequest; |
| 213 | + global $wgUser, $wgDBname, $wgOut, $wgGPGPubKey, $wgRequest; |
131 | 214 | $fname = "BoardVotePage::logVote"; |
132 | 215 | |
133 | 216 | $now = wfTimestampNow(); |
— | — | @@ -134,7 +217,7 @@ |
135 | 218 | $encrypted = $this->encrypt( $record ); |
136 | 219 | $gpgKey = file_get_contents( $wgGPGPubKey ); |
137 | 220 | $dbw =& $this->getDB(); |
138 | | - $log = $dbw->tableName( "log" ); |
| 221 | + $log = $dbw->tableName( "vote_log" ); |
139 | 222 | |
140 | 223 | # Mark previous votes as old |
141 | 224 | $encKey = $dbw->strencode( $this->mUserKey ); |
— | — | @@ -150,13 +233,12 @@ |
151 | 234 | $tokenMatch = $wgUser->matchEditToken( $wgRequest->getVal( 'edit_token' ) ); |
152 | 235 | |
153 | 236 | $dbw->insert( $log, array( |
154 | | - "log_user" => $wgUser->getID(), |
155 | | - "log_user_text" => $wgUser->getName(), |
| 237 | + "log_user" => 0, |
| 238 | + "log_user_text" => '', |
156 | 239 | "log_user_key" => $this->mUserKey, |
157 | 240 | "log_wiki" => $wgDBname, |
158 | | - "log_edits" => $this->mUserEdits, |
159 | 241 | "log_record" => $encrypted, |
160 | | - "log_ip" => $wgIP, |
| 242 | + "log_ip" => wfGetIP(), |
161 | 243 | "log_xff" => $xff, |
162 | 244 | "log_ua" => $_SERVER['HTTP_USER_AGENT'], |
163 | 245 | "log_timestamp" => $now, |
— | — | @@ -217,7 +299,7 @@ |
218 | 300 | |
219 | 301 | function notLoggedIn() { |
220 | 302 | global $wgOut, $wgBoardVoteEditCount, $wgBoardVoteCountDate, $wgLang, $wgBoardVoteFirstEdit; |
221 | | - $wgOut->addWikiText( wfMsg( "boardvote_notloggedin", $wgBoardVoteEditCount, |
| 303 | + $wgOut->addWikiText( wfMsg( "boardvote_nosession", $wgBoardVoteEditCount, |
222 | 304 | $wgLang->timeanddate( $wgBoardVoteCountDate ), |
223 | 305 | $wgLang->timeanddate( $wgBoardVoteFirstEdit ) |
224 | 306 | ) ); |
— | — | @@ -225,9 +307,8 @@ |
226 | 308 | |
227 | 309 | function notQualified() { |
228 | 310 | global $wgOut, $wgBoardVoteEditCount, $wgBoardVoteCountDate, $wgLang, $wgBoardVoteFirstEdit; |
229 | | - $wgOut->addWikiText( wfMsg( "boardvote_notqualified", $this->mUserEdits, |
230 | | - $wgLang->timeanddate( $wgBoardVoteCountDate ), $wgBoardVoteEditCount, |
231 | | - $wgLang->timeanddate( $this->mFirstEdit ), |
| 311 | + $wgOut->addWikiText( wfMsg( "boardvote_notqualified", '[unknown]', |
| 312 | + $wgLang->timeanddate( $wgBoardVoteCountDate ), $wgBoardVoteEditCount, '[unknown]', |
232 | 313 | $wgLang->timeanddate( $wgBoardVoteFirstEdit ) |
233 | 314 | ) ); |
234 | 315 | } |
— | — | @@ -266,7 +347,7 @@ |
267 | 348 | } |
268 | 349 | $command .= " " . wfEscapeShellArg( $input ) . " 2>&1"; |
269 | 350 | |
270 | | - $error = shell_exec( $command ); |
| 351 | + $error = wfShellExec( $command ); |
271 | 352 | |
272 | 353 | # Read result |
273 | 354 | $result = file_get_contents( $output ); |
— | — | @@ -283,27 +364,10 @@ |
284 | 365 | return $result; |
285 | 366 | } |
286 | 367 | |
287 | | - function getQualifications( &$user ) { |
288 | | - global $wgBoardVoteEditCount, $wgBoardVoteCountDate, $wgVersion; |
289 | | - |
290 | | - // Use the local database, not the boardvote database |
291 | | - $dbr =& wfGetDB( DB_SLAVE ); |
292 | | - |
293 | | - # Count contributions before $wgBoardVoteCountDate |
294 | | - |
295 | | - $id = $user->getID(); |
296 | | - if ( !$id ) { |
297 | | - $this->mUserEdits = 0; |
298 | | - return; |
299 | | - } |
300 | | - $date = $dbr->addQuotes( $wgBoardVoteCountDate ); |
301 | | - |
302 | | - extract( $dbr->tableNames( 'revision' ) ); |
303 | | - $sql = "SELECT MIN(rev_timestamp) as first, COUNT(*) as n FROM $revision WHERE rev_timestamp<=$date AND rev_user=$id"; |
304 | | - $res = $dbr->query( $sql, "BoardVotePage::getQualifications" ); |
305 | | - $row = $dbr->fetchObject( $res ); |
306 | | - $this->mUserEdits = $row->n; |
307 | | - $this->mFirstEdit = $row->first; |
| 368 | + function isQualified( $key ) { |
| 369 | + $db = $this->getDB(); |
| 370 | + $qualified = $db->selectField( 'voters', '1', array( 'user_key' => $key ), __METHOD__ ); |
| 371 | + return (bool)$qualified; |
308 | 372 | } |
309 | 373 | |
310 | 374 | function displayList() { |
— | — | @@ -312,7 +376,7 @@ |
313 | 377 | $userRights = $wgUser->getRights(); |
314 | 378 | $admin = $this->isAdmin(); |
315 | 379 | $dbr =& $this->getDB(); |
316 | | - $log = $dbr->tableName( "log" ); |
| 380 | + $log = $dbr->tableName( "vote_log" ); |
317 | 381 | |
318 | 382 | $sql = "SELECT * FROM $log ORDER BY log_user_key"; |
319 | 383 | $res = $dbr->query( $sql, "BoardVotePage::list" ); |
— | — | @@ -327,7 +391,6 @@ |
328 | 392 | $intro = wfMsg( "boardvote_listintro", $dumpLink ); |
329 | 393 | $hTime = wfMsg( "boardvote_time" ); |
330 | 394 | $hUser = wfMsg( "boardvote_user" ); |
331 | | - $hEdits = wfMsg( "boardvote_edits" ); |
332 | 395 | $hIp = wfMsg( "boardvote_ip" ); |
333 | 396 | $hUa = wfMsg( "boardvote_ua" ); |
334 | 397 | |
— | — | @@ -335,8 +398,6 @@ |
336 | 399 | $hUser |
337 | 400 | </th><th> |
338 | 401 | $hTime |
339 | | - </th><th> |
340 | | - $hEdits |
341 | 402 | </th>"; |
342 | 403 | |
343 | 404 | if ( $admin ) { |
— | — | @@ -349,13 +410,7 @@ |
350 | 411 | $s .= "</tr>"; |
351 | 412 | |
352 | 413 | while ( $row = $dbr->fetchObject( $res ) ) { |
353 | | - # Earlier versions of medaiwiki had selectable character set, wfUtf8HTML is removed |
354 | | - # in later versions. |
355 | | - if ( $wgOutputEncoding != "utf-8" && function_exists( 'wfUtf8ToHTML' ) ) { |
356 | | - $user = wfUtf8ToHTML( $row->log_user_key ); |
357 | | - } else { |
358 | | - $user = $row->log_user_key; |
359 | | - } |
| 414 | + $user = $row->log_user_key; |
360 | 415 | $time = $wgLang->timeanddate( $row->log_timestamp ); |
361 | 416 | $cellOpen = "<td>"; |
362 | 417 | $cellClose = "</td>"; |
— | — | @@ -367,13 +422,10 @@ |
368 | 423 | $cellOpen .= "<del>"; |
369 | 424 | $cellClose = "</del>$cellClose"; |
370 | 425 | } |
371 | | - $edits = $row->log_edits == 0x7fffffff ? wfMsgHtml( 'boardvote_edits_many' ) : $row->log_edits; |
372 | 426 | $s .= "<tr>$cellOpen |
373 | 427 | $user |
374 | 428 | {$cellClose}{$cellOpen} |
375 | 429 | $time |
376 | | - {$cellClose}{$cellOpen} |
377 | | - $edits |
378 | 430 | {$cellClose}"; |
379 | 431 | |
380 | 432 | if ( $admin ) { |
— | — | @@ -401,9 +453,9 @@ |
402 | 454 | } |
403 | 455 | |
404 | 456 | function dump() { |
405 | | - global $wgOut, $wgOutputEncoding, $wgLang, $wgUser; |
| 457 | + global $wgOut, $wgOutputEncoding, $wgLang; |
406 | 458 | $dbr =& $this->getDB(); |
407 | | - $log = $dbr->tableName( "log" ); |
| 459 | + $log = $dbr->tableName( "vote_log" ); |
408 | 460 | |
409 | 461 | $sql = "SELECT log_record FROM $log WHERE log_current=1 AND log_strike=0"; |
410 | 462 | $res = $dbr->query( $sql, DB_SLAVE, "BoardVotePage::list" ); |
— | — | @@ -434,7 +486,7 @@ |
435 | 487 | global $wgOut; |
436 | 488 | |
437 | 489 | $dbw =& $this->getDB(); |
438 | | - $log = $dbw->tableName( "log" ); |
| 490 | + $log = $dbw->tableName( "vote_log" ); |
439 | 491 | |
440 | 492 | if ( !$this->isAdmin() ) { |
441 | 493 | $wgOut->addWikiText( wfMsg( "boardvote_needadmin" ) ); |
Index: trunk/extensions/BoardVote/BoardVote.i18n.php |
— | — | @@ -52,6 +52,7 @@ |
53 | 53 | <pre>$3</pre> |
54 | 54 | |
55 | 55 | [[Special:Boardvote/entry|Back]]", |
| 56 | + 'boardvote_nosession' => "I can't determine your Wikimedia user ID. Please log in to the wiki where you are qualified, and go to <nowiki>[[Special:Go to board vote]]</nowiki>. To vote, you must use an account with at least $1 contributions before $2, and with a first edit before $3.", |
56 | 57 | 'boardvote_notloggedin' => "You are not logged in. To vote, you must use an account with at least $1 contributions before $2, and with a first edit before $3.", |
57 | 58 | 'boardvote_notqualified' => "You are not qualified to vote in this election. You need to have made $3 edits before $2, you have made $1. Also, your first edit was at $4, it needs to be before $5.", |
58 | 59 | 'boardvote_novotes' => "Nobody has voted yet.", |
— | — | @@ -75,6 +76,9 @@ |
76 | 77 | 'group-boardvote' => 'Board vote admins', |
77 | 78 | 'group-boardvote-member' => 'Board vote admin', |
78 | 79 | 'grouppage-boardvote' => '{{ns:project}}:Board vote admin', |
| 80 | + 'boardvote_blocked' => 'Sorry, you have been blocked on your registered wiki. Blocked users are not allowed to vote.', |
| 81 | + 'boardvote_welcome' => "Welcome '''$1'''!", |
| 82 | + 'go_to_board_vote' => 'Wikimedia Board Elections 2007', |
79 | 83 | ); |
80 | 84 | $wgBoardVoteMessages['cs'] = array( |
81 | 85 | 'boardvote' => "Volby do Správní rady nadace Wikimedia", |
Index: trunk/extensions/BoardVote/BoardVote.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | } |
10 | 10 | |
11 | 11 | # Internationalisation file |
12 | | -require_once( 'BoardVote.i18n.php' ); |
| 12 | +require_once( dirname(__FILE__ ) . '/BoardVote.i18n.php' ); |
13 | 13 | |
14 | 14 | # Default settings |
15 | 15 | $wgBoardVoteDB = "boardvote"; |
— | — | @@ -32,5 +32,16 @@ |
33 | 33 | require( dirname(__FILE__) . '/../ExtensionFunctions.php' ); |
34 | 34 | } |
35 | 35 | extAddSpecialPage( dirname(__FILE__) . '/BoardVote_body.php', 'Boardvote', 'BoardVotePage' ); |
| 36 | +extAddSpecialPage( dirname(__FILE__) . '/GoToBoardVote_body.php', 'Go_to_board_vote', 'GoToBoardVotePage' ); |
36 | 37 | |
| 38 | +$wgExtensionFunctions[] = 'wfSetupBoardVote'; |
| 39 | +function wfSetupBoardVote() { |
| 40 | + wfSetupSession(); |
| 41 | + if ( isset( $_SESSION['bvLang'] ) && !isset( $_REQUEST['uselang'] ) ) { |
| 42 | + wfDebug( __METHOD__.": Setting user language to {$_SESSION['bvLang']}\n" ); |
| 43 | + $_REQUEST['uselang'] = $_SESSION['bvLang']; |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | + |
37 | 48 | ?> |