From 48129139367f2666e19be68e547afe2297db1af5 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 29 Apr 2015 13:34:30 -0400 Subject: [PATCH] ChangeTags: Show checkbox on Special:Log when user lacks RevDel rights The actual production of checkboxes in LogEventsList didn't get updated to show checkboxes when the user can edit change tags but cannot use RevDel on log entries. This also renames LogEventsList::USE_REVDEL_CHECKBOXES to LogEventsList::USE_CHECKBOXES to be accurate with the change here; no extensions in Gerrit use this constant, so we should be safe. Bug: T97501 Change-Id: I72ca7371fe73b650d5ef32d18da19788084f9aeb --- includes/logging/LogEventsList.php | 27 ++++++++++++++++++++------- includes/specials/SpecialLog.php | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index 8b288218f7..dcddbd776b 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -26,7 +26,7 @@ class LogEventsList extends ContextSource { const NO_ACTION_LINK = 1; const NO_EXTRA_USER_LINKS = 2; - const USE_REVDEL_CHECKBOXES = 4; + const USE_CHECKBOXES = 4; public $flags; @@ -44,7 +44,7 @@ class LogEventsList extends ContextSource { * a Skin object. Use of Skin is deprecated. * @param null $unused Unused; used to be an OutputPage object. * @param int $flags Can be a combination of self::NO_ACTION_LINK, - * self::NO_EXTRA_USER_LINKS or self::USE_REVDEL_CHECKBOXES. + * self::NO_EXTRA_USER_LINKS or self::USE_CHECKBOXES. */ public function __construct( $context, $unused = null, $flags = 0 ) { if ( $context instanceof IContextSource ) { @@ -341,14 +341,27 @@ class LogEventsList extends ContextSource { */ private function getShowHideLinks( $row ) { // We don't want to see the links and + if ( $this->flags == self::NO_ACTION_LINK ) { + return ''; + } + + $user = $this->getUser(); + + // If change tag editing is available to this user, return the checkbox + if ( $this->flags & self::USE_CHECKBOXES && $user->isAllowed( 'changetags' ) ) { + return Xml::check( + 'showhiderevisions', + false, + array( 'name' => 'ids[' . $row->log_id . ']' ) + ); + } + // no one can hide items from the suppress log. - if ( ( $this->flags == self::NO_ACTION_LINK ) - || $row->log_type == 'suppress' - ) { + if ( $row->log_type == 'suppress' ) { return ''; } + $del = ''; - $user = $this->getUser(); // Don't show useless checkbox to people who cannot hide log entries if ( $user->isAllowed( 'deletedhistory' ) ) { $canHide = $user->isAllowed( 'deletelogentry' ); @@ -358,7 +371,7 @@ class LogEventsList extends ContextSource { $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed; if ( $row->log_deleted || $canHide ) { // Show checkboxes instead of links. - if ( $canHide && $this->flags & self::USE_REVDEL_CHECKBOXES && !$canViewThisSuppressedEntry ) { + if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) { // If event was hidden from sysops if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index f16e5ba224..fe6ce68d27 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -165,7 +165,7 @@ class SpecialLog extends SpecialPage { $loglist = new LogEventsList( $this->getContext(), null, - LogEventsList::USE_REVDEL_CHECKBOXES + LogEventsList::USE_CHECKBOXES ); $pager = new LogPager( $loglist, -- 2.20.1