MediaWiki  master
MediaWiki\Permissions\SimpleAuthority Class Reference

Represents an authority that has a specific set of permissions which are specified explicitly. More...

Inheritance diagram for MediaWiki\Permissions\SimpleAuthority:
Collaboration diagram for MediaWiki\Permissions\SimpleAuthority:

Public Member Functions

 __construct (UserIdentity $actor, array $permissions, bool $isTemp=false)
 
 authorizeRead (string $action, PageIdentity $target, PermissionStatus $status=null)
 Authorize read access.This should be used immediately before performing read access on restricted information.Calling this method may have non-trivial side-effects, such as incrementing a rate limit counter.
Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool
More...
 
 authorizeWrite (string $action, PageIdentity $target, PermissionStatus $status=null)
 Authorize write access.This should be used immediately before updating persisted information.Calling this method may have non-trivial side-effects, such as incrementing a rate limit counter.
Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool
More...
 
 definitelyCan (string $action, PageIdentity $target, PermissionStatus $status=null)
 Checks whether this authority can perform the given action on the given target page.This method performs a thorough check, but does not protect against race conditions. It is intended to be used when a user is intending to perform an action, but has not yet committed to it. For example, when a user goes to the edit page of an article, this method may be used to determine whether the user should be presented with a warning and a read-only view instead.
Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool
More...
 
 getBlock (int $freshness=self::READ_NORMAL)
 
 getUser ()
 The user identity associated with this authority. More...
 
 isAllowed (string $permission)
 Checks whether this authority has the given permission in general.For some permissions, exceptions may exist, both positive and negative, on a per-target basis.
Parameters
string$permission
Returns
bool
More...
 
 isAllowedAll (... $permissions)
 Checks whether this authority has any of the given permissions in general.Implementations must ensure that this method returns false if isAllowed would return false for any of the given permissions. Calling isAllowedAll() with one parameter must be equivalent to calling isAllowed(). Calling isAllowedAny() with no parameter is not allowed.
See also
isAllowed
Parameters
string...$permissions Permissions to test. At least one must be given.
Returns
bool True if the user is allowed to perform all of the given actions
More...
 
 isAllowedAny (... $permissions)
 Checks whether this authority has any of the given permissions in general.Implementations must ensure that this method returns true if isAllowed would return true for any of the given permissions. Calling isAllowedAny() with one parameter must be equivalent to calling isAllowed(). Calling isAllowedAny() with no parameter is not allowed.
See also
isAllowed
Parameters
string...$permissions Permissions to test. At least one must be given.
Returns
bool True if user is allowed to perform any of the given actions
More...
 
 isNamed ()
 Is the user a normal non-temporary registered user? More...
 
 isRegistered ()
 Get whether the user is registered. More...
 
 isTemp ()
 Is the user an autocreated temporary user? More...
 
 probablyCan (string $action, PageIdentity $target, PermissionStatus $status=null)
 Checks whether this authority can probably perform the given action on the given target page.This method offers a fast, lightweight check, and may produce false positives. It is intended for determining which UI elements should be offered to the user.
Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool
More...
 

Private Member Functions

 checkPermission (string $permission, ?PermissionStatus $status)
 

Private Attributes

UserIdentity $actor
 
bool $isTemp
 
true[] $permissions
 permissions (stored in the keys, values are ignored) More...
 

Detailed Description

Represents an authority that has a specific set of permissions which are specified explicitly.

This is useful for testing, but may also be used to represent a fixed set of permissions to be used in some context, e.g. in an asynchronous job.

Since
1.36
Stability: newable

Definition at line 37 of file SimpleAuthority.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Permissions\SimpleAuthority::__construct ( UserIdentity  $actor,
array  $permissions,
bool  $isTemp = false 
)
Stability: stable
to call
Parameters
UserIdentity$actor
string[]$permissionsA list of permissions to grant to the actor
bool$isTempWhether the user is auto-created (since 1.39)

Definition at line 54 of file SimpleAuthority.php.

References MediaWiki\Permissions\SimpleAuthority\$actor, MediaWiki\Permissions\SimpleAuthority\$isTemp, MediaWiki\Permissions\SimpleAuthority\$permissions, and MediaWiki\Permissions\SimpleAuthority\isTemp().

Member Function Documentation

◆ authorizeRead()

MediaWiki\Permissions\SimpleAuthority::authorizeRead ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)

Authorize read access.This should be used immediately before performing read access on restricted information.Calling this method may have non-trivial side-effects, such as incrementing a rate limit counter.

Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool

Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 190 of file SimpleAuthority.php.

◆ authorizeWrite()

MediaWiki\Permissions\SimpleAuthority::authorizeWrite ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)

Authorize write access.This should be used immediately before updating persisted information.Calling this method may have non-trivial side-effects, such as incrementing a rate limit counter.

Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool

Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 207 of file SimpleAuthority.php.

◆ checkPermission()

MediaWiki\Permissions\SimpleAuthority::checkPermission ( string  $permission,
?PermissionStatus  $status 
)
private

Definition at line 136 of file SimpleAuthority.php.

References StatusValue\fatal().

◆ definitelyCan()

MediaWiki\Permissions\SimpleAuthority::definitelyCan ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)

Checks whether this authority can perform the given action on the given target page.This method performs a thorough check, but does not protect against race conditions. It is intended to be used when a user is intending to perform an action, but has not yet committed to it. For example, when a user goes to the edit page of an article, this method may be used to determine whether the user should be presented with a warning and a read-only view instead.

Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool

Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 173 of file SimpleAuthority.php.

◆ getBlock()

MediaWiki\Permissions\SimpleAuthority::getBlock ( int  $freshness = self::READ_NORMAL)
Parameters
int$freshness
Returns
?Block always null
Since
1.37

Implements MediaWiki\Permissions\Authority.

Definition at line 79 of file SimpleAuthority.php.

◆ getUser()

MediaWiki\Permissions\SimpleAuthority::getUser ( )

The user identity associated with this authority.

Returns
UserIdentity

Implements MediaWiki\Permissions\Authority.

Definition at line 69 of file SimpleAuthority.php.

◆ isAllowed()

MediaWiki\Permissions\SimpleAuthority::isAllowed ( string  $permission)

Checks whether this authority has the given permission in general.For some permissions, exceptions may exist, both positive and negative, on a per-target basis.

Parameters
string$permission
Returns
bool

Parameters
string$permission
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 90 of file SimpleAuthority.php.

◆ isAllowedAll()

MediaWiki\Permissions\SimpleAuthority::isAllowedAll (   $permissions)

Checks whether this authority has any of the given permissions in general.Implementations must ensure that this method returns false if isAllowed would return false for any of the given permissions. Calling isAllowedAll() with one parameter must be equivalent to calling isAllowed(). Calling isAllowedAny() with no parameter is not allowed.

See also
isAllowed
Parameters
string...$permissions Permissions to test. At least one must be given.
Returns
bool True if the user is allowed to perform all of the given actions

Parameters
string...$permissions
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 122 of file SimpleAuthority.php.

◆ isAllowedAny()

MediaWiki\Permissions\SimpleAuthority::isAllowedAny (   $permissions)

Checks whether this authority has any of the given permissions in general.Implementations must ensure that this method returns true if isAllowed would return true for any of the given permissions. Calling isAllowedAny() with one parameter must be equivalent to calling isAllowed(). Calling isAllowedAny() with no parameter is not allowed.

See also
isAllowed
Parameters
string...$permissions Permissions to test. At least one must be given.
Returns
bool True if user is allowed to perform any of the given actions

Parameters
string...$permissions
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 101 of file SimpleAuthority.php.

◆ isNamed()

MediaWiki\Permissions\SimpleAuthority::isNamed ( )

Is the user a normal non-temporary registered user?

Since
1.39
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 223 of file SimpleAuthority.php.

◆ isRegistered()

MediaWiki\Permissions\SimpleAuthority::isRegistered ( )

Get whether the user is registered.

Returns
bool
Since
1.39

Implements MediaWiki\Permissions\Authority.

Definition at line 215 of file SimpleAuthority.php.

◆ isTemp()

MediaWiki\Permissions\SimpleAuthority::isTemp ( )

Is the user an autocreated temporary user?

Since
1.39
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 219 of file SimpleAuthority.php.

Referenced by MediaWiki\Permissions\SimpleAuthority\__construct().

◆ probablyCan()

MediaWiki\Permissions\SimpleAuthority::probablyCan ( string  $action,
PageIdentity  $target,
PermissionStatus  $status = null 
)

Checks whether this authority can probably perform the given action on the given target page.This method offers a fast, lightweight check, and may produce false positives. It is intended for determining which UI elements should be offered to the user.

Parameters
string$action
PageIdentity$target
PermissionStatus | null$statusaggregator for failures
Returns
bool

Parameters
string$action
PageIdentity$target
PermissionStatus | null$status
Returns
bool

Implements MediaWiki\Permissions\Authority.

Definition at line 156 of file SimpleAuthority.php.

Member Data Documentation

◆ $actor

UserIdentity MediaWiki\Permissions\SimpleAuthority::$actor
private

◆ $isTemp

bool MediaWiki\Permissions\SimpleAuthority::$isTemp
private

◆ $permissions

true [] MediaWiki\Permissions\SimpleAuthority::$permissions
private

permissions (stored in the keys, values are ignored)

Definition at line 46 of file SimpleAuthority.php.

Referenced by MediaWiki\Permissions\SimpleAuthority\__construct().


The documentation for this class was generated from the following file: