39 private $userGroupManager;
45 parent::__construct(
'PasswordPolicies' );
46 $this->userGroupManager = $userGroupManager;
58 $out->addModuleStyles(
'mediawiki.special' );
64 Xml::openElement(
'table', [
'class' =>
'wikitable mw-passwordpolicies-table' ] ) .
66 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-group' )->text() ) .
67 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-policies' )->text() ) .
72 $policies = $config->get( MainConfigNames::PasswordPolicy );
74 $implicitGroups = $this->userGroupManager->listAllImplicitGroups();
75 $allGroups = array_merge(
76 $this->userGroupManager->listAllGroups(),
84 foreach ( $allGroups as $group ) {
85 if ( $group ==
'*' ) {
89 $groupnameLocalized =
$lang->getGroupName( $group );
94 $grouppage = $linkRenderer->makeLink(
95 $grouppageLocalizedTitle,
99 if ( $group ===
'user' ) {
101 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
103 $this->
msg(
'listgrouprights-members' )->text()
105 } elseif ( !in_array( $group, $implicitGroups ) ) {
106 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
108 $this->
msg(
'listgrouprights-members' )->text(),
110 [
'group' => $group ]
118 <td>$grouppage$grouplink</td>
119 <td>" . $this->formatPolicies( $policies, $group ) .
'</td>
136 private function formatPolicies( $policies, $group ) {
138 $policies[
'policies'],
140 $policies[
'policies'][
'default']
144 foreach ( $groupPolicies as $gp => $settings ) {
145 if ( !is_array( $settings ) ) {
146 $settings = [
'value' => $settings ];
148 $val = $settings[
'value'];
149 $flags = array_diff_key( $settings, [
'value' =>
true ] );
154 $msg = $this->
msg(
'passwordpolicies-policy-' . strtolower( $gp ) )->numParams( $val );
156 foreach ( array_filter( $flags ) as $flag => $value ) {
157 $flagMsg = $this->
msg(
'passwordpolicies-policyflag-' . strtolower( $flag ) );
158 $flagMsg->params( $value );
159 $flagMsgs[] = $flagMsg;
163 'passwordpolicies-policy-displaywithflags',
165 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>',
170 'passwordpolicies-policy-display',
172 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>'
179 return '<ul><li>' . implode(
"</li>\n<li>", $ret ) .
'</li></ul>';
A class containing constants representing the names of configuration variables.
static escapeIdForAttribute( $id, $mode=self::ID_PRIMARY)
Given a section name or other user-generated or otherwise unsafe string, escapes it to be a valid HTM...
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
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,...
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
This special page lists the defined password policies for user groups.
__construct(UserGroupManager $userGroupManager)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Show the special page.
static getGroupPage( $group)
Gets the title of a page describing a particular user group.
static getPoliciesForGroups(array $policies, array $userGroups, array $defaultPolicy)
Utility function to get the effective policy from a list of policies, based on a list of groups.
static closeElement( $element)
Shortcut to close an XML element.
static openElement( $element, $attribs=null)
This opens an XML element.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
if(!isset( $args[0])) $lang