Tweaks for bug 18068:
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 26 Mar 2009 22:24:09 +0000 (22:24 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 26 Mar 2009 22:24:09 +0000 (22:24 +0000)
*Added unhide link for viewing of old deleted versions too
*Enabled diff buttons for privileged users

includes/Article.php
includes/PageHistory.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index ef219ea..4bebaa4 100644 (file)
@@ -929,17 +929,30 @@ class Article {
                                if( is_null( $this->mRevision ) ) {
                                        // FIXME: This would be a nice place to load the 'no such page' text.
                                } else {
-                                       $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
+                                       $this->setOldSubtitle( $oldid );
                                        # Allow admins to see deleted content if explicitly requested
                                        if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
-                                               if( !$unhide || !$this->mRevision->userCan(Revision::DELETED_TEXT) ) {
-                                                       $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n", 'rev-deleted-text-permission' );
+                                               // If the user is not allowed to see it...
+                                               if( !$this->mRevision->userCan(Revision::DELETED_TEXT) ) {
+                                                       $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n",
+                                                               'rev-deleted-text-permission' );
                                                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                                                        wfProfileOut( __METHOD__ );
                                                        return;
+                                               // If the user needs to confirm that they want to see it...
+                                               } else if( !$unhide ) {
+                                                       # Give explanation and add a link to view the revision...
+                                                       $link = $this->mTitle->getFullUrl( "oldid={$oldid}".
+                                                               '&unhide=1&token='.urlencode( $wgUser->editToken($oldid) ) );
+                                                       $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n",
+                                                               array('rev-deleted-text-unhide',$link) );
+                                                       $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+                                                       wfProfileOut( __METHOD__ );
+                                                       return;
+                                               // We are allowed to see...
                                                } else {
-                                                       $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n", 'rev-deleted-text-view' );
-                                                       // and we are allowed to see...
+                                                       $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n",
+                                                               'rev-deleted-text-view' );
                                                }
                                        }
                                        // Is this the current revision and otherwise cacheable? Try the parser cache...
index fd47943..9007187 100644 (file)
@@ -252,7 +252,9 @@ class PageHistory {
         * @param bool $firstInList Whether this row corresponds to the first displayed on this history page.
         * @return string HTML output for the row
         */
-       function historyLine( $row, $next, $counter = '', $notificationtimestamp = false, $latest = false, $firstInList = false ) {
+       function historyLine( $row, $next, $counter = '', $notificationtimestamp = false,
+               $latest = false, $firstInList = false )
+       {
                global $wgUser, $wgLang;
                $rev = new Revision( $row );
                $rev->setTitle( $this->mTitle );
@@ -268,10 +270,12 @@ class PageHistory {
                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'].')' );
+                               $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.
+                                       $this->message['rev-delundel'].')' );
                        } else 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'].')' );
+                               $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.
+                                       $this->message['rev-delundel'].')' );
                        } else {
                                $query = array( 'target' => $this->mTitle->getPrefixedDbkey(),
                                        'oldid' => $rev->getId()
@@ -350,10 +354,13 @@ class PageHistory {
        function revLink( $rev ) {
                global $wgLang;
                $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
-               if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
+               if( $rev->userCan( Revision::DELETED_TEXT ) ) {
                        $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() );
                } else {
-                       $link = '<span class="history-deleted">' . $date . '</span>';
+                       $link = $date;
+               }
+               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+                       $link = "<span class=\"history-deleted\">$link</span>";
                }
                return $link;
        }
@@ -366,7 +373,7 @@ class PageHistory {
         */
        function curLink( $rev, $latest ) {
                $cur = $this->message['cur'];
-               if( $latest || $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+               if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
                        return $cur;
                } else {
                        return $this->mSkin->makeKnownLinkObj( $this->mTitle, $cur,
@@ -392,7 +399,7 @@ class PageHistory {
                        # Next row probably exists but is unknown, use an oldid=prev link
                        return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last,
                                "diff=" . $prevRev->getId() . "&oldid=prev" );
-               } elseif( $prevRev->isDeleted(Revision::DELETED_TEXT) || $nextRev->isDeleted(Revision::DELETED_TEXT) ) {
+               } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) {
                        return $last;
                } else {
                        return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last,
@@ -419,7 +426,7 @@ class PageHistory {
                                $checkmark = array( 'checked' => 'checked' );
                        } else {
                                # Check visibility of old revisions
-                               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+                               if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
                                        $radio['disabled'] = 'disabled';
                                        $checkmark = array(); // We will check the next possible one
                                } else if( $counter == 2 || !$this->mOldIdChecked ) {
index 563ea47..60a1fec 100644 (file)
@@ -1294,6 +1294,9 @@ Try [[Special:Search|searching on the wiki]] for relevant new pages.',
 'rev-deleted-event'              => '(log action removed)',
 'rev-deleted-text-permission'    => "This page revision has been '''removed from the public archives'''.
 There may be details in the [{{fullurl:Special:Log/delete|page={{FULLPAGENAMEE}}}} deletion log].",
+'rev-deleted-text-unhide'        => "This page revision has been '''removed from the public archives'''.
+There may be details in the [{{fullurl:Special:Log/delete|page={{FULLPAGENAMEE}}}} deletion log].
+As an administrator you can still [$1 view this revision] if you wish to proceed.",
 'rev-deleted-text-view'          => "This page revision has been '''removed from the public archives'''.
 As an administrator you can view it; there may be details in the [{{fullurl:Special:Log/delete|page={{FULLPAGENAMEE}}}} deletion log].",
 'rev-deleted-no-diff'            => "You cannot view this diff because one of the revisions has been '''removed from the public archives'''.
index fb22bc9..ccc3dd8 100644 (file)
@@ -640,6 +640,7 @@ $wgMessageStructure = array(
                'rev-deleted-user',
                'rev-deleted-event',
                'rev-deleted-text-permission',
+               'rev-deleted-text-unhide',
                'rev-deleted-text-view',
                'rev-deleted-no-diff',
                'rev-deleted-unhide-diff',