57 parent::__construct(
'Listgrouprights' );
58 $this->nsInfo = $nsInfo;
59 $this->userGroupManager = $userGroupManager;
61 $this->groupPermissionsLookup = $groupPermissionsLookup;
73 $out->addModuleStyles(
'mediawiki.special' );
74 $this->
addHelpLink(
'Help:User_rights_and_groups' );
76 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
79 Html::openElement(
'table', [
'class' => [
'wikitable',
'mw-listgrouprights-table' ] ] ) .
91 $allGroups = array_merge(
92 $this->userGroupManager->listAllGroups(),
93 $this->userGroupManager->listAllImplicitGroups()
100 foreach ( $allGroups as $group ) {
101 $permissions = $this->groupPermissionsLookup->getGrantedPermissions( $group );
102 $groupname = ( $group ==
'*' )
106 $groupnameLocalized = $lang->getGroupName( $groupname );
108 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
109 ?: Title::makeTitleSafe(
NS_PROJECT, $groupname );
111 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
113 $grouppage = htmlspecialchars( $groupnameLocalized );
115 $grouppage = $linkRenderer->makeLink(
116 $grouppageLocalizedTitle,
121 $groupWithParentheses = $this->
msg(
'parentheses' )->rawParams( $group )->escaped();
122 $groupname =
"<br /><code>$groupWithParentheses</code>";
124 if ( $group ===
'user' ) {
126 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
128 $this->
msg(
'listgrouprights-members' )->text()
131 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
133 $this->
msg(
'listgrouprights-members' )->text(),
135 [
'group' => $group ]
142 $revoke = $this->groupPermissionsLookup->getRevokedPermissions( $group );
143 $addgroups = $addGroups[$group] ?? [];
144 $removegroups = $removeGroups[$group] ?? [];
145 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
146 $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
148 $id = $group ==
'*' ? false : Sanitizer::escapeIdForAttribute( $group );
149 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
150 <td>$grouppage$groupname$grouplink</td>
152 $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
153 $addgroupsSelf, $removegroupsSelf ) .
158 $out->addHTML( Html::closeElement(
'table' ) );
159 $this->outputNamespaceProtectionInfo();
162 private function outputNamespaceProtectionInfo() {
166 if ( count( $namespaceProtection ) == 0 ) {
170 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
173 'id' => Sanitizer::escapeIdForAttribute( $header )
175 Html::openElement(
'table', [
'class' =>
'wikitable' ] ) .
179 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->text()
184 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
188 ksort( $namespaceProtection );
189 $validNamespaces = $this->nsInfo->getValidNamespaces();
190 foreach ( $namespaceProtection as $namespace => $rights ) {
191 if ( !in_array( $namespace, $validNamespaces ) ) {
196 $namespaceText = $this->
msg(
'blanknamespace' )->text();
198 $namespaceText = $this->languageConverter->convertNamespace( $namespace );
202 Html::openElement(
'tr' ) .
206 $linkRenderer->makeLink(
210 [
'namespace' => $namespace ]
213 Html::openElement(
'td' ) . Html::openElement(
'ul' )
216 if ( !is_array( $rights ) ) {
217 $rights = [ $rights ];
220 foreach ( $rights as $right ) {
221 $out->addHTML( Html::rawElement(
'li', [],
222 $this->
msg(
'listgrouprights-right-display' )
223 ->params( User::getRightDescription( $right ) )
226 [
'class' =>
'mw-listgrouprights-right-name' ],
233 Html::closeElement(
'ul' ) .
234 Html::closeElement(
'td' ) .
235 Html::closeElement(
'tr' )
238 $out->addHTML( Html::closeElement(
'table' ) );
252 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
254 foreach ( $permissions as $permission ) {
256 if ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) {
257 $r[] = $this->
msg(
'listgrouprights-right-display' )
258 ->params( User::getRightDescription( $permission ) )
261 [
'class' =>
'mw-listgrouprights-right-name' ],
266 foreach ( $revoke as $permission ) {
267 $r[] = $this->
msg(
'listgrouprights-right-revoked' )
268 ->params( User::getRightDescription( $permission ) )
271 [
'class' =>
'mw-listgrouprights-right-name' ],
279 $allGroups = $this->userGroupManager->listAllGroups();
283 'removegroup' => $remove,
284 'addgroup-self' => $addSelf,
285 'removegroup-self' => $removeSelf
288 foreach ( $changeGroups as $messageKey => $changeGroup ) {
290 if ( $changeGroup ===
true ) {
293 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
294 } elseif ( is_array( $changeGroup ) ) {
295 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
296 if ( count( $changeGroup ) ) {
298 foreach ( $changeGroup as $group ) {
299 $groupLinks[] = UserGroupMembership::getLinkWiki( $group, $this->
getContext() );
303 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
304 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
312 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';
322class_alias( SpecialListGroupRights::class,
'SpecialListGroupRights' );
A class containing constants representing the names of configuration variables.
const ImplicitGroups
Name constant for the ImplicitGroups setting, for use with Config::get()
const NamespaceProtection
Name constant for the NamespaceProtection setting, for use with Config::get()
const GroupsRemoveFromSelf
Name constant for the GroupsRemoveFromSelf setting, for use with Config::get()
const AddGroups
Name constant for the AddGroups setting, for use with Config::get()
const GroupsAddToSelf
Name constant for the GroupsAddToSelf setting, for use with Config::get()
const RemoveGroups
Name constant for the RemoveGroups setting, for use with Config::get()
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getConfig()
Shortcut to get main config object.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.