r16299 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16298‎ | r16299 | r16300 >
Date:15:04, 31 August 2006
Author:tstarling
Status:old
Tags:
Comment:
Manage our own DB connection. Some i18n updates.
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)

Diff [purge]

Index: trunk/extensions/BoardVote/BoardVote_body.php
@@ -11,7 +11,7 @@
1212 }
1313
1414 class BoardVotePage extends SpecialPage {
15 - var $mPosted, $mVotedFor, $mDBname, $mUserDays, $mUserEdits;
 15+ var $mPosted, $mVotedFor, $mUserDays, $mUserEdits;
1616 var $mHasVoted, $mAction, $mUserKey, $mId, $mFinished;
1717 var $mDb;
1818
@@ -20,7 +20,7 @@
2121 }
2222
2323 function execute( $par ) {
24 - global $wgUser, $wgDBname, $wgInputEncoding, $wgRequest, $wgBoardVoteDB,
 24+ global $wgUser, $wgDBname, $wgInputEncoding, $wgRequest,
2525 $wgBoardVoteEditCount, $wgBoardVoteEndDate;
2626
2727 $this->mUserKey = iconv( $wgInputEncoding, "UTF-8", $wgUser->getName() ) . "@$wgDBname";
@@ -32,7 +32,6 @@
3333 }
3434 $this->mId = $wgRequest->getInt( "id", 0 );
3535
36 - $this->mDBname = $wgBoardVoteDB;
3736 $this->mHasVoted = $this->hasVoted( $wgUser );
3837
3938 if ( $par ) {
@@ -88,15 +87,21 @@
8988
9089 function getDB() {
9190 if ( !$this->mDb ) {
92 - $this->mDb = wfGetDB( DB_MASTER, 'boardvote' );
 91+ global $wgBoardVoteDBServer, $wgBoardVoteDB, $wgDBuser, $wgDBpassword;
 92+
 93+ $this->mDb = new Database( $wgBoardVoteDBServer, $wgDBuser, $wgDBpassword,
 94+ $wgBoardVoteDB, /*failfn*/false, /*flags*/0, /*prefix*/'' );
 95+ if ( !$this->mDb->isOpen() ) {
 96+ // This should be handled inside the constructor, but we'll check just in case
 97+ throw new MWException( "DB connection failed unexpectedly" );
 98+ }
9399 }
94100 return $this->mDb;
95101 }
96102
97103 function hasVoted( &$user ) {
98 - global $wgDBname;
99104 $dbr =& $this->getDB();
100 - $row = $dbr->selectRow( "`{$this->mDBname}`.log", array( "1" ),
 105+ $row = $dbr->selectRow( 'log', array( "1" ),
101106 array( "log_user_key" => $this->mUserKey ), "BoardVotePage::getUserVote" );
102107 if ( $row === false ) {
103108 return false;
@@ -114,7 +119,7 @@
115120 $encrypted = $this->encrypt( $record );
116121 $gpgKey = file_get_contents( $wgGPGPubKey );
117122 $dbw =& $this->getDB();
118 - $log = $dbw->tableName( "`{$this->mDBname}`.log" );
 123+ $log = $dbw->tableName( "log" );
119124
120125 # Mark previous votes as old
121126 $encKey = $dbw->strencode( $this->mUserKey );
@@ -286,7 +291,7 @@
287292 $userRights = $wgUser->getRights();
288293 $admin = $this->isAdmin();
289294 $dbr =& $this->getDB();
290 - $log = $dbr->tableName( "`{$this->mDBname}`.log" );
 295+ $log = $dbr->tableName( "log" );
291296
292297 $sql = "SELECT * FROM $log ORDER BY log_user_key";
293298 $res = $dbr->query( $sql, "BoardVotePage::list" );
@@ -377,7 +382,7 @@
378383 function dump() {
379384 global $wgOut, $wgOutputEncoding, $wgLang, $wgUser;
380385 $dbr =& $this->getDB();
381 - $log = $dbr->tableName( "`{$this->mDBname}`.log" );
 386+ $log = $dbr->tableName( "log" );
382387
383388 $sql = "SELECT log_record FROM $log WHERE log_current=1 AND log_strike=0";
384389 $res = $dbr->query( $sql, DB_SLAVE, "BoardVotePage::list" );
@@ -408,7 +413,7 @@
409414 global $wgOut;
410415
411416 $dbw =& $this->getDB();
412 - $log = $dbw->tableName( "`{$this->mDBname}`.log" );
 417+ $log = $dbw->tableName( "log" );
413418
414419 if ( !$this->isAdmin() ) {
415420 $wgOut->addWikiText( wfMsg( "boardvote_needadmin" ) );
Index: trunk/extensions/BoardVote/BoardVote.i18n.php
@@ -31,8 +31,8 @@
3232 position. In the event of a tie, a run-off election will be held.</p>
3333
3434 <p>For more information, see:</p>
35 -<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2005\" class=\"external\">Election FAQ</a></li>
36 -<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2005\" class=\"external\">Candidates</a></li></ul>
 35+<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2006\" class=\"external\">Election FAQ</a></li>
 36+<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2006\" class=\"external\">Candidates</a></li></ul>
3737 ",
3838 'boardvote_intro_change' => "<p>You have voted before. However you may change
3939 your vote using the form below. Please check the boxes next to each candidate whom
@@ -53,10 +53,8 @@
5454 <pre>$3</pre>
5555
5656 [[Special:Boardvote/entry|Back]]",
57 - 'boardvote_notloggedin' => "You are not logged in. To vote, you must use an account
58 -with at least $1 contributions before $2.",
59 - 'boardvote_notqualified' => "Sorry, you made only $1 edits before $2. You
60 -need at least $3 to be able to vote.",
 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.",
 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. ",
6159 'boardvote_novotes' => "Nobody has voted yet.",
6260 'boardvote_time' => "Time",
6361 'boardvote_user' => "User",
@@ -71,7 +69,7 @@
7270 'boardvote_unstrike' => "Unstrike",
7371 'boardvote_needadmin' => "Only election administrators can perform this operation.",
7472 'boardvote_sitenotice' => "<a href=\"{{localurle:Special:Boardvote/vote}}\">Wikimedia Board Elections</a>: Vote open until July 12",
75 - 'boardvote_closed' => 'Voting is now closed, see [http://meta.wikimedia.org/wiki/Elections_for_the_Board_of_Trustees_of_the_Wikimedia_Foundation%2C_2005/En the elections page for results] soon.',
 73+ 'boardvote_closed' => 'Voting is now closed, see [http://meta.wikimedia.org/wiki/Elections_for_the_Board_of_Trustees_of_the_Wikimedia_Foundation%2C_2006/En the elections page for results] soon.',
7674 'boardvote_edits_many' => 'many',
7775 'group-boardvote' => 'Board vote admins',
7876 'group-boardvote-member' => 'Board vote admin',
@@ -90,8 +88,8 @@
9189 <p>באפשרותכם להצביע עבור מספר מועמדים. המועמדים עם מירב ההצבעות בכל עמדה יוכרזו כמנצחים בעמדה זו. במידה ויתקיים שיוויון בין מספר מועמדים, תתבצע הצבעה נוספת ביניהם.</p>
9290
9391 <p>למידע נוסף, ראו:</p>
94 -<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2005\" class=\"external\">שאלות נפוצות על הבחירות</a></li>
95 -<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2005\" class=\"external\">המועמדים</a></li></ul>
 92+<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2006\" class=\"external\">שאלות נפוצות על הבחירות</a></li>
 93+<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2006\" class=\"external\">המועמדים</a></li></ul>
9694 ",
9795 'boardvote_intro_change' => "<p>כבר הצבעתם בעבר. עם זאת, באפשרותכם לשנות את הצבעתכם באמצעות הטופס המצורף למטה. אנא סמנו את תיבת הסימון ליד כל אחד מהמועמדים המועדפים עליכם.</p>",
9896 'boardvote_entered' => "תודה לכם, הצבעתכם נרשמה.
@@ -124,7 +122,7 @@
125123 'boardvote_unstrike' => "הסתרה",
126124 'boardvote_needadmin' => "רק מנהלי הבחירות יכולים לבצע פעולה זו.",
127125 'boardvote_sitenotice' => "<a href=\"{{localurle:{{ns:special}}:Boardvote/vote}}\">בחירות לחבר הנאמנים של ויקימדיה</a>: ההצבעה פתוחה עד 12 ביולי",
128 - 'boardvote_closed' => 'ההצבעה סגורה כעת, ראו [http://meta.wikimedia.org/wiki/Elections_for_the_Board_of_Trustees_of_the_Wikimedia_Foundation%2C_2005/En את הדף על תוצאות הבחירות] בקרוב.',
 126+ 'boardvote_closed' => 'ההצבעה סגורה כעת, ראו [http://meta.wikimedia.org/wiki/Elections_for_the_Board_of_Trustees_of_the_Wikimedia_Foundation%2C_2006/En את הדף על תוצאות הבחירות] בקרוב.',
129127 'boardvote_edits_many' => 'הרבה',
130128 'group-boardvote' => 'מנהלי הבחירות לחבר המנהלים',
131129 'group-boardvote-member' => 'מנהל הבחירות לחבר המנהלים',
@@ -174,8 +172,8 @@
175173 positie. In geval de stemmen staken wordt er een tweede ronde gehouden.</p>
176174
177175 <p>Meer informatie:</p>
178 -<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2005\" class=\"external\">Bestuursverkiezing FAQ</a></li>
179 -<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2005\" class=\"external\">Kandidaten</a></li></ul>
 176+<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2006\" class=\"external\">Bestuursverkiezing FAQ</a></li>
 177+<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2006\" class=\"external\">Kandidaten</a></li></ul>
180178 ",
181179 "boardvote_intro_change" => "<p>U heeft al gestemd. U kunt uw stem wijzigen via
182180 het onderstaande formulier. Vink alstublieft de vakjes naar iedere kandidaat die
@@ -229,8 +227,8 @@
230228 <p>Poderá votar em tantos candidatos quantos desejar. O candidato que apurar mais votos em cada posição será declarado vencedor dessa posição. Em caso de empate, serão lançadas votações para desempate.</p>
231229
232230 <p>Para mais informações, consulte:</p>
233 -<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2005\" class=\"external\">FAQ de eleição</a></li>
234 -<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2005\" class=\"external\">Candidatos</a></li></ul>
 231+<ul><li><a href=\"http://meta.wikipedia.org/wiki/Election_FAQ_2006\" class=\"external\">FAQ de eleição</a></li>
 232+<li><a href=\"http://meta.wikipedia.org/wiki/Election_Candidates_2006\" class=\"external\">Candidatos</a></li></ul>
235233 ",
236234 'boardvote_intro_change' => "<p>Já votou anteriormente. Contudo pode alterar o seu voto utilizando o formulário abaixo. Por favor marque a caixa ao lado de cada candidato que aprovar.</p>",
237235 'boardvote_entered' => "Obrigado, o seu voto foi registado.
@@ -263,7 +261,7 @@
264262 'boardvote_unstrike' => "Limpar risco",
265263 'boardvote_needadmin' => "Apenas administradores podem efectuar esta operação.",
266264 'boardvote_sitenotice' => "<a href=\"{{localurle:Especial:Boardvote/vote}}\">Comité da Fundação Wikimedia</a>: Votação aberta até 12 de Julho",
267 - 'boardvote_closed' => 'As eleições estão agora encerradas, ver [http://meta.wikimedia.org/wiki/Elections_for_the_Board_of_Trustees_of_the_Wikimedia_Foundation%2C_2005/Pt a página de eleições para os resultados] brevemente.',
 265+ 'boardvote_closed' => 'As eleições estão agora encerradas, ver [http://meta.wikimedia.org/wiki/Elections_for_the_Board_of_Trustees_of_the_Wikimedia_Foundation%2C_2006/Pt a página de eleições para os resultados] brevemente.',
268266 'boardvote_edits_many' => 'muitos',
269267 'group-boardvote' => 'Board vote administradores',
270268 'group-boardvote-member' => 'Board vote administrador',
Index: trunk/extensions/BoardVote/BoardVote.php
@@ -22,6 +22,7 @@
2323 $wgBoardVoteCountDate = '20060801000000';
2424 $wgBoardVoteStartDate = '20060901000000';
2525 $wgBoardVoteEndDate = '20060922000000';
 26+$wgBoardVoteDBServer = $wgDBserver;
2627
2728 # Vote admins
2829 $wgGroupPermissions['boardvote']['boardvote'] = true;