ChangeTags: Show checkbox on Special:Log when user lacks RevDel rights
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 29 Apr 2015 17:34:30 +0000 (13:34 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 29 Apr 2015 17:36:48 +0000 (13:36 -0400)
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
includes/specials/SpecialLog.php

index 8b28821..dcddbd7 100644 (file)
@@ -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' ) );
index f16e5ba..fe6ce68 100644 (file)
@@ -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,