Special:Preferences Remove red box in email and changed confirm error to warning
[lhc/web/wiklou.git] / includes / actions / MarkpatrolledAction.php
index e52d0c4..4016f67 100644 (file)
  * @ingroup Actions
  */
 
+/**
+ * Mark a revision as patrolled on a page
+ *
+ * @ingroup Actions
+ */
 class MarkpatrolledAction extends FormlessAction {
 
        public function getName() {
                return 'markpatrolled';
        }
 
-       public function getRestriction() {
-               return null;
-       }
-
        protected function getDescription() {
                return '';
        }
 
-       protected function checkCanExecute( User $user ) {
-               if ( !$user->matchEditToken( $this->getRequest()->getVal( 'token' ), $this->getRequest()->getInt( 'rcid' ) ) ) {
-                       throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
-               }
-
-               return parent::checkCanExecute( $user );
-       }
-
        public function onView() {
-               $rc = RecentChange::newFromId( $this->getRequest()->getInt( 'rcid' ) );
+               $request = $this->getRequest();
 
+               $rcId = $request->getInt( 'rcid' );
+               $rc = RecentChange::newFromId( $rcId );
                if ( is_null( $rc ) ) {
                        throw new ErrorPageError( 'markedaspatrollederror', 'markedaspatrollederrortext' );
                }
 
-               $errors = $rc->doMarkPatrolled( $this->getUser() );
+               $user = $this->getUser();
+               if ( !$user->matchEditToken( $request->getVal( 'token' ), $rcId ) ) {
+                       throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
+               }
+
+               $errors = $rc->doMarkPatrolled( $user );
 
                if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) {
                        throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' );
@@ -70,11 +70,12 @@ class MarkpatrolledAction extends FormlessAction {
                        $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrollederror' ) );
                        $this->getOutput()->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
                        $this->getOutput()->returnToMain( null, $return );
+
                        return;
                }
 
                if ( count( $errors ) ) {
-                       throw new PermissionsErrorPage( 'patrol', $errors );
+                       throw new PermissionsError( 'patrol', $errors );
                }
 
                # Inform the user