35 parent::__construct(
'Listgrouprights' );
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 ==
'*' )
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 ) .
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 )
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 );
190 [
'namespace' => $namespace ]
196 if ( !is_array( $rights ) ) {
197 $rights = [ $rights ];
200 foreach ( $rights as $right ) {
202 Html::rawElement(
'li', [], $this->
msg(
203 'listgrouprights-right-display',
207 [
'class' =>
'mw-listgrouprights-right-name' ],
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',
241 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
245 foreach ( $revoke as $permission => $revoked ) {
247 $r[] = $this->
msg(
'listgrouprights-right-revoked',
249 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
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 ) {
281 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
282 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
290 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';