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