47 $out->addModuleStyles(
'mediawiki.special' );
49 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
52 Xml::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
54 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-group' )->
text() ) .
55 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-rights' )->
text() ) .
60 $groupPermissions = $config->get(
'GroupPermissions' );
61 $revokePermissions = $config->get(
'RevokePermissions' );
62 $addGroups = $config->get(
'AddGroups' );
63 $removeGroups = $config->get(
'RemoveGroups' );
64 $groupsAddToSelf = $config->get(
'GroupsAddToSelf' );
65 $groupsRemoveFromSelf = $config->get(
'GroupsRemoveFromSelf' );
66 $allGroups = array_unique( array_merge(
67 array_keys( $groupPermissions ),
68 array_keys( $revokePermissions ),
69 array_keys( $addGroups ),
70 array_keys( $removeGroups ),
71 array_keys( $groupsAddToSelf ),
72 array_keys( $groupsRemoveFromSelf )
78 foreach ( $allGroups
as $group ) {
79 $permissions = $groupPermissions[$group] ?? [];
80 $groupname = ( $group ==
'*' )
84 $groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
86 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
87 ?: Title::newFromText( MWNamespace::getCanonicalName(
NS_PROJECT ) .
':' . $groupname );
89 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
91 $grouppage = htmlspecialchars( $groupnameLocalized );
94 $grouppageLocalizedTitle,
99 if ( $group ===
'user' ) {
103 $this->
msg(
'listgrouprights-members' )->
text()
105 } elseif ( !in_array( $group, $config->get(
'ImplicitGroups' ) ) ) {
108 $this->
msg(
'listgrouprights-members' )->
text(),
110 [
'group' => $group ]
117 $revoke = $revokePermissions[$group] ?? [];
118 $addgroups = $addGroups[$group] ?? [];
119 $removegroups = $removeGroups[$group] ?? [];
120 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
121 $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
123 $id = $group ==
'*' ?
false : Sanitizer::escapeIdForAttribute( $group );
124 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
125 <td>$grouppage$grouplink</td>
128 $addgroupsSelf, $removegroupsSelf ) .
133 $out->addHTML( Xml::closeElement(
'table' ) );
139 $namespaceProtection = $this->
getConfig()->get(
'NamespaceProtection' );
141 if ( count( $namespaceProtection ) == 0 ) {
145 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
147 Html::rawElement(
'h2', [], Html::element(
'span', [
148 'class' =>
'mw-headline',
149 'id' => substr( Parser::guessSectionNameFromStrippedText(
$header ), 1 )
151 Xml::openElement(
'table', [
'class' =>
'wikitable' ] ) .
155 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->
text()
160 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->
text()
164 ksort( $namespaceProtection );
165 $validNamespaces = MWNamespace::getValidNamespaces();
166 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
167 foreach ( $namespaceProtection
as $namespace => $rights ) {
168 if ( !in_array( $namespace, $validNamespaces ) ) {
173 $namespaceText = $this->
msg(
'blanknamespace' )->text();
175 $namespaceText = $contLang->convertNamespace( $namespace );
179 Xml::openElement(
'tr' ) .
187 [
'namespace' => $namespace ]
190 Xml::openElement(
'td' ) . Xml::openElement(
'ul' )
193 if ( !is_array( $rights ) ) {
194 $rights = [ $rights ];
197 foreach ( $rights
as $right ) {
199 Html::rawElement(
'li', [], $this->
msg(
200 'listgrouprights-right-display',
204 [
'class' =>
'mw-listgrouprights-right-name' ],
212 Xml::closeElement(
'ul' ) .
213 Xml::closeElement(
'td' ) .
214 Xml::closeElement(
'tr' )
217 $out->addHTML( Xml::closeElement(
'table' ) );
231 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
233 foreach ( $permissions
as $permission => $granted ) {
235 if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
236 $r[] = $this->
msg(
'listgrouprights-right-display',
238 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
242 foreach ( $revoke
as $permission => $revoked ) {
244 $r[] = $this->
msg(
'listgrouprights-right-revoked',
246 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
258 'removegroup' => $remove,
259 'addgroup-self' => $addSelf,
260 'removegroup-self' => $removeSelf
263 foreach ( $changeGroups
as $messageKey => $changeGroup ) {
264 if ( $changeGroup ===
true ) {
267 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
268 } elseif ( is_array( $changeGroup ) ) {
269 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
270 if ( count( $changeGroup ) ) {
272 foreach ( $changeGroup
as $group ) {
273 $groupLinks[] = UserGroupMembership::getLink( $group, $this->
getContext(),
'wiki' );
277 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
278 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
286 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';