r51666 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51665‎ | r51666 | r51667 >
Date:22:54, 9 June 2009
Author:demon
Status:deferred
Tags:
Comment:
Code style tweaks:
* Remove unused globals
* Clean up action handling for readability
* $wgTitle -> $this->getTitle()
* Handle blocking in execute(), rather than duplicating code everywhere.
** Remove now-unnecessary block messages
* Cleaned up a lot of un-needed variables, just use methods directly.
* AND/OR to &&/||
Modified paths:
  • /trunk/extensions/Poll/Poll.i18n.php (modified) (history)
  • /trunk/extensions/Poll/Poll_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Poll/Poll_body.php
@@ -15,62 +15,58 @@
1616 }
1717
1818 public function execute( $par ) {
19 - global $wgRequest, $wgOut;
 19+ global $wgRequest, $wgUser, $wgOut;
2020
2121 wfLoadExtensionMessages( 'Poll' );
2222
2323 $this->setHeaders();
2424
25 - # Get request data from, e.g.
26 - $action = htmlentities( $wgRequest->getText( 'action' ) );
 25+ # Get request data. Default the action to list if none given
 26+ $action = htmlentities( $wgRequest->getText( 'action', 'list' ) );
2727 $id = htmlentities( $wgRequest->getText( 'id' ) );
2828
29 - if ( $action == "" OR $action == "list" ) {
30 - $this->make_list();
 29+ # Blocked users can't use this except to list
 30+ if( $wgUser->isBlocked() && $action != 'list' ) {
 31+ $wgOut->addWikiMsg( 'poll-create-block-error' );
 32+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 33+ return;
3134 }
3235
33 - if ( $action == "create" ) {
34 - $this->create();
 36+ # Handle the action
 37+ switch( $action ) {
 38+ case 'create':
 39+ $this->create();
 40+ break;
 41+ case 'vote':
 42+ case 'score':
 43+ case 'change':
 44+ case 'delete':
 45+ case 'submit':
 46+ $this->$action( $id );
 47+ break;
 48+ case 'list':
 49+ default:
 50+ $this->make_list();
3551 }
36 -
37 - if ( $action == "vote" ) {
38 - $this->vote( $id );
39 - }
40 -
41 - if ( $action == "score" ) {
42 - $this->score( $id );
43 - }
44 -
45 - if ( $action == "change" ) {
46 - $this->change( $id );
47 - }
48 -
49 - if ( $action == "delete" ) {
50 - $this->delete( $id );
51 - }
52 -
53 - if ( $action == "submit" ) {
54 - $this->submit( $id );
55 - }
5652 }
5753
5854 public function make_list() {
59 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 55+ global $wgOut;
6056 $wgOut->setPagetitle( wfMsg( 'poll' ) );
6157
6258 $dbr = wfGetDB( DB_SLAVE );
6359 $query = $dbr->select( 'poll', 'question, dis, id' );
6460
65 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a>' );
 61+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=create').'">'.wfMsg( 'poll-create-link' ).'</a>' );
6662
6763 $wgOut->addWikiMsg( 'poll-list-current' );
6864 $wgOut->addHtml( Xml::openElement( 'table' ) );
6965 $wgOut->addHtml( '<tr><th>'.wfMsg( 'poll-question' ).'</th><th>'.wfMsg( 'poll-dis' ).'</th><th>&nbsp;</th></tr>' );
7066
7167 while( $row = $dbr->fetchObject( $query ) ) {
72 - $wgOut->addHtml( '<tr><td><a href="'.$wgTitle->getFullURL( 'action=vote&id='.$row->id ).'">'.htmlentities( $row->question, ENT_QUOTES, "UTF-8" ).'</a></td>' );
 68+ $wgOut->addHtml( '<tr><td><a href="'.$this->getTitle()->getFullURL( 'action=vote&id='.$row->id ).'">'.htmlentities( $row->question, ENT_QUOTES, "UTF-8" ).'</a></td>' );
7369 $wgOut->addHtml( '<td>'.$row->dis.'</td>' );
74 - $wgOut->addHtml( '<td><a href="'.$wgTitle->getFullURL( 'action=score&id='.$row->id ).'">'.wfMsg( 'poll-title-score' ).'</a></td></tr>' );
 70+ $wgOut->addHtml( '<td><a href="'.$this->getTitle()->getFullURL( 'action=score&id='.$row->id ).'">'.wfMsg( 'poll-title-score' ).'</a></td></tr>' );
7571 }
7672
7773 $wgOut->addHtml( Xml::closeElement( 'table' ) );
@@ -78,22 +74,16 @@
7975 }
8076
8177 public function create() {
82 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 78+ global $wgOut, $wgUser;
8379
8480 $wgOut->setPagetitle( wfMsg( 'poll-title-create' ) );
8581
86 - $controll_create_right = $wgUser->isAllowed( 'poll-create' );
87 - $controll_create_blocked = $wgUser->isBlocked();
88 - if ( $controll_create_right != true ) {
 82+ if ( !$wgUser->isAllowed( 'poll-create' ) ) {
8983 $wgOut->addWikiMsg( 'poll-create-right-error' );
90 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 84+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
9185 }
92 - elseif ( $controll_create_blocked == true ) {
93 - $wgOut->addWikiMsg( 'poll-create-block-error' );
94 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
95 - }
9686 else {
97 - $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $wgTitle->getFullURL('action=submit') ) ) );
 87+ $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $this->getTitle()->getFullURL('action=submit') ) ) );
9888 $wgOut->addHtml( Xml::openElement( 'table' ) );
9989 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('question').'</td></tr>' );
10090 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 1:</td><td>'.Xml::input('poll_alternative_1').'</td></tr>' );
@@ -111,25 +101,17 @@
112102 }
113103
114104 public function vote( $vid ) {
115 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 105+ global $wgOut, $wgUser;
116106
117107 $wgOut->setPagetitle( wfMsg( 'poll-title-vote' ) );
118108
119 - $controll_vote_right = $wgUser->isAllowed( 'poll-vote' );
120 - $controll_vote_blocked = $wgUser->isBlocked();
121 - if ( $controll_vote_right != true ) {
 109+ if ( !$wgUser->isAllowed( 'poll-vote' ) ) {
122110 $wgOut->addWikiMsg( 'poll-vote-right-error' );
123 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 111+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
124112 }
125 - elseif ( $controll_vote_blocked == true ) {
126 - $wgOut->addWikiMsg( 'poll-vote-block-error' );
127 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
128 - }
129113 else {
130114 $dbr = wfGetDB( DB_SLAVE );
131115 $query = $dbr->select( 'poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6, creater, multi', array( 'id' => $vid ) );
132 - $poll_admin = $wgUser->isAllowed( 'poll-admin' );
133 - $user = $wgUser->getName();
134116
135117 while( $row = $dbr->fetchObject( $query ) ) {
136118 $question = htmlentities( $row->question, ENT_QUOTES, 'UTF-8' );
@@ -143,7 +125,7 @@
144126 $multi = $row->multi;
145127 }
146128
147 - $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $wgTitle->getFullURL('action=submit&id='.$vid) ) ) );
 129+ $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $this->getTitle()->getFullURL('action=submit&id='.$vid) ) ) );
148130 $wgOut->addHtml( Xml::openElement( 'table' ) );
149131 $wgOut->addHtml( '<tr><th>'.$question.'</th></tr>' );
150132 if( $multi != 1 ) {
@@ -162,20 +144,20 @@
163145 if($alternative_5 != "") { $wgOut->addHtml( '<tr><td>'.Xml::check('vote_5').' '.$alternative_5.'</td></tr>' ); }
164146 if($alternative_6 != "") { $wgOut->addHtml( '<tr><td>'.Xml::check('vote_6').' '.$alternative_6.'</td></tr>' ); }
165147 }
166 - $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).''.Xml::hidden('type', 'vote').''.Xml::hidden('multi', $multi).'</td><td><a href="'.$wgTitle->getFullURL( 'action=score&id='.$vid ).'">'.wfMsg( 'poll-title-score' ).'</a></td></tr>' );
 148+ $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).''.Xml::hidden('type', 'vote').''.Xml::hidden('multi', $multi).'</td><td><a href="'.$this->getTitle()->getFullURL( 'action=score&id='.$vid ).'">'.wfMsg( 'poll-title-score' ).'</a></td></tr>' );
167149 $wgOut->addHtml( '<tr><td>' );
168150 $wgOut->addWikiText( '<small>'.wfMsg( 'poll-score-created', $creater ).'</small>' );
169151 $wgOut->addHtml( '</td></tr>' );
170152 $wgOut->addHtml( Xml::closeElement( 'table' ) );
171 - if( ($poll_admin == true) OR ($creater == $user) ) {
172 - $wgOut->addHtml( wfMsg('poll-administration').' <a href="'.$wgTitle->getFullURL('action=change&id='.$vid).'">'.wfMsg('poll-change').'</a> · <a href="'.$wgTitle->getFullURL('action=delete&id='.$vid).'">'.wfMsg('poll-delete').'</a>' );
 153+ if( $wgUser->isAllowed( 'poll-admin' ) || ($creater == $wgUser->getName()) ) {
 154+ $wgOut->addHtml( wfMsg('poll-administration').' <a href="'.$this->getTitle()->getFullURL('action=change&id='.$vid).'">'.wfMsg('poll-change').'</a> · <a href="'.$this->getTitle()->getFullURL('action=delete&id='.$vid).'">'.wfMsg('poll-delete').'</a>' );
173155 }
174156 $wgOut->addHtml( Xml::closeElement( 'form' ) );
175157 }
176158 }
177159
178160 public function score( $sid ) {
179 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 161+ global $wgOut;
180162
181163 $wgOut->setPagetitle( wfMsg( 'poll-title-score' ) );
182164
@@ -244,11 +226,11 @@
245227 $wgOut->addWikiText( '<small>'.wfMsg( 'poll-score-created', $creater ).'</small>' );
246228 $wgOut->addHtml( '</td></tr>' );
247229 $wgOut->addHtml( Xml::closeElement( 'table' ) );
248 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 230+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
249231 }
250232
251233 public function delete( $did ) {
252 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 234+ global $wgOut;
253235 $wgOut->setPagetitle( wfMsg( 'poll-title-delete' ) );
254236
255237 $dbr = wfGetDB( DB_SLAVE );
@@ -258,20 +240,23 @@
259241 $question = htmlentities( $row->question, ENT_QUOTES, 'UTF-8' );
260242 }
261243
262 - $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $wgTitle->getFullURL('action=submit&id='.$did) ) ) );
263 - $wgOut->addHtml( Xml::check( 'controll_delete' ).' '.wfMsg('poll-delete-question', $question).'<br />' );
264 - $wgOut->addHtml( Xml::submitButton(wfMsg( 'poll-submit' )).' <a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>'.Xml::hidden('type', 'delete') );
265 - $wgOut->addHtml( Xml::closeElement( 'form' ) );
 244+ if( $question ) {
 245+ $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $this->getTitle()->getFullURL('action=submit&id='.$did) ) ) );
 246+ $wgOut->addHtml( Xml::check( 'controll_delete' ).' '.wfMsg('poll-delete-question', $question).'<br />' );
 247+ $wgOut->addHtml( Xml::submitButton(wfMsg( 'poll-submit' )).' <a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>'.Xml::hidden('type', 'delete') );
 248+ $wgOut->addHtml( Xml::closeElement( 'form' ) );
 249+ } else {
 250+ $wgOut->addWikiMsg( 'poll-invalid-id' );
 251+ }
266252 }
267253
268254 public function change($cid) {
269 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 255+ global $wgOut, $wgUser;
270256
271257 $wgOut->setPagetitle( wfMsg( 'poll-title-change' ) );
272258
273259 $dbr = wfGetDB( DB_SLAVE );
274260 $query = $dbr->select( 'poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6, creater, dis', array( 'id' => $cid ) );
275 - $user = $wgUser->getName();
276261
277262 while( $row = $dbr->fetchObject( $query ) ) {
278263 $question = $row->question;
@@ -285,17 +270,12 @@
286271 $dis = $row->dis;
287272 }
288273
289 - $controll_create_blocked = $wgUser->isBlocked();
290 - if ( $user != $creater ) {
 274+ if ( $wgUser->getName() != $creater ) {
291275 $wgOut->addWikiMsg( 'poll-change-right-error' );
292 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 276+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
293277 }
294 - elseif ( $controll_create_blocked == true ) {
295 - $wgOut->addWikiMsg( 'poll-change-block-error' );
296 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
297 - }
298278 else {
299 - $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $wgTitle->getFullURL('action=submit&id='.$cid) ) ) );
 279+ $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => $this->getTitle()->getFullURL('action=submit&id='.$cid) ) ) );
300280 $wgOut->addHtml( Xml::openElement( 'table' ) );
301281 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('question', false, $question).'</td></tr>' );
302282 $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 1:</td><td>'.Xml::input('poll_alternative_1', false, $alternative_1).'</td></tr>' );
@@ -312,22 +292,15 @@
313293 }
314294
315295 public function submit( $pid ) {
316 - global $wgRequest, $wgOut, $wgUser, $wgTitle;
 296+ global $wgRequest, $wgOut, $wgUser;
317297
318298 $type = $wgRequest->getVal('type');
319299
320300 if($type == 'create') {
321 - $controll_create_right = $wgUser->isAllowed( 'poll-create' );
322 - $controll_create_blocked = $wgUser->isBlocked();
323 - if ( $controll_create_right != true ) {
 301+ if ( !$wgUser->isAllowed( 'poll-create' ) ) {
324302 $wgOut->addWikiMsg( 'poll-create-right-error' );
325 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 303+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
326304 }
327 - elseif ( $controll_create_blocked == true ) {
328 - $wgOut->addWikiMsg( 'poll-create-block-error' );
329 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
330 - }
331 -
332305 else {
333306 $dbw = wfGetDB( DB_MASTER );
334307 $question = $wgRequest->getVal('question');
@@ -347,40 +320,31 @@
348321 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis, 'multi' => $multi ) );
349322
350323 $log = new LogPage( "poll" );
351 - $title = $wgTitle;
 324+ $title = $this->getTitle();
352325 $log->addEntry( "poll", $title, wfMsg( 'poll-log-create', "[[User:".htmlentities( $user, ENT_QUOTES, 'UTF-8' )."]]", htmlentities( $question, ENT_QUOTES, 'UTF-8' ) ) );
353326
354327 $wgOut->addWikiMsg( 'poll-create-pass' );
355 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 328+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
356329 }
357330 else {
358331 $wgOut->addWikiMsg( 'poll-create-fields-error' );
359 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 332+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
360333 }
361334 }
362335 }
363336
364337 if($type == 'vote') {
365 - $controll_vote_right = $wgUser->isAllowed( 'poll-vote' );
366 - $controll_vote_blocked = $wgUser->isBlocked();
367 - if ( $controll_vote_right != true ) {
 338+ if ( !$wgUser->isAllowed( 'poll-vote' ) ) {
368339 $wgOut->addWikiMsg( 'poll-vote-right-error' );
369 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 340+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
370341 }
371 - elseif ( $controll_vote_blocked == true ) {
372 - $wgOut->addWikiMsg( 'poll-vote-block-error' );
373 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
374 - }
375 -
376342 else {
377343 $dbw = wfGetDB( DB_MASTER );
378 - $dbr = wfGetDB( DB_SLAVE );
379344 $multi = $wgRequest->getVal('multi');
380 - $user = $wgUser->getName();
381345 $uid = $wgUser->getId();
382346
383 - $query = $dbr->select( 'poll_answer', 'uid', array( 'uid' => $uid, 'pid' => $pid ));
384 - $num = $dbr->numRows( $query );;
 347+ $query = $dbw->select( 'poll_answer', 'uid', array( 'uid' => $uid, 'pid' => $pid ));
 348+ $num = $dbw->numRows( $query );;
385349
386350 if($multi != 1) {
387351 $vote = $wgRequest->getVal('vote');
@@ -403,14 +367,14 @@
404368 }
405369
406370 if( $num == 0 ) {
407 - $dbw->insert( 'poll_answer', array( 'pid' => $pid, 'uid' => $uid, 'vote' => $vote, 'user' => $user ) );
 371+ $dbw->insert( 'poll_answer', array( 'pid' => $pid, 'uid' => $uid, 'vote' => $vote, 'user' => $wgUser->getName() ) );
408372
409373 $wgOut->addWikiMsg( 'poll-vote-pass' );
410 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 374+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
411375 }
412376 else {
413377 $wgOut->addWikiMsg( 'poll-vote-already-error' );
414 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 378+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
415379 }
416380 }
417381 }
@@ -418,28 +382,19 @@
419383 if($type == 'change') {
420384 $dbr = wfGetDB( DB_SLAVE );
421385 $query = $dbr->select( 'poll', 'creater', array( 'id' => $pid ) );
422 - $user = $wgUser->getName();
423386
424387 while( $row = $dbr->fetchObject( $query ) ) {
425388 $creater = htmlentities( $row->creater );
426389 }
427390
428 - $controll_change_right = $wgUser->isAllowed( 'poll-admin' );
429 - $controll_change_blocked = $wgUser->isBlocked();
 391+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
430392
431 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
432 -
433 - if ( ( $creater != $user ) AND ( $controll_change_right == false ) ) {
 393+ if ( ( $creater != $wgUser->getName() ) && !$wgUser->isAllowed( 'poll-admin' ) ) {
434394 $wgOut->addWikiMsg( 'poll-change-right-error' );
435 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 395+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 396+ return;
436397 }
437 -
438 - if ( $controll_change_blocked == true ) {
439 - $wgOut->addWikiMsg( 'poll-change-block-error' );
440 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
441 - }
442 -
443 - if ( ( ( $creater == $user ) OR ( $controll_change_right == true ) ) AND ( $controll_change_blocked != true ) ) {
 398+ if ( ( $creater == $wgUser->getName() ) || $wgUser->isAllowed( 'poll-admin' ) ) {
444399 $dbw = wfGetDB( DB_MASTER );
445400 $question = $wgRequest->getVal('question');
446401 $alternative_1 = $wgRequest->getVal('poll_alternative_1');
@@ -456,55 +411,45 @@
457412 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis ), array( 'id' => $pid ) );
458413
459414 $log = new LogPage( "poll" );
460 - $title = $wgTitle;
 415+ $title = $this->getTitle();
461416 $log->addEntry( "poll", $title, wfMsg( 'poll-log-change', "[[User:".htmlentities( $user, ENT_QUOTES, 'UTF-8' )."]]", htmlentities( $question, ENT_QUOTES, 'UTF-8' ) ) );
462417
463418 $wgOut->addWikiMsg( 'poll-change-pass' );
464 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 419+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
465420 }
466421 }
467422
468423 if($type == 'delete') {
469424 $dbr = wfGetDB( DB_SLAVE );
470425 $query = $dbr->select( 'poll', 'creater, question', array( 'id' => $pid ) );
471 - $user = $wgUser->getName();
472426
473427 while( $row = $dbr->fetchObject( $query ) ) {
474428 $creater = htmlentities( $row->creater );
475429 $question = $row->question;
476430 }
477431
478 - $controll_delete_right = $wgUser->isAllowed( 'poll-admin' );
479 - $controll_delete_blocked = $wgUser->isBlocked();
480 -
481 - if ( ( $creater != $user ) AND ( $controll_delete_right == false ) ) {
 432+ if ( ( $creater != $wgUser->getName() ) && !$wgUser->isAllowed( 'poll-admin' ) ) {
482433 $wgOut->addWikiMsg( 'poll-delete-right-error' );
483 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 434+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 435+ return;
484436 }
485 -
486 - if ( $controll_delete_blocked == true ) {
487 - $wgOut->addWikiMsg( 'poll-delete-block-error' );
488 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
489 - }
490 -
491 - if ( ( ( $creater == $user ) OR ( $controll_delete_right == true ) ) AND ( $controll_delete_blocked != true ) ) {
492 - if( $wgRequest->getCheck('controll_delete') AND $wgRequest->getVal('controll_delete') == 1 ) {
 437+ if ( ( $creater == $wgUser->getName() ) || $wgUser->isAllowed( 'poll-admin' ) ) {
 438+ if( $wgRequest->getCheck('controll_delete') && $wgRequest->getVal('controll_delete') == 1 ) {
493439 $dbw = wfGetDB( DB_MASTER );
494 - $user = $wgUser->getName();
495440
496441 $dbw->delete( 'poll', array( 'id' => $pid ) );
497442 $dbw->delete( 'poll_answer', array( 'uid' => $pid ) );
498443
499444 $log = new LogPage( "poll" );
500 - $title = $wgTitle;
501 - $log->addEntry( "poll", $title, wfMsg( 'poll-log-delete', "[[User:".htmlentities( $user, ENT_QUOTES, 'UTF-8' )."]]", htmlentities( $question, ENT_QUOTES, 'UTF-8' ) ) );
 445+ $title = $this->getTitle();
 446+ $log->addEntry( "poll", $title, wfMsg( 'poll-log-delete', "[[User:".htmlentities( $wgUser->getName(), ENT_QUOTES, 'UTF-8' )."]]", htmlentities( $question, ENT_QUOTES, 'UTF-8' ) ) );
502447
503448 $wgOut->addWikiMsg( 'poll-delete-pass' );
504 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 449+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
505450 }
506451 else {
507452 $wgOut->addWikiMsg( 'poll-delete-cancel' );
508 - $wgOut->addHtml( '<a href="'.$wgTitle->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
 453+ $wgOut->addHtml( '<a href="'.$this->getTitle()->getFullURL('action=list').'">'.wfMsg('poll-back').'</a>' );
509454 }
510455 }
511456 }
Index: trunk/extensions/Poll/Poll.i18n.php
@@ -18,9 +18,7 @@
1919 'poll-title-vote' => 'Voting page',
2020 'poll-title-score' => 'Score',
2121 'poll-create-right-error' => 'You are not allowed to create a new poll(needed right: poll-create)',
22 - 'poll-create-block-error' => 'You are not allowed to create a new poll because you use a blocked user',
2322 'poll-vote-right-error' => 'You are not allowed to vote(needed right: poll-vote)',
24 - 'poll-vote-block-error' => 'You are not allowed to vote because you use a blocked user',
2523 'poll-alternative' => 'Alternative',
2624 'poll-question' => 'Question',
2725 'poll-submit' => 'Submit',
@@ -40,15 +38,14 @@
4139 'poll-title-change' => 'Change Poll',
4240 'poll-title-delete' => 'Delete Poll',
4341 'poll-change-right-error' => 'You must be the creater of the Poll or have the "poll-admin" right to change this Poll',
44 - 'poll-change-block-error' => 'You are not allowed to change a poll because you use a blocked user',
4542 'poll-change-pass' => 'Changed!',
4643 'poll-number-poll' => 'Number of Votes',
4744 'poll-title-delete' => 'Delete Poll',
4845 'poll-delete-question' => 'Do you really want to delete the Poll "$1"?',
4946 'poll-delete-right-error' => 'You must be the creater of the Poll or have the "poll-admin" right to delete this Poll',
50 - 'poll-delete-block-error' => 'You are not allowed to delete a poll because you use a blocked user',
5147 'poll-delete-pass' => 'Deleted!',
5248 'poll-delete-cancel' => 'Poll wasn\'t deleted (checkbox not set)',
 49+ 'poll-invalid-id' => 'Invalid poll id',
5350 'poll-logpage' => 'Poll log',
5451 'poll-logpagetext' => 'This is a log of changes to polls.',
5552 'poll-log-create' => '$1 created poll "$2"',
@@ -71,9 +68,7 @@
7269 'poll-title-vote' => 'Abstimmen',
7370 'poll-title-score' => 'Auswertung',
7471 'poll-create-right-error' => 'Leider darfst du keine neue Umfrage erstellen(benötige Gruppenberechttigung: poll-create)',
75 - 'poll-create-block-error' => 'Leider darfst du keine neue Umfrage erstellen, weil du einen gesperten Benutzer benutzt',
7672 'poll-vote-right-error' => 'Leider darfst du nicht abstimmen(benötige Gruppenberechttigung: poll-vote)',
77 - 'poll-vote-block-error' => 'Leider darfst du nicht abstimmen, weil du einen gesperten Benutzer benutzt',
7873 'poll-alternative' => 'Antwortmöglichkeit',
7974 'poll-question' => 'Frage',
8075 'poll-submit' => 'Absenden',
@@ -93,13 +88,11 @@
9489 'poll-title-change' => 'Umfrage ändern',
9590 'poll-title-delete' => 'Umfrage löschen',
9691 'poll-change-right-error' => 'Du musst der Autor dieser Umfrage sein oder die "poll-admin"-Gruppenberechtigung haben, um diese Umfrage zu ändern',
97 - 'poll-change-block-error' => 'Leider darfst du keine Umfrage ändern, weil du einen gesperten Benutzer benutzt',
9892 'poll-change-pass' => 'Umfrage erfolgreich geändert!',
9993 'poll-number-poll' => 'Anzahl der abgegebenen Stimmen',
10094 'poll-title-delete' => 'Umfrage löschen',
10195 'poll-delete-question' => 'Möchtest du wirklich die Umfrage "$1" löschen?',
10296 'poll-delete-right-error' => 'Du musst der Autor dieser Umfrage sein oder die "poll-admin"-Gruppenberechtigung haben, um diese Umfrage zu löschen',
103 - 'poll-delete-block-error' => 'Leider darfst du keine Umfrage löschen, weil du einen gesperten Benutzer benutzt',
10497 'poll-delete-pass' => 'Umfrage erfolgreich gelöscht',
10598 'poll-delete-cancel' => 'Umfrage wurde nicht gelöscht(Häckchen nicht gesetzt)!',
10699 'poll-logpage' => 'Umfrage-Logbuch',

Status & tagging log