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 );
91 $grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $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 ]
117 $out->addHTML( Html::rawElement(
'tr', [
'id' => Sanitizer::escapeIdForAttribute( $group ) ],
"
118 <td>$grouppage$grouplink</td>
119 <td>" . $this->formatPolicies( $policies, $group ) .
'</td>
125 $out->addHTML( Xml::closeElement(
'table' ) );
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>';
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.
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.