From 3af407f364f5fbcedbba27b3ba25b7684108fe4a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Aug 2022 14:14:47 +0200 Subject: [PATCH 1/2] Fix plural usage in LDAP wizard Signed-off-by: Joas Schilling --- apps/user_ldap/lib/Wizard.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index 6e0d6f80f8d13..3d79f5bec6f6e 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -138,7 +138,7 @@ 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; } @@ -152,12 +152,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; } @@ -170,12 +174,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; } From 2d748c928e210b67acca74006c8fe554562a4466 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Aug 2022 14:15:32 +0200 Subject: [PATCH 2/2] Remove unused method Signed-off-by: Joas Schilling --- apps/user_ldap/lib/Wizard.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index 3d79f5bec6f6e..19d0d1e5c743c 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -120,20 +120,6 @@ 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;