65 parent::__construct(
'Listgrouprights' );
66 $this->nsInfo = $nsInfo;
67 $this->userGroupManager = $userGroupManager;
69 $this->groupPermissionsLookup = $groupPermissionsLookup;
81 $out->addModuleStyles(
'mediawiki.special' );
82 $this->
addHelpLink(
'Help:User_rights_and_groups' );
84 $out->wrapWikiMsg(
"<div class=\"mw-listgrouprights-key\">\n$1\n</div>",
'listgrouprights-key' );
87 Html::openElement(
'table', [
'class' =>
'wikitable mw-listgrouprights-table' ] ) .
99 $allGroups = array_merge(
100 $this->userGroupManager->listAllGroups(),
101 $this->userGroupManager->listAllImplicitGroups()
108 foreach ( $allGroups as $group ) {
109 $permissions = $this->groupPermissionsLookup->getGrantedPermissions( $group );
110 $groupname = ( $group ==
'*' )
114 $groupnameLocalized = $lang->getGroupName( $groupname );
116 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
117 ?: Title::makeTitleSafe(
NS_PROJECT, $groupname );
119 if ( $group ==
'*' || !$grouppageLocalizedTitle ) {
121 $grouppage = htmlspecialchars( $groupnameLocalized );
123 $grouppage = $linkRenderer->makeLink(
124 $grouppageLocalizedTitle,
129 $groupWithParentheses = $this->
msg(
'parentheses' )->rawParams( $group )->escaped();
130 $groupname =
"<br /><code>$groupWithParentheses</code>";
132 if ( $group ===
'user' ) {
134 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
136 $this->
msg(
'listgrouprights-members' )->text()
139 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
141 $this->
msg(
'listgrouprights-members' )->text(),
143 [
'group' => $group ]
150 $revoke = $this->groupPermissionsLookup->getRevokedPermissions( $group );
151 $addgroups = $addGroups[$group] ?? [];
152 $removegroups = $removeGroups[$group] ?? [];
153 $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
154 $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
156 $id = $group ==
'*' ? false : Sanitizer::escapeIdForAttribute( $group );
157 $out->addHTML( Html::rawElement(
'tr', [
'id' => $id ],
"
158 <td>$grouppage$groupname$grouplink</td>
160 $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
161 $addgroupsSelf, $removegroupsSelf ) .
166 $out->addHTML( Html::closeElement(
'table' ) );
167 $this->outputNamespaceProtectionInfo();
170 private function outputNamespaceProtectionInfo() {
174 if ( count( $namespaceProtection ) == 0 ) {
178 $header = $this->
msg(
'listgrouprights-namespaceprotection-header' )->text();
181 'id' => Sanitizer::escapeIdForAttribute(
$header )
183 Html::openElement(
'table', [
'class' =>
'wikitable' ] ) .
187 $this->
msg(
'listgrouprights-namespaceprotection-namespace' )->text()
192 $this->
msg(
'listgrouprights-namespaceprotection-restrictedto' )->text()
196 ksort( $namespaceProtection );
197 $validNamespaces = $this->nsInfo->getValidNamespaces();
198 foreach ( $namespaceProtection as $namespace => $rights ) {
199 if ( !in_array( $namespace, $validNamespaces ) ) {
204 $namespaceText = $this->
msg(
'blanknamespace' )->text();
206 $namespaceText = $this->languageConverter->convertNamespace( $namespace );
210 Html::openElement(
'tr' ) .
214 $linkRenderer->makeLink(
218 [
'namespace' => $namespace ]
221 Html::openElement(
'td' ) . Html::openElement(
'ul' )
224 if ( !is_array( $rights ) ) {
225 $rights = [ $rights ];
228 foreach ( $rights as $right ) {
229 $out->addHTML( Html::rawElement(
'li', [],
230 $this->
msg(
'listgrouprights-right-display' )
231 ->params( User::getRightDescription( $right ) )
234 [
'class' =>
'mw-listgrouprights-right-name' ],
241 Html::closeElement(
'ul' ) .
242 Html::closeElement(
'td' ) .
243 Html::closeElement(
'tr' )
246 $out->addHTML( Html::closeElement(
'table' ) );
260 private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
262 foreach ( $permissions as $permission ) {
264 if ( !isset( $revoke[$permission] ) || !$revoke[$permission] ) {
265 $r[] = $this->
msg(
'listgrouprights-right-display' )
266 ->params( User::getRightDescription( $permission ) )
269 [
'class' =>
'mw-listgrouprights-right-name' ],
274 foreach ( $revoke as $permission ) {
275 $r[] = $this->
msg(
'listgrouprights-right-revoked' )
276 ->params( User::getRightDescription( $permission ) )
279 [
'class' =>
'mw-listgrouprights-right-name' ],
287 $allGroups = $this->userGroupManager->listAllGroups();
291 'removegroup' => $remove,
292 'addgroup-self' => $addSelf,
293 'removegroup-self' => $removeSelf
296 foreach ( $changeGroups as $messageKey => $changeGroup ) {
298 if ( $changeGroup ===
true ) {
301 $r[] = $this->
msg(
'listgrouprights-' . $messageKey .
'-all' )->escaped();
302 } elseif ( is_array( $changeGroup ) ) {
303 $changeGroup = array_intersect( array_values( array_unique( $changeGroup ) ), $allGroups );
304 if ( count( $changeGroup ) ) {
306 foreach ( $changeGroup as $group ) {
307 $groupLinks[] = UserGroupMembership::getLinkWiki( $group, $this->
getContext() );
311 $r[] = $this->
msg(
'listgrouprights-' . $messageKey,
312 $lang->listToText( $groupLinks ), count( $changeGroup ) )->parse();
320 return '<ul><li>' . implode(
"</li>\n<li>", $r ) .
'</li></ul>';
330class_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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
The shared interface for all language converters.