added Traffic.listing ApiCommand; added first Unit-Tests for Traffic-Api; SQL IN-clause cannot be prepared, replaced all occurances accordingly; added --no-fork parameter to traffic-cron

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-11-11 21:51:39 +01:00
parent 41acbc745c
commit 18aa8eb5d2
15 changed files with 206 additions and 48 deletions

View File

@@ -159,13 +159,12 @@ class Emails extends ApiCommand implements ResourceEntity
$params = array();
$customer_ids = $this->getAllowedCustomerIds('email');
$params['customerid'] = implode(", ", $customer_ids);
$params['idea'] = ($id <= 0 ? $emailaddr : $id);
$result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, u.`quota`
FROM `" . TABLE_MAIL_VIRTUAL . "` v
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id`
WHERE v.`customerid` IN (:customerid)
WHERE v.`customerid` IN (".implode(", ", $customer_ids).")
AND (v.`id`= :idea OR (v.`email` = :idea OR v.`email_full` = :idea))
");
$result = Database::pexecute_first($result_stmt, $params, true, true);
@@ -270,15 +269,14 @@ class Emails extends ApiCommand implements ResourceEntity
{
$customer_ids = $this->getAllowedCustomerIds('email');
$result = array();
$params['customerid'] = implode(", ", $customer_ids);
$result_stmt = Database::prepare("
SELECT m.`id`, m.`domainid`, m.`email`, m.`email_full`, m.`iscatchall`, u.`quota`, m.`destination`, m.`popaccountid`, d.`domain`, u.`mboxsize`
FROM `" . TABLE_MAIL_VIRTUAL . "` m
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON (m.`domainid` = d.`id`)
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON (m.`popaccountid` = u.`id`)
WHERE m.`customerid` IN (:customerid)
WHERE m.`customerid` IN (".implode(", ", $customer_ids).")
");
Database::pexecute($result_stmt, $params, true, true);
Database::pexecute($result_stmt, null, true, true);
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$result[] = $row;
}