37 private $userGroupManager;
43 parent::__construct(
'PasswordPolicies' );
44 $this->userGroupManager = $userGroupManager;
56 $out->addModuleStyles(
'mediawiki.special' );
62 Xml::openElement(
'table', [
'class' =>
'wikitable mw-passwordpolicies-table' ] ) .
64 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-group' )->text() ) .
65 Xml::element(
'th',
null, $this->
msg(
'passwordpolicies-policies' )->text() ) .
70 $policies = $config->get( MainConfigNames::PasswordPolicy );
72 $implicitGroups = $this->userGroupManager->listAllImplicitGroups();
73 $allGroups = array_merge(
74 $this->userGroupManager->listAllGroups(),
82 foreach ( $allGroups as $group ) {
83 if ( $group ==
'*' ) {
87 $groupnameLocalized =
$lang->getGroupName( $group );
92 $grouppage = $linkRenderer->makeLink(
93 $grouppageLocalizedTitle,
97 if ( $group ===
'user' ) {
99 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
101 $this->
msg(
'listgrouprights-members' )->text()
103 } elseif ( !in_array( $group, $implicitGroups ) ) {
104 $grouplink =
'<br />' . $linkRenderer->makeKnownLink(
106 $this->
msg(
'listgrouprights-members' )->text(),
108 [
'group' => $group ]
116 <td>$grouppage$grouplink</td>
117 <td>" . $this->formatPolicies( $policies, $group ) .
'</td>
134 private function formatPolicies( $policies, $group ) {
136 $policies[
'policies'],
138 $policies[
'policies'][
'default']
142 foreach ( $groupPolicies as $gp => $settings ) {
143 if ( !is_array( $settings ) ) {
144 $settings = [
'value' => $settings ];
146 $val = $settings[
'value'];
147 $flags = array_diff_key( $settings, [
'value' =>
true ] );
152 $msg = $this->
msg(
'passwordpolicies-policy-' . strtolower( $gp ) )->numParams( $val );
154 foreach ( array_filter( $flags ) as $flag => $value ) {
155 $flagMsg = $this->
msg(
'passwordpolicies-policyflag-' . strtolower( $flag ) );
156 $flagMsg->params( $value );
157 $flagMsgs[] = $flagMsg;
161 'passwordpolicies-policy-displaywithflags',
163 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>',
168 'passwordpolicies-policy-display',
170 '<span class="mw-passwordpolicies-policy-name">' . $gp .
'</span>'
177 return '<ul><li>' . implode(
"</li>\n<li>", $ret ) .
'</li></ul>';
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
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 makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
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