Index: trunk/phase3/includes/Block.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | */ |
61 | 61 | function __construct( $address = '', $user = 0, $by = 0, $reason = '', |
62 | 62 | $timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, |
63 | | - $hideName = 0, $blockEmail = 0, $allowUsertalk = 0 ) |
| 63 | + $hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = '' ) |
64 | 64 | { |
65 | 65 | if( $timestamp === 0 ){ |
66 | 66 | $timestamp = wfTimestampNow(); |
— | — | @@ -71,7 +71,11 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | $this->setTarget( $address ); |
75 | | - $this->setBlocker( User::newFromID( $by ) ); |
| 75 | + if ( $by ) { // local user |
| 76 | + $this->setBlocker( User::newFromID( $by ) ); |
| 77 | + } else { // foreign user |
| 78 | + $this->setBlocker( $byText ); |
| 79 | + } |
76 | 80 | $this->mReason = $reason; |
77 | 81 | $this->mTimestamp = wfTimestamp( TS_MW, $timestamp ); |
78 | 82 | $this->mAuto = $auto; |
— | — | @@ -345,7 +349,11 @@ |
346 | 350 | */ |
347 | 351 | protected function initFromRow( $row ) { |
348 | 352 | $this->setTarget( $row->ipb_address ); |
349 | | - $this->setBlocker( User::newFromId( $row->ipb_by ) ); |
| 353 | + if ( $row->ipb_by ) { // local user |
| 354 | + $this->setBlocker( User::newFromID( $row->ipb_by ) ); |
| 355 | + } else { // foreign user |
| 356 | + $this->setBlocker( $row->ipb_by_text ); |
| 357 | + } |
350 | 358 | |
351 | 359 | $this->mReason = $row->ipb_reason; |
352 | 360 | $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp ); |
— | — | @@ -470,8 +478,8 @@ |
471 | 479 | $a = array( |
472 | 480 | 'ipb_address' => (string)$this->target, |
473 | 481 | 'ipb_user' => $this->target instanceof User ? $this->target->getID() : 0, |
474 | | - 'ipb_by' => $this->getBlocker()->getId(), |
475 | | - 'ipb_by_text' => $this->getBlocker()->getName(), |
| 482 | + 'ipb_by' => $this->getBy(), |
| 483 | + 'ipb_by_text' => $this->getByName(), |
476 | 484 | 'ipb_reason' => $this->mReason, |
477 | 485 | 'ipb_timestamp' => $db->timestamp( $this->mTimestamp ), |
478 | 486 | 'ipb_auto' => $this->mAuto, |
— | — | @@ -760,11 +768,12 @@ |
761 | 769 | /** |
762 | 770 | * Get the user id of the blocking sysop |
763 | 771 | * |
764 | | - * @return Integer |
| 772 | + * @return Integer (0 for foreign users) |
765 | 773 | */ |
766 | 774 | public function getBy() { |
767 | | - return $this->getBlocker() instanceof User |
768 | | - ? $this->getBlocker()->getId() |
| 775 | + $blocker = $this->getBlocker(); |
| 776 | + return ( $blocker instanceof User ) |
| 777 | + ? $blocker->getId() |
769 | 778 | : 0; |
770 | 779 | } |
771 | 780 | |
— | — | @@ -774,9 +783,10 @@ |
775 | 784 | * @return String |
776 | 785 | */ |
777 | 786 | public function getByName() { |
778 | | - return $this->getBlocker() instanceof User |
779 | | - ? $this->getBlocker()->getName() |
780 | | - : null; |
| 787 | + $blocker = $this->getBlocker(); |
| 788 | + return ( $blocker instanceof User ) |
| 789 | + ? $blocker->getName() |
| 790 | + : (string)$blocker; // username |
781 | 791 | } |
782 | 792 | |
783 | 793 | /** |
— | — | @@ -926,7 +936,8 @@ |
927 | 937 | */ |
928 | 938 | public static function purgeExpired() { |
929 | 939 | $dbw = wfGetDB( DB_MASTER ); |
930 | | - $dbw->delete( 'ipblocks', array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ ); |
| 940 | + $dbw->delete( 'ipblocks', |
| 941 | + array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ ); |
931 | 942 | } |
932 | 943 | |
933 | 944 | /** |
— | — | @@ -1135,7 +1146,7 @@ |
1136 | 1147 | |
1137 | 1148 | /** |
1138 | 1149 | * Get the user who implemented this block |
1139 | | - * @return User |
| 1150 | + * @return User|string Local User object or string for a foreign user |
1140 | 1151 | */ |
1141 | 1152 | public function getBlocker(){ |
1142 | 1153 | return $this->blocker; |
— | — | @@ -1143,9 +1154,9 @@ |
1144 | 1155 | |
1145 | 1156 | /** |
1146 | 1157 | * Set the user who implemented (or will implement) this block |
1147 | | - * @param $user User |
| 1158 | + * @param $user User|string Local User object or username string for foriegn users |
1148 | 1159 | */ |
1149 | | - public function setBlocker( User $user ){ |
| 1160 | + public function setBlocker( $user ){ |
1150 | 1161 | $this->blocker = $user; |
1151 | 1162 | } |
1152 | 1163 | } |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -348,8 +348,13 @@ |
349 | 349 | public function __construct( Block $block ){ |
350 | 350 | global $wgLang, $wgRequest; |
351 | 351 | |
352 | | - $blockerUserpage = $block->getBlocker()->getUserPage(); |
353 | | - $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]"; |
| 352 | + $blocker = $block->getBlocker(); |
| 353 | + if ( $blocker instanceof User ) { // local user |
| 354 | + $blockerUserpage = $block->getBlocker()->getUserPage(); |
| 355 | + $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]"; |
| 356 | + } else { // foreign user |
| 357 | + $link = $blocker; |
| 358 | + } |
354 | 359 | |
355 | 360 | $reason = $block->mReason; |
356 | 361 | if( $reason == '' ) { |