63 parent::__construct(
'Listgrouprights' );
64 $this->nsInfo = $nsInfo;
65 $this->userGroupManager = $userGroupManager;
67 $this->groupPermissionsLookup = $groupPermissionsLookup;
79 $out->addModuleStyles(
'mediawiki.special' );
80 $this->
addHelpLink(
'Help:User_rights_and_groups' );
82 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
85 Html::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
97 $allGroups = array_merge(
98 $this->userGroupManager->listAllGroups(),
99 $this->userGroupManager->listAllImplicitGroups()
106 foreach ( $allGroups as $group ) {
107 $permissions = $this->groupPermissionsLookup->getGrantedPermissions( $group );
108 $groupname = ( $group ==
'*' )
112 $groupnameLocalized = $lang->getGroupName( $groupname );
114 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
115 ?: Title::makeTitleSafe(
NS_PROJECT, $groupname );
117 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
119 $grouppage = htmlspecialchars( $groupnameLocalized );
121 $grouppage = $linkRenderer->makeLink(
122 $grouppageLocalizedTitle,
127 $groupWithParentheses = $this->
msg(
'parentheses' )->rawParams( $group )->escaped();
128 $groupname =
"<br /><code>$groupWithParentheses</code>";
130 if ( $group ===
'user' ) {
132 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
134 $this->
msg(
'listgrouprights-members' )->text()
137 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
139 $this->
msg(
'listgrouprights-members' )->text(),
141 [
'group' => $group ]
148 $revoke = $this->groupPermissionsLookup->getRevokedPermissions( $group );
149 $addgroups = $addGroups[$group] ?? [];
150 $removegroups = $removeGroups[$group] ?? [];
151 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
152 $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
154 $id = $group ==
'*' ? false : Sanitizer::escapeIdForAttribute( $group );
155 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
156 <td>$grouppage$groupname$grouplink</td>
158 $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
159 $addgroupsSelf, $removegroupsSelf ) .
164 $out->addHTML( Html::closeElement(
'table' ) );
165 $this->outputNamespaceProtectionInfo();
168 private function outputNamespaceProtectionInfo() {
172 if ( count( $namespaceProtection ) == 0 ) {
176 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
179 'id' => Sanitizer::escapeIdForAttribute(
$header )
181 Html::openElement(
'table', [
'class' =>
'wikitable' ] ) .
185 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->text()
190 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
194 ksort( $namespaceProtection );
195 $validNamespaces = $this->nsInfo->getValidNamespaces();
196 foreach ( $namespaceProtection as $namespace => $rights ) {
197 if ( !in_array( $namespace, $validNamespaces ) ) {
202 $namespaceText = $this->
msg(
'blanknamespace' )->text();
204 $namespaceText = $this->languageConverter->convertNamespace( $namespace );
208 Html::openElement(
'tr' ) .
212 $linkRenderer->makeLink(
216 [
'namespace' => $namespace ]
219 Html::openElement(
'td' ) . Html::openElement(
'ul' )
222 if ( !is_array( $rights ) ) {
223 $rights = [ $rights ];
226 foreach ( $rights as $right ) {
227 $out->addHTML( Html::rawElement(
'li', [],
228 $this->
msg(
'listgrouprights-right-display' )
229 ->params( User::getRightDescription( $right ) )
232 [
'class' =>
'mw-listgrouprights-right-name' ],
239 Html::closeElement(
'ul' ) .
240 Html::closeElement(
'td' ) .
241 Html::closeElement(
'tr' )
244 $out->addHTML( Html::closeElement(
'table' ) );
258 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
260 foreach ( $permissions as $permission ) {
262 if ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) {
263 $r[] = $this->
msg(
'listgrouprights-right-display' )
264 ->params( User::getRightDescription( $permission ) )
267 [
'class' =>
'mw-listgrouprights-right-name' ],
272 foreach ( $revoke as $permission ) {
273 $r[] = $this->
msg(
'listgrouprights-right-revoked' )
274 ->params( User::getRightDescription( $permission ) )
277 [
'class' =>
'mw-listgrouprights-right-name' ],
285 $allGroups = $this->userGroupManager->listAllGroups();
289 'removegroup' => $remove,
290 'addgroup-self' => $addSelf,
291 'removegroup-self' => $removeSelf
294 foreach ( $changeGroups as $messageKey => $changeGroup ) {
296 if ( $changeGroup ===
true ) {
299 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
300 } elseif ( is_array( $changeGroup ) ) {
301 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
302 if ( count( $changeGroup ) ) {
304 foreach ( $changeGroup as $group ) {
305 $groupLinks[] = UserGroupMembership::getLinkWiki( $group, $this->
getContext() );
309 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
310 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
318 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';
328class_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.