MediaWiki  1.28.1
Go to the documentation of this file.
1 <?php
32  public function getName() {
33  return 'markpatrolled';
34  }
36  protected function getDescription() {
37  return '';
38  }
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' );
47  }
49  $user = $this->getUser();
50  if ( !$user->matchEditToken( $request->getVal( 'token' ), $rcId ) ) {
51  throw new ErrorPageError( 'sessionfailure-title', 'sessionfailure' );
52  }
54  $errors = $rc->doMarkPatrolled( $user );
56  if ( in_array( [ 'rcpatroldisabled' ], $errors ) ) {
57  throw new ErrorPageError( 'rcpatroldisabled', 'rcpatroldisabledtext' );
58  }
60  if ( in_array( [ 'hookaborted' ], $errors ) ) {
61  // The hook itself has handled any output
62  return;
63  }
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';
70  } else {
71  $returnTo = 'Recentchanges';
72  }
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 );
80  return;
81  }
83  if ( count( $errors ) ) {
84  throw new PermissionsError( 'patrol', $errors );
85  }
87  # Inform the user
88  $this->getOutput()->setPageTitle( $this->msg( 'markedaspatrolled' ) );
89  $this->getOutput()->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
90  $this->getOutput()->returnToMain( null, $return );
91  }
93  public function doesWrites() {
94  return true;
95  }
96 }
Get the OutputPage being used for this instance.
Definition: Action.php:207
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name If you don't need a full Title object...
Definition: SpecialPage.php:82
Shortcut to get the User being used for this instance.
Definition: Action.php:217
static newFromId($rcid)
Obtain the recent change with a given rc_id value.
Mark a revision as patrolled on a page.
An error page which can definitely be safely rendered using the OutputPage.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:242
An action which just does something, without showing a form first.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2573
Show an error when a user tries to do something they do not have the necessary permissions for...
const RC_NEW
Definition: Defines.php:137
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect & $returnTo
Definition: hooks.txt:2491
Get a Message object with context set Parameters are the same as wfMessage()
Definition: Action.php:256
Get the WebRequest being used for this instance.
Definition: Action.php:197