X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fchanges%2FRecentChange.php;h=159cfd93de318dcfad3fffd2311f1138361b082a;hb=fd42f6c8486e27d7f386e2467b5c92a30371a2bf;hp=2c959285096fed9fd415d0267da56ac108b176a8;hpb=9ba3fca2d8adc56787c8efc32c41424cb212e387;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 2c95928509..159cfd93de 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -430,9 +430,11 @@ class RecentChange { * * @param RecentChange|int $change RecentChange or corresponding rc_id * @param bool $auto For automatic patrol + * @param string|string[] $tags Change tags to add to the patrol log entry + * ($user should be able to add the specified tags before this is called) * @return array See doMarkPatrolled(), or null if $change is not an existing rc_id */ - public static function markPatrolled( $change, $auto = false ) { + public static function markPatrolled( $change, $auto = false, $tags = null ) { global $wgUser; $change = $change instanceof RecentChange @@ -443,7 +445,7 @@ class RecentChange { return null; } - return $change->doMarkPatrolled( $wgUser, $auto ); + return $change->doMarkPatrolled( $wgUser, $auto, $tags ); } /** @@ -453,10 +455,13 @@ class RecentChange { * 'markedaspatrollederror-noautopatrol' as errors * @param User $user User object doing the action * @param bool $auto For automatic patrol + * @param string|string[] $tags Change tags to add to the patrol log entry + * ($user should be able to add the specified tags before this is called) * @return array Array of permissions errors, see Title::getUserPermissionsErrors() */ - public function doMarkPatrolled( User $user, $auto = false ) { + public function doMarkPatrolled( User $user, $auto = false, $tags = null ) { global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol; + $errors = []; // If recentchanges patrol is disabled, only new pages or new file versions // can be patrolled, provided the appropriate config variable is set @@ -490,10 +495,11 @@ class RecentChange { // Actually set the 'patrolled' flag in RC $this->reallyMarkPatrolled(); // Log this patrol event - PatrolLog::record( $this, $auto, $user ); + PatrolLog::record( $this, $auto, $user, $tags ); + Hooks::run( - 'MarkPatrolledComplete', - [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] + 'MarkPatrolledComplete', + [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] ); return []; @@ -714,11 +720,12 @@ class RecentChange { * @param int $newId * @param string $actionCommentIRC * @param int $revId Id of associated revision, if any + * @param bool $isPatrollable Whether this log entry is patrollable * @return RecentChange */ public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '', - $revId = 0 ) { + $revId = 0, $isPatrollable = false ) { global $wgRequest; # # Get pageStatus for email notification @@ -742,9 +749,8 @@ class RecentChange { break; } - // Allow unpatrolled status when an associated rev id is passed - // May be used in core by moves and uploads - $markPatrolled = ( $revId > 0 ) ? $user->isAllowed( 'autopatrol' ) : true; + // Allow unpatrolled status for patrollable log entries + $markPatrolled = $isPatrollable ? $user->isAllowed( 'autopatrol' ) : true; $rc = new RecentChange; $rc->mTitle = $target; @@ -845,7 +851,9 @@ class RecentChange { 'rc_logid' => 0, 'rc_log_type' => null, 'rc_log_action' => '', - 'rc_params' => '' + 'rc_params' => serialize( [ + 'hidden-cat' => WikiCategoryPage::factory( $categoryTitle )->isHidden() + ] ) ]; $rc->mExtra = [ @@ -859,6 +867,19 @@ class RecentChange { return $rc; } + /** + * Get a parameter value + * + * @since 1.27 + * + * @param string $name parameter name + * @return mixed + */ + public function getParam( $name ) { + $params = $this->parseParams(); + return isset( $params[$name] ) ? $params[$name] : null; + } + /** * Initialises the members of this object from a mysql row object * @@ -967,7 +988,7 @@ class RecentChange { * * @since 1.26 * - * @return array|null + * @return mixed|bool false on failed unserialization */ public function parseParams() { $rcParams = $this->getAttribute( 'rc_params' );