diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT
index 8c80746e..03fee667 100644
--- a/CHANGELOG.TXT
+++ b/CHANGELOG.TXT
@@ -9,6 +9,7 @@
Changes in 'master' (not in a release yet) (20XX/XX/XX)
--------------------------
+ - Show available usage for unlimited quotas and retain neutral quota boxes.
- Remove the obsolete quota_usage.pl example and Horde 3 SQL password guide.
See ADDITIONS/README.md for quota integration and modernization notes.
- Restore the legacy md5crypt password scheme compatibility (see #1123, thanks @8ctopus)
diff --git a/templates/list-virtual_mailbox.tpl b/templates/list-virtual_mailbox.tpl
index 91231361..95ca9af1 100644
--- a/templates/list-virtual_mailbox.tpl
+++ b/templates/list-virtual_mailbox.tpl
@@ -75,7 +75,9 @@
{if $CONF.quota===YES}
{if $item.quota==0}
- {$PALANG.pOverview_unlimited}
+
+ {if $boolconf_used_quotas}{$divide_quota.current[$i]} / ∞{else}∞{/if}
+
{elseif $item.quota<0}
{$PALANG.pOverview_disabled}
{else}
diff --git a/templates/list.tpl b/templates/list.tpl
index c3090499..a9afe579 100644
--- a/templates/list.tpl
+++ b/templates/list.tpl
@@ -167,12 +167,12 @@
{if $table == 'domain' && $key == 'total_quot' && isset($item.total_quota_used)}
{assign "quota_tooltip" "{$PALANG.quota_assigned}: {$linktext}
{$PALANG.quota_used}: {$item.total_quota_used} MB"}
{/if}
-
+
{if $item[$tmpkey] > -1}
{$linktext}
{else}
- {$linktext}
+ {if $table == 'domain' && $key == 'total_quot' && $item.quota == 0 && $CONF.used_quotas === YES && isset($item.total_quota_used)}{$item.total_quota_used} / ∞{else}{$linktext}{/if}
{/if}
diff --git a/tests/UnlimitedQuotaTemplateTest.php b/tests/UnlimitedQuotaTemplateTest.php
new file mode 100644
index 00000000..170c3a0c
--- /dev/null
+++ b/tests/UnlimitedQuotaTemplateTest.php
@@ -0,0 +1,84 @@
+setCompileDir(sys_get_temp_dir());
+ $smarty->assign($variables);
+ return $smarty->fetch('string:' . substr($source, $offset, $length));
+ }
+
+ public function testUnlimitedMailboxRetainsAvailableAndUnknownUsage(): void
+ {
+ foreach (['0', '256', 'N/D'] as $usage) {
+ $html = $this->mailbox(0, true, $usage);
+ self::assertStringContainsString($usage . ' / ∞', $html);
+ self::assertStringContainsString('class="quota_bar"', $html);
+ self::assertStringNotContainsString('quota_fill', $html);
+ }
+ $html = $this->mailbox(0, false, 'N/D');
+ self::assertStringContainsString('∞', $html);
+ self::assertStringNotContainsString('N/D', $html);
+ }
+
+ public function testLimitedAndDisabledMailboxBehaviorIsPreserved(): void
+ {
+ self::assertStringContainsString('quota_fill', $this->mailbox(1024, true, '256'));
+ self::assertStringContainsString('256 / 1024', $this->mailbox(1024, true, '256'));
+ self::assertStringContainsString('Disabled', $this->mailbox(-1, true, '256'));
+ self::assertStringNotContainsString('quota_bar', $this->mailbox(-1, true, '256'));
+ }
+
+ private function mailbox(int $quota, bool $tracking, string $usage): string
+ {
+ return $this->renderQuota('list-virtual_mailbox.tpl', '{if $item.quota==0}', ' | ', [
+ 'item' => ['quota' => $quota], 'i' => 0,
+ 'boolconf_used_quotas' => $tracking,
+ 'divide_quota' => ['current' => [$usage], 'quota' => [1024], 'percent' => [25]],
+ 'CONF' => ['quota_level_high_pct' => 90, 'quota_level_med_pct' => 80],
+ 'PALANG' => ['pOverview_disabled' => 'Disabled'],
+ ]);
+ }
+
+ public function testUnlimitedDomainCountersKeepNeutralBoxesAndActualUsage(): void
+ {
+ foreach (['aliases_quot', 'mailboxes_quot', 'total_quot'] as $key) {
+ $html = $this->domain($key, 0, true);
+ self::assertStringContainsString('class="quota_bar"', $html);
+ self::assertStringNotContainsString('quota_fill', $html);
+ self::assertStringContainsString($key == 'total_quot' ? '256 / ∞' : '7 / infinity', $html);
+ }
+ $html = $this->domain('total_quot', 0, true);
+ self::assertStringContainsString('Assigned: 7 / infinity', $html);
+ self::assertStringContainsString('Used: 256 MB', $html);
+ self::assertStringContainsString('7 / infinity', $this->domain('total_quot', 0, false));
+ }
+
+ public function testFiniteAndDisabledDomainCountersKeepTheirBehavior(): void
+ {
+ foreach (['aliases_quot', 'mailboxes_quot', 'total_quot'] as $key) {
+ self::assertStringContainsString('quota_fill', $this->domain($key, 1024, true));
+ self::assertStringContainsString('quota_no_border', $this->domain($key, -1, true));
+ }
+ }
+
+ private function domain(string $key, int $limit, bool $tracking): string
+ {
+ return $this->renderQuota('list.tpl', '{assign "tmpkey" "_{$key}_percent"}', "{elseif \$field.type == 'txtl'}", [
+ 'key' => $key, 'table' => 'domain', 'linktext' => '7 / infinity',
+ 'item' => ['aliases' => $limit, 'mailboxes' => $limit, 'quota' => $limit,
+ '_' . $key . '_percent' => $limit > 0 ? 25 : -1, 'total_quota_used' => 256],
+ 'CONF' => ['used_quotas' => $tracking ? 'YES' : 'NO', 'quota_level_high_pct' => 90, 'quota_level_med_pct' => 80],
+ 'PALANG' => ['quota_assigned' => 'Assigned', 'quota_used' => 'Used'],
+ ]);
+ }
+}