* Hide (undo) link if user isn't able to edit page
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 12 Apr 2008 17:58:58 +0000 (17:58 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 12 Apr 2008 17:58:58 +0000 (17:58 +0000)
RELEASE-NOTES
includes/DifferenceEngine.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 2707ea5..779ecc8 100644 (file)
@@ -173,6 +173,7 @@ Special:EmailUser
 * (bug 13678) Fix CSS validation for Monobook
 * (bug 13684) Links in Special:ListGroupRights should be in content language
 * (bug 13690) Fix PHP notice on accessing some URLs
+* Hide (undo) link if user isn't able to edit page
 
 === API changes in 1.13 ===
 
index 4d5848a..37c73ec 100644 (file)
@@ -638,6 +638,9 @@ CONTROL;
                
                // Update the new revision ID in case it was 0 (makes life easier doing UI stuff)
                $this->mNewid = $this->mNewRev->getId();
+
+               // Check if page is editable
+               $editable = $this->mNewRev->getTitle()->userCan( 'edit' );
                
                // Set assorted variables
                $timestamp = $wgLang->timeanddate( $this->mNewRev->getTimestamp(), true );
@@ -647,16 +650,16 @@ CONTROL;
                        $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) );
                        $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' );
 
-                       $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)"
-                               . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
+                       $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)";
+                       $this->mNewtitle .= " (<a href='$newEdit'>" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
 
                } else {
                        $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
                        $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid );
                        $this->mPagetitle = wfMsgHTML( 'revisionasof', $timestamp );
 
-                       $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>"
-                               . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
+                       $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>";
+                       $this->mNewtitle .= " (<a href='$newEdit'>" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
                }
                if ( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
                        $this->mNewtitle = "<span class='history-deleted'>{$this->mPagetitle}</span>";
@@ -693,10 +696,10 @@ CONTROL;
                        $this->mOldPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t ) );
                        
                        $this->mOldtitle = "<a href='$oldLink'>{$this->mOldPagetitle}</a>"
-                               . " (<a href='$oldEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)";
+                               . " (<a href='$oldEdit'>" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
                        // Add an "undo" link
                        $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid);
-                       if ( $this->mNewRev->userCan(Revision::DELETED_TEXT) )
+                       if ( $editable && $this->mNewRev->userCan(Revision::DELETED_TEXT) )
                                $this->mNewtitle .= " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)";
                        
                        if ( !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) {
index 14b7a71..1063e8f 100644 (file)
@@ -721,6 +721,7 @@ XHTML id names.
 'editsection'                  => 'edit',
 'editsection-brackets'         => '[$1]', # only translate this message to other languages if you have to change it
 'editold'                      => 'edit',
+'viewsourceold'                => 'view source',
 'editsectionhint'              => 'Edit section: $1',
 'toc'                          => 'Contents',
 'showtoc'                      => 'show',
index cbf4d8c..6b0df77 100644 (file)
@@ -270,6 +270,7 @@ $wgMessageStructure = array(
                'editsection',
                'editsection-brackets',
                'editold',
+               'viewsourceold',
                'editsectionhint',
                'toc',
                'showtoc',