r23418 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23417‎ | r23418 | r23419 >
Date:13:06, 26 June 2007
Author:tstarling
Status:old
Tags:
Comment:
Updates for 2007. Support for session transfer to an external server using an SSL back channel.
Modified paths:
  • /trunk/extensions/BoardVote/BoardVote.i18n.php (modified) (history)
  • /trunk/extensions/BoardVote/BoardVote.php (modified) (history)
  • /trunk/extensions/BoardVote/BoardVote_body.php (modified) (history)
  • /trunk/extensions/BoardVote/GoToBoardVote_body.php (added) (history)
  • /trunk/extensions/BoardVote/boardvote.sql (modified) (history)
  • /trunk/extensions/BoardVote/cacert-both.crt (added) (history)

Diff [purge]

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
140 + native
Index: trunk/extensions/BoardVote/cacert-both.crt
@@ -0,0 +1,77 @@
 2+-----BEGIN CERTIFICATE-----
 3+MIIGCDCCA/CgAwIBAgIBATANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290
 4+IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB
 5+IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA
 6+Y2FjZXJ0Lm9yZzAeFw0wNTEwMTQwNzM2NTVaFw0zMzAzMjgwNzM2NTVaMFQxFDAS
 7+BgNVBAoTC0NBY2VydCBJbmMuMR4wHAYDVQQLExVodHRwOi8vd3d3LkNBY2VydC5v
 8+cmcxHDAaBgNVBAMTE0NBY2VydCBDbGFzcyAzIFJvb3QwggIiMA0GCSqGSIb3DQEB
 9+AQUAA4ICDwAwggIKAoICAQCrSTURSHzSJn5TlM9Dqd0o10Iqi/OHeBlYfA+e2ol9
 10+4fvrcpANdKGWZKufoCSZc9riVXbHF3v1BKxGuMO+f2SNEGwk82GcwPKQ+lHm9WkB
 11+Y8MPVuJKQs/iRIwlKKjFeQl9RrmK8+nzNCkIReQcn8uUBByBqBSzmGXEQ+xOgo0J
 12+0b2qW42S0OzekMV/CsLj6+YxWl50PpczWejDAz1gM7/30W9HxM3uYoNSbi4ImqTZ
 13+FRiRpoWSR7CuSOtttyHshRpocjWr//AQXcD0lKdq1TuSfkyQBX6TwSyLpI5idBVx
 14+bgtxA+qvFTia1NIFcm+M+SvrWnIl+TlG43IbPgTDZCciECqKT1inA62+tC4T7V2q
 15+SNfVfdQqe1z6RgRQ5MwOQluM7dvyz/yWk+DbETZUYjQ4jwxgmzuXVjit89Jbi6Bb
 16+6k6WuHz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8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB
 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 @@
22 -- Board of Trustees vote
33
4 -CREATE TABLE log (
 4+CREATE TABLE vote_log (
55 log_id int(5) not null auto_increment,
66 log_user int(5) not null default 0,
77 log_user_text varchar(255) binary not null default '',
@@ -20,4 +20,8 @@
2121 index log_user_key (log_user_key)
2222 );
2323
 24+CREATE TABLE voters (
 25+ user_key VARBINARY(255) not null,
 26+ unique index (user_key)
 27+);
2428
Index: trunk/extensions/BoardVote/BoardVote_body.php
@@ -19,12 +19,85 @@
2020 SpecialPage::SpecialPage( "Boardvote" );
2121 }
2222
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+ }
2733
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+
29102 $this->mPosted = $wgRequest->wasPosted();
30103 if ( method_exists( $wgRequest, 'getArray' ) ) {
31104 $this->mVotedFor = $wgRequest->getArray( "votedfor", array() );
@@ -33,25 +106,39 @@
34107 }
35108 $this->mId = $wgRequest->getInt( "id", 0 );
36109
37 - $this->mHasVoted = $this->hasVoted( $wgUser );
 110+ $this->mHasVoted = $this->hasVoted();
38111
39112 if ( $par ) {
40113 $this->mAction = $par;
41114 } else {
42115 $this->mAction = $wgRequest->getText( "action" );
43116 }
 117+ }
44118
 119+
 120+ function execute( $par ) {
 121+ global $wgBoardVoteEditCount, $wgBoardVoteEndDate, $wgBoardVoteStartDate,
 122+ $wgBoardVoteFirstEdit, $wgOut;
 123+
 124+ $this->init( $par );
45125 $this->setHeaders();
46126
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+
49136 if ( wfTimestampNow() < $wgBoardVoteStartDate && !$this->isAdmin() ) {
50137 $wgOut->addWikiText( wfMsg( 'boardvote_notstarted' ) );
51138 return;
52139 }
53140
54 - if ( $wgUser->isBlocked() ) {
55 - $wgOut->blockedPage();
 141+ if ( $this->mBlocked ) {
 142+ $wgOut->addWikiText( wfMsg( 'boardvote_blocked' ) );
56143 return;
57144 }
58145
@@ -75,14 +162,10 @@
76163 } elseif ( $this->mAction == "unstrike" ) {
77164 $this->strike( $this->mId, true );
78165 } elseif( $this->mAction == "vote" && !$this->mFinished ) {
79 - if ( !$wgUser->getID() ) {
 166+ if ( !$this->mUserKey ) {
80167 $this->notLoggedIn();
81168 } else {
82 - $this->getQualifications( $wgUser );
83 - if ( !$this->isAdmin() &&
84 - ( $this->mUserEdits < $wgBoardVoteEditCount ||
85 - $this->mFirstEdit > $wgBoardVoteFirstEdit )
86 - ) {
 169+ if ( !$this->isQualified( $this->mUserKey ) ) {
87170 $this->notQualified();
88171 } elseif ( $this->mPosted ) {
89172 $this->logVote();
@@ -114,9 +197,9 @@
115198 return $this->mDb;
116199 }
117200
118 - function hasVoted( &$user ) {
 201+ function hasVoted() {
119202 $dbr =& $this->getDB();
120 - $row = $dbr->selectRow( 'log', array( "1" ),
 203+ $row = $dbr->selectRow( 'vote_log', array( "1" ),
121204 array( "log_user_key" => $this->mUserKey ), "BoardVotePage::getUserVote" );
122205 if ( $row === false ) {
123206 return false;
@@ -126,7 +209,7 @@
127210 }
128211
129212 function logVote() {
130 - global $wgUser, $wgDBname, $wgIP, $wgOut, $wgGPGPubKey, $wgRequest;
 213+ global $wgUser, $wgDBname, $wgOut, $wgGPGPubKey, $wgRequest;
131214 $fname = "BoardVotePage::logVote";
132215
133216 $now = wfTimestampNow();
@@ -134,7 +217,7 @@
135218 $encrypted = $this->encrypt( $record );
136219 $gpgKey = file_get_contents( $wgGPGPubKey );
137220 $dbw =& $this->getDB();
138 - $log = $dbw->tableName( "log" );
 221+ $log = $dbw->tableName( "vote_log" );
139222
140223 # Mark previous votes as old
141224 $encKey = $dbw->strencode( $this->mUserKey );
@@ -150,13 +233,12 @@
151234 $tokenMatch = $wgUser->matchEditToken( $wgRequest->getVal( 'edit_token' ) );
152235
153236 $dbw->insert( $log, array(
154 - "log_user" => $wgUser->getID(),
155 - "log_user_text" => $wgUser->getName(),
 237+ "log_user" => 0,
 238+ "log_user_text" => '',
156239 "log_user_key" => $this->mUserKey,
157240 "log_wiki" => $wgDBname,
158 - "log_edits" => $this->mUserEdits,
159241 "log_record" => $encrypted,
160 - "log_ip" => $wgIP,
 242+ "log_ip" => wfGetIP(),
161243 "log_xff" => $xff,
162244 "log_ua" => $_SERVER['HTTP_USER_AGENT'],
163245 "log_timestamp" => $now,
@@ -217,7 +299,7 @@
218300
219301 function notLoggedIn() {
220302 global $wgOut, $wgBoardVoteEditCount, $wgBoardVoteCountDate, $wgLang, $wgBoardVoteFirstEdit;
221 - $wgOut->addWikiText( wfMsg( "boardvote_notloggedin", $wgBoardVoteEditCount,
 303+ $wgOut->addWikiText( wfMsg( "boardvote_nosession", $wgBoardVoteEditCount,
222304 $wgLang->timeanddate( $wgBoardVoteCountDate ),
223305 $wgLang->timeanddate( $wgBoardVoteFirstEdit )
224306 ) );
@@ -225,9 +307,8 @@
226308
227309 function notQualified() {
228310 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]',
232313 $wgLang->timeanddate( $wgBoardVoteFirstEdit )
233314 ) );
234315 }
@@ -266,7 +347,7 @@
267348 }
268349 $command .= " " . wfEscapeShellArg( $input ) . " 2>&1";
269350
270 - $error = shell_exec( $command );
 351+ $error = wfShellExec( $command );
271352
272353 # Read result
273354 $result = file_get_contents( $output );
@@ -283,27 +364,10 @@
284365 return $result;
285366 }
286367
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;
308372 }
309373
310374 function displayList() {
@@ -312,7 +376,7 @@
313377 $userRights = $wgUser->getRights();
314378 $admin = $this->isAdmin();
315379 $dbr =& $this->getDB();
316 - $log = $dbr->tableName( "log" );
 380+ $log = $dbr->tableName( "vote_log" );
317381
318382 $sql = "SELECT * FROM $log ORDER BY log_user_key";
319383 $res = $dbr->query( $sql, "BoardVotePage::list" );
@@ -327,7 +391,6 @@
328392 $intro = wfMsg( "boardvote_listintro", $dumpLink );
329393 $hTime = wfMsg( "boardvote_time" );
330394 $hUser = wfMsg( "boardvote_user" );
331 - $hEdits = wfMsg( "boardvote_edits" );
332395 $hIp = wfMsg( "boardvote_ip" );
333396 $hUa = wfMsg( "boardvote_ua" );
334397
@@ -335,8 +398,6 @@
336399 $hUser
337400 </th><th>
338401 $hTime
339 - </th><th>
340 - $hEdits
341402 </th>";
342403
343404 if ( $admin ) {
@@ -349,13 +410,7 @@
350411 $s .= "</tr>";
351412
352413 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;
360415 $time = $wgLang->timeanddate( $row->log_timestamp );
361416 $cellOpen = "<td>";
362417 $cellClose = "</td>";
@@ -367,13 +422,10 @@
368423 $cellOpen .= "<del>";
369424 $cellClose = "</del>$cellClose";
370425 }
371 - $edits = $row->log_edits == 0x7fffffff ? wfMsgHtml( 'boardvote_edits_many' ) : $row->log_edits;
372426 $s .= "<tr>$cellOpen
373427 $user
374428 {$cellClose}{$cellOpen}
375429 $time
376 - {$cellClose}{$cellOpen}
377 - $edits
378430 {$cellClose}";
379431
380432 if ( $admin ) {
@@ -401,9 +453,9 @@
402454 }
403455
404456 function dump() {
405 - global $wgOut, $wgOutputEncoding, $wgLang, $wgUser;
 457+ global $wgOut, $wgOutputEncoding, $wgLang;
406458 $dbr =& $this->getDB();
407 - $log = $dbr->tableName( "log" );
 459+ $log = $dbr->tableName( "vote_log" );
408460
409461 $sql = "SELECT log_record FROM $log WHERE log_current=1 AND log_strike=0";
410462 $res = $dbr->query( $sql, DB_SLAVE, "BoardVotePage::list" );
@@ -434,7 +486,7 @@
435487 global $wgOut;
436488
437489 $dbw =& $this->getDB();
438 - $log = $dbw->tableName( "log" );
 490+ $log = $dbw->tableName( "vote_log" );
439491
440492 if ( !$this->isAdmin() ) {
441493 $wgOut->addWikiText( wfMsg( "boardvote_needadmin" ) );
Index: trunk/extensions/BoardVote/BoardVote.i18n.php
@@ -52,6 +52,7 @@
5353 <pre>$3</pre>
5454
5555 [[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.",
5657 '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.",
5758 '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.",
5859 'boardvote_novotes' => "Nobody has voted yet.",
@@ -75,6 +76,9 @@
7677 'group-boardvote' => 'Board vote admins',
7778 'group-boardvote-member' => 'Board vote admin',
7879 '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',
7983 );
8084 $wgBoardVoteMessages['cs'] = array(
8185 'boardvote' => "Volby do Správní rady nadace Wikimedia",
Index: trunk/extensions/BoardVote/BoardVote.php
@@ -8,7 +8,7 @@
99 }
1010
1111 # Internationalisation file
12 -require_once( 'BoardVote.i18n.php' );
 12+require_once( dirname(__FILE__ ) . '/BoardVote.i18n.php' );
1313
1414 # Default settings
1515 $wgBoardVoteDB = "boardvote";
@@ -32,5 +32,16 @@
3333 require( dirname(__FILE__) . '/../ExtensionFunctions.php' );
3434 }
3535 extAddSpecialPage( dirname(__FILE__) . '/BoardVote_body.php', 'Boardvote', 'BoardVotePage' );
 36+extAddSpecialPage( dirname(__FILE__) . '/GoToBoardVote_body.php', 'Go_to_board_vote', 'GoToBoardVotePage' );
3637
 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+
3748 ?>

Status & tagging log