Partially fixing bug 20186: Allow filtering history for revision deletion. Checking...
authorTobias <churchofemacs@users.mediawiki.org>
Mon, 26 Oct 2009 18:45:27 +0000 (18:45 +0000)
committerTobias <churchofemacs@users.mediawiki.org>
Mon, 26 Oct 2009 18:45:27 +0000 (18:45 +0000)
RELEASE-NOTES
includes/HistoryPage.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 72eec62..2abe831 100644 (file)
@@ -262,6 +262,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 3480) The warning saying that the page has a history when deleting it now
   contains the number of revisions in the history
 * $wgStylePath and $wgLogo are now set in the default LocalSettings.php file.
+* (bug 20186) Allow filtering history for revision deletion.
 
 === Bug fixes in 1.16 ===
 
index 2c43285..9a620e6 100644 (file)
@@ -129,6 +129,20 @@ class HistoryPage {
                $month = $wgRequest->getInt( 'month' );
                $tagFilter = $wgRequest->getVal( 'tagfilter' );
                $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
+               /**
+                * Option to show only revisions that have been (partially) hidden via RevisionDelete
+                * Note that this can run a *long* time if there are many revisions to look at.
+                * We use "isBigDeletion" to determine if the history is too big to go through.
+                * Additionally, only users with 'deleterevision' right can filter for deleted edits.
+                */
+               if ( $this->title->userCan( 'deleterevision' ) && ( !$this->article->isBigDeletion() || $this->title->userCan( 'bigdelete' ) ) ) {
+                       $conds = ( $wgRequest->getBool( 'deleted' ) ) ? array("rev_deleted != '0'") : array();
+                       $checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ), 'deleted', '', $wgRequest->getBool( 'deleted' ) ) . "\n";
+               }
+               else { # Don't filter and don't add the checkbox for filtering
+                       $conds = array();
+                       $checkDeleted = '';
+               }
 
                $action = htmlspecialchars( $wgScript );
                $wgOut->addHTML(
@@ -140,8 +154,9 @@ class HistoryPage {
                        ) .
                        Xml::hidden( 'title', $this->title->getPrefixedDBKey() ) . "\n" .
                        Xml::hidden( 'action', 'history' ) . "\n" .
-                       xml::dateMenu( $year, $month ) . '&nbsp;' .
+                       Xml::dateMenu( $year, $month ) . '&nbsp;' .
                        ( $tagSelector ? ( implode( '&nbsp;', $tagSelector ) . '&nbsp;' ) : '' ) .
+                       $checkDeleted .
                        Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
                        '</fieldset></form>'
                );
@@ -151,7 +166,7 @@ class HistoryPage {
                /**
                 * Do the list
                 */
-               $pager = new HistoryPager( $this, $year, $month, $tagFilter );
+               $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
                $wgOut->addHTML(
                        $pager->getNavigationBar() .
                        $pager->getBody() .
@@ -284,15 +299,16 @@ class HistoryPage {
  * @ingroup Pager
  */
 class HistoryPager extends ReverseChronologicalPager {
-       public $lastRow = false, $counter, $historyPage, $title, $buttons;
+       public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds;
        protected $oldIdChecked;
 
-       function __construct( $historyPage, $year='', $month='', $tagFilter = '' ) {
+       function __construct( $historyPage, $year='', $month='', $tagFilter = '', $conds = array() ) {
                parent::__construct();
                $this->historyPage = $historyPage;
                $this->title = $this->historyPage->title;
                $this->tagFilter = $tagFilter;
                $this->getDateCond( $year, $month );
+               $this->conds = $conds;
        }
 
        // For hook compatibility...
@@ -304,7 +320,7 @@ class HistoryPager extends ReverseChronologicalPager {
                $queryInfo = array(
                        'tables'  => array('revision'),
                        'fields'  => array_merge( Revision::selectFields(), array('ts_tags') ),
-                       'conds'   => array('rev_page' => $this->historyPage->title->getArticleID() ),
+                       'conds'   => array_merge( array('rev_page' => $this->historyPage->title->getArticleID() ), $this->conds ),
                        'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
                        'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
                );
index 485ac70..f4383a4 100644 (file)
@@ -1407,6 +1407,7 @@ The reason given by $3 is ''$2''",
 Legend: '''({{int:cur}})''' = difference with current revision,
 '''({{int:last}})''' = difference with preceding revision, '''{{int:minoreditletter}}''' = minor edit.",
 'history-fieldset-title' => 'Browse history',
+'history-show-deleted'   => 'Deleted only',
 'history_copyright'      => '-', # do not translate or duplicate this message to other languages
 'histfirst'              => 'Earliest',
 'histlast'               => 'Latest',
index 990f364..f6d7536 100644 (file)
@@ -641,6 +641,7 @@ $wgMessageStructure = array(
                'page_last',
                'histlegend',
                'history-fieldset-title',
+               'history-show-deleted',
                'history_copyright',
                'histfirst',
                'histlast',