Index: trunk/phase3/includes/actions/MarkpatrolledAction.php |
— | — | @@ -51,12 +51,8 @@ |
52 | 52 | throw new ErrorPageError( 'markedaspatrollederror', 'markedaspatrollederrortext' ); |
53 | 53 | } |
54 | 54 | |
55 | | - # It would be nice to see where the user had actually come from, but for now just guess |
56 | | - $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'Newpages' : 'Recentchanges'; |
57 | | - $return = SpecialPage::getTitleFor( $returnto ); |
| 55 | + $errors = $rc->doMarkPatrolled( $this->getUser() ); |
58 | 56 | |
59 | | - $errors = $rc->doMarkPatrolled(); |
60 | | - |
61 | 57 | if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) { |
62 | 58 | throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' ); |
63 | 59 | } |
— | — | @@ -66,6 +62,10 @@ |
67 | 63 | return; |
68 | 64 | } |
69 | 65 | |
| 66 | + # It would be nice to see where the user had actually come from, but for now just guess |
| 67 | + $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'Newpages' : 'Recentchanges'; |
| 68 | + $return = SpecialPage::getTitleFor( $returnto ); |
| 69 | + |
70 | 70 | if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) { |
71 | 71 | $this->getOutput()->setPageTitle( wfMsg( 'markedaspatrollederror' ) ); |
72 | 72 | $this->getOutput()->addWikiMsg( 'markedaspatrollederror-noautopatrol' ); |
Index: trunk/phase3/includes/RecentChange.php |
— | — | @@ -268,24 +268,28 @@ |
269 | 269 | * @return Array See doMarkPatrolled(), or null if $change is not an existing rc_id |
270 | 270 | */ |
271 | 271 | public static function markPatrolled( $change, $auto = false ) { |
| 272 | + global $wgUser; |
| 273 | + |
272 | 274 | $change = $change instanceof RecentChange |
273 | 275 | ? $change |
274 | 276 | : RecentChange::newFromId($change); |
| 277 | + |
275 | 278 | if( !$change instanceof RecentChange ) { |
276 | 279 | return null; |
277 | 280 | } |
278 | | - return $change->doMarkPatrolled( $auto ); |
| 281 | + return $change->doMarkPatrolled( $wgUser, $auto ); |
279 | 282 | } |
280 | 283 | |
281 | 284 | /** |
282 | 285 | * Mark this RecentChange as patrolled |
283 | 286 | * |
284 | 287 | * NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and 'markedaspatrollederror-noautopatrol' as errors |
| 288 | + * @param $user User object doing the action |
285 | 289 | * @param $auto Boolean: for automatic patrol |
286 | 290 | * @return array of permissions errors, see Title::getUserPermissionsErrors() |
287 | 291 | */ |
288 | | - public function doMarkPatrolled( $auto = false ) { |
289 | | - global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol; |
| 292 | + public function doMarkPatrolled( User $user, $auto = false ) { |
| 293 | + global $wgUseRCPatrol, $wgUseNPPatrol; |
290 | 294 | $errors = array(); |
291 | 295 | // If recentchanges patrol is disabled, only new pages |
292 | 296 | // can be patrolled |
— | — | @@ -294,13 +298,13 @@ |
295 | 299 | } |
296 | 300 | // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol" |
297 | 301 | $right = $auto ? 'autopatrol' : 'patrol'; |
298 | | - $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $wgUser ) ); |
| 302 | + $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) ); |
299 | 303 | if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$wgUser, false)) ) { |
300 | 304 | $errors[] = array('hookaborted'); |
301 | 305 | } |
302 | 306 | // Users without the 'autopatrol' right can't patrol their |
303 | 307 | // own revisions |
304 | | - if( $wgUser->getName() == $this->getAttribute('rc_user_text') && !$wgUser->isAllowed('autopatrol') ) { |
| 308 | + if( $user->getName() == $this->getAttribute('rc_user_text') && !$user->isAllowed('autopatrol') ) { |
305 | 309 | $errors[] = array('markedaspatrollederror-noautopatrol'); |
306 | 310 | } |
307 | 311 | if( $errors ) { |
— | — | @@ -314,7 +318,7 @@ |
315 | 319 | $this->reallyMarkPatrolled(); |
316 | 320 | // Log this patrol event |
317 | 321 | PatrolLog::record( $this, $auto ); |
318 | | - wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$wgUser, false) ); |
| 322 | + wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$user, false) ); |
319 | 323 | return array(); |
320 | 324 | } |
321 | 325 | |