MediaWiki REL1_35
PermissionsError.php
Go to the documentation of this file.
1<?php
22
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()
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()
$wgOut
Definition Setup.php:786
$wgLang
Definition Setup.php:781
An error page which can definitely be safely rendered using the OutputPage.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
Definition Message.php:452
Show an error when a user tries to do something they do not have the necessary permissions for.
report( $action=self::SEND_OUTPUT)
Stable to override.
__construct( $permission, $errors=[])
Stable to call.