MediaWiki
REL1_35
PermissionsError.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\MediaWikiServices
;
22
31
class
PermissionsError
extends
ErrorPageError
{
32
public
$permission
,
$errors
;
33
42
public
function
__construct
(
$permission
,
$errors
= [] ) {
43
global
$wgLang
;
44
45
if
(
$permission
===
null
&& !
$errors
) {
46
throw
new \InvalidArgumentException( __METHOD__ .
47
': $permission and $errors cannot both be empty'
);
48
}
49
50
$this->permission =
$permission
;
51
52
if
( !count(
$errors
) ) {
53
$groups = [];
54
foreach
( MediaWikiServices::getInstance()
55
->
getPermissionManager
()
56
->getGroupsWithPermission( $this->permission ) as $group ) {
57
$groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(),
'wiki'
);
58
}
59
60
if
( $groups ) {
61
$errors
[] = [
'badaccess-groups'
,
$wgLang
->commaList( $groups ), count( $groups ) ];
62
}
else
{
63
$errors
[] = [
'badaccess-group0'
];
64
}
65
}
66
67
$this->errors =
$errors
;
68
69
// Give the parent class something to work with
70
parent::__construct(
'permissionserrors'
,
Message::newFromSpecifier
(
$errors
[0] ) );
71
}
72
73
public
function
report
( $action = self::SEND_OUTPUT ) {
74
global
$wgOut
;
75
76
$wgOut
->showPermissionsErrorPage( $this->errors, $this->permission );
77
if
( $action === self::SEND_OUTPUT ) {
78
$wgOut
->output();
79
}
80
}
81
}
getPermissionManager
getPermissionManager()
$wgOut
$wgOut
Definition
Setup.php:786
$wgLang
$wgLang
Definition
Setup.php:781
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:30
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:152
Message\newFromSpecifier
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
Definition
Message.php:452
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition
PermissionsError.php:31
PermissionsError\$permission
$permission
Definition
PermissionsError.php:32
PermissionsError\report
report( $action=self::SEND_OUTPUT)
Stable to override.
Definition
PermissionsError.php:73
PermissionsError\$errors
$errors
Definition
PermissionsError.php:32
PermissionsError\__construct
__construct( $permission, $errors=[])
Stable to call.
Definition
PermissionsError.php:42
includes
exception
PermissionsError.php
Generated on Sat Apr 6 2024 00:07:08 for MediaWiki by
1.9.8