51 parent::__construct(
'PasswordPolicies' );
52 $this->userGroupManager = $userGroupManager;
64 $out->addModuleStyles(
'mediawiki.special' );
70 Xml::openElement(
'table', [
'class' =>
'wikitable mw-passwordpolicies-table' ] ) .
72 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-group' )->text() ) .
73 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-policies' )->text() ) .
80 $implicitGroups = $this->userGroupManager->listAllImplicitGroups();
81 $allGroups = array_merge(
82 $this->userGroupManager->listAllGroups(),
90 foreach ( $allGroups as $group ) {
91 if ( $group ==
'*' ) {
95 $groupnameLocalized = $lang->getGroupName( $group );
97 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $group )
100 $grouppage = $linkRenderer->makeLink(
101 $grouppageLocalizedTitle,
105 if ( $group ===
'user' ) {
107 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
109 $this->
msg(
'listgrouprights-members' )->text()
111 } elseif ( !in_array( $group, $implicitGroups ) ) {
112 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
114 $this->
msg(
'listgrouprights-members' )->text(),
116 [
'group' => $group ]
123 $out->addHTML( Html::rawElement(
'tr', [
'id' => Sanitizer::escapeIdForAttribute( $group ) ],
"
124 <td>$grouppage$grouplink</td>
125 <td>" . $this->formatPolicies( $policies, $group ) .
'</td>
131 $out->addHTML( Xml::closeElement(
'table' ) );
142 private function formatPolicies( $policies, $group ) {
143 $groupPolicies = UserPasswordPolicy::getPoliciesForGroups(
144 $policies[
'policies'],
146 $policies[
'policies'][
'default']
150 foreach ( $groupPolicies as $gp => $settings ) {
151 if ( !is_array( $settings ) ) {
152 $settings = [
'value' => $settings ];
154 $val = $settings[
'value'];
155 $flags = array_diff_key( $settings, [
'value' =>
true ] );
160 $msg = $this->
msg(
'passwordpolicies-policy-' . strtolower( $gp ) )->numParams( $val );
162 foreach ( array_filter( $flags ) as $flag => $value ) {
163 $flagMsg = $this->
msg(
'passwordpolicies-policyflag-' . strtolower( $flag ) );
164 $flagMsg->params( $value );
165 $flagMsgs[] = $flagMsg;
169 'passwordpolicies-policy-displaywithflags',
171 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>',
176 'passwordpolicies-policy-display',
178 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>'
185 return '<ul><li>' . implode(
"</li>\n<li>", $ret ) .
'</li></ul>';
198class_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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Check if a user's password complies with any password policies that apply to that user,...
Module of static functions for generating XML.