* (bug 17543) Allow partial hiding of top revision
authorAaron Schulz <aaron@users.mediawiki.org>
Mon, 6 Apr 2009 01:43:38 +0000 (01:43 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Mon, 6 Apr 2009 01:43:38 +0000 (01:43 +0000)
* Fixed isCurrent() check
* Cleaned up/fixed some UI code duplication

includes/PageHistory.php
includes/specials/SpecialRevisiondelete.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index a137235..fde2167 100644 (file)
@@ -268,11 +268,7 @@ class PageHistory {
                $s = "($curlink) ($lastlink) $arbitrary";
 
                if( $wgUser->isAllowed( 'deleterevision' ) ) {
-                       if( $latest ) {
-                               // We don't currently handle well changing the top revision's settings
-                               $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.
-                                       $this->message['rev-delundel'].')' );
-                       } else if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
+                       if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
                                // If revision was hidden from sysops
                                $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.
                                        $this->message['rev-delundel'].')' );
index cf55929..3bc8709 100644 (file)
@@ -267,11 +267,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                $revObjs[$row->rev_id] = new Revision( $row );
                        }
                        foreach( $this->revisions as $revid ) {
-                               // Hiding top revisison is bad
-                               if( !isset($revObjs[$revid]) || $revObjs[$revid]->isCurrent() ) {
-                                       continue;
-                               } else if( !$revObjs[$revid]->userCan(Revision::DELETED_RESTRICTED) ) {
-                               // If a rev is hidden from sysops
+                               if( !isset($revObjs[$revid]) ) continue; // Must exist
+                               // Check if the revision was Oversighted
+                               if( !$revObjs[$revid]->userCan(Revision::DELETED_RESTRICTED) ) {
                                        if( !$this->wasPosted ) {
                                                $wgOut->permissionRequired( 'suppressrevision' );
                                                return;
@@ -812,31 +810,26 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $wgOut->permissionRequired( 'suppressrevision' );
                        return false;
                }
-               # If the save went through, go to success message. Otherwise
-               # bounce back to form...
+               # If the save went through, go to success message...
                if( $this->save( $bitfield, $comment, $this->page ) ) {
                        $this->success();
-               } else if( $request->getCheck( 'oldid' ) || $request->getCheck( 'artimestamp' ) ) {
-                       return $this->showRevs();
-               } else if( $request->getCheck( 'logid' ) ) {
-                       return $this->showLogs();
-               } else if( $request->getCheck( 'oldimage' ) || $request->getCheck( 'fileid' ) ) {
-                       return $this->showImages();
+                       return true;
+               # ...otherwise, bounce back to form...
+               } else {
+                       $this->failure();
                }
+               return false;
        }
 
        private function success() {
                global $wgOut;
-
                $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
-
                $wrap = '<span class="success">$1</span>';
-
                if( $this->deleteKey == 'logid' ) {
                        $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
                        $this->showLogItems();
                } else if( $this->deleteKey == 'oldid' || $this->deleteKey == 'artimestamp' ) {
-                               $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
+                       $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
                        $this->showRevs();
                } else if( $this->deleteKey == 'fileid' ) {
                        $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
@@ -846,6 +839,24 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $this->showImages();
                }
        }
+       
+       private function failure() {
+               global $wgOut;
+               $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
+               $wrap = '<span class="error">$1</span>';
+               if( $this->deleteKey == 'logid' ) {
+                       $this->showLogItems();
+               } else if( $this->deleteKey == 'oldid' || $this->deleteKey == 'artimestamp' ) {
+                       $wgOut->wrapWikiMsg( $wrap, 'revdelete-failure' );
+                       $this->showRevs();
+               } else if( $this->deleteKey == 'fileid' ) {
+                       $wgOut->wrapWikiMsg( $wrap, 'revdelete-failure' );
+                       $this->showImages();
+               } else if( $this->deleteKey == 'oldimage' ) {
+                       $wgOut->wrapWikiMsg( $wrap, 'revdelete-failure' );
+                       $this->showImages();
+               }
+       }
 
        /**
         * Put together a rev_deleted bitfield from the submitted checkboxes
@@ -882,6 +893,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                } else if( isset($this->events) ) {
                        return $deleter->setEventVisibility( $title, $this->events, $bitfield, $reason );
                }
+               return false;
        }
 }
 
@@ -910,30 +922,32 @@ class RevisionDeleter {
                foreach( $items as $revid ) {
                        $where[] = intval($revid);
                }
-               $result = $this->dbw->select( 'revision', '*',
-                       array(
-                               'rev_page' => $title->getArticleID(),
-                               'rev_id' => $where ),
-                       __METHOD__ );
+               $result = $this->dbw->select( array('revision','page'), '*',
+                       array( 'rev_page' => $title->getArticleID(),
+                               'rev_id' => $where, 'rev_page = page_id' ),
+                       __METHOD__
+               );
                while( $row = $this->dbw->fetchObject( $result ) ) {
                        $revObjs[$row->rev_id] = new Revision( $row );
                }
                // To work!
                foreach( $items as $revid ) {
-                       if( !isset($revObjs[$revid]) || $revObjs[$revid]->isCurrent() ) {
+                       if( !isset($revObjs[$revid]) ) {
                                $success = false;
                                continue; // Must exist
+                       } else if( $revObjs[$revid]->isCurrent() && ($bitfield & Revision::DELETED_TEXT) ) {
+                               $success = false;
+                               continue; // Cannot hide current version text
                        } else if( !$revObjs[$revid]->userCan(Revision::DELETED_RESTRICTED) ) {
-                       $userAllowedAll=false;
+                       $userAllowedAll = false;
                                continue;
                        }
                        // For logging, maintain a count of revisions
                        if( $revObjs[$revid]->mDeleted != $bitfield ) {
-                               $revCount++;
-                               $revIDs[]=$revid;
-
+                               $revIDs[] = $revid;
                                $this->updateRevision( $revObjs[$revid], $bitfield );
                                $this->updateRecentChangesEdits( $revObjs[$revid], $bitfield, false );
+                               $revCount++;
                        }
                }
                // Clear caches...
index 0014f79..8620cca 100644 (file)
@@ -1340,6 +1340,7 @@ Please confirm that you intend to do this, that you understand the consequences,
 'revdelete-logentry'             => 'changed revision visibility of [[$1]]',
 'logdelete-logentry'             => 'changed event visibility of [[$1]]',
 'revdelete-success'              => "'''Revision visibility successfully set.'''",
+'revdelete-failure'              => "'''Revision visibility could not be set.'''",
 'logdelete-success'              => "'''Log visibility successfully set.'''",
 'revdel-restore'                 => 'change visibility',
 'pagehist'                       => 'Page history',
index b951dda..9c90eb4 100644 (file)
@@ -674,6 +674,7 @@ $wgMessageStructure = array(
                'revdelete-logaction',
                'logdelete-logaction',
                'revdelete-success',
+               'revdelete-failure',
                'logdelete-success',
                'revdel-restore',
                'pagehist',