X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flogging%2FLogEventsList.php;h=d97ddfddf2055951b6f8f1fdc756c08b9ba5cc72;hp=00d3bd33151fc8da7eda0a0131357140e0728233;hb=2aeede8f4c56209e0ea786d23d4c809a9d8f34d6;hpb=ace44e2064851dda9d9e7327494bd7b7b3379825 diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index 00d3bd3315..d97ddfddf2 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -98,8 +98,9 @@ class LogEventsList extends ContextSource { * @param string $user * @param string $page * @param string $pattern - * @param int $year Year - * @param int $month Month + * @param int|string $year Use 0 to start with no year preselected. + * @param int|string $month A month in the 1..12 range. Use 0 to start with no month + * preselected. * @param array $filter * @param string $tagFilter Tag to select by default * @param string $action @@ -426,7 +427,7 @@ class LogEventsList extends ContextSource { } /** - * @param stdClass $row Row + * @param stdClass $row * @return string */ private function getShowHideLinks( $row ) { @@ -496,7 +497,7 @@ class LogEventsList extends ContextSource { } /** - * @param stdClass $row Row + * @param stdClass $row * @param string|array $type * @param string|array $action * @param string $right @@ -519,15 +520,16 @@ class LogEventsList extends ContextSource { /** * Determine if the current user is allowed to view a particular - * field of this log row, if it's marked as deleted. + * field of this log row, if it's marked as deleted and/or restricted log type. * - * @param stdClass $row Row + * @param stdClass $row * @param int $field * @param User $user User to check, or null to use $wgUser * @return bool */ public static function userCan( $row, $field, User $user = null ) { - return self::userCanBitfield( $row->log_deleted, $field, $user ); + return self::userCanBitfield( $row->log_deleted, $field, $user ) && + self::userCanViewLogType( $row->log_type, $user ); } /** @@ -558,7 +560,27 @@ class LogEventsList extends ContextSource { } /** - * @param stdClass $row Row + * Determine if the current user is allowed to view a particular + * field of this log row, if it's marked as restricted log type. + * + * @param stdClass $type + * @param User|null $user User to check, or null to use $wgUser + * @return bool + */ + public static function userCanViewLogType( $type, User $user = null ) { + if ( $user === null ) { + global $wgUser; + $user = $wgUser; + } + $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get( 'LogRestrictions' ); + if ( isset( $logRestrictions[$type] ) && !$user->isAllowed( $logRestrictions[$type] ) ) { + return false; + } + return true; + } + + /** + * @param stdClass $row * @param int $field One of DELETED_* bitfield constants * @return bool */