MediaWiki  REL1_19
MarkpatrolledAction.php
Go to the documentation of this file.
00001 <?php
00025 class MarkpatrolledAction extends FormlessAction {
00026 
00027         public function getName() {
00028                 return 'markpatrolled';
00029         }
00030 
00031         protected function getDescription() {
00032                 return '';
00033         }
00034 
00035         public function onView() {
00036                 $request = $this->getRequest();
00037 
00038                 $rcId = $request->getInt( 'rcid' );
00039                 $rc = RecentChange::newFromId( $rcId );
00040                 if ( is_null( $rc ) ) {
00041                         throw new ErrorPageError( 'markedaspatrollederror', 'markedaspatrollederrortext' );
00042                 }
00043 
00044                 $user = $this->getUser();
00045                 if ( !$user->matchEditToken( $request->getVal( 'token' ), $rcId ) ) {
00046                         throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
00047                 }
00048 
00049                 $errors = $rc->doMarkPatrolled( $user );
00050 
00051                 if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) {
00052                         throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' );
00053                 }
00054 
00055                 if ( in_array( array( 'hookaborted' ), $errors ) ) {
00056                         // The hook itself has handled any output
00057                         return;
00058                 }
00059 
00060                 # It would be nice to see where the user had actually come from, but for now just guess
00061                 $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'Newpages' : 'Recentchanges';
00062                 $return = SpecialPage::getTitleFor( $returnto );
00063 
00064                 if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) {
00065                         $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrollederror' ) );
00066                         $this->getOutput()->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
00067                         $this->getOutput()->returnToMain( null, $return );
00068                         return;
00069                 }
00070 
00071                 if ( count( $errors ) ) {
00072                         throw new PermissionsError( 'patrol', $errors );
00073                 }
00074 
00075                 # Inform the user
00076                 $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrolled' ) );
00077                 $this->getOutput()->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
00078                 $this->getOutput()->returnToMain( null, $return );
00079         }
00080 }