Index: trunk/phase3/includes/User.php |
— | — | @@ -1157,7 +1157,7 @@ |
1158 | 1158 | $this->mBlockedby = $this->mBlock->mByName; |
1159 | 1159 | $this->mBlockreason = $this->mBlock->mReason; |
1160 | 1160 | $this->mHideName = $this->mBlock->mHideName; |
1161 | | - $this->mAllowUsertalk = !$this->mBlock->prevents( 'editusertalk' ); |
| 1161 | + $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' ); |
1162 | 1162 | if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) { |
1163 | 1163 | $this->spreadBlock(); |
1164 | 1164 | } |
Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -218,7 +218,7 @@ |
219 | 219 | $fields['HideUser']['default'] = $block->mHideName; |
220 | 220 | } |
221 | 221 | if( isset( $fields['DisableUTEdit'] ) ){ |
222 | | - $fields['DisableUTEdit']['default'] = $block->prevents( 'editusertalk' ); |
| 222 | + $fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' ); |
223 | 223 | } |
224 | 224 | $fields['Reason']['default'] = $block->mReason; |
225 | 225 | $fields['AlreadyBlocked']['default'] = true; |
— | — | @@ -547,7 +547,7 @@ |
548 | 548 | $data['HideUser'] |
549 | 549 | ); |
550 | 550 | |
551 | | - $block->prevents( 'editusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) ); |
| 551 | + $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) ); |
552 | 552 | $block->prevents( 'sendemail', $data['DisableEmail'] ); |
553 | 553 | |
554 | 554 | if( !wfRunHooks( 'BlockIp', array( &$block, &$wgUser ) ) ) { |
Index: trunk/phase3/includes/Block.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry, |
20 | 20 | $mEnableAutoblock, $mHideName, |
21 | 21 | $mByName, $mAngryAutoblock; |
22 | | - private |
| 22 | + protected |
23 | 23 | $mFromMaster, |
24 | 24 | $mRangeStart, |
25 | 25 | $mRangeEnd, |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | $mAllowUsertalk, |
29 | 29 | $mCreateAccount; |
30 | 30 | |
31 | | - /// TYPE constants |
| 31 | + # TYPE constants |
32 | 32 | const TYPE_USER = 1; |
33 | 33 | const TYPE_IP = 2; |
34 | 34 | const TYPE_RANGE = 3; |
— | — | @@ -240,8 +240,8 @@ |
241 | 241 | * @param $end String Hexadecimal IP represenation, or null to use $start = $end |
242 | 242 | * @return String |
243 | 243 | */ |
244 | | - public static function getRangeCond( $start, $end = null ){ |
245 | | - if( $end === null ){ |
| 244 | + public static function getRangeCond( $start, $end = null ) { |
| 245 | + if ( $end === null ) { |
246 | 246 | $end = $start; |
247 | 247 | } |
248 | 248 | # Per bug 14634, we want to include relevant active rangeblocks; for |
— | — | @@ -273,9 +273,9 @@ |
274 | 274 | * @param $hex String Hexadecimal IP representation |
275 | 275 | * @return String |
276 | 276 | */ |
277 | | - protected static function getIpFragment( $hex ){ |
| 277 | + protected static function getIpFragment( $hex ) { |
278 | 278 | global $wgBlockCIDRLimit; |
279 | | - if( substr( $hex, 0, 3 ) == 'v6-' ){ |
| 279 | + if ( substr( $hex, 0, 3 ) == 'v6-' ) { |
280 | 280 | return 'v6-' . substr( substr( $hex, 3 ), 0, floor( $wgBlockCIDRLimit['IPv6'] / 4 ) ); |
281 | 281 | } else { |
282 | 282 | return substr( $hex, 0, floor( $wgBlockCIDRLimit['IPv4'] / 4 ) ); |
— | — | @@ -766,8 +766,8 @@ |
767 | 767 | * Get the IP address at the start of the range in Hex form |
768 | 768 | * @return String IP in Hex form |
769 | 769 | */ |
770 | | - public function getRangeStart(){ |
771 | | - switch( $this->type ){ |
| 770 | + public function getRangeStart() { |
| 771 | + switch( $this->type ) { |
772 | 772 | case self::TYPE_USER: |
773 | 773 | return null; |
774 | 774 | case self::TYPE_IP: |
— | — | @@ -782,8 +782,8 @@ |
783 | 783 | * Get the IP address at the start of the range in Hex form |
784 | 784 | * @return String IP in Hex form |
785 | 785 | */ |
786 | | - public function getRangeEnd(){ |
787 | | - switch( $this->type ){ |
| 786 | + public function getRangeEnd() { |
| 787 | + switch( $this->type ) { |
788 | 788 | case self::TYPE_USER: |
789 | 789 | return null; |
790 | 790 | case self::TYPE_IP: |
— | — | @@ -832,9 +832,9 @@ |
833 | 833 | * @param $x Bool |
834 | 834 | * @return Bool |
835 | 835 | */ |
836 | | - public function isHardblock( $x = null ){ |
| 836 | + public function isHardblock( $x = null ) { |
837 | 837 | $y = $this->mAnonOnly; |
838 | | - if( $x !== null){ |
| 838 | + if ( $x !== null ) { |
839 | 839 | $this->mAnonOnly = !$x; |
840 | 840 | } |
841 | 841 | return !$y; |
— | — | @@ -846,8 +846,8 @@ |
847 | 847 | * @param $x Bool |
848 | 848 | * @return Bool |
849 | 849 | */ |
850 | | - public function prevents( $action, $x = null ){ |
851 | | - switch( $action ){ |
| 850 | + public function prevents( $action, $x = null ) { |
| 851 | + switch( $action ) { |
852 | 852 | case 'edit': |
853 | 853 | # TODO Not actually quite this simple (bug 13611 etc) |
854 | 854 | return true; |
— | — | @@ -858,9 +858,9 @@ |
859 | 859 | case 'sendemail': |
860 | 860 | return wfSetVar( $this->mBlockEmail, $x ); |
861 | 861 | |
862 | | - case 'editusertalk': |
| 862 | + case 'editownusertalk': |
863 | 863 | $y = $this->mAllowUsertalk; |
864 | | - if( $x !== null){ |
| 864 | + if ( $x !== null ) { |
865 | 865 | $this->mAllowUsertalk = !$x; |
866 | 866 | } |
867 | 867 | return !$y; |
— | — | @@ -1013,21 +1013,21 @@ |
1014 | 1014 | * @param $type Block::TYPE_ constant the type of block as described above |
1015 | 1015 | * @return Block|null (null if the target is not blocked) |
1016 | 1016 | */ |
1017 | | - public static function newFromTargetAndType( $target, $type ){ |
1018 | | - if( $target instanceof User ){ |
1019 | | - if( $type == Block::TYPE_IP ){ |
| 1017 | + public static function newFromTargetAndType( $target, $type ) { |
| 1018 | + if ( $target instanceof User ) { |
| 1019 | + if ( $type == Block::TYPE_IP ) { |
1020 | 1020 | return Block::newFromDB( $target->getName(), 0 ); |
1021 | | - } elseif( $type == Block::TYPE_USER ) { |
| 1021 | + } elseif ( $type == Block::TYPE_USER ) { |
1022 | 1022 | return Block::newFromDB( '', $target->getId() ); |
1023 | 1023 | } else { |
1024 | 1024 | # Should be unreachable; |
1025 | 1025 | return null; |
1026 | 1026 | } |
1027 | 1027 | |
1028 | | - } elseif( $type == Block::TYPE_RANGE ){ |
| 1028 | + } elseif ( $type == Block::TYPE_RANGE ) { |
1029 | 1029 | return Block::newFromDB( $target, 0 ); |
1030 | 1030 | |
1031 | | - } elseif( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ){ |
| 1031 | + } elseif ( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) { |
1032 | 1032 | return Block::newFromID( $target ); |
1033 | 1033 | |
1034 | 1034 | } else { |
— | — | @@ -1035,7 +1035,7 @@ |
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | |
1039 | | - public static function newFromTarget( $target ){ |
| 1039 | + public static function newFromTarget( $target ) { |
1040 | 1040 | list( $target, $type ) = self::parseTarget( $target ); |
1041 | 1041 | return self::newFromTargetAndType( $target, $type ); |
1042 | 1042 | } |
— | — | @@ -1046,17 +1046,17 @@ |
1047 | 1047 | * User::__toString() which in turn gives User::getName(). |
1048 | 1048 | * @return array( User|String, Block::TYPE_ constant ) |
1049 | 1049 | */ |
1050 | | - public static function parseTarget( $target ){ |
| 1050 | + public static function parseTarget( $target ) { |
1051 | 1051 | $target = trim( $target ); |
1052 | 1052 | |
1053 | 1053 | $userObj = User::newFromName( $target ); |
1054 | | - if( $userObj instanceof User ){ |
| 1054 | + if ( $userObj instanceof User ) { |
1055 | 1055 | # Note that since numbers are valid usernames, a $target of "12345" will be |
1056 | 1056 | # considered a User. If you want to pass a block ID, prepend a hash "#12345", |
1057 | 1057 | # since hash characters are not valid in usernames or titles generally. |
1058 | 1058 | return array( $userObj, Block::TYPE_USER ); |
1059 | 1059 | |
1060 | | - } elseif( IP::isValid( $target ) ){ |
| 1060 | + } elseif ( IP::isValid( $target ) ) { |
1061 | 1061 | # We can still create a User if it's an IP address, but we need to turn |
1062 | 1062 | # off validation checking (which would exclude IP addresses) |
1063 | 1063 | return array( |
— | — | @@ -1064,11 +1064,11 @@ |
1065 | 1065 | Block::TYPE_IP |
1066 | 1066 | ); |
1067 | 1067 | |
1068 | | - } elseif( IP::isValidBlock( $target ) ){ |
| 1068 | + } elseif ( IP::isValidBlock( $target ) ) { |
1069 | 1069 | # Can't create a User from an IP range |
1070 | | - return array( Block::normaliseRange( $target ), Block::TYPE_RANGE ); |
| 1070 | + return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE ); |
1071 | 1071 | |
1072 | | - } elseif( preg_match( '/^#\d+$/', $target ) ){ |
| 1072 | + } elseif ( preg_match( '/^#\d+$/', $target ) ) { |
1073 | 1073 | # Autoblock reference in the form "#12345" |
1074 | 1074 | return array( substr( $target, 1 ), Block::TYPE_AUTO ); |
1075 | 1075 | |
— | — | @@ -1085,23 +1085,23 @@ |
1086 | 1086 | * @return array( User|String, Block::TYPE_ constant ) |
1087 | 1087 | * FIXME: this should be an integral part of the Block member variables |
1088 | 1088 | */ |
1089 | | - public function getTargetAndType(){ |
| 1089 | + public function getTargetAndType() { |
1090 | 1090 | list( $target, $type ) = self::parseTarget( $this->mAddress ); |
1091 | 1091 | |
1092 | 1092 | # Check whether it's an autoblock |
1093 | | - if( $this->mAuto ){ |
| 1093 | + if ( $this->mAuto ) { |
1094 | 1094 | $type = self::TYPE_AUTO; |
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | return array( $target, $type ); |
1098 | 1098 | } |
1099 | 1099 | |
1100 | | - public function getType(){ |
| 1100 | + public function getType() { |
1101 | 1101 | list( /*...*/, $type ) = $this->getTargetAndType(); |
1102 | 1102 | return $type; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | | - public function getTarget(){ |
| 1105 | + public function getTarget() { |
1106 | 1106 | list( $target, /*...*/ ) = $this->getTargetAndType(); |
1107 | 1107 | return $target; |
1108 | 1108 | } |