45 $out->addModuleStyles(
'mediawiki.special' );
47 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
50 Xml::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
52 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-group' )->
text() ) .
53 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-rights' )->
text() ) .
58 $groupPermissions = $config->get(
'GroupPermissions' );
59 $revokePermissions = $config->get(
'RevokePermissions' );
60 $addGroups = $config->get(
'AddGroups' );
61 $removeGroups = $config->get(
'RemoveGroups' );
62 $groupsAddToSelf = $config->get(
'GroupsAddToSelf' );
63 $groupsRemoveFromSelf = $config->get(
'GroupsRemoveFromSelf' );
64 $allGroups = array_unique( array_merge(
65 array_keys( $groupPermissions ),
66 array_keys( $revokePermissions ),
67 array_keys( $addGroups ),
68 array_keys( $removeGroups ),
69 array_keys( $groupsAddToSelf ),
70 array_keys( $groupsRemoveFromSelf )
76 foreach ( $allGroups as $group ) {
77 $permissions = isset( $groupPermissions[$group] )
78 ? $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 = isset( $revokePermissions[$group] ) ? $revokePermissions[$group] : [];
118 $addgroups = isset( $addGroups[$group] ) ? $addGroups[$group] : [];
119 $removegroups = isset( $removeGroups[$group] ) ? $removeGroups[$group] : [];
120 $addgroupsSelf = isset( $groupsAddToSelf[$group] ) ? $groupsAddToSelf[$group] : [];
121 $removegroupsSelf = isset( $groupsRemoveFromSelf[$group] )
122 ? $groupsRemoveFromSelf[$group]
125 $id = $group ==
'*' ?
false : Sanitizer::escapeIdForAttribute( $group );
126 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
127 <td>$grouppage$grouplink</td>
130 $addgroupsSelf, $removegroupsSelf ) .
135 $out->addHTML( Xml::closeElement(
'table' ) );
142 $namespaceProtection = $this->
getConfig()->get(
'NamespaceProtection' );
144 if ( count( $namespaceProtection ) == 0 ) {
148 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
150 Html::rawElement(
'h2', [], Html::element(
'span', [
151 'class' =>
'mw-headline',
152 'id' => substr( Parser::guessSectionNameFromStrippedText(
$header ), 1 )
154 Xml::openElement(
'table', [
'class' =>
'wikitable' ] ) .
158 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->
text()
163 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->
text()
167 ksort( $namespaceProtection );
168 foreach ( $namespaceProtection as $namespace => $rights ) {
169 if ( !in_array( $namespace, MWNamespace::getValidNamespaces() ) ) {
174 $namespaceText = $this->
msg(
'blanknamespace' )->text();
176 $namespaceText =
$wgContLang->convertNamespace( $namespace );
180 Xml::openElement(
'tr' ) .
188 [
'namespace' => $namespace ]
191 Xml::openElement(
'td' ) . Xml::openElement(
'ul' )
194 if ( !is_array( $rights ) ) {
195 $rights = [ $rights ];
198 foreach ( $rights as $right ) {
200 Html::rawElement(
'li', [], $this->
msg(
201 'listgrouprights-right-display',
205 [
'class' =>
'mw-listgrouprights-right-name' ],
213 Xml::closeElement(
'ul' ) .
214 Xml::closeElement(
'td' ) .
215 Xml::closeElement(
'tr' )
218 $out->addHTML( Xml::closeElement(
'table' ) );
232 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
234 foreach ( $permissions as $permission => $granted ) {
236 if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
237 $r[] = $this->
msg(
'listgrouprights-right-display',
239 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
243 foreach ( $revoke as $permission => $revoked ) {
245 $r[] = $this->
msg(
'listgrouprights-right-revoked',
247 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
259 'removegroup' => $remove,
260 'addgroup-self' => $addSelf,
261 'removegroup-self' => $removeSelf
264 foreach ( $changeGroups as $messageKey => $changeGroup ) {
265 if ( $changeGroup ===
true ) {
268 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
269 } elseif ( is_array( $changeGroup ) ) {
270 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
271 if ( count( $changeGroup ) ) {
273 foreach ( $changeGroup as $group ) {
274 $groupLinks[] = UserGroupMembership::getLink( $group, $this->
getContext(),
'wiki' );
278 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
279 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
287 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';