| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Permissions; |
| 22 |
|
| 23 |
use InvalidArgumentException; |
| 24 |
use MediaWiki\Block\Block; |
| 25 |
use MediaWiki\Page\PageIdentity; |
| 26 |
use MediaWiki\User\UserIdentity; |
| 27 |
use Wikimedia\Rdbms\IDBAccessObject; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
class UltimateAuthority implements Authority { |
| 37 |
|
| 38 |
|
| 39 |
private $actor; |
| 40 |
|
| 41 |
|
| 42 |
private $isTemp; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public function __construct( UserIdentity $actor, $isTemp = false ) { |
| 50 |
$this->actor = $actor; |
| 51 |
$this->isTemp = $isTemp; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
public function getUser(): UserIdentity { |
| 56 |
return $this->actor; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
public function getBlock( int $freshness = IDBAccessObject::READ_NORMAL ): ?Block { |
| 61 |
return null; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
public function isAllowed( string $permission, ?PermissionStatus $status = null ): bool { |
| 66 |
return true; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
public function isAllowedAny( ...$permissions ): bool { |
| 71 |
if ( !$permissions ) { |
| 72 |
throw new InvalidArgumentException( 'At least one permission must be specified' ); |
| 73 |
} |
| 74 |
|
| 75 |
return true; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
public function isAllowedAll( ...$permissions ): bool { |
| 80 |
if ( !$permissions ) { |
| 81 |
throw new InvalidArgumentException( 'At least one permission must be specified' ); |
| 82 |
} |
| 83 |
|
| 84 |
return true; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
public function probablyCan( |
| 89 |
string $action, |
| 90 |
PageIdentity $target, |
| 91 |
?PermissionStatus $status = null |
| 92 |
): bool { |
| 93 |
return true; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
public function definitelyCan( |
| 98 |
string $action, |
| 99 |
PageIdentity $target, |
| 100 |
?PermissionStatus $status = null |
| 101 |
): bool { |
| 102 |
return true; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
public function isDefinitelyAllowed( string $action, ?PermissionStatus $status = null ): bool { |
| 107 |
return true; |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
public function authorizeAction( string $action, ?PermissionStatus $status = null ): bool { |
| 112 |
return true; |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
public function authorizeRead( |
| 117 |
string $action, |
| 118 |
PageIdentity $target, |
| 119 |
?PermissionStatus $status = null |
| 120 |
): bool { |
| 121 |
return true; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
public function authorizeWrite( |
| 126 |
string $action, |
| 127 |
PageIdentity $target, |
| 128 |
?PermissionStatus $status = null |
| 129 |
): bool { |
| 130 |
return true; |
| 131 |
} |
| 132 |
|
| 133 |
public function isRegistered(): bool { |
| 134 |
return $this->actor->isRegistered(); |
| 135 |
} |
| 136 |
|
| 137 |
public function isTemp(): bool { |
| 138 |
return $this->isTemp; |
| 139 |
} |
| 140 |
|
| 141 |
public function isNamed(): bool { |
| 142 |
return $this->isRegistered() && !$this->isTemp(); |
| 143 |
} |
| 144 |
} |