From be057fb89e337055d2b229503e8e1f7d57dd2411 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 24 Oct 2009 22:07:59 +0000 Subject: [PATCH] Follow-up r57470: Add show/hide links for users that can view deleted revisions but not delete them --- includes/HistoryPage.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index 6103a936b9..2c43285b62 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -476,20 +476,29 @@ class HistoryPager extends ReverseChronologicalPager { $link = $this->revLink( $rev ); $classes = array(); + $del = ''; if( $wgUser->isAllowed( 'deleterevision' ) ) { - // Don't show useless link to people who cannot hide revisions - if( !$rev->getVisibility() && !$wgUser->isAllowed( 'deleterevision' ) ) { - $del = Xml::check( 'deleterevisions', false, array('class' => 'mw-revdelundel-hidden') ); - // If revision was hidden from sysops - } else if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { - $del = Xml::check( 'deleterevisions', false, array('disabled' => 'disabled') ); + // If revision was hidden from sysops, disable the checkbox + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { + $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); + // Otherwise, enable the checkbox... + } else { + $del = Xml::check( 'showhiderevisions', false, array( 'name' => 'ids['.$rev->getId().']' ) ); + } + // User can only view deleted revisions... + } else if( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) { + // If revision was hidden from sysops, disable the link + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { + $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), + '(' . $this->historyPage->message['rev-delundel'] . ')' ); // Otherwise, show the link... } else { - $id = $rev->getId(); - $del = Xml::check( 'showhiderevisions', false, array( 'name' => "ids[$id]" ) ); + $query = array( 'type' => 'revision', + 'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() ); + $del .= $this->getSkin()->revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ) ); } - $s .= " $del "; } + if( $del ) $s .= " $del "; $s .= " $link"; $s .= " " . $this->getSkin()->revUserTools( $rev, true ) . ""; @@ -670,7 +679,7 @@ class HistoryPager extends ReverseChronologicalPager { ); $checkmark = array( 'checked' => 'checked' ); } else { - # Check ility of old revisions + # Check visibility of old revisions if( !$rev->userCan( Revision::DELETED_TEXT ) ) { $radio['disabled'] = 'disabled'; $checkmark = array(); // We will check the next possible one -- 2.20.1