Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add user id information to quota warning
This is a temporary solution, we’ll need to add the list in array format
 so that the UI can do something nice with it.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Oct 3, 2023
commit 2f96c57f6f3c0a2f6d08747a9d54ee345cf15351
10 changes: 5 additions & 5 deletions apps/settings/lib/AccountWarnings/QuotaWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ class QuotaWarning implements IAccountWarning {

public function __construct(
private IL10N $l10n,
private int $count,
private array $userIds,
private int $threshold,
) {
}

public function getText(): string {
return $this->l10n->n(
'%n account is using more than %d%% of their quota',
'%n accounts are using more than %d%% of their quota',
$this->count,
[$this->threshold]
'%n account is using more than %d%% of their quota: %s',
'%n accounts are using more than %d%% of their quota: %s',
count($this->userIds),
[$this->threshold, implode(',', $this->userIds)]
);
}

Expand Down
9 changes: 5 additions & 4 deletions apps/settings/lib/AccountWarnings/QuotaWarningsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getName(): string {
public function getAccountWarnings(): array {
$users = [];
foreach (QuotaWarning::THRESHOLDS as $threshold) {
$users[$threshold] = 0;
$users[$threshold] = [];
}
$this->userManager->callForSeenUsers(function (IUser $user) use (&$users) {
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
Expand All @@ -59,15 +59,16 @@ public function getAccountWarnings(): array {
$usage = 100 * ($size / $quota);
foreach (QuotaWarning::THRESHOLDS as $threshold => $level) {
if ($usage >= $threshold) {
$users[$threshold]++;
$users[$threshold][] = $user->getUID();
break;
}
}
});
$warnings = [];
foreach ($users as $threshold => $count) {
foreach ($users as $threshold => $uids) {
$count = count($uids);
if ($count > 0) {
$warnings[] = new QuotaWarning($this->l10n, $count, $threshold);
$warnings[] = new QuotaWarning($this->l10n, $uids, $threshold);
}
}
return $warnings;
Expand Down