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 $msg = $this->
msg(
'group-' . $groupname );
85 $groupnameLocalized = !$msg->isBlank() ? $msg->text() : $groupname;
87 $msg = $this->
msg(
'grouppage-' . $groupname )->inContentLanguage();
88 $grouppageLocalized = !$msg->isBlank() ?
90 MWNamespace::getCanonicalName(
NS_PROJECT ) .
':' . $groupname;
91 $grouppageLocalizedTitle = Title::newFromText( $grouppageLocalized );
93 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
95 $grouppage = htmlspecialchars( $groupnameLocalized );
98 $grouppageLocalizedTitle,
103 if ( $group ===
'user' ) {
107 $this->
msg(
'listgrouprights-members' )->
text()
109 } elseif ( !in_array( $group, $config->get(
'ImplicitGroups' ) ) ) {
112 $this->
msg(
'listgrouprights-members' )->
text(),
114 [
'group' => $group ]
121 $revoke = isset( $revokePermissions[$group] ) ? $revokePermissions[$group] : [];
122 $addgroups = isset( $addGroups[$group] ) ? $addGroups[$group] : [];
123 $removegroups = isset( $removeGroups[$group] ) ? $removeGroups[$group] : [];
124 $addgroupsSelf = isset( $groupsAddToSelf[$group] ) ? $groupsAddToSelf[$group] : [];
125 $removegroupsSelf = isset( $groupsRemoveFromSelf[$group] )
126 ? $groupsRemoveFromSelf[$group]
129 $id = $group ==
'*' ?
false : Sanitizer::escapeIdForAttribute( $group );
130 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
131 <td>$grouppage$grouplink</td>
134 $addgroupsSelf, $removegroupsSelf ) .
139 $out->addHTML( Xml::closeElement(
'table' ) );
146 $namespaceProtection = $this->
getConfig()->get(
'NamespaceProtection' );
148 if ( count( $namespaceProtection ) == 0 ) {
152 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->parse();
154 Html::rawElement(
'h2', [], Html::element(
'span', [
155 'class' =>
'mw-headline',
158 Xml::openElement(
'table', [
'class' =>
'wikitable' ] ) .
162 $this->msg(
'listgrouprights-namespaceprotection-namespace' )->text()
167 $this->msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
171 ksort( $namespaceProtection );
172 foreach ( $namespaceProtection as $namespace => $rights ) {
173 if ( !in_array( $namespace, MWNamespace::getValidNamespaces() ) ) {
178 $namespaceText = $this->
msg(
'blanknamespace' )->text();
180 $namespaceText =
$wgContLang->convertNamespace( $namespace );
184 Xml::openElement(
'tr' ) .
192 [
'namespace' => $namespace ]
195 Xml::openElement(
'td' ) . Xml::openElement(
'ul' )
198 if ( !is_array( $rights ) ) {
199 $rights = [ $rights ];
202 foreach ( $rights as $right ) {
204 Html::rawElement(
'li', [], $this->
msg(
205 'listgrouprights-right-display',
206 User::getRightDescription( $right ),
209 [
'class' =>
'mw-listgrouprights-right-name' ],
217 Xml::closeElement(
'ul' ) .
218 Xml::closeElement(
'td' ) .
219 Xml::closeElement(
'tr' )
222 $out->addHTML( Xml::closeElement(
'table' ) );
236 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
238 foreach ( $permissions as $permission => $granted ) {
240 if ( $granted && ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) ) {
241 $r[] = $this->
msg(
'listgrouprights-right-display',
242 User::getRightDescription( $permission ),
243 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
247 foreach ( $revoke as $permission => $revoked ) {
249 $r[] = $this->
msg(
'listgrouprights-right-revoked',
250 User::getRightDescription( $permission ),
251 '<span class="mw-listgrouprights-right-name">' . $permission .
'</span>'
259 $allGroups = User::getAllGroups();
263 'removegroup' => $remove,
264 'addgroup-self' => $addSelf,
265 'removegroup-self' => $removeSelf
268 foreach ( $changeGroups as $messageKey => $changeGroup ) {
269 if ( $changeGroup ===
true ) {
272 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
273 } elseif ( is_array( $changeGroup ) ) {
274 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
275 if ( count( $changeGroup ) ) {
277 foreach ( $changeGroup as $group ) {
282 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
283 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
291 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';