55 parent::__construct(
'Listgrouprights' );
70 $out->addModuleStyles(
'mediawiki.special' );
71 $this->
addHelpLink(
'Help:User_rights_and_groups' );
73 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
76 Xml::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
78 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-group' )->text() ) .
79 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-rights' )->text() ) .
84 $groupPermissions = $config->get(
'GroupPermissions' );
85 $revokePermissions = $config->get(
'RevokePermissions' );
86 $addGroups = $config->get(
'AddGroups' );
87 $removeGroups = $config->get(
'RemoveGroups' );
88 $groupsAddToSelf = $config->get(
'GroupsAddToSelf' );
89 $groupsRemoveFromSelf = $config->get(
'GroupsRemoveFromSelf' );
90 $allGroups = array_unique( array_merge(
91 array_keys( $groupPermissions ),
92 array_keys( $revokePermissions ),
93 array_keys( $addGroups ),
94 array_keys( $removeGroups ),
95 array_keys( $groupsAddToSelf ),
96 array_keys( $groupsRemoveFromSelf )
102 foreach ( $allGroups as $group ) {
103 $permissions = $groupPermissions[$group] ?? [];
104 $groupname = ( $group ==
'*' )
108 $groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
110 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
111 ?: Title::makeTitleSafe(
NS_PROJECT, $groupname );
113 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
115 $grouppage = htmlspecialchars( $groupnameLocalized );
118 $grouppageLocalizedTitle,
123 if ( $group ===
'user' ) {
127 $this->
msg(
'listgrouprights-members' )->text()
129 } elseif ( !in_array( $group, $config->get(
'ImplicitGroups' ) ) ) {
132 $this->
msg(
'listgrouprights-members' )->text(),
134 [
'group' => $group ]
141 $revoke = $revokePermissions[$group] ?? [];
142 $addgroups = $addGroups[$group] ?? [];
143 $removegroups = $removeGroups[$group] ?? [];
144 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
145 $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
147 $id = $group ==
'*' ? false : Sanitizer::escapeIdForAttribute( $group );
148 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
149 <td>$grouppage$grouplink</td>
152 $addgroupsSelf, $removegroupsSelf ) .
157 $out->addHTML( Xml::closeElement(
'table' ) );
163 $namespaceProtection = $this->
getConfig()->get(
'NamespaceProtection' );
165 if ( count( $namespaceProtection ) == 0 ) {
169 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
171 Html::rawElement(
'h2', [], Html::element(
'span', [
172 'class' =>
'mw-headline',
175 Xml::openElement(
'table', [
'class' =>
'wikitable' ] ) .
179 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->text()
184 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
188 ksort( $namespaceProtection );
189 $validNamespaces = $this->nsInfo->getValidNamespaces();
190 foreach ( $namespaceProtection as $namespace => $rights ) {
191 if ( !in_array( $namespace, $validNamespaces ) ) {
196 $namespaceText = $this->
msg(
'blanknamespace' )->text();
198 $namespaceText = $this->languageConverter->convertNamespace( $namespace );
202 Xml::openElement(
'tr' ) .
210 [
'namespace' => $namespace ]
213 Xml::openElement(
'td' ) . Xml::openElement(
'ul' )
216 if ( !is_array( $rights ) ) {
217 $rights = [ $rights ];
220 foreach ( $rights as $right ) {
222 Html::rawElement(
'li', [], $this->
msg(
223 'listgrouprights-right-display',
227 [
'class' =>
'mw-listgrouprights-right-name' ],
235 Xml::closeElement(
'ul' ) .
236 Xml::closeElement(
'td' ) .
237 Xml::closeElement(
'tr' )
240 $out->addHTML( Xml::closeElement(
'table' ) );
254 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
256 foreach ( $permissions as $permission => $granted ) {
258 if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
259 $r[] = $this->
msg(
'listgrouprights-right-display',
261 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
265 foreach ( $revoke as $permission => $revoked ) {
267 $r[] = $this->
msg(
'listgrouprights-right-revoked',
269 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
277 $allGroups = $this->userGroupManager->listAllGroups();
281 'removegroup' => $remove,
282 'addgroup-self' => $addSelf,
283 'removegroup-self' => $removeSelf
286 foreach ( $changeGroups as $messageKey => $changeGroup ) {
288 if ( $changeGroup ===
true ) {
291 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
292 } elseif ( is_array( $changeGroup ) ) {
293 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
294 if ( count( $changeGroup ) ) {
296 foreach ( $changeGroup as $group ) {
297 $groupLinks[] = UserGroupMembership::getLink( $group, $this->
getContext(),
'wiki' );
301 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
302 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
310 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
static guessSectionNameFromStrippedText( $text)
Like guessSectionNameFromWikiText(), but takes already-stripped text as input.
This special page lists all defined user groups and the associated rights.
UserGroupManager $userGroupManager
execute( $par)
Show the special page.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
ILanguageConverter $languageConverter
outputNamespaceProtectionInfo()
__construct(NamespaceInfo $nsInfo, UserGroupManager $userGroupManager, LanguageConverterFactory $languageConverterFactory)
formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf)
Create a user-readable list of permissions from the given array.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
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,...
getContext()
Gets the context this SpecialPage is executed in.
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getContentLanguage()
Shortcut to get content language.
static getRightDescription( $right)
Get the description of a given right.
The shared interface for all language converters.
if(!isset( $args[0])) $lang