r60945 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60944‎ | r60945 | r60946 >
Date:21:35, 11 January 2010
Author:aaron
Status:ok
Tags:
Comment:
Refactored duplication into revisionDeleteLink()
Modified paths:
  • /trunk/phase3/includes/diff/DifferenceInterface.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceInterface.php
@@ -312,47 +312,21 @@
313313 $newminor = ChangesList::flag( 'minor' );
314314 }
315315
316 - $rdel = $ldel = '';
317316 # Handle RevisionDelete links...
318 - $canHide = $wgUser->isAllowed( 'deleterevision' );
319 - // Don't show useless link to people who cannot hide revisions
320 - if( $canHide || ($this->mOldRev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
321 - if( !$this->mOldRev->userCan( Revision::DELETED_RESTRICTED ) ) {
322 - $ldel = $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
323 - } else {
324 - $query = array(
325 - 'type' => 'revision',
326 - 'target' => $this->mOldRev->mTitle->getPrefixedDbkey(),
327 - 'ids' => $this->mOldRev->getId()
328 - );
329 - $ldel = $sk->revDeleteLink( $query,
330 - $this->mOldRev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
331 - }
332 - $ldel = "   $ldel ";
333 - }
334 - // Don't show useless link to people who cannot hide revisions
335 - if( $canHide || ($this->mNewRev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
336 - if( !$this->mNewRev->userCan( Revision::DELETED_RESTRICTED ) ) {
337 - $rdel = $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
338 - } else {
339 - $query = array(
340 - 'type' => 'revision',
341 - 'target' => $this->mNewRev->mTitle->getPrefixedDbkey(),
342 - 'ids' => $this->mNewRev->getId()
343 - );
344 - $rdel = $sk->revDeleteLink( $query,
345 - $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
346 - }
347 - $rdel = "   $rdel ";
348 - }
 317+ $ldel = $this->revisionDeleteLink( $this->mOldRev );
 318+ $rdel = $this->revisionDeleteLink( $this->mNewRev );
349319
350320 $oldHeader = '<div id="mw-diff-otitle1"><strong>'.$this->mOldtitle.'</strong></div>' .
351 - '<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, !$this->unhide ) . "</div>" .
352 - '<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, !$this->unhide ).$ldel."</div>" .
 321+ '<div id="mw-diff-otitle2">' .
 322+ $sk->revUserTools( $this->mOldRev, !$this->unhide ).'</div>' .
 323+ '<div id="mw-diff-otitle3">' . $oldminor .
 324+ $sk->revComment( $this->mOldRev, !$diffOnly, !$this->unhide ).$ldel.'</div>' .
353325 '<div id="mw-diff-otitle4">' . $prevlink .'</div>';
354326 $newHeader = '<div id="mw-diff-ntitle1"><strong>'.$this->mNewtitle.'</strong></div>' .
355 - '<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, !$this->unhide ) . " $rollback</div>" .
356 - '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, !$this->unhide ).$rdel."</div>" .
 327+ '<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, !$this->unhide ) .
 328+ " $rollback</div>" .
 329+ '<div id="mw-diff-ntitle3">' . $newminor .
 330+ $sk->revComment( $this->mNewRev, !$diffOnly, !$this->unhide ).$rdel.'</div>' .
357331 '<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';
358332
359333 # Check if this user can see the revisions
@@ -406,6 +380,31 @@
407381 }
408382 wfProfileOut( __METHOD__ );
409383 }
 384+
 385+ protected function revisionDeleteLink( $rev ) {
 386+ global $wgUser;
 387+ $link = '';
 388+ $canHide = $wgUser->isAllowed( 'deleterevision' );
 389+ // Show del/undel link if:
 390+ // (a) the user can delete revisions, or
 391+ // (b) the user can view deleted revision *and* this one is deleted
 392+ if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' )) ) {
 393+ $sk = $wgUser->getSkin();
 394+ if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
 395+ $link = $sk->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
 396+ } else {
 397+ $query = array(
 398+ 'type' => 'revision',
 399+ 'target' => $this->mOldRev->mTitle->getPrefixedDbkey(),
 400+ 'ids' => $this->mOldRev->getId()
 401+ );
 402+ $link = $sk->revDeleteLink( $query,
 403+ $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
 404+ }
 405+ $link = '&nbsp;&nbsp;&nbsp'.$link.' ';
 406+ }
 407+ return $link;
 408+ }
410409
411410 /**
412411 * Show the new revision of the page.

Follow-up revisions

RevisionCommit summaryAuthorDate
r64802fixing bug 23113 (introduced in r60945) which breaks show/hide links in diffschurchofemacs14:38, 9 April 2010

Status & tagging log