3 * Mark a revision as patrolled on a page
5 * Copyright © 2011 Alexandre Emsenhuber
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 * Mark a revision as patrolled on a page
30 class MarkpatrolledAction
extends FormlessAction
{
32 public function getName() {
33 return 'markpatrolled';
36 protected function getDescription() {
40 public function onView() {
41 $request = $this->getRequest();
43 $rcId = $request->getInt( 'rcid' );
44 $rc = RecentChange
::newFromId( $rcId );
45 if ( is_null( $rc ) ) {
46 throw new ErrorPageError( 'markedaspatrollederror', 'markedaspatrollederrortext' );
49 $user = $this->getUser();
50 if ( !$user->matchEditToken( $request->getVal( 'token' ), $rcId ) ) {
51 throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
54 $errors = $rc->doMarkPatrolled( $user );
56 if ( in_array( [ 'rcpatroldisabled' ], $errors ) ) {
57 throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' );
60 if ( in_array( [ 'hookaborted' ], $errors ) ) {
61 // The hook itself has handled any output
65 # It would be nice to see where the user had actually come from, but for now just guess
66 if ( $rc->getAttribute( 'rc_type' ) == RC_NEW
) {
67 $returnTo = 'Newpages';
68 } elseif ( $rc->getAttribute( 'rc_log_type' ) == 'upload' ) {
69 $returnTo = 'Newfiles';
71 $returnTo = 'Recentchanges';
73 $return = SpecialPage
::getTitleFor( $returnTo );
75 if ( in_array( [ 'markedaspatrollederror-noautopatrol' ], $errors ) ) {
76 $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrollederror' ) );
77 $this->getOutput()->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
78 $this->getOutput()->returnToMain( null, $return );
83 if ( count( $errors ) ) {
84 throw new PermissionsError( 'patrol', $errors );
88 $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrolled' ) );
89 $this->getOutput()->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
90 $this->getOutput()->returnToMain( null, $return );
93 public function doesWrites() {