Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable24] Fix plural usage in LDAP wizard #33667

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 20 additions & 27 deletions apps/user_ldap/lib/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,11 @@ public function countEntries(string $filter, string $type): int {
return (int)$result;
}

/**
* formats the return value of a count operation to the string to be
* inserted.
*
* @param int $count
* @return string
*/
private function formatCountResult(int $count): string {
if ($count > 1000) {
return '> 1000';
}
return (string)$count;
}

public function countGroups() {
$filter = $this->configuration->ldapGroupFilter;

if (empty($filter)) {
$output = self::$l->n('%s group found', '%s groups found', 0, [0]);
$output = self::$l->n('%n group found', '%n groups found', 0);
$this->result->addChange('ldap_group_count', $output);
return $this->result;
}
Expand All @@ -152,12 +138,16 @@ public function countGroups() {
}
return false;
}
$output = self::$l->n(
'%s group found',
'%s groups found',
$groupsTotal,
[$this->formatCountResult($groupsTotal)]
);

if ($groupsTotal > 1000) {
$output = self::$l->t('> 1000 groups found');
} else {
$output = self::$l->n(
'%n group found',
'%n groups found',
$groupsTotal
);
}
$this->result->addChange('ldap_group_count', $output);
return $this->result;
}
Expand All @@ -170,12 +160,15 @@ public function countUsers() {
$filter = $this->access->getFilterForUserCount();

$usersTotal = $this->countEntries($filter, 'users');
$output = self::$l->n(
'%s user found',
'%s users found',
$usersTotal,
[$this->formatCountResult($usersTotal)]
);
if ($usersTotal > 1000) {
$output = self::$l->t('> 1000 users found');
} else {
$output = self::$l->n(
'%n user found',
'%n users found',
$usersTotal
);
}
$this->result->addChange('ldap_user_count', $output);
return $this->result;
}
Expand Down