47 $out->addModuleStyles(
'mediawiki.special' );
48 $this->
addHelpLink(
'Help:User_rights_and_groups' );
50 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
53 Xml::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
55 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-group' )->text() ) .
56 Xml::element(
'th',
null, $this->
msg(
'listgrouprights-rights' )->text() ) .
61 $groupPermissions = $config->get(
'GroupPermissions' );
62 $revokePermissions = $config->get(
'RevokePermissions' );
63 $addGroups = $config->get(
'AddGroups' );
64 $removeGroups = $config->get(
'RemoveGroups' );
65 $groupsAddToSelf = $config->get(
'GroupsAddToSelf' );
66 $groupsRemoveFromSelf = $config->get(
'GroupsRemoveFromSelf' );
67 $allGroups = array_unique( array_merge(
68 array_keys( $groupPermissions ),
69 array_keys( $revokePermissions ),
70 array_keys( $addGroups ),
71 array_keys( $removeGroups ),
72 array_keys( $groupsAddToSelf ),
73 array_keys( $groupsRemoveFromSelf )
79 foreach ( $allGroups as $group ) {
80 $permissions = $groupPermissions[$group] ?? [];
81 $groupname = ( $group ==
'*' )
85 $groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
87 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
88 ?: Title::newFromText( MediaWikiServices::getInstance()->getNamespaceInfo()->
89 getCanonicalName(
NS_PROJECT ) .
':' . $groupname );
91 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
93 $grouppage = htmlspecialchars( $groupnameLocalized );
96 $grouppageLocalizedTitle,
101 if ( $group ===
'user' ) {
105 $this->
msg(
'listgrouprights-members' )->text()
107 } elseif ( !in_array( $group, $config->get(
'ImplicitGroups' ) ) ) {
110 $this->
msg(
'listgrouprights-members' )->text(),
112 [
'group' => $group ]
119 $revoke = $revokePermissions[$group] ?? [];
120 $addgroups = $addGroups[$group] ?? [];
121 $removegroups = $removeGroups[$group] ?? [];
122 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
123 $removegroupsSelf = $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' ) );
141 $namespaceProtection = $this->
getConfig()->get(
'NamespaceProtection' );
143 if ( count( $namespaceProtection ) == 0 ) {
147 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
149 Html::rawElement(
'h2', [], Html::element(
'span', [
150 'class' =>
'mw-headline',
151 'id' => substr( Parser::guessSectionNameFromStrippedText(
$header ), 1 )
153 Xml::openElement(
'table', [
'class' =>
'wikitable' ] ) .
157 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->text()
162 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
166 ksort( $namespaceProtection );
168 MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces();
169 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
170 foreach ( $namespaceProtection as $namespace => $rights ) {
171 if ( !in_array( $namespace, $validNamespaces ) ) {
176 $namespaceText = $this->
msg(
'blanknamespace' )->text();
178 $namespaceText = $contLang->convertNamespace( $namespace );
182 Xml::openElement(
'tr' ) .
190 [
'namespace' => $namespace ]
193 Xml::openElement(
'td' ) . Xml::openElement(
'ul' )
196 if ( !is_array( $rights ) ) {
197 $rights = [ $rights ];
200 foreach ( $rights as $right ) {
202 Html::rawElement(
'li', [], $this->
msg(
203 'listgrouprights-right-display',
204 User::getRightDescription( $right ),
207 [
'class' =>
'mw-listgrouprights-right-name' ],
215 Xml::closeElement(
'ul' ) .
216 Xml::closeElement(
'td' ) .
217 Xml::closeElement(
'tr' )
220 $out->addHTML( Xml::closeElement(
'table' ) );
234 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
236 foreach ( $permissions as $permission => $granted ) {
238 if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
239 $r[] = $this->
msg(
'listgrouprights-right-display',
240 User::getRightDescription( $permission ),
241 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
245 foreach ( $revoke as $permission => $revoked ) {
247 $r[] = $this->
msg(
'listgrouprights-right-revoked',
248 User::getRightDescription( $permission ),
249 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
257 $allGroups = User::getAllGroups();
261 'removegroup' => $remove,
262 'addgroup-self' => $addSelf,
263 'removegroup-self' => $removeSelf
266 foreach ( $changeGroups as $messageKey => $changeGroup ) {
268 if ( $changeGroup ===
true ) {
271 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
272 } elseif ( is_array( $changeGroup ) ) {
273 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
274 if ( count( $changeGroup ) ) {
276 foreach ( $changeGroup as $group ) {
277 $groupLinks[] = UserGroupMembership::getLink( $group, $this->
getContext(),
'wiki' );
281 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
282 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
290 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';