Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | $change = RecentChange::newFromConds( |
178 | 178 | array( |
179 | 179 | // Add redundant user,timestamp condition so we can use the existing index |
180 | | - 'rc_user_text' => $this->mNewRev->getUserText(false), |
| 180 | + 'rc_user_text' => $this->mNewRev->getUserText( Revision::FOR_THIS_USER ), |
181 | 181 | 'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ), |
182 | 182 | 'rc_this_oldid' => $this->mNewid, |
183 | 183 | 'rc_last_oldid' => $this->mOldid, |
— | — | @@ -847,13 +847,13 @@ |
848 | 848 | return false; |
849 | 849 | } |
850 | 850 | if ( $this->mOldRev ) { |
851 | | - $this->mOldtext = $this->mOldRev->getText( false ); |
| 851 | + $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER ); |
852 | 852 | if ( $this->mOldtext === false ) { |
853 | 853 | return false; |
854 | 854 | } |
855 | 855 | } |
856 | 856 | if ( $this->mNewRev ) { |
857 | | - $this->mNewtext = $this->mNewRev->getText( false ); |
| 857 | + $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER ); |
858 | 858 | if ( $this->mNewtext === false ) { |
859 | 859 | return false; |
860 | 860 | } |
— | — | @@ -2114,4 +2114,4 @@ |
2115 | 2115 | } |
2116 | 2116 | wfProfileOut( __METHOD__ ); |
2117 | 2117 | } |
2118 | | -} |
\ No newline at end of file |
| 2118 | +} |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -448,7 +448,7 @@ |
449 | 449 | |
450 | 450 | // FIXME: Horrible, horrible! This content-loading interface just plain sucks. |
451 | 451 | // We should instead work with the Revision object when we need it... |
452 | | - $this->mContent = $revision->getText( false ); // Loads if user is allowed |
| 452 | + $this->mContent = $revision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed |
453 | 453 | |
454 | 454 | $this->mUser = $revision->getUser(); |
455 | 455 | $this->mUserText = $revision->getUserText(); |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -1113,7 +1113,8 @@ |
1114 | 1114 | if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { |
1115 | 1115 | $link = wfMsgHtml( 'rev-deleted-user' ); |
1116 | 1116 | } else if( $rev->userCan( Revision::DELETED_USER ) ) { |
1117 | | - $link = $this->userLink( $rev->getUser(false), $rev->getUserText(false) ); |
| 1117 | + $link = $this->userLink( $rev->getUser( Revision::FOR_THIS_USER ), |
| 1118 | + $rev->getUserText( Revision::FOR_THIS_USER ) ); |
1118 | 1119 | } else { |
1119 | 1120 | $link = wfMsgHtml( 'rev-deleted-user' ); |
1120 | 1121 | } |
— | — | @@ -1133,8 +1134,10 @@ |
1134 | 1135 | if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { |
1135 | 1136 | $link = wfMsgHtml( 'rev-deleted-user' ); |
1136 | 1137 | } else if( $rev->userCan( Revision::DELETED_USER ) ) { |
1137 | | - $link = $this->userLink( $rev->getUser(false), $rev->getUserText(false) ) . |
1138 | | - ' ' . $this->userToolLinks( $rev->getUser(false), $rev->getUserText(false) ); |
| 1138 | + $userId = $rev->getUser( Revision::FOR_THIS_USER ); |
| 1139 | + $userText = $rev->getUserText( Revision::FOR_THIS_USER ); |
| 1140 | + $link = $this->userLink( $userId, $userText ) . |
| 1141 | + ' ' . $this->userToolLinks( $userId, $userText ); |
1139 | 1142 | } else { |
1140 | 1143 | $link = wfMsgHtml( 'rev-deleted-user' ); |
1141 | 1144 | } |
— | — | @@ -1340,7 +1343,8 @@ |
1341 | 1344 | if( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) { |
1342 | 1345 | $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>"; |
1343 | 1346 | } else if( $rev->userCan( Revision::DELETED_COMMENT ) ) { |
1344 | | - $block = $this->commentBlock( $rev->getComment(false), $rev->getTitle(), $local ); |
| 1347 | + $block = $this->commentBlock( $rev->getComment( Revision::FOR_THIS_USER ), |
| 1348 | + $rev->getTitle(), $local ); |
1345 | 1349 | } else { |
1346 | 1350 | $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>"; |
1347 | 1351 | } |
Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | $this->dieUsage("There is no revision ID $oldid", 'missingrev'); |
65 | 65 | if(!$rev->userCan(Revision::DELETED_TEXT)) |
66 | 66 | $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied'); |
67 | | - $text = $rev->getText(false); |
| 67 | + $text = $rev->getText( Revision::FOR_THIS_USER ); |
68 | 68 | $titleObj = $rev->getTitle(); |
69 | 69 | $p_result = $wgParser->parse($text, $titleObj, $popts); |
70 | 70 | } |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -13,6 +13,11 @@ |
14 | 14 | const DELETED_USER = 4; |
15 | 15 | const DELETED_RESTRICTED = 8; |
16 | 16 | |
| 17 | + // Audience options for Revision::getText() |
| 18 | + const FOR_PUBLIC = 1; |
| 19 | + const FOR_THIS_USER = 2; |
| 20 | + const RAW = 3; |
| 21 | + |
17 | 22 | /** |
18 | 23 | * Load a page revision from a given revision ID number. |
19 | 24 | * Returns null if no such revision can be found. |
— | — | @@ -427,13 +432,22 @@ |
428 | 433 | } |
429 | 434 | |
430 | 435 | /** |
431 | | - * Fetch revision's user id if it's available to all users |
| 436 | + * Fetch revision's user id if it's available to the specified audience. |
| 437 | + * If the specified audience does not have access to it, zero will be |
| 438 | + * returned. |
| 439 | + * |
| 440 | + * @param integer $audience One of: |
| 441 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 442 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 443 | + * Revision::RAW get the ID regardless of permissions |
| 444 | + * |
| 445 | + * |
432 | 446 | * @return int |
433 | 447 | */ |
434 | | - public function getUser( $isPublic = true ) { |
435 | | - if( $isPublic && $this->isDeleted( self::DELETED_USER ) ) { |
| 448 | + public function getUser( $audience = self::FOR_PUBLIC ) { |
| 449 | + if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) { |
436 | 450 | return 0; |
437 | | - } else if( !$this->userCan( self::DELETED_USER ) ) { |
| 451 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) { |
438 | 452 | return 0; |
439 | 453 | } else { |
440 | 454 | return $this->mUser; |
— | — | @@ -449,13 +463,21 @@ |
450 | 464 | } |
451 | 465 | |
452 | 466 | /** |
453 | | - * Fetch revision's username if it's available to all users |
| 467 | + * Fetch revision's username if it's available to the specified audience. |
| 468 | + * If the specified audience does not have access to the username, an |
| 469 | + * empty string will be returned. |
| 470 | + * |
| 471 | + * @param integer $audience One of: |
| 472 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 473 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 474 | + * Revision::RAW get the text regardless of permissions |
| 475 | + * |
454 | 476 | * @return string |
455 | 477 | */ |
456 | | - public function getUserText( $isPublic = true ) { |
457 | | - if( $isPublic && $this->isDeleted( self::DELETED_USER ) ) { |
| 478 | + public function getUserText( $audience = self::FOR_PUBLIC ) { |
| 479 | + if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) { |
458 | 480 | return ""; |
459 | | - } else if( !$this->userCan( self::DELETED_USER ) ) { |
| 481 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) { |
460 | 482 | return ""; |
461 | 483 | } else { |
462 | 484 | return $this->mUserText; |
— | — | @@ -471,13 +493,21 @@ |
472 | 494 | } |
473 | 495 | |
474 | 496 | /** |
475 | | - * Fetch revision comment if it's available to all users |
| 497 | + * Fetch revision comment if it's available to the specified audience. |
| 498 | + * If the specified audience does not have access to the comment, an |
| 499 | + * empty string will be returned. |
| 500 | + * |
| 501 | + * @param integer $audience One of: |
| 502 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 503 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 504 | + * Revision::RAW get the text regardless of permissions |
| 505 | + * |
476 | 506 | * @return string |
477 | 507 | */ |
478 | | - function getComment( $isPublic = true ) { |
479 | | - if( $isPublic && $this->isDeleted( self::DELETED_COMMENT ) ) { |
| 508 | + function getComment( $audience = self::FOR_PUBLIC ) { |
| 509 | + if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) { |
480 | 510 | return ""; |
481 | | - } else if( !$this->userCan( self::DELETED_COMMENT ) ) { |
| 511 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT ) ) { |
482 | 512 | return ""; |
483 | 513 | } else { |
484 | 514 | return $this->mComment; |
— | — | @@ -508,13 +538,22 @@ |
509 | 539 | } |
510 | 540 | |
511 | 541 | /** |
512 | | - * Fetch revision text if it's available to all users |
| 542 | + * Fetch revision text if it's available to the specified audience. |
| 543 | + * If the specified audience does not have the ability to view this |
| 544 | + * revision, an empty string will be returned. |
| 545 | + * |
| 546 | + * @param integer $audience One of: |
| 547 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 548 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 549 | + * Revision::RAW get the text regardless of permissions |
| 550 | + * |
| 551 | + * |
513 | 552 | * @return string |
514 | 553 | */ |
515 | | - public function getText( $isPublic = true ) { |
516 | | - if( $isPublic && $this->isDeleted( self::DELETED_TEXT ) ) { |
| 554 | + public function getText( $audience = self::FOR_PUBLIC ) { |
| 555 | + if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) { |
517 | 556 | return ""; |
518 | | - } else if( !$this->userCan( self::DELETED_TEXT ) ) { |
| 557 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT ) ) { |
519 | 558 | return ""; |
520 | 559 | } else { |
521 | 560 | return $this->getRawText(); |
— | — | @@ -522,6 +561,13 @@ |
523 | 562 | } |
524 | 563 | |
525 | 564 | /** |
| 565 | + * Alias for getText(Revision::FOR_THIS_USER) |
| 566 | + */ |
| 567 | + public function revText() { |
| 568 | + return $this->getText( self::FOR_THIS_USER ); |
| 569 | + } |
| 570 | + |
| 571 | + /** |
526 | 572 | * Fetch revision text without regard for view restrictions |
527 | 573 | * @return string |
528 | 574 | */ |
Index: trunk/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -787,7 +787,7 @@ |
788 | 788 | $popts = $wgOut->parserOptions(); |
789 | 789 | $popts->setEditSection( false ); |
790 | 790 | $wgOut->parserOptions( $popts ); |
791 | | - $wgOut->addWikiTextTitleTidy( $rev->getText( false ), $this->mTargetObj, true ); |
| 791 | + $wgOut->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER ), $this->mTargetObj, true ); |
792 | 792 | } |
793 | 793 | |
794 | 794 | $wgOut->addHtml( |
— | — | @@ -795,7 +795,7 @@ |
796 | 796 | 'readonly' => 'readonly', |
797 | 797 | 'cols' => intval( $wgUser->getOption( 'cols' ) ), |
798 | 798 | 'rows' => intval( $wgUser->getOption( 'rows' ) ) ), |
799 | | - $rev->getText( false ) . "\n" ) . |
| 799 | + $rev->getText( Revision::FOR_THIS_USER ) . "\n" ) . |
800 | 800 | wfOpenElement( 'div' ) . |
801 | 801 | wfOpenElement( 'form', array( |
802 | 802 | 'method' => 'post', |
— | — | @@ -1223,8 +1223,8 @@ |
1224 | 1224 | if( !$file->userCan(File::DELETED_USER) ) { |
1225 | 1225 | return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
1226 | 1226 | } else { |
1227 | | - $link = $sk->userLink( $file->getUser(false), $file->getUserText(false) ) . |
1228 | | - $sk->userToolLinks( $file->getUser(false), $file->getUserText(false) ); |
| 1227 | + $link = $sk->userLink( $file->getUser(), $file->getUserText() ) . |
| 1228 | + $sk->userToolLinks( $file->getUser(), $file->getUserText() ); |
1229 | 1229 | if( $file->isDeleted(File::DELETED_USER) ) |
1230 | 1230 | $link = '<span class="history-deleted">' . $link . '</span>'; |
1231 | 1231 | return $link; |