Index: trunk/extensions/Poll/archives/Poll-answer.sql |
— | — | @@ -6,5 +6,5 @@ |
7 | 7 | CREATE TABLE /*$wgDBprefix*/poll_answer ( |
8 | 8 | `pid` INT( 10 ) NOT NULL , |
9 | 9 | `uid` INT( 10 ) NOT NULL , |
10 | | -`vote` VARCHAR( 255 ) NOT NULL , |
| 10 | +`vote` VARCHAR( 255 ) NOT NULL |
11 | 11 | ) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Index: trunk/extensions/Poll/Poll_body.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | $action = htmlentities( $wgRequest->getText( 'action' ) ); |
26 | 26 | $id = htmlentities( $wgRequest->getText( 'id' ) ); |
27 | 27 | |
28 | | - if ( $action == "" ) { |
| 28 | + if ( $action == "" OR $action="list" ) { |
29 | 29 | $this->make_list(); |
30 | 30 | } |
31 | 31 | |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | } |
39 | 39 | |
40 | 40 | if ( $action == "submit" ) { |
41 | | - $this->submit( $pid ); |
| 41 | + $this->submit( $id ); |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
— | — | @@ -48,12 +48,14 @@ |
49 | 49 | $dbr = wfGetDB( DB_SLAVE ); |
50 | 50 | $query = $dbr->select( 'poll', 'question, dis, id' ); |
51 | 51 | |
| 52 | + $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a>' ); |
| 53 | + |
52 | 54 | $wgOut->addWikiMsg( 'poll-list-current' ); |
53 | 55 | $wgOut->addHtml( Xml::openElement( 'table' ) ); |
54 | 56 | $wgOut->addHtml( '<tr><th>'.wfMsg( 'poll-question' ).'</th><th>'.wfMsg( 'poll-dis' ).'</th></tr>' ); |
55 | 57 | |
56 | 58 | 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>' ); |
58 | 60 | $wgOut->addHtml( '<td>'.$row->dis.'</td></tr>' ); |
59 | 61 | } |
60 | 62 | |
— | — | @@ -166,6 +168,7 @@ |
167 | 169 | 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis ) ); |
168 | 170 | |
169 | 171 | $wgOut->addWikiMsg( 'poll-create-pass' ); |
| 172 | + $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
170 | 173 | } |
171 | 174 | else { |
172 | 175 | $wgOut->addWikiMsg( 'poll-create-fields-error' ); |
— | — | @@ -189,13 +192,20 @@ |
190 | 193 | $vote = $_POST['vote']; |
191 | 194 | $uid = $wgUser->getId(); |
192 | 195 | |
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; |
195 | 198 | |
| 199 | + while( $row = $dbr->fetchObject( $query ) ) { |
| 200 | + if($row->uid != "") { |
| 201 | + $num++; |
| 202 | + } |
| 203 | + } |
| 204 | + |
196 | 205 | if( $num == 0 ) { |
197 | 206 | $dbw->insert( 'poll_answer', array( 'pid' => $pid, 'uid' => $uid, 'vote' => $vote ) ); |
198 | 207 | |
199 | 208 | $wgOut->addWikiMsg( 'poll-vote-pass' ); |
| 209 | + $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
200 | 210 | } |
201 | 211 | else { |
202 | 212 | $wgOut->addWikiMsg( 'poll-vote-already-error' ); |
Index: trunk/extensions/Poll/Poll.i18n.php |
— | — | @@ -32,7 +32,9 @@ |
33 | 33 | 'poll-list-current' => '== Current Polls ==', |
34 | 34 | 'poll-create-pass' => 'Poll created!', |
35 | 35 | '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!', |
37 | 39 | ); |
38 | 40 | |
39 | 41 | /** German (Deutsch) |
— | — | @@ -59,5 +61,7 @@ |
60 | 62 | 'poll-list-current' => '== Aktuelle Umfragen ==', |
61 | 63 | 'poll-create-pass' => 'Umfrage erfolgreich erstellt!', |
62 | 64 | '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!', |
64 | 68 | ); |