quota needs a left join to report mailboxes without quota

This commit is contained in:
Ralf Becker 2019-07-04 10:33:29 +02:00
parent 027ef6bd18
commit 206fdb367f

View File

@ -366,8 +366,8 @@ class Sql extends Mail\Smtp
}
if ($return_extra)
{
$join .= ' JOIN '.self::TABLE.' quota ON quota.account_id='.Api\Accounts\Sql::TABLE.'.account_id';
$cols .= ',account_id,quota.mail_value AS quota';
$join .= ' LEFT JOIN '.self::TABLE.' quota ON quota.account_id='.Api\Accounts\Sql::TABLE.'.account_id AND quota.mail_type='.self::TYPE_QUOTA;
$cols .= ','.Api\Accounts\Sql::TABLE.'.account_id AS account_id,quota.mail_value AS quota';
}
$mailboxes = array();
foreach($this->db->select(self::TABLE, $cols,
@ -384,7 +384,7 @@ class Sql extends Mail\Smtp
{
$mailboxes[$row['uid']] = [
'mbox' => $mailbox,
'quota' => $row['quota'] ? $row['quota'] : $GLOBALS['egw_info']['server']['default_quota'],
'quota' => !empty($row['quota']) ? $row['quota'] : $GLOBALS['egw_info']['server']['default_quota'],
'groups' => array_values($GLOBALS['egw']->accounts->memberships($row['account_id'])),
];
}