MediaWiki
REL1_32
PermissionsError.php
Go to the documentation of this file.
1
<?php
28
class
PermissionsError
extends
ErrorPageError
{
29
public
$permission
,
$errors
;
30
37
public
function
__construct
(
$permission
,
$errors
= [] ) {
38
global
$wgLang
;
39
40
if
(
$permission
===
null
&& !
$errors
) {
41
throw
new \InvalidArgumentException( __METHOD__ .
42
': $permission and $errors cannot both be empty'
);
43
}
44
45
$this->permission =
$permission
;
46
47
if
( !count(
$errors
) ) {
48
$groups = [];
49
foreach
(
User::getGroupsWithPermission
( $this->permission ) as $group ) {
50
$groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(),
'wiki'
);
51
}
52
53
if
( $groups ) {
54
$errors
[] = [
'badaccess-groups'
,
$wgLang
->commaList( $groups ), count( $groups ) ];
55
}
else
{
56
$errors
[] = [
'badaccess-group0'
];
57
}
58
}
59
60
$this->errors =
$errors
;
61
62
// Give the parent class something to work with
63
parent::__construct(
'permissionserrors'
, Message::newFromSpecifier(
$errors
[0] ) );
64
}
65
66
public
function
report
() {
67
global
$wgOut
;
68
69
$wgOut
->showPermissionsErrorPage( $this->errors, $this->permission );
70
$wgOut
->output();
71
}
72
}
$wgOut
$wgOut
Definition
Setup.php:915
$wgLang
$wgLang
Definition
Setup.php:910
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:27
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition
PermissionsError.php:28
PermissionsError\$permission
$permission
Definition
PermissionsError.php:29
PermissionsError\report
report()
Output a report about the exception and takes care of formatting.
Definition
PermissionsError.php:66
PermissionsError\$errors
$errors
Definition
PermissionsError.php:29
PermissionsError\__construct
__construct( $permission, $errors=[])
Definition
PermissionsError.php:37
User\getGroupsWithPermission
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
Definition
User.php:4990
includes
exception
PermissionsError.php
Generated on Mon Nov 25 2024 15:57:02 for MediaWiki by
1.10.0