24 namespace MediaWiki\Specials;
66 parent::__construct(
'Listgrouprights' );
67 $this->nsInfo = $nsInfo;
68 $this->userGroupManager = $userGroupManager;
70 $this->groupPermissionsLookup = $groupPermissionsLookup;
82 $out->addModuleStyles(
'mediawiki.special' );
83 $this->
addHelpLink(
'Help:User_rights_and_groups' );
85 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
88 Xml::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
90 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-group' )->text() ) .
91 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-rights' )->text() ) .
100 $allGroups = array_merge(
101 $this->userGroupManager->listAllGroups(),
102 $this->userGroupManager->listAllImplicitGroups()
109 foreach ( $allGroups as $group ) {
110 $permissions = $this->groupPermissionsLookup->getGrantedPermissions( $group );
111 $groupname = ( $group ==
'*' )
115 $groupnameLocalized = $lang->getGroupName( $groupname );
120 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
122 $grouppage = htmlspecialchars( $groupnameLocalized );
124 $grouppage = $linkRenderer->makeLink(
125 $grouppageLocalizedTitle,
130 $groupWithParentheses = $this->
msg(
'parentheses' )->rawParams( $group )->escaped();
131 $groupname =
"<br /><code>$groupWithParentheses</code>";
133 if ( $group ===
'user' ) {
135 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
137 $this->
msg(
'listgrouprights-members' )->text()
140 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
142 $this->
msg(
'listgrouprights-members' )->text(),
144 [
'group' => $group ]
151 $revoke = $this->groupPermissionsLookup->getRevokedPermissions( $group );
152 $addgroups = $addGroups[$group] ?? [];
153 $removegroups = $removeGroups[$group] ?? [];
154 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
155 $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
159 <td>$grouppage$groupname$grouplink</td>
161 $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
162 $addgroupsSelf, $removegroupsSelf ) .
168 $this->outputNamespaceProtectionInfo();
171 private function outputNamespaceProtectionInfo() {
175 if ( count( $namespaceProtection ) == 0 ) {
179 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
188 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->text()
193 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
197 ksort( $namespaceProtection );
198 $validNamespaces = $this->nsInfo->getValidNamespaces();
199 foreach ( $namespaceProtection as $namespace => $rights ) {
200 if ( !in_array( $namespace, $validNamespaces ) ) {
205 $namespaceText = $this->
msg(
'blanknamespace' )->text();
207 $namespaceText = $this->languageConverter->convertNamespace( $namespace );
215 $linkRenderer->makeLink(
219 [
'namespace' => $namespace ]
225 if ( !is_array( $rights ) ) {
226 $rights = [ $rights ];
229 foreach ( $rights as $right ) {
231 $this->
msg(
'listgrouprights-right-display' )
235 [
'class' =>
'mw-listgrouprights-right-name' ],
261 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
263 foreach ( $permissions as $permission ) {
265 if ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) {
266 $r[] = $this->
msg(
'listgrouprights-right-display' )
270 [
'class' =>
'mw-listgrouprights-right-name' ],
275 foreach ( $revoke as $permission ) {
276 $r[] = $this->
msg(
'listgrouprights-right-revoked' )
280 [
'class' =>
'mw-listgrouprights-right-name' ],
288 $allGroups = $this->userGroupManager->listAllGroups();
292 'removegroup' => $remove,
293 'addgroup-self' => $addSelf,
294 'removegroup-self' => $removeSelf
297 foreach ( $changeGroups as $messageKey => $changeGroup ) {
299 if ( $changeGroup ===
true ) {
302 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
303 } elseif ( is_array( $changeGroup ) ) {
304 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
305 if ( count( $changeGroup ) ) {
307 foreach ( $changeGroup as $group ) {
312 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
313 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
321 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';
333 class_alias( SpecialListGroupRights::class,
'SpecialListGroupRights' );
A class containing constants representing the names of configuration variables.
const ImplicitGroups
Name constant for the ImplicitGroups setting, for use with Config::get()
const NamespaceProtection
Name constant for the NamespaceProtection setting, for use with Config::get()
const GroupsRemoveFromSelf
Name constant for the GroupsRemoveFromSelf setting, for use with Config::get()
const AddGroups
Name constant for the AddGroups setting, for use with Config::get()
const GroupsAddToSelf
Name constant for the GroupsAddToSelf setting, for use with Config::get()
const RemoveGroups
Name constant for the RemoveGroups setting, for use with Config::get()
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getConfig()
Shortcut to get main config object.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Module of static functions for generating XML.
static closeElement( $element)
Shortcut to close an XML element.
static openElement( $element, $attribs=null)
This opens an XML element.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
The shared interface for all language converters.