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