r50594 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50593‎ | r50594 | r50595 >
Date:17:52, 14 May 2009
Author:jan
Status:deferred
Tags:
Comment:
* Add some links
* Add new field
Modified paths:
  • /trunk/extensions/Poll/Poll.php (modified) (history)
  • /trunk/extensions/Poll/Poll_body.php (modified) (history)
  • /trunk/extensions/Poll/archives/patch-user.sql (added) (history)

Diff [purge]

Index: trunk/extensions/Poll/archives/patch-user.sql
@@ -0,0 +1,6 @@
 2+-- (c) Jan Luca, 2009, CC by-sa 3.0 or later
 3+-- Table structure for table `Poll`
 4+-- Replace /*$wgDBprefix*/ with the proper prefix
 5+
 6+ALTER TABLE /*$wgDBprefix*/poll_answer
 7+ADD `user` VARCHAR( 255 ) NOT NULL ;
\ No newline at end of file
Property changes on: trunk/extensions/Poll/archives/patch-user.sql
___________________________________________________________________
Name: svn:eol-style
18 + native
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 == "" OR $action="list" ) {
 28+ if ( $action == "" OR $action == "list" ) {
2929 $this->make_list();
3030 }
3131
@@ -72,9 +72,11 @@
7373 $controll_create_blocked = $wgUser->isBlocked();
7474 if ( $controll_create_right != true ) {
7575 $wgOut->addWikiMsg( 'poll-create-right-error' );
 76+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
7677 }
7778 elseif ( $controll_create_blocked == true ) {
7879 $wgOut->addWikiMsg( 'poll-create-block-error' );
 80+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
7981 }
8082 else {
8183 $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $wgTitle->getFullURL('action=submit') ) ) );
@@ -102,9 +104,11 @@
103105 $controll_vote_blocked = $wgUser->isBlocked();
104106 if ( $controll_vote_right != true ) {
105107 $wgOut->addWikiMsg( 'poll-vote-right-error' );
 108+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
106109 }
107110 elseif ( $controll_vote_blocked == true ) {
108111 $wgOut->addWikiMsg( 'poll-vote-block-error' );
 112+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
109113 }
110114 else {
111115 $dbr = wfGetDB( DB_SLAVE );
@@ -136,7 +140,7 @@
137141 }
138142
139143 public function submit( $pid ) {
140 - global $wgRequest, $wgOut, $wgUser;
 144+ global $wgRequest, $wgOut, $wgUser, $wgTitle;
141145
142146 $type = $_POST['type'];
143147
@@ -145,9 +149,11 @@
146150 $controll_create_blocked = $wgUser->isBlocked();
147151 if ( $controll_create_right != true ) {
148152 $wgOut->addWikiMsg( 'poll-create-right-error' );
 153+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
149154 }
150155 elseif ( $controll_create_blocked == true ) {
151156 $wgOut->addWikiMsg( 'poll-create-block-error' );
 157+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
152158 }
153159
154160 else {
@@ -172,6 +178,7 @@
173179 }
174180 else {
175181 $wgOut->addWikiMsg( 'poll-create-fields-error' );
 182+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
176183 }
177184 }
178185 }
@@ -181,15 +188,18 @@
182189 $controll_vote_blocked = $wgUser->isBlocked();
183190 if ( $controll_vote_right != true ) {
184191 $wgOut->addWikiMsg( 'poll-vote-right-error' );
 192+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
185193 }
186194 elseif ( $controll_vote_blocked == true ) {
187195 $wgOut->addWikiMsg( 'poll-vote-block-error' );
 196+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
188197 }
189198
190199 else {
191200 $dbw = wfGetDB( DB_MASTER );
192201 $dbr = wfGetDB( DB_SLAVE );
193202 $vote = $_POST['vote'];
 203+ $user = $wgUser->getName();
194204 $uid = $wgUser->getId();
195205
196206 $query = $dbr->select( 'poll_answer', 'uid', 'uid = ' . $uid);
@@ -202,13 +212,14 @@
203213 }
204214
205215 if( $num == 0 ) {
206 - $dbw->insert( 'poll_answer', array( 'pid' => $pid, 'uid' => $uid, 'vote' => $vote ) );
 216+ $dbw->insert( 'poll_answer', array( 'pid' => $pid, 'uid' => $uid, 'vote' => $vote, 'user' => $user ) );
207217
208218 $wgOut->addWikiMsg( 'poll-vote-pass' );
209219 $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
210220 }
211221 else {
212222 $wgOut->addWikiMsg( 'poll-vote-already-error' );
 223+ $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
213224 }
214225 }
215226 }
Index: trunk/extensions/Poll/Poll.php
@@ -67,6 +67,7 @@
6868 $wgExtNewFields[] = array( 'poll', 'creater', "$base/archives/patch-creater.sql" ); // Add creater
6969 $wgExtNewFields[] = array( 'poll', 'dis', "$base/archives/patch-dis.sql" ); // Add dis
7070 $wgExtNewTables[] = array( 'poll_answer', "$base/archives/Poll-answer.sql" ); // Initial answer tables
 71+ $wgExtNewFields[] = array( 'poll_answer', 'user', "$base/archives/patch-user.sql" ); // Add dis
7172 }
7273 return true;
7374 }

Status & tagging log