Index: trunk/phase3/includes/filerepo/OldLocalFile.php |
— | — | @@ -205,11 +205,12 @@ |
206 | 206 | * field of this image file, if it's marked as deleted. |
207 | 207 | * |
208 | 208 | * @param $field Integer |
| 209 | + * @param $user User object to check, or null to use $wgUser |
209 | 210 | * @return bool |
210 | 211 | */ |
211 | | - function userCan( $field ) { |
| 212 | + function userCan( $field, User $user = null ) { |
212 | 213 | $this->load(); |
213 | | - return Revision::userCanBitfield( $this->deleted, $field ); |
| 214 | + return Revision::userCanBitfield( $this->deleted, $field, $user ); |
214 | 215 | } |
215 | 216 | |
216 | 217 | /** |
Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -1437,9 +1437,10 @@ |
1438 | 1438 | * field of this file, if it's marked as deleted. |
1439 | 1439 | * STUB |
1440 | 1440 | * @param $field Integer |
| 1441 | + * @param $user User object to check, or null to use $wgUser |
1441 | 1442 | * @return Boolean |
1442 | 1443 | */ |
1443 | | - function userCan( $field ) { |
| 1444 | + function userCan( $field, User $user = null ) { |
1444 | 1445 | return true; |
1445 | 1446 | } |
1446 | 1447 | |
Index: trunk/phase3/includes/filerepo/ArchivedFile.php |
— | — | @@ -461,10 +461,11 @@ |
462 | 462 | * Determine if the current user is allowed to view a particular |
463 | 463 | * field of this FileStore image file, if it's marked as deleted. |
464 | 464 | * @param $field Integer |
| 465 | + * @param $user User object to check, or null to use $wgUser |
465 | 466 | * @return bool |
466 | 467 | */ |
467 | | - public function userCan( $field ) { |
| 468 | + public function userCan( $field, User $user = null ) { |
468 | 469 | $this->load(); |
469 | | - return Revision::userCanBitfield( $this->deleted, $field ); |
| 470 | + return Revision::userCanBitfield( $this->deleted, $field, $user ); |
470 | 471 | } |
471 | 472 | } |
Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php |
— | — | @@ -132,11 +132,11 @@ |
133 | 133 | } |
134 | 134 | |
135 | 135 | public function canView() { |
136 | | - return $this->revision->userCan( Revision::DELETED_RESTRICTED ); |
| 136 | + return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->list->getUser() ); |
137 | 137 | } |
138 | 138 | |
139 | 139 | public function canViewContent() { |
140 | | - return $this->revision->userCan( Revision::DELETED_TEXT ); |
| 140 | + return $this->revision->userCan( Revision::DELETED_TEXT, $this->list->getUser() ); |
141 | 141 | } |
142 | 142 | |
143 | 143 | public function getBits() { |
— | — | @@ -509,11 +509,11 @@ |
510 | 510 | } |
511 | 511 | |
512 | 512 | public function canView() { |
513 | | - return $this->file->userCan( File::DELETED_RESTRICTED ); |
| 513 | + return $this->file->userCan( File::DELETED_RESTRICTED, $this->list->getUser() ); |
514 | 514 | } |
515 | 515 | |
516 | 516 | public function canViewContent() { |
517 | | - return $this->file->userCan( File::DELETED_FILE ); |
| 517 | + return $this->file->userCan( File::DELETED_FILE, $this->list->getUser() ); |
518 | 518 | } |
519 | 519 | |
520 | 520 | public function getBits() { |
— | — | @@ -596,7 +596,7 @@ |
597 | 597 | * @return string HTML |
598 | 598 | */ |
599 | 599 | protected function getUserTools() { |
600 | | - if( $this->file->userCan( Revision::DELETED_USER ) ) { |
| 600 | + if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) { |
601 | 601 | $link = Linker::userLink( $this->file->user, $this->file->user_text ) . |
602 | 602 | Linker::userToolLinks( $this->file->user, $this->file->user_text ); |
603 | 603 | } else { |
— | — | @@ -615,7 +615,7 @@ |
616 | 616 | * @return string HTML |
617 | 617 | */ |
618 | 618 | protected function getComment() { |
619 | | - if( $this->file->userCan( File::DELETED_COMMENT ) ) { |
| 619 | + if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { |
620 | 620 | $block = Linker::commentBlock( $this->file->description ); |
621 | 621 | } else { |
622 | 622 | $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); |
— | — | @@ -807,7 +807,7 @@ |
808 | 808 | } |
809 | 809 | |
810 | 810 | public function canView() { |
811 | | - return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED ); |
| 811 | + return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() ); |
812 | 812 | } |
813 | 813 | |
814 | 814 | public function canViewContent() { |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -557,10 +557,11 @@ |
558 | 558 | * |
559 | 559 | * @param $row Row |
560 | 560 | * @param $field Integer |
| 561 | + * @param $user User object to check, or null to use $wgUser |
561 | 562 | * @return Boolean |
562 | 563 | */ |
563 | | - public static function userCan( $row, $field ) { |
564 | | - return self::userCanBitfield( $row->log_deleted, $field ); |
| 564 | + public static function userCan( $row, $field, User $user = null ) { |
| 565 | + return self::userCanBitfield( $row->log_deleted, $field, $user ); |
565 | 566 | } |
566 | 567 | |
567 | 568 | /** |
— | — | @@ -569,19 +570,22 @@ |
570 | 571 | * |
571 | 572 | * @param $bitfield Integer (current field) |
572 | 573 | * @param $field Integer |
| 574 | + * @param $user User object to check, or null to use $wgUser |
573 | 575 | * @return Boolean |
574 | 576 | */ |
575 | | - public static function userCanBitfield( $bitfield, $field ) { |
| 577 | + public static function userCanBitfield( $bitfield, $field, User $user = null ) { |
576 | 578 | if( $bitfield & $field ) { |
577 | | - global $wgUser; |
578 | | - |
579 | 579 | if ( $bitfield & LogPage::DELETED_RESTRICTED ) { |
580 | 580 | $permission = 'suppressrevision'; |
581 | 581 | } else { |
582 | 582 | $permission = 'deletedhistory'; |
583 | 583 | } |
584 | 584 | wfDebug( "Checking for $permission due to $field match on $bitfield\n" ); |
585 | | - return $wgUser->isAllowed( $permission ); |
| 585 | + if ( $user === null ) { |
| 586 | + global $wgUser; |
| 587 | + $user = $wgUser; |
| 588 | + } |
| 589 | + return $user->isAllowed( $permission ); |
586 | 590 | } else { |
587 | 591 | return true; |
588 | 592 | } |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -490,14 +490,14 @@ |
491 | 491 | * Revision::FOR_PUBLIC to be displayed to all users |
492 | 492 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
493 | 493 | * Revision::RAW get the ID regardless of permissions |
494 | | - * |
495 | | - * |
| 494 | + * @param $user User object to check for, only if FOR_THIS_USER is passed |
| 495 | + * to the $audience parameter |
496 | 496 | * @return Integer |
497 | 497 | */ |
498 | | - public function getUser( $audience = self::FOR_PUBLIC ) { |
| 498 | + public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) { |
499 | 499 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) { |
500 | 500 | return 0; |
501 | | - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) { |
| 501 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) { |
502 | 502 | return 0; |
503 | 503 | } else { |
504 | 504 | return $this->mUser; |
— | — | @@ -522,13 +522,14 @@ |
523 | 523 | * Revision::FOR_PUBLIC to be displayed to all users |
524 | 524 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
525 | 525 | * Revision::RAW get the text regardless of permissions |
526 | | - * |
| 526 | + * @param $user User object to check for, only if FOR_THIS_USER is passed |
| 527 | + * to the $audience parameter |
527 | 528 | * @return string |
528 | 529 | */ |
529 | | - public function getUserText( $audience = self::FOR_PUBLIC ) { |
| 530 | + public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) { |
530 | 531 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) { |
531 | 532 | return ''; |
532 | | - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) { |
| 533 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) { |
533 | 534 | return ''; |
534 | 535 | } else { |
535 | 536 | return $this->mUserText; |
— | — | @@ -553,13 +554,14 @@ |
554 | 555 | * Revision::FOR_PUBLIC to be displayed to all users |
555 | 556 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
556 | 557 | * Revision::RAW get the text regardless of permissions |
557 | | - * |
| 558 | + * @param $user User object to check for, only if FOR_THIS_USER is passed |
| 559 | + * to the $audience parameter |
558 | 560 | * @return String |
559 | 561 | */ |
560 | | - function getComment( $audience = self::FOR_PUBLIC ) { |
| 562 | + function getComment( $audience = self::FOR_PUBLIC, User $user = null ) { |
561 | 563 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) { |
562 | 564 | return ''; |
563 | | - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT ) ) { |
| 565 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT, $user ) ) { |
564 | 566 | return ''; |
565 | 567 | } else { |
566 | 568 | return $this->mComment; |
— | — | @@ -630,13 +632,14 @@ |
631 | 633 | * Revision::FOR_PUBLIC to be displayed to all users |
632 | 634 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
633 | 635 | * Revision::RAW get the text regardless of permissions |
634 | | - * |
| 636 | + * @param $user User object to check for, only if FOR_THIS_USER is passed |
| 637 | + * to the $audience parameter |
635 | 638 | * @return String |
636 | 639 | */ |
637 | | - public function getText( $audience = self::FOR_PUBLIC ) { |
| 640 | + public function getText( $audience = self::FOR_PUBLIC, User $user = null ) { |
638 | 641 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) { |
639 | 642 | return ''; |
640 | | - } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT ) ) { |
| 643 | + } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT, $user ) ) { |
641 | 644 | return ''; |
642 | 645 | } else { |
643 | 646 | return $this->getRawText(); |
— | — | @@ -1023,10 +1026,11 @@ |
1024 | 1027 | * @param $field Integer:one of self::DELETED_TEXT, |
1025 | 1028 | * self::DELETED_COMMENT, |
1026 | 1029 | * self::DELETED_USER |
| 1030 | + * @param $user User object to check, or null to use $wgUser |
1027 | 1031 | * @return Boolean |
1028 | 1032 | */ |
1029 | | - public function userCan( $field ) { |
1030 | | - return self::userCanBitfield( $this->mDeleted, $field ); |
| 1033 | + public function userCan( $field, User $user = null ) { |
| 1034 | + return self::userCanBitfield( $this->mDeleted, $field, $user ); |
1031 | 1035 | } |
1032 | 1036 | |
1033 | 1037 | /** |
— | — | @@ -1038,11 +1042,11 @@ |
1039 | 1043 | * @param $field Integer: one of self::DELETED_TEXT = File::DELETED_FILE, |
1040 | 1044 | * self::DELETED_COMMENT = File::DELETED_COMMENT, |
1041 | 1045 | * self::DELETED_USER = File::DELETED_USER |
| 1046 | + * @param $user User object to check, or null to use $wgUser |
1042 | 1047 | * @return Boolean |
1043 | 1048 | */ |
1044 | | - public static function userCanBitfield( $bitfield, $field ) { |
| 1049 | + public static function userCanBitfield( $bitfield, $field, User $user = null ) { |
1045 | 1050 | if( $bitfield & $field ) { // aspect is deleted |
1046 | | - global $wgUser; |
1047 | 1051 | if ( $bitfield & self::DELETED_RESTRICTED ) { |
1048 | 1052 | $permission = 'suppressrevision'; |
1049 | 1053 | } elseif ( $field & self::DELETED_TEXT ) { |
— | — | @@ -1051,7 +1055,11 @@ |
1052 | 1056 | $permission = 'deletedhistory'; |
1053 | 1057 | } |
1054 | 1058 | wfDebug( "Checking for $permission due to $field match on $bitfield\n" ); |
1055 | | - return $wgUser->isAllowed( $permission ); |
| 1059 | + if ( $user === null ) { |
| 1060 | + global $wgUser; |
| 1061 | + $user = $wgUser; |
| 1062 | + } |
| 1063 | + return $user->isAllowed( $permission ); |
1056 | 1064 | } else { |
1057 | 1065 | return true; |
1058 | 1066 | } |
Index: trunk/phase3/includes/ChangesList.php |
— | — | @@ -262,7 +262,7 @@ |
263 | 263 | # Diff link |
264 | 264 | if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) { |
265 | 265 | $diffLink = $this->message['diff']; |
266 | | - } elseif( !self::userCan($rc,Revision::DELETED_TEXT) ) { |
| 266 | + } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) { |
267 | 267 | $diffLink = $this->message['diff']; |
268 | 268 | } else { |
269 | 269 | $query = array( |
— | — | @@ -422,13 +422,14 @@ |
423 | 423 | * field of this revision, if it's marked as deleted. |
424 | 424 | * @param $rc RCCacheEntry |
425 | 425 | * @param $field Integer |
| 426 | + * @param $user User object to check, or null to use $wgUser |
426 | 427 | * @return Boolean |
427 | 428 | */ |
428 | | - public static function userCan( $rc, $field ) { |
| 429 | + public static function userCan( $rc, $field, User $user = null ) { |
429 | 430 | if( $rc->mAttribs['rc_type'] == RC_LOG ) { |
430 | | - return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field ); |
| 431 | + return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user ); |
431 | 432 | } else { |
432 | | - return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field ); |
| 433 | + return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user ); |
433 | 434 | } |
434 | 435 | } |
435 | 436 | |
— | — | @@ -675,7 +676,7 @@ |
676 | 677 | } |
677 | 678 | |
678 | 679 | # Don't show unusable diff links |
679 | | - if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) { |
| 680 | + if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) { |
680 | 681 | $showdifflinks = false; |
681 | 682 | } |
682 | 683 | |
— | — | @@ -883,7 +884,7 @@ |
884 | 885 | $r .= ' '; |
885 | 886 | if( !$allLogs ) { |
886 | 887 | $r .= '('; |
887 | | - if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) { |
| 888 | + if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { |
888 | 889 | $r .= $nchanges[$n]; |
889 | 890 | } elseif( $isnew ) { |
890 | 891 | $r .= $nchanges[$n]; |
— | — | @@ -972,7 +973,7 @@ |
973 | 974 | if( $type == RC_LOG ) { |
974 | 975 | $link = $rcObj->timestamp; |
975 | 976 | # Revision link |
976 | | - } elseif( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) { |
| 977 | + } elseif( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { |
977 | 978 | $link = '<span class="history-deleted">'.$rcObj->timestamp.'</span> '; |
978 | 979 | } else { |
979 | 980 | if ( $rcObj->unpatrolled && $type == RC_NEW) { |
Index: trunk/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -634,7 +634,9 @@ |
635 | 635 | |
636 | 636 | function execute( $par ) { |
637 | 637 | $this->setHeaders(); |
638 | | - if ( !$this->userCanExecute( $this->getUser() ) ) { |
| 638 | + |
| 639 | + $user = $this->getUser(); |
| 640 | + if ( !$this->userCanExecute( $user ) ) { |
639 | 641 | $this->displayRestrictionError(); |
640 | 642 | return; |
641 | 643 | } |
— | — | @@ -663,7 +665,7 @@ |
664 | 666 | |
665 | 667 | if( is_null( $this->mTargetObj ) ) { |
666 | 668 | # Not all users can just browse every deleted page from the list |
667 | | - if( $this->getUser()->isAllowed( 'browsearchive' ) ) { |
| 669 | + if( $user->isAllowed( 'browsearchive' ) ) { |
668 | 670 | $this->showSearchForm(); |
669 | 671 | |
670 | 672 | # List undeletable articles |
— | — | @@ -685,14 +687,14 @@ |
686 | 688 | if ( !$file->exists() ) { |
687 | 689 | $out->addWikiMsg( 'filedelete-nofile', $this->mFilename ); |
688 | 690 | return; |
689 | | - } elseif( !$file->userCan( File::DELETED_FILE ) ) { |
| 691 | + } elseif( !$file->userCan( File::DELETED_FILE, $user ) ) { |
690 | 692 | if( $file->isDeleted( File::DELETED_RESTRICTED ) ) { |
691 | 693 | $out->permissionRequired( 'suppressrevision' ); |
692 | 694 | } else { |
693 | 695 | $out->permissionRequired( 'deletedtext' ); |
694 | 696 | } |
695 | 697 | return false; |
696 | | - } elseif ( !$this->getUser()->matchEditToken( $this->mToken, $this->mFilename ) ) { |
| 698 | + } elseif ( !$user->matchEditToken( $this->mToken, $this->mFilename ) ) { |
697 | 699 | $this->showFileConfirmationForm( $this->mFilename ); |
698 | 700 | return false; |
699 | 701 | } else { |
— | — | @@ -772,8 +774,6 @@ |
773 | 775 | } |
774 | 776 | |
775 | 777 | private function showRevision( $timestamp ) { |
776 | | - $out = $this->getOutput(); |
777 | | - |
778 | 778 | if( !preg_match( '/[0-9]{14}/', $timestamp ) ) { |
779 | 779 | return 0; |
780 | 780 | } |
— | — | @@ -782,13 +782,16 @@ |
783 | 783 | wfRunHooks( 'UndeleteForm::showRevision', array( &$archive, $this->mTargetObj ) ); |
784 | 784 | $rev = $archive->getRevision( $timestamp ); |
785 | 785 | |
| 786 | + $out = $this->getOutput(); |
| 787 | + $user = $this->getUser(); |
| 788 | + |
786 | 789 | if( !$rev ) { |
787 | 790 | $out->addWikiMsg( 'undeleterevision-missing' ); |
788 | 791 | return; |
789 | 792 | } |
790 | 793 | |
791 | 794 | if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
792 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 795 | + if( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) { |
793 | 796 | $out->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' ); |
794 | 797 | return; |
795 | 798 | } else { |
— | — | @@ -804,7 +807,7 @@ |
805 | 808 | $previousRev = $archive->getPreviousRevision( $timestamp ); |
806 | 809 | if( $previousRev ) { |
807 | 810 | $this->showDiff( $previousRev, $rev ); |
808 | | - if( $this->getUser()->getOption( 'diffonly' ) ) { |
| 811 | + if( $user->getOption( 'diffonly' ) ) { |
809 | 812 | return; |
810 | 813 | } else { |
811 | 814 | $out->addHTML( '<hr />' ); |
— | — | @@ -824,7 +827,7 @@ |
825 | 828 | $time = $this->getLang()->timeAndDate( $timestamp, true ); |
826 | 829 | $d = $this->getLang()->date( $timestamp, true ); |
827 | 830 | $t = $this->getLang()->time( $timestamp, true ); |
828 | | - $user = Linker::revUserTools( $rev ); |
| 831 | + $userLink = Linker::revUserTools( $rev ); |
829 | 832 | |
830 | 833 | if( $this->mPreview ) { |
831 | 834 | $openDiv = '<div id="mw-undelete-revision" class="mw-warning">'; |
— | — | @@ -835,14 +838,14 @@ |
836 | 839 | |
837 | 840 | // Revision delete links |
838 | 841 | if ( !$this->mDiff ) { |
839 | | - $revdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj ); |
| 842 | + $revdel = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj ); |
840 | 843 | if ( $revdel ) { |
841 | 844 | $out->addHTML( "$revdel " ); |
842 | 845 | } |
843 | 846 | } |
844 | 847 | |
845 | 848 | $out->addHTML( wfMessage( 'undelete-revision' )->rawParams( $link )->params( |
846 | | - $time )->rawParams( $user )->params( $d, $t )->parse() . '</div>' ); |
| 849 | + $time )->rawParams( $userLink )->params( $d, $t )->parse() . '</div>' ); |
847 | 850 | wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) ); |
848 | 851 | |
849 | 852 | if( $this->mPreview ) { |
— | — | @@ -850,15 +853,15 @@ |
851 | 854 | $popts = $out->parserOptions(); |
852 | 855 | $popts->setEditSection( false ); |
853 | 856 | $out->parserOptions( $popts ); |
854 | | - $out->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER ), $this->mTargetObj, true ); |
| 857 | + $out->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER, $user ), $this->mTargetObj, true ); |
855 | 858 | } |
856 | 859 | |
857 | 860 | $out->addHTML( |
858 | 861 | Xml::element( 'textarea', array( |
859 | 862 | 'readonly' => 'readonly', |
860 | | - 'cols' => intval( $this->getUser()->getOption( 'cols' ) ), |
861 | | - 'rows' => intval( $this->getUser()->getOption( 'rows' ) ) ), |
862 | | - $rev->getText( Revision::FOR_THIS_USER ) . "\n" ) . |
| 863 | + 'cols' => intval( $user->getOption( 'cols' ) ), |
| 864 | + 'rows' => intval( $user->getOption( 'rows' ) ) ), |
| 865 | + $rev->getText( Revision::FOR_THIS_USER, $user ) . "\n" ) . |
863 | 866 | Xml::openElement( 'div' ) . |
864 | 867 | Xml::openElement( 'form', array( |
865 | 868 | 'method' => 'post', |
— | — | @@ -874,7 +877,7 @@ |
875 | 878 | Xml::element( 'input', array( |
876 | 879 | 'type' => 'hidden', |
877 | 880 | 'name' => 'wpEditToken', |
878 | | - 'value' => $this->getUser()->editToken() ) ) . |
| 881 | + 'value' => $user->editToken() ) ) . |
879 | 882 | Xml::element( 'input', array( |
880 | 883 | 'type' => 'submit', |
881 | 884 | 'name' => 'preview', |
— | — | @@ -1189,7 +1192,7 @@ |
1190 | 1193 | if( $this->mCanView ) { |
1191 | 1194 | $titleObj = $this->getTitle(); |
1192 | 1195 | # Last link |
1193 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 1196 | + if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) { |
1194 | 1197 | $pageLink = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) ); |
1195 | 1198 | $last = wfMsgHtml( 'diff' ); |
1196 | 1199 | } elseif( $remaining > 0 || ( $earliestLiveTime && $ts > $earliestLiveTime ) ) { |
— | — | @@ -1250,9 +1253,10 @@ |
1251 | 1254 | $comment = $this->getFileComment( $file ); |
1252 | 1255 | |
1253 | 1256 | // Add show/hide deletion links if available |
1254 | | - $canHide = $this->getUser()->isAllowed( 'deleterevision' ); |
1255 | | - if( $canHide || ( $file->getVisibility() && $this->getUser()->isAllowed( 'deletedhistory' ) ) ) { |
1256 | | - if( !$file->userCan( File::DELETED_RESTRICTED ) ) { |
| 1257 | + $user = $this->getUser(); |
| 1258 | + $canHide = $user->isAllowed( 'deleterevision' ); |
| 1259 | + if( $canHide || ( $file->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) { |
| 1260 | + if( !$file->userCan( File::DELETED_RESTRICTED, $user ) ) { |
1257 | 1261 | $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
1258 | 1262 | } else { |
1259 | 1263 | $query = array( |
— | — | @@ -1279,7 +1283,7 @@ |
1280 | 1284 | function getPageLink( $rev, $titleObj, $ts ) { |
1281 | 1285 | $time = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) ); |
1282 | 1286 | |
1283 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 1287 | + if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) { |
1284 | 1288 | return '<span class="history-deleted">' . $time . '</span>'; |
1285 | 1289 | } else { |
1286 | 1290 | $link = Linker::linkKnown( |
— | — | @@ -1305,7 +1309,7 @@ |
1306 | 1310 | * @return String: HTML fragment |
1307 | 1311 | */ |
1308 | 1312 | function getFileLink( $file, $titleObj, $ts, $key ) { |
1309 | | - if( !$file->userCan( File::DELETED_FILE ) ) { |
| 1313 | + if( !$file->userCan( File::DELETED_FILE, $this->getUser() ) ) { |
1310 | 1314 | return '<span class="history-deleted">' . $this->getLang()->timeanddate( $ts, true ) . '</span>'; |
1311 | 1315 | } else { |
1312 | 1316 | $link = Linker::linkKnown( |
— | — | @@ -1332,7 +1336,7 @@ |
1333 | 1337 | * @return String: HTML fragment |
1334 | 1338 | */ |
1335 | 1339 | function getFileUser( $file ) { |
1336 | | - if( !$file->userCan( File::DELETED_USER ) ) { |
| 1340 | + if( !$file->userCan( File::DELETED_USER, $this->getUser() ) ) { |
1337 | 1341 | return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
1338 | 1342 | } else { |
1339 | 1343 | $link = Linker::userLink( $file->getRawUser(), $file->getRawUserText() ) . |
— | — | @@ -1351,7 +1355,7 @@ |
1352 | 1356 | * @return String: HTML fragment |
1353 | 1357 | */ |
1354 | 1358 | function getFileComment( $file ) { |
1355 | | - if( !$file->userCan( File::DELETED_COMMENT ) ) { |
| 1359 | + if( !$file->userCan( File::DELETED_COMMENT, $this->getUser() ) ) { |
1356 | 1360 | return '<span class="history-deleted"><span class="comment">' . |
1357 | 1361 | wfMsgHtml( 'rev-deleted-comment' ) . '</span></span>'; |
1358 | 1362 | } else { |
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -278,7 +278,7 @@ |
279 | 279 | $this->getOutput()->addWikiMsg( 'revdelete-no-file' ); |
280 | 280 | return; |
281 | 281 | } |
282 | | - if( !$oimage->userCan(File::DELETED_FILE) ) { |
| 282 | + if( !$oimage->userCan( File::DELETED_FILE, $this->getUser() ) ) { |
283 | 283 | if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) { |
284 | 284 | $this->getOutput()->permissionRequired( 'suppressrevision' ); |
285 | 285 | } else { |
Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -616,8 +616,9 @@ |
617 | 617 | $topmarktext .= ' '.Linker::generateRollback( $rev ); |
618 | 618 | } |
619 | 619 | } |
| 620 | + $user = $this->getUser(); |
620 | 621 | # Is there a visible previous revision? |
621 | | - if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) { |
| 622 | + if( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) { |
622 | 623 | $difftext = Linker::linkKnown( |
623 | 624 | $page, |
624 | 625 | $this->messages['diff'], |
— | — | @@ -646,7 +647,7 @@ |
647 | 648 | |
648 | 649 | $comment = $this->getLang()->getDirMark() . Linker::revComment( $rev, false, true ); |
649 | 650 | $date = $this->getLang()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); |
650 | | - if( $rev->userCan( Revision::DELETED_TEXT ) ) { |
| 651 | + if( $rev->userCan( Revision::DELETED_TEXT, $user ) ) { |
651 | 652 | $d = Linker::linkKnown( |
652 | 653 | $page, |
653 | 654 | htmlspecialchars($date), |
— | — | @@ -680,9 +681,9 @@ |
681 | 682 | } |
682 | 683 | |
683 | 684 | // Don't show useless link to people who cannot hide revisions |
684 | | - $canHide = $this->getUser()->isAllowed( 'deleterevision' ); |
685 | | - if( $canHide || ($rev->getVisibility() && $this->getUser()->isAllowed('deletedhistory')) ) { |
686 | | - if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 685 | + $canHide = $user->isAllowed( 'deleterevision' ); |
| 686 | + if( $canHide || ($rev->getVisibility() && $user->isAllowed('deletedhistory')) ) { |
| 687 | + if( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) { |
687 | 688 | $del = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops |
688 | 689 | } else { |
689 | 690 | $query = array( |
Index: trunk/phase3/includes/specials/SpecialDeletedContributions.php |
— | — | @@ -184,7 +184,7 @@ |
185 | 185 | $comment = Linker::revComment( $rev ); |
186 | 186 | $date = htmlspecialchars( $this->getLang()->timeanddate( $rev->getTimestamp(), true ) ); |
187 | 187 | |
188 | | - if( !$user->isAllowed('undelete') || !$rev->userCan(Revision::DELETED_TEXT) ) { |
| 188 | + if( !$user->isAllowed( 'undelete' ) || !$rev->userCan( Revision::DELETED_TEXT, $user ) ) { |
189 | 189 | $link = $date; // unusable link |
190 | 190 | } else { |
191 | 191 | $link = Linker::linkKnown( |
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php |
— | — | @@ -271,7 +271,7 @@ |
272 | 272 | } |
273 | 273 | |
274 | 274 | # Last link |
275 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 275 | + if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) { |
276 | 276 | $last = $this->message['last']; |
277 | 277 | } elseif( isset( $this->prevId[$row->rev_id] ) ) { |
278 | 278 | $last = Linker::linkKnown( |
Index: trunk/phase3/includes/RevisionList.php |
— | — | @@ -300,11 +300,11 @@ |
301 | 301 | } |
302 | 302 | |
303 | 303 | public function canView() { |
304 | | - return $this->revision->userCan( Revision::DELETED_RESTRICTED ); |
| 304 | + return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->context->getUser() ); |
305 | 305 | } |
306 | 306 | |
307 | 307 | public function canViewContent() { |
308 | | - return $this->revision->userCan( Revision::DELETED_TEXT ); |
| 308 | + return $this->revision->userCan( Revision::DELETED_TEXT, $this->context->getUser() ); |
309 | 309 | } |
310 | 310 | |
311 | 311 | public function isDeleted() { |