- /**
- * Indicates that the block is a sitewide block. This means the user is
- * prohibited from editing any page on the site (other than their own talk
- * page).
- *
- * @since 1.33
- * @param null|bool $x
- * @return bool
- */
- public function isSitewide( $x = null ) {
- return wfSetVar( $this->isSitewide, $x );
- }
-
- /**
- * Get or set the flag indicating whether this block blocks the target from
- * creating an account. (Note that the flag may be overridden depending on
- * global configs.)
- *
- * @since 1.33
- * @param null|bool $x Value to set (if null, just get the property value)
- * @return bool Value of the property
- */
- public function isCreateAccountBlocked( $x = null ) {
- return wfSetVar( $this->blockCreateAccount, $x );
- }
-
- /**
- * Get or set the flag indicating whether this block blocks the target from
- * sending emails. (Note that the flag may be overridden depending on
- * global configs.)
- *
- * @since 1.33
- * @param null|bool $x Value to set (if null, just get the property value)
- * @return bool Value of the property
- */
- public function isEmailBlocked( $x = null ) {
- return wfSetVar( $this->mBlockEmail, $x );
- }
-
- /**
- * Get or set the flag indicating whether this block blocks the target from
- * editing their own user talk page. (Note that the flag may be overridden
- * depending on global configs.)
- *
- * @since 1.33
- * @param null|bool $x Value to set (if null, just get the property value)
- * @return bool Value of the property
- */
- public function isUsertalkEditAllowed( $x = null ) {
- return wfSetVar( $this->allowUsertalk, $x );
- }
-
- /**
- * Determine whether the Block prevents a given right. A right
- * may be blacklisted or whitelisted, or determined from a
- * property on the Block object. For certain rights, the property
- * may be overridden according to global configs.
- *
- * @since 1.33
- * @param string $right Right to check
- * @return bool|null null if unrecognized right or unset property
- */
- public function appliesToRight( $right ) {
- $config = RequestContext::getMain()->getConfig();
- $blockDisablesLogin = $config->get( 'BlockDisablesLogin' );
-
- $res = null;
- switch ( $right ) {
- case 'edit':
- // TODO: fix this case to return proper value
- $res = true;
- break;
- case 'createaccount':
- $res = $this->isCreateAccountBlocked();
- break;
- case 'sendemail':
- $res = $this->isEmailBlocked();
- break;
- case 'upload':
- // Until T6995 is completed
- $res = $this->isSitewide();
- break;
- case 'read':
- $res = false;
- break;
- case 'purge':
- $res = false;
- break;
- }
- if ( !$res && $blockDisablesLogin ) {
- // If a block would disable login, then it should
- // prevent any right that all users cannot do
- $anon = new User;
- $res = $anon->isAllowed( $right ) ? $res : true;
- }
-
- return $res;
- }
-
- /**
- * Get/set whether the Block prevents a given action
- *
- * @deprecated since 1.33, use appliesToRight to determine block
- * behaviour, and specific methods to get/set properties
- * @param string $action Action to check
- * @param bool|null $x Value for set, or null to just get value
- * @return bool|null Null for unrecognized rights.
- */
- public function prevents( $action, $x = null ) {
- $config = RequestContext::getMain()->getConfig();
- $blockDisablesLogin = $config->get( 'BlockDisablesLogin' );
- $blockAllowsUTEdit = $config->get( 'BlockAllowsUTEdit' );
-
- $res = null;
- switch ( $action ) {
- case 'edit':
- # For now... <evil laugh>
- $res = true;
- break;
- case 'createaccount':
- $res = wfSetVar( $this->blockCreateAccount, $x );
- break;
- case 'sendemail':
- $res = wfSetVar( $this->mBlockEmail, $x );
- break;
- case 'upload':
- // Until T6995 is completed
- $res = $this->isSitewide();
- break;
- case 'editownusertalk':
- // NOTE: this check is not reliable on partial blocks
- // since partially blocked users are always allowed to edit
- // their own talk page unless a restriction exists on the
- // page or User_talk: namespace
- wfSetVar( $this->allowUsertalk, $x === null ? null : !$x );
- $res = !$this->isUsertalkEditAllowed();
-
- // edit own user talk can be disabled by config
- if ( !$blockAllowsUTEdit ) {
- $res = true;
- }
- break;
- case 'read':
- $res = false;
- break;
- case 'purge':
- $res = false;
- break;
- }
- if ( !$res && $blockDisablesLogin ) {
- // If a block would disable login, then it should
- // prevent any action that all users cannot do
- $anon = new User;
- $res = $anon->isAllowed( $action ) ? $res : true;
- }
-
- return $res;
- }
-