r50591 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50590‎ | r50591 | r50592 >
Date:17:33, 14 May 2009
Author:jan
Status:deferred
Tags:
Comment:
See diff
Modified paths:
  • /trunk/extensions/Poll/Poll.i18n.php (modified) (history)
  • /trunk/extensions/Poll/Poll_body.php (modified) (history)
  • /trunk/extensions/Poll/archives/Poll-answer.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Poll/archives/Poll-answer.sql
@@ -6,5 +6,5 @@
77 CREATE TABLE /*$wgDBprefix*/poll_answer (
88 `pid` INT( 10 ) NOT NULL ,
99 `uid` INT( 10 ) NOT NULL ,
10 -`vote` VARCHAR( 255 ) NOT NULL ,
 10+`vote` VARCHAR( 255 ) NOT NULL
1111 ) /*$wgDBTableOptions*/;
\ No newline at end of file
Index: trunk/extensions/Poll/Poll_body.php
@@ -24,7 +24,7 @@
2525 $action = htmlentities( $wgRequest->getText( 'action' ) );
2626 $id = htmlentities( $wgRequest->getText( 'id' ) );
2727
28 - if ( $action == "" ) {
 28+ if ( $action == "" OR $action="list" ) {
2929 $this->make_list();
3030 }
3131
@@ -37,7 +37,7 @@
3838 }
3939
4040 if ( $action == "submit" ) {
41 - $this->submit( $pid );
 41+ $this->submit( $id );
4242 }
4343 }
4444
@@ -48,12 +48,14 @@
4949 $dbr = wfGetDB( DB_SLAVE );
5050 $query = $dbr->select( 'poll', 'question, dis, id' );
5151
 52+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a>' );
 53+
5254 $wgOut->addWikiMsg( 'poll-list-current' );
5355 $wgOut->addHtml( Xml::openElement( 'table' ) );
5456 $wgOut->addHtml( '<tr><th>'.wfMsg( 'poll-question' ).'</th><th>'.wfMsg( 'poll-dis' ).'</th></tr>' );
5557
5658 while( $row = $dbr->fetchObject( $query ) ) {
57 - $wgOut->addHtml( '<tr><td><a href='.$wgTitle->getFullURL('action=vote&id='.$row->id).'>'.$row->question.'</a></td>' );
 59+ $wgOut->addHtml( '<tr><td><a href="'.$wgTitle->getFullURL('action=vote&id='.$row->id).'">'.$row->question.'</a></td>' );
5860 $wgOut->addHtml( '<td>'.$row->dis.'</td></tr>' );
5961 }
6062
@@ -166,6 +168,7 @@
167169 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis ) );
168170
169171 $wgOut->addWikiMsg( 'poll-create-pass' );
 172+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
170173 }
171174 else {
172175 $wgOut->addWikiMsg( 'poll-create-fields-error' );
@@ -189,13 +192,20 @@
190193 $vote = $_POST['vote'];
191194 $uid = $wgUser->getId();
192195
193 - $query = $dbr->select( 'poll', 'uid', 'uid = ' . $uid);
194 - $num = mysql_num_rows($query);
 196+ $query = $dbr->select( 'poll_answer', 'uid', 'uid = ' . $uid);
 197+ $num = 0;
195198
 199+ while( $row = $dbr->fetchObject( $query ) ) {
 200+ if($row->uid != "") {
 201+ $num++;
 202+ }
 203+ }
 204+
196205 if( $num == 0 ) {
197206 $dbw->insert( 'poll_answer', array( 'pid' => $pid, 'uid' => $uid, 'vote' => $vote ) );
198207
199208 $wgOut->addWikiMsg( 'poll-vote-pass' );
 209+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
200210 }
201211 else {
202212 $wgOut->addWikiMsg( 'poll-vote-already-error' );
Index: trunk/extensions/Poll/Poll.i18n.php
@@ -32,7 +32,9 @@
3333 'poll-list-current' => '== Current Polls ==',
3434 'poll-create-pass' => 'Poll created!',
3535 'poll-vote-pass' => 'Voted!',
36 - 'poll-vote-already-error' => 'You has already voted!'
 36+ 'poll-vote-already-error' => 'You has already voted!',
 37+ 'poll-create-link' => 'Create a new Poll',
 38+ 'poll-back' => 'Back to Overview!',
3739 );
3840
3941 /** German (Deutsch)
@@ -59,5 +61,7 @@
6062 'poll-list-current' => '== Aktuelle Umfragen ==',
6163 'poll-create-pass' => 'Umfrage erfolgreich erstellt!',
6264 'poll-vote-pass' => 'Erfolgreich abgestimmt!',
63 - 'poll-vote-already-error' => 'Du hast bereits abgestimmt!'
 65+ 'poll-vote-already-error' => 'Du hast bereits abgestimmt!',
 66+ 'poll-create-link' => 'Eine neue Umfrage erstellen',
 67+ 'poll-back' => 'Zurück zur Übersicht!',
6468 );

Status & tagging log