MediaWiki REL1_35
CompositeBlock.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Block;
24
25use Title;
26
38
46 public function __construct( array $options = [] ) {
47 parent::__construct( $options );
48
49 $defaults = [
50 'originalBlocks' => [],
51 ];
52
53 $options += $defaults;
54
55 $this->originalBlocks = $options[ 'originalBlocks' ];
56
57 $this->setHideName( $this->propHasValue( 'mHideName', true ) );
58 $this->isSitewide( $this->propHasValue( 'isSitewide', true ) );
59 $this->isEmailBlocked( $this->propHasValue( 'mBlockEmail', true ) );
60 $this->isCreateAccountBlocked( $this->propHasValue( 'blockCreateAccount', true ) );
61 $this->isUsertalkEditAllowed( !$this->propHasValue( 'allowUsertalk', false ) );
62 }
63
72 private function propHasValue( $prop, $value ) {
73 foreach ( $this->originalBlocks as $block ) {
74 if ( $block->$prop == $value ) {
75 return true;
76 }
77 }
78 return false;
79 }
80
90 private function methodReturnsValue( $method, $value, ...$params ) {
91 foreach ( $this->originalBlocks as $block ) {
92 if ( $block->$method( ...$params ) == $value ) {
93 return true;
94 }
95 }
96 return false;
97 }
98
105 public function getOriginalBlocks() {
107 }
108
112 public function getExpiry() {
113 $maxExpiry = null;
114 foreach ( $this->originalBlocks as $block ) {
115 $expiry = $block->getExpiry();
116 if ( $maxExpiry === null || $expiry === '' || $expiry > $maxExpiry ) {
117 $maxExpiry = $expiry;
118 }
119 }
120 return $maxExpiry;
121 }
122
126 public function getIdentifier() {
127 $identifier = [];
128 foreach ( $this->originalBlocks as $block ) {
129 $identifier[] = $block->getIdentifier();
130 }
131 return $identifier;
132 }
133
144 public function appliesToRight( $right ) {
145 $isUnsure = false;
146
147 foreach ( $this->originalBlocks as $block ) {
148 $appliesToRight = $block->appliesToRight( $right );
149
150 if ( $appliesToRight ) {
151 return true;
152 } elseif ( $appliesToRight === null ) {
153 $isUnsure = true;
154 }
155 }
156
157 return $isUnsure ? null : false;
158 }
159
163 public function appliesToUsertalk( Title $usertalk = null ) {
164 return $this->methodReturnsValue( __FUNCTION__, true, $usertalk );
165 }
166
170 public function appliesToTitle( Title $title ) {
171 return $this->methodReturnsValue( __FUNCTION__, true, $title );
172 }
173
177 public function appliesToNamespace( $ns ) {
178 return $this->methodReturnsValue( __FUNCTION__, true, $ns );
179 }
180
184 public function appliesToPage( $pageId ) {
185 return $this->methodReturnsValue( __FUNCTION__, true, $pageId );
186 }
187
191 public function appliesToPasswordReset() {
192 return $this->methodReturnsValue( __FUNCTION__, true );
193 }
194
198 public function getBy() {
199 return 0;
200 }
201
205 public function getByName() {
206 return '';
207 }
208}
isUsertalkEditAllowed( $x=null)
Get or set the flag indicating whether this block blocks the target from editing their own user talk ...
setHideName( $hideName)
Set whether ths block hides the target's username.
isCreateAccountBlocked( $x=null)
Get or set the flag indicating whether this block blocks the target from creating an account.
isEmailBlocked( $x=null)
Get or set the flag indicating whether this block blocks the target from sending emails.
isSitewide( $x=null)
Indicates that the block is a sitewide block.
appliesToNamespace( $ns)
Checks if a block applies to a particular namespace.1.33bool
getExpiry()
Get the block expiry time.1.19 string
methodReturnsValue( $method, $value,... $params)
Determine whether any original blocks have a particular method returning a particular value.
propHasValue( $prop, $value)
Determine whether any original blocks have a particular property set to a particular value.
getOriginalBlocks()
Get the original blocks from which this block is composed.
getByName()
Get the username of the blocking sysop.string
appliesToRight( $right)
Determine whether the block prevents a given right.A right may be blacklisted or whitelisted,...
appliesToPage( $pageId)
Checks if a block applies to a particular page.This check does not consider whether $this->isUsertalk...
appliesToUsertalk(Title $usertalk=null)
Determine whether the block allows the user to edit their own user talk page.This is done separately ...
appliesToPasswordReset()
Check if the block prevents a user from resetting their password.1.33 bool The block blocks password ...
getBy()
Get the user id of the blocking sysop.int (0 for foreign users)
getIdentifier()
Get the information that identifies this block, such that a user could look up everything that can be...
__construct(array $options=[])
Create a new block with specified parameters on a user, IP or IP range.
appliesToTitle(Title $title)
Checks if a block applies to a particular title.This check does not consider whether $this->isUsertal...
Represents a title within MediaWiki.
Definition Title.php:42