Index: trunk/extensions/Poll/Poll_body.php |
— | — | @@ -20,17 +20,22 @@ |
21 | 21 | wfLoadExtensionMessages( 'Poll' ); |
22 | 22 | |
23 | 23 | $this->setHeaders(); |
| 24 | + |
| 25 | + $skin = $wgUser->getSkin(); |
24 | 26 | |
25 | 27 | # Get request data. Default the action to list if none given |
26 | 28 | $action = htmlentities( $wgRequest->getText( 'action', 'list' ) ); |
27 | 29 | $id = htmlentities( $wgRequest->getText( 'id' ) ); |
| 30 | + $page = htmlentities( $wgRequest->getText( 'page', 1 ) ); |
28 | 31 | |
29 | 32 | # Blocked users can't use this except to list |
30 | 33 | if( $wgUser->isBlocked() && $action != 'list' ) { |
31 | 34 | $wgOut->addWikiMsg( 'poll-create-block-error' ); |
32 | | - $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
| 35 | + $wgOut->addHtml( $skin->link( $this->getTitle(), wfMsg('poll-back'), array(), array( 'action' => 'list' ) ) ); |
33 | 36 | return; |
34 | 37 | } |
| 38 | + |
| 39 | + $this->start(); |
35 | 40 | |
36 | 41 | # Handle the action |
37 | 42 | switch( $action ) { |
— | — | @@ -44,11 +49,42 @@ |
45 | 50 | case 'submit': |
46 | 51 | $this->$action( $id ); |
47 | 52 | break; |
| 53 | + case 'list_old': |
| 54 | + $this->list_old( $page ); |
| 55 | + break; |
48 | 56 | case 'list': |
49 | 57 | default: |
50 | 58 | $this->make_list(); |
51 | 59 | } |
52 | 60 | } |
| 61 | + |
| 62 | + public function start() { |
| 63 | + $dbr = wfGetDB( DB_SLAVE ); |
| 64 | + $dbw = wfGetDB( DB_MASTER ); |
| 65 | + |
| 66 | + $query_log = $dbr->select( 'poll_start_log', 'time', '', 'Database::select', array( 'ORDER BY' => 'time DESC', 'LIMIT' => '1' ) ); |
| 67 | + while( $row = $dbr->fetchObject( $query_log ) ) { |
| 68 | + $log_time = $row->time; |
| 69 | + } |
| 70 | + if( !isset( $log_time ) OR $log_time == "" ) $log_time = 0; |
| 71 | + $log_diff = time() - $log_time; |
| 72 | + if( $log_diff <= 3600 ) return; |
| 73 | + |
| 74 | + $query = $dbr->select( 'poll', 'id, starttime, runtime' ); |
| 75 | + |
| 76 | + while( $row = $dbr->fetchObject( $query ) ) { |
| 77 | + $starttime = $row->starttime; |
| 78 | + $runtime = $row->runtime; |
| 79 | + $id = $row->id; |
| 80 | + $sum = $starttime + $runtime; |
| 81 | + |
| 82 | + if( $sum <= time() ) { |
| 83 | + $dbw->update( 'poll', array( 'end' => 1 ), array( 'id' => $id ) ); |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + $dbw->insert( 'poll_start_log', array( 'time' => time() ) ); |
| 88 | + } |
53 | 89 | |
54 | 90 | // This function create a list with all polls that are in the DB |
55 | 91 | public function make_list() { |
— | — | @@ -56,11 +92,14 @@ |
57 | 93 | $wgOut->setPagetitle( wfMsg( 'poll' ) ); |
58 | 94 | |
59 | 95 | $dbr = wfGetDB( DB_SLAVE ); |
60 | | - $query = $dbr->select( 'poll', 'question, dis, id' ); |
| 96 | + $query = $dbr->select( 'poll', 'question, dis, id', array( 'end' => 0 ) ); |
| 97 | + |
| 98 | + $wgOut->addHtml( '<ul>' ); |
| 99 | + $wgOut->addHtml( '<li><a href="'.$this->getTitle()->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a></li>' ); |
| 100 | + $wgOut->addHtml( '<li><a href="'.$this->getTitle()->getFullURL('action=list_old').'">'.wfMsg( 'poll-list-old' ).'</a></li>' ); |
| 101 | + $wgOut->addHtml( '</ul>' ); |
61 | 102 | |
62 | | - $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a>' ); |
63 | | - |
64 | | - $wgOut->addWikiMsg( 'poll-list-current' ); |
| 103 | + $wgOut->addWikiText( '== '.wfMsg( 'poll-list-current' ).' ==' ); |
65 | 104 | $wgOut->addHtml( Xml::openElement( 'table' ) ); |
66 | 105 | $wgOut->addHtml( '<tr><th>'.wfMsg( 'poll-question' ).'</th><th>'.wfMsg( 'poll-dis' ).'</th><th> </th></tr>' ); |
67 | 106 | |
— | — | @@ -73,7 +112,40 @@ |
74 | 113 | $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
75 | 114 | |
76 | 115 | } |
| 116 | + |
| 117 | + public function list_old( $page ) { |
| 118 | + global $wgOut; |
| 119 | + $wgOut->setPagetitle( wfMsg( 'poll' ) ); |
| 120 | + |
| 121 | + if( $page > 1 ) { |
| 122 | + $page *= 50; |
| 123 | + $limit = $page.', 50'; |
| 124 | + } |
| 125 | + else { |
| 126 | + $limit = '50'; |
| 127 | + } |
77 | 128 | |
| 129 | + $dbr = wfGetDB( DB_SLAVE ); |
| 130 | + $query = $dbr->select( 'poll', 'question, dis, id', array( 'end' => 1 ), 'Database::select', array( 'ORDER BY' => 'id DESC', 'LIMIT' => $limit ) ); |
| 131 | + |
| 132 | + $wgOut->addHtml( '<ul>' ); |
| 133 | + $wgOut->addHtml( '<li><a href="'.$this->getTitle()->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a></li>' ); |
| 134 | + $wgOut->addHtml( '<li><a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg( 'poll-list-current' ).'</a></li>' ); |
| 135 | + $wgOut->addHtml( '</ul>' ); |
| 136 | + |
| 137 | + $wgOut->addWikiText( '== '.wfMsg( 'poll-list-old' ).' ==' ); |
| 138 | + $wgOut->addHtml( Xml::openElement( 'table' ) ); |
| 139 | + $wgOut->addHtml( '<tr><th>'.wfMsg( 'poll-question' ).'</th><th>'.wfMsg( 'poll-dis' ).'</th><th> </th></tr>' ); |
| 140 | + |
| 141 | + while( $row = $dbr->fetchObject( $query ) ) { |
| 142 | + $wgOut->addHtml( '<tr><td><a href="'.$this->getTitle()->getFullURL( 'action=score&id='.$row->id ).'">'.htmlentities( $row->question, ENT_QUOTES, "UTF-8" ).'</a></td>' ); |
| 143 | + $wgOut->addHtml( '<td>'.htmlentities( $row->dis, ENT_QUOTES, "UTF-8" ).'</td>' ); |
| 144 | + } |
| 145 | + |
| 146 | + $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
| 147 | + |
| 148 | + } |
| 149 | + |
78 | 150 | // This function create a interface for create new polls |
79 | 151 | public function create() { |
80 | 152 | global $wgOut, $wgUser; |
— | — | @@ -100,6 +172,14 @@ |
101 | 173 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 5:</td><td>'.Xml::input('poll_alternative_5').'</td></tr>' ); |
102 | 174 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 6:</td><td>'.Xml::input('poll_alternative_6').'</td></tr>' ); |
103 | 175 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-dis' ).':</td><td>'.Xml::textarea('dis', '').'</td></tr>' ); |
| 176 | + $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-runtime' ).'</td><td><select name="runtime" size="1">' ); |
| 177 | + $wgOut->addHtml( Xml::option( wfMsg( 'poll-runtime-1-day' ), 86400 ) ); |
| 178 | + $wgOut->addHtml( Xml::option( wfMsg( 'poll-runtime-2-days' ), 172800 ) ); |
| 179 | + $wgOut->addHtml( Xml::option( wfMsg( 'poll-runtime-1-week' ), 604800 ) ); |
| 180 | + $wgOut->addHtml( Xml::option( wfMsg( 'poll-runtime-2-weeks' ), 1209600 ) ); |
| 181 | + $wgOut->addHtml( Xml::option( wfMsg( 'poll-runtime-3-weeks' ), 1814400 ) ); |
| 182 | + $wgOut->addHtml( Xml::option( wfMsg( 'poll-runtime-4-weeks' ), 2419200 ) ); |
| 183 | + $wgOut->addHtml( '</select></td></tr>' ); |
104 | 184 | $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
105 | 185 | $wgOut->addHtml( Xml::check('allow_more').' '.wfMsg( 'poll-create-allow-more' ).'<br />' ); |
106 | 186 | $wgOut->addHtml( Xml::check('allow_ip', $ip_checked).' '.wfMsg( 'poll-create-allow-ip' ).'<br />' ); |
— | — | @@ -175,98 +255,104 @@ |
176 | 256 | |
177 | 257 | // This function create a score for the polls |
178 | 258 | public function score( $sid ) { |
179 | | - global $wgOut; |
| 259 | + global $wgOut, $wgUser; |
180 | 260 | |
181 | 261 | $wgOut->setPagetitle( wfMsg( 'poll-title-score' ) ); |
182 | | - |
183 | | - $dbr = wfGetDB( DB_SLAVE ); |
184 | | - $query = $dbr->select( 'poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6, creater, multi', array( 'id' => $sid ) ); |
185 | | - |
186 | | - while( $row = $dbr->fetchObject( $query ) ) { |
187 | | - $question = htmlentities( $row->question, ENT_QUOTES, 'UTF-8' ); |
188 | | - $alternative_1 = htmlentities( $row->alternative_1, ENT_QUOTES, 'UTF-8' ); |
189 | | - $alternative_2 = htmlentities( $row->alternative_2, ENT_QUOTES, 'UTF-8' ); |
190 | | - $alternative_3 = htmlentities( $row->alternative_3, ENT_QUOTES, 'UTF-8' ); |
191 | | - $alternative_4 = htmlentities( $row->alternative_4, ENT_QUOTES, 'UTF-8' ); |
192 | | - $alternative_5 = htmlentities( $row->alternative_5, ENT_QUOTES, 'UTF-8' ); |
193 | | - $alternative_6 = htmlentities( $row->alternative_6, ENT_QUOTES, 'UTF-8' ); |
194 | | - $creater = htmlentities( $row->creater, ENT_QUOTES, 'UTF-8' ); |
195 | | - $multi = $row->multi; |
196 | | - } |
197 | 262 | |
198 | | - if( !isset($question) OR $question == "" ) { |
199 | | - $wgOut->addWikiMsg( 'poll-invalid-id' ); |
| 263 | + if ( !$wgUser->isAllowed( 'poll-score' ) ) { |
| 264 | + $wgOut->addWikiMsg( 'poll-score-right-error' ); |
200 | 265 | $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
201 | | - return; |
202 | 266 | } |
| 267 | + else { |
| 268 | + $dbr = wfGetDB( DB_SLAVE ); |
| 269 | + $query = $dbr->select( 'poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6, creater, multi', array( 'id' => $sid ) ); |
| 270 | + |
| 271 | + while( $row = $dbr->fetchObject( $query ) ) { |
| 272 | + $question = htmlentities( $row->question, ENT_QUOTES, 'UTF-8' ); |
| 273 | + $alternative_1 = htmlentities( $row->alternative_1, ENT_QUOTES, 'UTF-8' ); |
| 274 | + $alternative_2 = htmlentities( $row->alternative_2, ENT_QUOTES, 'UTF-8' ); |
| 275 | + $alternative_3 = htmlentities( $row->alternative_3, ENT_QUOTES, 'UTF-8' ); |
| 276 | + $alternative_4 = htmlentities( $row->alternative_4, ENT_QUOTES, 'UTF-8' ); |
| 277 | + $alternative_5 = htmlentities( $row->alternative_5, ENT_QUOTES, 'UTF-8' ); |
| 278 | + $alternative_6 = htmlentities( $row->alternative_6, ENT_QUOTES, 'UTF-8' ); |
| 279 | + $creater = htmlentities( $row->creater, ENT_QUOTES, 'UTF-8' ); |
| 280 | + $multi = $row->multi; |
| 281 | + } |
203 | 282 | |
204 | | - if($multi != 1) { |
205 | | - $query_1 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '1', 'pid' => $sid ) ); |
206 | | - $query_2 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '2', 'pid' => $sid ) ); |
207 | | - $query_3 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '3', 'pid' => $sid ) ); |
208 | | - $query_4 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '4', 'pid' => $sid ) ); |
209 | | - $query_5 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '5', 'pid' => $sid ) ); |
210 | | - $query_6 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '6', 'pid' => $sid ) ); |
| 283 | + if( !isset($question) OR $question == "" ) { |
| 284 | + $wgOut->addWikiMsg( 'poll-invalid-id' ); |
| 285 | + $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
| 286 | + return; |
| 287 | + } |
| 288 | + |
| 289 | + if($multi != 1) { |
| 290 | + $query_1 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '1', 'pid' => $sid ) ); |
| 291 | + $query_2 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '2', 'pid' => $sid ) ); |
| 292 | + $query_3 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '3', 'pid' => $sid ) ); |
| 293 | + $query_4 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '4', 'pid' => $sid ) ); |
| 294 | + $query_5 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '5', 'pid' => $sid ) ); |
| 295 | + $query_6 = $dbr->select( 'poll_answer', 'uid', array( 'vote' => '6', 'pid' => $sid ) ); |
211 | 296 | |
212 | | - $query_num_1 = $dbr->numRows( $query_1 ); |
213 | | - $query_num_2 = $dbr->numRows( $query_2 ); |
214 | | - $query_num_3 = $dbr->numRows( $query_3 ); |
215 | | - $query_num_4 = $dbr->numRows( $query_4 ); |
216 | | - $query_num_5 = $dbr->numRows( $query_5 ); |
217 | | - $query_num_6 = $dbr->numRows( $query_6 ); |
218 | | - } |
| 297 | + $query_num_1 = $dbr->numRows( $query_1 ); |
| 298 | + $query_num_2 = $dbr->numRows( $query_2 ); |
| 299 | + $query_num_3 = $dbr->numRows( $query_3 ); |
| 300 | + $query_num_4 = $dbr->numRows( $query_4 ); |
| 301 | + $query_num_5 = $dbr->numRows( $query_5 ); |
| 302 | + $query_num_6 = $dbr->numRows( $query_6 ); |
| 303 | + } |
219 | 304 | |
220 | | - if($multi == 1) { |
221 | | - $query_num_1 = 0; |
222 | | - $query_num_2 = 0; |
223 | | - $query_num_3 = 0; |
224 | | - $query_num_4 = 0; |
225 | | - $query_num_5 = 0; |
226 | | - $query_num_6 = 0; |
| 305 | + if($multi == 1) { |
| 306 | + $query_num_1 = 0; |
| 307 | + $query_num_2 = 0; |
| 308 | + $query_num_3 = 0; |
| 309 | + $query_num_4 = 0; |
| 310 | + $query_num_5 = 0; |
| 311 | + $query_num_6 = 0; |
227 | 312 | |
228 | | - $query_multi = $dbr->select( 'poll_answer', 'vote', array( 'pid' => $sid ) ); |
229 | | - while( $row = $dbr->fetchObject( $query_multi ) ) { |
230 | | - $vote = $row->vote; |
231 | | - $vote = explode("|", $vote); |
| 313 | + $query_multi = $dbr->select( 'poll_answer', 'vote', array( 'pid' => $sid ) ); |
| 314 | + while( $row = $dbr->fetchObject( $query_multi ) ) { |
| 315 | + $vote = $row->vote; |
| 316 | + $vote = explode("|", $vote); |
232 | 317 | |
233 | | - if($vote[0] == "1") { $query_num_1++; } |
234 | | - if($vote[1] == "1") { $query_num_2++; } |
235 | | - if($vote[2] == "1") { $query_num_3++; } |
236 | | - if($vote[3] == "1") { $query_num_4++; } |
237 | | - if($vote[4] == "1") { $query_num_5++; } |
238 | | - if($vote[5] == "1") { $query_num_6++; } |
| 318 | + if($vote[0] == "1") { $query_num_1++; } |
| 319 | + if($vote[1] == "1") { $query_num_2++; } |
| 320 | + if($vote[2] == "1") { $query_num_3++; } |
| 321 | + if($vote[3] == "1") { $query_num_4++; } |
| 322 | + if($vote[4] == "1") { $query_num_5++; } |
| 323 | + if($vote[5] == "1") { $query_num_6++; } |
| 324 | + } |
239 | 325 | } |
240 | | - } |
241 | 326 | |
242 | | - $query_other = $dbr->select( 'poll_answer', 'vote_other', array( 'pid' => $sid, 'isset_vote_other' => 1 ) ); |
243 | | - $score_other = array( ); |
244 | | - while( $row = $dbr->fetchObject( $query_other ) ) { |
245 | | - if( !isset($score_other[$row->vote_other]['first']) ) { |
246 | | - $score_other[$row->vote_other]['first'] = 0; |
247 | | - $score_other[$row->vote_other]['number'] = 1; |
248 | | - continue; |
| 327 | + $query_other = $dbr->select( 'poll_answer', 'vote_other', array( 'pid' => $sid, 'isset_vote_other' => 1 ) ); |
| 328 | + $score_other = array( ); |
| 329 | + while( $row = $dbr->fetchObject( $query_other ) ) { |
| 330 | + if( !isset($score_other[$row->vote_other]['first']) ) { |
| 331 | + $score_other[$row->vote_other]['first'] = 0; |
| 332 | + $score_other[$row->vote_other]['number'] = 1; |
| 333 | + continue; |
| 334 | + } |
| 335 | + $score_other[$row->vote_other]['number']++; |
249 | 336 | } |
250 | | - $score_other[$row->vote_other]['number']++; |
| 337 | + $score_other_out = ""; |
| 338 | + foreach($score_other as $name => $value) { |
| 339 | + $score_other_out .= '<tr><td>'.htmlentities( $name, ENT_QUOTES, 'UTF-8' ).'</td><td>'.htmlentities( $value['number'], ENT_QUOTES, 'UTF-8' ).'</td></tr>'; |
| 340 | + } |
| 341 | + |
| 342 | + $wgOut->addHtml( Xml::openElement( 'table' ) ); |
| 343 | + $wgOut->addHtml( '<tr><th><center>'.$question.'</center></th></tr>' );; |
| 344 | + $wgOut->addHtml( '<tr><td>'.$alternative_1.'</td><td>'.$query_num_1.'</td></tr>' ); |
| 345 | + $wgOut->addHtml( '<tr><td>'.$alternative_2.'</td><td>'.$query_num_2.'</td></tr>' ); |
| 346 | + if($alternative_3 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_3.'</td><td>'.$query_num_3.'</td></tr>' ); } |
| 347 | + if($alternative_4 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_4.'</td><td>'.$query_num_4.'</td></tr>' ); } |
| 348 | + if($alternative_5 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_5.'</td><td>'.$query_num_5.'</td></tr>' ); } |
| 349 | + if($alternative_6 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_6.'</td><td>'.$query_num_6.'</td></tr>' ); } |
| 350 | + if($score_other_out != "") { $wgOut->addHtml( '<tr><td colspan="2">'.wfMsg( 'poll-vote-other' ).' </td></tr>'. $score_other_out ); } |
| 351 | + $wgOut->addHtml( '<tr><td>' ); |
| 352 | + $wgOut->addWikiText( '<small>'.wfMsg( 'poll-score-created', $creater ).'</small>' ); |
| 353 | + $wgOut->addHtml( '</td></tr>' ); |
| 354 | + $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
| 355 | + $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
251 | 356 | } |
252 | | - $score_other_out = ""; |
253 | | - foreach($score_other as $name => $value) { |
254 | | - $score_other_out .= '<tr><td>'.htmlentities( $name, ENT_QUOTES, 'UTF-8' ).'</td><td>'.htmlentities( $value['number'], ENT_QUOTES, 'UTF-8' ).'</td></tr>'; |
255 | | - } |
256 | | - |
257 | | - $wgOut->addHtml( Xml::openElement( 'table' ) ); |
258 | | - $wgOut->addHtml( '<tr><th><center>'.$question.'</center></th></tr>' );; |
259 | | - $wgOut->addHtml( '<tr><td>'.$alternative_1.'</td><td>'.$query_num_1.'</td></tr>' ); |
260 | | - $wgOut->addHtml( '<tr><td>'.$alternative_2.'</td><td>'.$query_num_2.'</td></tr>' ); |
261 | | - if($alternative_3 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_3.'</td><td>'.$query_num_3.'</td></tr>' ); } |
262 | | - if($alternative_4 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_4.'</td><td>'.$query_num_4.'</td></tr>' ); } |
263 | | - if($alternative_5 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_5.'</td><td>'.$query_num_5.'</td></tr>' ); } |
264 | | - if($alternative_6 != "") { $wgOut->addHtml( '<tr><td>'.$alternative_6.'</td><td>'.$query_num_6.'</td></tr>' ); } |
265 | | - if($score_other_out != "") { $wgOut->addHtml( '<tr><td colspan="2">'.wfMsg( 'poll-vote-other' ).' </td></tr>'. $score_other_out ); } |
266 | | - $wgOut->addHtml( '<tr><td>' ); |
267 | | - $wgOut->addWikiText( '<small>'.wfMsg( 'poll-score-created', $creater ).'</small>' ); |
268 | | - $wgOut->addHtml( '</td></tr>' ); |
269 | | - $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
270 | | - $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' ); |
271 | 357 | } |
272 | 358 | |
273 | 359 | // This function create a interfache for deleting polls |
— | — | @@ -378,11 +464,13 @@ |
379 | 465 | $multi = ($wgRequest->getVal( 'allow_more' ) == 1)? 1 : 0; |
380 | 466 | $user = $wgUser->getName(); |
381 | 467 | $ip = ($wgRequest->getVal( 'allow_ip' ) == 1)? 1 : 0; |
| 468 | + $runtime = $wgRequest->getVal('runtime'); |
382 | 469 | |
383 | 470 | if($question != "" && $alternative_1 != "" && $alternative_2 != "") { |
384 | 471 | $dbw->insert( 'poll', array( 'question' => $question, 'alternative_1' => $alternative_1, 'alternative_2' => $alternative_2, |
385 | 472 | 'alternative_3' => $alternative_3, 'alternative_4' => $alternative_4, 'alternative_5' => $alternative_5, |
386 | | - 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis, 'multi' => $multi, 'ip' => $ip ) ); |
| 473 | + 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis, 'multi' => $multi, 'ip' => $ip, |
| 474 | + 'starttime' => time(), 'runtime' => $runtime ) ); |
387 | 475 | |
388 | 476 | $log = new LogPage( "poll" ); |
389 | 477 | $title = $this->getTitle(); |
— | — | @@ -422,12 +510,12 @@ |
423 | 511 | } |
424 | 512 | |
425 | 513 | if($ip == 1) { |
426 | | - $query = $dbw->select( 'poll_answer', 'uid', array( 'uid' => $uid, 'pid' => $pid, 'ip' => $user )); |
427 | | - $num = $dbw->numRows( $query ); |
| 514 | + $query = $dbr->select( 'poll_answer', 'uid', array( 'uid' => $uid, 'pid' => $pid, 'ip' => $user )); |
| 515 | + $num = $dbr->numRows( $query ); |
428 | 516 | } |
429 | 517 | else { |
430 | | - $query = $dbw->select( 'poll_answer', 'uid', array( 'uid' => $uid, 'pid' => $pid )); |
431 | | - $num = $dbw->numRows( $query ); |
| 518 | + $query = $dbr->select( 'poll_answer', 'uid', array( 'uid' => $uid, 'pid' => $pid )); |
| 519 | + $num = $dbr->numRows( $query ); |
432 | 520 | } |
433 | 521 | |
434 | 522 | if($multi != 1) { |
Index: trunk/extensions/Poll/Poll.i18n.php |
— | — | @@ -19,15 +19,17 @@ |
20 | 20 | 'poll-title-score' => 'Score', |
21 | 21 | 'poll-create-right-error' => 'You are not allowed to create a new poll(needed right: poll-create)', |
22 | 22 | 'poll-vote-right-error' => 'You are not allowed to vote(needed right: poll-vote)', |
| 23 | + 'poll-score-right-error' => 'You are not allowed to view the score(needed right: poll-score)', |
23 | 24 | 'poll-alternative' => 'Alternative', |
24 | 25 | 'poll-question' => 'Question', |
25 | 26 | 'poll-submit' => 'Submit', |
26 | 27 | 'right-poll-create' => 'Create Poll', |
27 | 28 | 'right-poll-vote' => 'Vote by a Poll', |
28 | 29 | 'right-poll-admin' => 'Manage the Polls', |
| 30 | + 'right-poll-score' => 'View the score of the Polls', |
29 | 31 | 'poll-create-fields-error' => 'The fields Question, Alternative 1 and Alternative 2 must be set', |
30 | 32 | 'poll-dis' => 'Description', |
31 | | - 'poll-list-current' => '== Current Polls ==', |
| 33 | + 'poll-list-current' => 'Current Polls', |
32 | 34 | 'poll-create-pass' => 'Poll created!', |
33 | 35 | 'poll-vote-pass' => 'Voted!', |
34 | 36 | 'poll-vote-already-error' => 'You has already voted!', |
— | — | @@ -60,7 +62,15 @@ |
61 | 63 | 'poll-vote-other' => 'Other answers:', |
62 | 64 | 'poll-ip-error' => 'Unregistered person can not vote at this poll!', |
63 | 65 | 'poll-create-allow-ip' => 'Allow unregistered users to vote', |
64 | | - 'poll-vote-error-ip-change' => 'Unregistered users can not change his vote!', |
| 66 | + 'poll-vote-error-ip-change' => 'Someone has already voted with your IP and unregistered users can not change his vote!', |
| 67 | + 'poll-runtime' => 'Runtime:', |
| 68 | + 'poll-runtime-1-day' => '1 Day', |
| 69 | + 'poll-runtime-2-days' => '2 Days', |
| 70 | + 'poll-runtime-1-week' => '1 Week', |
| 71 | + 'poll-runtime-2-weeks' => '2 Weeks', |
| 72 | + 'poll-runtime-3-weeks' => '3 Weeks', |
| 73 | + 'poll-runtime-4-weeks' => '4 Weeks', |
| 74 | + 'poll-list-old' => 'Old Polls', |
65 | 75 | ); |
66 | 76 | |
67 | 77 | /** German (Deutsch) |
— | — | @@ -74,15 +84,17 @@ |
75 | 85 | 'poll-title-score' => 'Auswertung', |
76 | 86 | 'poll-create-right-error' => 'Leider darfst du keine neue Umfrage erstellen(benötige Gruppenberechttigung: poll-create)', |
77 | 87 | 'poll-vote-right-error' => 'Leider darfst du nicht abstimmen(benötige Gruppenberechttigung: poll-vote)', |
| 88 | + 'poll-score-right-error' => 'Leider darfst du nicht die Auswertung betrachten(benötige Gruppenberechttigung: poll-score)', |
78 | 89 | 'poll-alternative' => 'Antwortmöglichkeit', |
79 | 90 | 'poll-question' => 'Frage', |
80 | 91 | 'poll-submit' => 'Absenden', |
81 | 92 | 'right-poll-create' => 'Umfrage erstellen', |
82 | 93 | 'right-poll-vote' => 'Bei einer Umfrage abstimmen', |
83 | 94 | 'right-poll-admin' => 'Umfragen verwalten', |
| 95 | + 'right-poll-score' => 'Auswertung der Umfragen betrachten', |
84 | 96 | 'poll-create-fields-error' => 'Die Felder Frage, Antwortmöglichkeit 1 sowie Antwortmöglichkeit 2 müssen ausgefüllt sein', |
85 | 97 | 'poll-dis' => 'Beschreibung', |
86 | | - 'poll-list-current' => '== Aktuelle Umfragen ==', |
| 98 | + 'poll-list-current' => 'Aktuelle Umfragen', |
87 | 99 | 'poll-create-pass' => 'Umfrage erfolgreich erstellt!', |
88 | 100 | 'poll-vote-pass' => 'Erfolgreich abgestimmt!', |
89 | 101 | 'poll-vote-already-error' => 'Du hast bereits abgestimmt!', |
— | — | @@ -115,5 +127,13 @@ |
116 | 128 | 'poll-vote-other' => 'Andere Antworten:', |
117 | 129 | 'poll-ip-error' => 'Nicht registrierte Benutzer können bei dieser Umfrage nicht abstimmen!', |
118 | 130 | 'poll-create-allow-ip' => 'Erlaube nicht registrierten Benutzer abzustimmen', |
119 | | - 'poll-vote-error-ip-change' => 'Leider können nicht registrierten Benutzer ihr Stimme nicht nachträglich ändern!', |
| 131 | + 'poll-vote-error-ip-change' => 'Ihre Stimme wurde nicht gezählt, da mit Ihrer IP-Adresse wurde bereits eine Stimme abgegeben wurde und nicht registierte Benutzer ihre Stimme nicht nachträglich ändern dürfen.', |
| 132 | + 'poll-runtime' => 'Laufzeit:', |
| 133 | + 'poll-runtime-1-day' => '1 Tag', |
| 134 | + 'poll-runtime-2-days' => '2 Tage', |
| 135 | + 'poll-runtime-1-week' => '1 Woche', |
| 136 | + 'poll-runtime-2-weeks' => '2 Wochen', |
| 137 | + 'poll-runtime-3-weeks' => '3 Wochen', |
| 138 | + 'poll-runtime-4-weeks' => '4 Wochen', |
| 139 | + 'poll-list-old' => 'Alte Umfragen', |
120 | 140 | ); |
Index: trunk/extensions/Poll/Poll.php |
— | — | @@ -48,6 +48,10 @@ |
49 | 49 | $wgGroupPermissions['*']['poll-vote'] = false; |
50 | 50 | $wgAvailableRights[] = 'poll-vote'; |
51 | 51 | |
| 52 | +// New right: poll-score |
| 53 | +$wgGroupPermissions['*']['poll-score'] = true; |
| 54 | +$wgAvailableRights[] = 'poll-score'; |
| 55 | + |
52 | 56 | $dir = dirname( __FILE__ ) . '/'; |
53 | 57 | |
54 | 58 | // Infomation about the Special Page "Poll" |
— | — | @@ -82,6 +86,9 @@ |
83 | 87 | $wgExtNewFields[] = array( 'poll_answer', 'user', "$base/archives/patch-user.sql" ); // Add user |
84 | 88 | $wgExtNewFields[] = array( 'poll_answer', 'vote_other', "$base/archives/patch-vote_other.sql" ); // Add vote_other |
85 | 89 | $wgExtNewFields[] = array( 'poll_answer', 'ip', "$base/archives/patch-answer-ip.sql" ); // Add ip |
| 90 | + |
| 91 | + // "poll_start_log"-Table: Time with last run of Poll::start() |
| 92 | + $wgExtNewTables[] = array( 'poll_start_log', "$base/archives/Poll-start-log.sql" ); // Initial start_log tables |
86 | 93 | } |
87 | 94 | return true; |
88 | 95 | } |