Index: trunk/extensions/Poll/Poll_body.php |
— | — | @@ -15,62 +15,58 @@ |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function execute( $par ) { |
19 | | - global $wgRequest, $wgOut; |
| 19 | + global $wgRequest, $wgUser, $wgOut; |
20 | 20 | |
21 | 21 | wfLoadExtensionMessages( 'Poll' ); |
22 | 22 | |
23 | 23 | $this->setHeaders(); |
24 | 24 | |
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' ) ); |
27 | 27 | $id = htmlentities( $wgRequest->getText( 'id' ) ); |
28 | 28 | |
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; |
31 | 34 | } |
32 | 35 | |
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(); |
35 | 51 | } |
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 | | - } |
56 | 52 | } |
57 | 53 | |
58 | 54 | public function make_list() { |
59 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 55 | + global $wgOut; |
60 | 56 | $wgOut->setPagetitle( wfMsg( 'poll' ) ); |
61 | 57 | |
62 | 58 | $dbr = wfGetDB( DB_SLAVE ); |
63 | 59 | $query = $dbr->select( 'poll', 'question, dis, id' ); |
64 | 60 | |
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>' ); |
66 | 62 | |
67 | 63 | $wgOut->addWikiMsg( 'poll-list-current' ); |
68 | 64 | $wgOut->addHtml( Xml::openElement( 'table' ) ); |
69 | 65 | $wgOut->addHtml( '<tr><th>'.wfMsg( 'poll-question' ).'</th><th>'.wfMsg( 'poll-dis' ).'</th><th> </th></tr>' ); |
70 | 66 | |
71 | 67 | 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>' ); |
73 | 69 | $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>' ); |
75 | 71 | } |
76 | 72 | |
77 | 73 | $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
— | — | @@ -78,22 +74,16 @@ |
79 | 75 | } |
80 | 76 | |
81 | 77 | public function create() { |
82 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 78 | + global $wgOut, $wgUser; |
83 | 79 | |
84 | 80 | $wgOut->setPagetitle( wfMsg( 'poll-title-create' ) ); |
85 | 81 | |
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' ) ) { |
89 | 83 | $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>' ); |
91 | 85 | } |
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 | | - } |
96 | 86 | 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') ) ) ); |
98 | 88 | $wgOut->addHtml( Xml::openElement( 'table' ) ); |
99 | 89 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('question').'</td></tr>' ); |
100 | 90 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 1:</td><td>'.Xml::input('poll_alternative_1').'</td></tr>' ); |
— | — | @@ -111,25 +101,17 @@ |
112 | 102 | } |
113 | 103 | |
114 | 104 | public function vote( $vid ) { |
115 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 105 | + global $wgOut, $wgUser; |
116 | 106 | |
117 | 107 | $wgOut->setPagetitle( wfMsg( 'poll-title-vote' ) ); |
118 | 108 | |
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' ) ) { |
122 | 110 | $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>' ); |
124 | 112 | } |
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 | | - } |
129 | 113 | else { |
130 | 114 | $dbr = wfGetDB( DB_SLAVE ); |
131 | 115 | $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(); |
134 | 116 | |
135 | 117 | while( $row = $dbr->fetchObject( $query ) ) { |
136 | 118 | $question = htmlentities( $row->question, ENT_QUOTES, 'UTF-8' ); |
— | — | @@ -143,7 +125,7 @@ |
144 | 126 | $multi = $row->multi; |
145 | 127 | } |
146 | 128 | |
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) ) ) ); |
148 | 130 | $wgOut->addHtml( Xml::openElement( 'table' ) ); |
149 | 131 | $wgOut->addHtml( '<tr><th>'.$question.'</th></tr>' ); |
150 | 132 | if( $multi != 1 ) { |
— | — | @@ -162,20 +144,20 @@ |
163 | 145 | if($alternative_5 != "") { $wgOut->addHtml( '<tr><td>'.Xml::check('vote_5').' '.$alternative_5.'</td></tr>' ); } |
164 | 146 | if($alternative_6 != "") { $wgOut->addHtml( '<tr><td>'.Xml::check('vote_6').' '.$alternative_6.'</td></tr>' ); } |
165 | 147 | } |
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>' ); |
167 | 149 | $wgOut->addHtml( '<tr><td>' ); |
168 | 150 | $wgOut->addWikiText( '<small>'.wfMsg( 'poll-score-created', $creater ).'</small>' ); |
169 | 151 | $wgOut->addHtml( '</td></tr>' ); |
170 | 152 | $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>' ); |
173 | 155 | } |
174 | 156 | $wgOut->addHtml( Xml::closeElement( 'form' ) ); |
175 | 157 | } |
176 | 158 | } |
177 | 159 | |
178 | 160 | public function score( $sid ) { |
179 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 161 | + global $wgOut; |
180 | 162 | |
181 | 163 | $wgOut->setPagetitle( wfMsg( 'poll-title-score' ) ); |
182 | 164 | |
— | — | @@ -244,11 +226,11 @@ |
245 | 227 | $wgOut->addWikiText( '<small>'.wfMsg( 'poll-score-created', $creater ).'</small>' ); |
246 | 228 | $wgOut->addHtml( '</td></tr>' ); |
247 | 229 | $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>' ); |
249 | 231 | } |
250 | 232 | |
251 | 233 | public function delete( $did ) { |
252 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 234 | + global $wgOut; |
253 | 235 | $wgOut->setPagetitle( wfMsg( 'poll-title-delete' ) ); |
254 | 236 | |
255 | 237 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -258,20 +240,23 @@ |
259 | 241 | $question = htmlentities( $row->question, ENT_QUOTES, 'UTF-8' ); |
260 | 242 | } |
261 | 243 | |
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 | + } |
266 | 252 | } |
267 | 253 | |
268 | 254 | public function change($cid) { |
269 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 255 | + global $wgOut, $wgUser; |
270 | 256 | |
271 | 257 | $wgOut->setPagetitle( wfMsg( 'poll-title-change' ) ); |
272 | 258 | |
273 | 259 | $dbr = wfGetDB( DB_SLAVE ); |
274 | 260 | $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(); |
276 | 261 | |
277 | 262 | while( $row = $dbr->fetchObject( $query ) ) { |
278 | 263 | $question = $row->question; |
— | — | @@ -285,17 +270,12 @@ |
286 | 271 | $dis = $row->dis; |
287 | 272 | } |
288 | 273 | |
289 | | - $controll_create_blocked = $wgUser->isBlocked(); |
290 | | - if ( $user != $creater ) { |
| 274 | + if ( $wgUser->getName() != $creater ) { |
291 | 275 | $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>' ); |
293 | 277 | } |
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 | | - } |
298 | 278 | 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) ) ) ); |
300 | 280 | $wgOut->addHtml( Xml::openElement( 'table' ) ); |
301 | 281 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('question', false, $question).'</td></tr>' ); |
302 | 282 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 1:</td><td>'.Xml::input('poll_alternative_1', false, $alternative_1).'</td></tr>' ); |
— | — | @@ -312,22 +292,15 @@ |
313 | 293 | } |
314 | 294 | |
315 | 295 | public function submit( $pid ) { |
316 | | - global $wgRequest, $wgOut, $wgUser, $wgTitle; |
| 296 | + global $wgRequest, $wgOut, $wgUser; |
317 | 297 | |
318 | 298 | $type = $wgRequest->getVal('type'); |
319 | 299 | |
320 | 300 | 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' ) ) { |
324 | 302 | $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>' ); |
326 | 304 | } |
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 | | - |
332 | 305 | else { |
333 | 306 | $dbw = wfGetDB( DB_MASTER ); |
334 | 307 | $question = $wgRequest->getVal('question'); |
— | — | @@ -347,40 +320,31 @@ |
348 | 321 | 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis, 'multi' => $multi ) ); |
349 | 322 | |
350 | 323 | $log = new LogPage( "poll" ); |
351 | | - $title = $wgTitle; |
| 324 | + $title = $this->getTitle(); |
352 | 325 | $log->addEntry( "poll", $title, wfMsg( 'poll-log-create', "[[User:".htmlentities( $user, ENT_QUOTES, 'UTF-8' )."]]", htmlentities( $question, ENT_QUOTES, 'UTF-8' ) ) ); |
353 | 326 | |
354 | 327 | $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>' ); |
356 | 329 | } |
357 | 330 | else { |
358 | 331 | $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>' ); |
360 | 333 | } |
361 | 334 | } |
362 | 335 | } |
363 | 336 | |
364 | 337 | 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' ) ) { |
368 | 339 | $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>' ); |
370 | 341 | } |
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 | | - |
376 | 342 | else { |
377 | 343 | $dbw = wfGetDB( DB_MASTER ); |
378 | | - $dbr = wfGetDB( DB_SLAVE ); |
379 | 344 | $multi = $wgRequest->getVal('multi'); |
380 | | - $user = $wgUser->getName(); |
381 | 345 | $uid = $wgUser->getId(); |
382 | 346 | |
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 );; |
385 | 349 | |
386 | 350 | if($multi != 1) { |
387 | 351 | $vote = $wgRequest->getVal('vote'); |
— | — | @@ -403,14 +367,14 @@ |
404 | 368 | } |
405 | 369 | |
406 | 370 | 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() ) ); |
408 | 372 | |
409 | 373 | $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>' ); |
411 | 375 | } |
412 | 376 | else { |
413 | 377 | $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>' ); |
415 | 379 | } |
416 | 380 | } |
417 | 381 | } |
— | — | @@ -418,28 +382,19 @@ |
419 | 383 | if($type == 'change') { |
420 | 384 | $dbr = wfGetDB( DB_SLAVE ); |
421 | 385 | $query = $dbr->select( 'poll', 'creater', array( 'id' => $pid ) ); |
422 | | - $user = $wgUser->getName(); |
423 | 386 | |
424 | 387 | while( $row = $dbr->fetchObject( $query ) ) { |
425 | 388 | $creater = htmlentities( $row->creater ); |
426 | 389 | } |
427 | 390 | |
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>' ); |
430 | 392 | |
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' ) ) { |
434 | 394 | $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; |
436 | 397 | } |
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' ) ) { |
444 | 399 | $dbw = wfGetDB( DB_MASTER ); |
445 | 400 | $question = $wgRequest->getVal('question'); |
446 | 401 | $alternative_1 = $wgRequest->getVal('poll_alternative_1'); |
— | — | @@ -456,55 +411,45 @@ |
457 | 412 | 'alternative_6' => $alternative_6, 'creater' => $user, 'dis' => $dis ), array( 'id' => $pid ) ); |
458 | 413 | |
459 | 414 | $log = new LogPage( "poll" ); |
460 | | - $title = $wgTitle; |
| 415 | + $title = $this->getTitle(); |
461 | 416 | $log->addEntry( "poll", $title, wfMsg( 'poll-log-change', "[[User:".htmlentities( $user, ENT_QUOTES, 'UTF-8' )."]]", htmlentities( $question, ENT_QUOTES, 'UTF-8' ) ) ); |
462 | 417 | |
463 | 418 | $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>' ); |
465 | 420 | } |
466 | 421 | } |
467 | 422 | |
468 | 423 | if($type == 'delete') { |
469 | 424 | $dbr = wfGetDB( DB_SLAVE ); |
470 | 425 | $query = $dbr->select( 'poll', 'creater, question', array( 'id' => $pid ) ); |
471 | | - $user = $wgUser->getName(); |
472 | 426 | |
473 | 427 | while( $row = $dbr->fetchObject( $query ) ) { |
474 | 428 | $creater = htmlentities( $row->creater ); |
475 | 429 | $question = $row->question; |
476 | 430 | } |
477 | 431 | |
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' ) ) { |
482 | 433 | $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; |
484 | 436 | } |
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 ) { |
493 | 439 | $dbw = wfGetDB( DB_MASTER ); |
494 | | - $user = $wgUser->getName(); |
495 | 440 | |
496 | 441 | $dbw->delete( 'poll', array( 'id' => $pid ) ); |
497 | 442 | $dbw->delete( 'poll_answer', array( 'uid' => $pid ) ); |
498 | 443 | |
499 | 444 | $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' ) ) ); |
502 | 447 | |
503 | 448 | $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>' ); |
505 | 450 | } |
506 | 451 | else { |
507 | 452 | $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>' ); |
509 | 454 | } |
510 | 455 | } |
511 | 456 | } |
Index: trunk/extensions/Poll/Poll.i18n.php |
— | — | @@ -18,9 +18,7 @@ |
19 | 19 | 'poll-title-vote' => 'Voting page', |
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 | | - 'poll-create-block-error' => 'You are not allowed to create a new poll because you use a blocked user', |
23 | 22 | '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', |
25 | 23 | 'poll-alternative' => 'Alternative', |
26 | 24 | 'poll-question' => 'Question', |
27 | 25 | 'poll-submit' => 'Submit', |
— | — | @@ -40,15 +38,14 @@ |
41 | 39 | 'poll-title-change' => 'Change Poll', |
42 | 40 | 'poll-title-delete' => 'Delete Poll', |
43 | 41 | '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', |
45 | 42 | 'poll-change-pass' => 'Changed!', |
46 | 43 | 'poll-number-poll' => 'Number of Votes', |
47 | 44 | 'poll-title-delete' => 'Delete Poll', |
48 | 45 | 'poll-delete-question' => 'Do you really want to delete the Poll "$1"?', |
49 | 46 | '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', |
51 | 47 | 'poll-delete-pass' => 'Deleted!', |
52 | 48 | 'poll-delete-cancel' => 'Poll wasn\'t deleted (checkbox not set)', |
| 49 | + 'poll-invalid-id' => 'Invalid poll id', |
53 | 50 | 'poll-logpage' => 'Poll log', |
54 | 51 | 'poll-logpagetext' => 'This is a log of changes to polls.', |
55 | 52 | 'poll-log-create' => '$1 created poll "$2"', |
— | — | @@ -71,9 +68,7 @@ |
72 | 69 | 'poll-title-vote' => 'Abstimmen', |
73 | 70 | 'poll-title-score' => 'Auswertung', |
74 | 71 | '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', |
76 | 72 | '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', |
78 | 73 | 'poll-alternative' => 'Antwortmöglichkeit', |
79 | 74 | 'poll-question' => 'Frage', |
80 | 75 | 'poll-submit' => 'Absenden', |
— | — | @@ -93,13 +88,11 @@ |
94 | 89 | 'poll-title-change' => 'Umfrage ändern', |
95 | 90 | 'poll-title-delete' => 'Umfrage löschen', |
96 | 91 | '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', |
98 | 92 | 'poll-change-pass' => 'Umfrage erfolgreich geändert!', |
99 | 93 | 'poll-number-poll' => 'Anzahl der abgegebenen Stimmen', |
100 | 94 | 'poll-title-delete' => 'Umfrage löschen', |
101 | 95 | 'poll-delete-question' => 'Möchtest du wirklich die Umfrage "$1" löschen?', |
102 | 96 | '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', |
104 | 97 | 'poll-delete-pass' => 'Umfrage erfolgreich gelöscht', |
105 | 98 | 'poll-delete-cancel' => 'Umfrage wurde nicht gelöscht(Häckchen nicht gesetzt)!', |
106 | 99 | 'poll-logpage' => 'Umfrage-Logbuch', |