MediaWiki REL1_31
PermissionsError.php
Go to the documentation of this file.
1<?php
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
Definition Setup.php:912
An error page which can definitely be safely rendered using the OutputPage.
Show an error when a user tries to do something they do not have the necessary permissions for.
report()
Output a report about the exception and takes care of formatting.
__construct( $permission, $errors=[])
static getMain()
Get the RequestContext object associated with the main request.
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
Definition User.php:4982
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56