MediaWiki REL1_33
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}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgOut
Definition Setup.php:880
$wgLang
Definition Setup.php:875
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 getGroupsWithPermission( $role)
Get all the groups who have a given permission.
Definition User.php:5039