46 parent::__construct(
'PasswordPolicies' );
47 $this->userGroupManager = $userGroupManager;
59 $out->addModuleStyles(
'mediawiki.special' );
65 Xml::openElement(
'table', [
'class' =>
'wikitable mw-passwordpolicies-table' ] ) .
67 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-group' )->text() ) .
68 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-policies' )->text() ) .
75 $implicitGroups = $this->userGroupManager->listAllImplicitGroups();
76 $allGroups = array_merge(
77 $this->userGroupManager->listAllGroups(),
85 foreach ( $allGroups as $group ) {
86 if ( $group ==
'*' ) {
90 $groupnameLocalized = $lang->getGroupName( $group );
92 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $group )
95 $grouppage = $linkRenderer->makeLink(
96 $grouppageLocalizedTitle,
100 if ( $group ===
'user' ) {
102 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
104 $this->
msg(
'listgrouprights-members' )->text()
106 } elseif ( !in_array( $group, $implicitGroups ) ) {
107 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
109 $this->
msg(
'listgrouprights-members' )->text(),
111 [
'group' => $group ]
118 $out->addHTML( Html::rawElement(
'tr', [
'id' => Sanitizer::escapeIdForAttribute( $group ) ],
"
119 <td>$grouppage$grouplink</td>
120 <td>" . $this->formatPolicies( $policies, $group ) .
'</td>
137 private function formatPolicies( $policies, $group ) {
138 $groupPolicies = UserPasswordPolicy::getPoliciesForGroups(
139 $policies[
'policies'],
141 $policies[
'policies'][
'default']
145 foreach ( $groupPolicies as $gp => $settings ) {
146 if ( !is_array( $settings ) ) {
147 $settings = [
'value' => $settings ];
149 $val = $settings[
'value'];
150 $flags = array_diff_key( $settings, [
'value' =>
true ] );
156 $msg = $this->
msg(
'passwordpolicies-policy-' . strtolower( $gp ) );
158 if ( is_numeric( $val ) ) {
159 $msg->numParams( $val );
163 foreach ( array_filter( $flags ) as $flag => $value ) {
164 $flagMsg = $this->
msg(
'passwordpolicies-policyflag-' . strtolower( $flag ) );
165 $flagMsg->params( $value );
166 $flagMsgs[] = $flagMsg;
170 'passwordpolicies-policy-displaywithflags',
172 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>',
177 'passwordpolicies-policy-display',
179 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>'
186 return '<ul><li>' . implode(
"</li>\n<li>", $ret ) .
'</li></ul>';
199class_alias( SpecialPasswordPolicies::class,
'SpecialPasswordPolicies' );
A class containing constants representing the names of configuration variables.
const PasswordPolicy
Name constant for the PasswordPolicy 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.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
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.