|
|
|
|
@@ -75,6 +75,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
$iscatchall = $this->getBoolParam('iscatchall', true, 0);
|
|
|
|
|
$disablegreylist = $this->getBoolParam('disablegreylist', true, 0);
|
|
|
|
|
$description = $this->getParam('description', true, '');
|
|
|
|
|
|
|
|
|
|
// validation
|
|
|
|
|
@@ -118,7 +119,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
|
|
|
|
|
// duplicate check
|
|
|
|
|
$stmt = Database::prepare("
|
|
|
|
|
SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid` FROM `" . TABLE_MAIL_VIRTUAL . "`
|
|
|
|
|
SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid`, `disablegreylist` FROM `" . TABLE_MAIL_VIRTUAL . "`
|
|
|
|
|
WHERE (`email` = :email OR `email_full` = :emailfull )
|
|
|
|
|
AND `customerid`= :cid
|
|
|
|
|
");
|
|
|
|
|
@@ -144,7 +145,8 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
`email_full` = :email_full,
|
|
|
|
|
`iscatchall` = :iscatchall,
|
|
|
|
|
`domainid` = :domainid,
|
|
|
|
|
`description` = :description
|
|
|
|
|
`description` = :description,
|
|
|
|
|
`disablegreylist` = :disablegreylist
|
|
|
|
|
");
|
|
|
|
|
$params = [
|
|
|
|
|
"cid" => $customer['customerid'],
|
|
|
|
|
@@ -152,7 +154,8 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
"email_full" => $email_full,
|
|
|
|
|
"iscatchall" => $iscatchall,
|
|
|
|
|
"domainid" => $domain_check['id'],
|
|
|
|
|
"description" => $description
|
|
|
|
|
"description" => $description,
|
|
|
|
|
"disablegreylist" => $disablegreylist
|
|
|
|
|
];
|
|
|
|
|
Database::pexecute($stmt, $params, true, true);
|
|
|
|
|
|
|
|
|
|
@@ -191,7 +194,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
$customer_ids = $this->getAllowedCustomerIds('email');
|
|
|
|
|
$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`, v.`description`, u.`quota`, u.`imap`, u.`pop3`, u.`postfix`, u.`mboxsize`
|
|
|
|
|
$result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`disablegreylist`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, v.`description`, u.`quota`, u.`imap`, u.`pop3`, u.`postfix`, u.`mboxsize`
|
|
|
|
|
FROM `" . TABLE_MAIL_VIRTUAL . "` v
|
|
|
|
|
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id`
|
|
|
|
|
WHERE v.`customerid` IN (" . implode(", ", $customer_ids) . ")
|
|
|
|
|
@@ -302,6 +305,81 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
return $this->response($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* toggle greylist flag of given email address either by id or email-address
|
|
|
|
|
*
|
|
|
|
|
* @param int $id
|
|
|
|
|
* optional, the email-address-id
|
|
|
|
|
* @param string $emailaddr
|
|
|
|
|
* optional, the email-address
|
|
|
|
|
* @param int $customerid
|
|
|
|
|
* optional, required when called as admin (if $loginname is not specified)
|
|
|
|
|
* @param string $loginname
|
|
|
|
|
* optional, required when called as admin (if $customerid is not specified)
|
|
|
|
|
* @param boolean $greylist
|
|
|
|
|
* optional
|
|
|
|
|
* @param string $description
|
|
|
|
|
* optional custom description (currently not used/shown in the frontend), default empty
|
|
|
|
|
*
|
|
|
|
|
* @access admin, customer
|
|
|
|
|
* @return string json-encoded array
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function updateGreylist()
|
|
|
|
|
{
|
|
|
|
|
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'email')) {
|
|
|
|
|
throw new Exception("You cannot access this resource", 405);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if enabling catchall is not allowed by settings, we do not need
|
|
|
|
|
// to run update()
|
|
|
|
|
/** if (Settings::Get('catchall.catchall_enabled') != '1') {
|
|
|
|
|
Response::standardError([
|
|
|
|
|
'operationnotpermitted',
|
|
|
|
|
'featureisdisabled'
|
|
|
|
|
], 'catchall', true);
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
$id = $this->getParam('id', true, 0);
|
|
|
|
|
$ea_optional = $id > 0;
|
|
|
|
|
$emailaddr = $this->getParam('emailaddr', $ea_optional, '');
|
|
|
|
|
|
|
|
|
|
$result = $this->apiCall('Emails.get', [
|
|
|
|
|
'id' => $id,
|
|
|
|
|
'emailaddr' => $emailaddr
|
|
|
|
|
]);
|
|
|
|
|
$id = $result['id'];
|
|
|
|
|
$email = $result['email'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
$disablegreylist = $this->getBoolParam('disablegreylist', true, $result['disablegreylist']);
|
|
|
|
|
$description = $this->getParam('description', true, $result['description']);
|
|
|
|
|
|
|
|
|
|
// get needed customer info to reduce the email-address-counter by one
|
|
|
|
|
$customer = $this->getCustomerData();
|
|
|
|
|
|
|
|
|
|
// check for catchall-flag
|
|
|
|
|
$stmt = Database::prepare("
|
|
|
|
|
UPDATE `" . TABLE_MAIL_VIRTUAL . "`
|
|
|
|
|
SET `email` = :email , `disablegreylist` = :grflag, `description` = :description
|
|
|
|
|
WHERE `customerid`= :cid AND `id`= :id
|
|
|
|
|
");
|
|
|
|
|
$params = [
|
|
|
|
|
"email" => $email,
|
|
|
|
|
"grflag" => $disablegreylist,
|
|
|
|
|
"description" => $description,
|
|
|
|
|
"cid" => $customer['customerid'],
|
|
|
|
|
"id" => $id
|
|
|
|
|
];
|
|
|
|
|
Database::pexecute($stmt, $params, true, true);
|
|
|
|
|
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] toggled greylist-flag for email address '" . $result['email_full'] . "'");
|
|
|
|
|
|
|
|
|
|
$result = $this->apiCall('Emails.get', [
|
|
|
|
|
'emailaddr' => $result['email_full']
|
|
|
|
|
]);
|
|
|
|
|
return $this->response($result);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* list all email addresses, if called from an admin, list all email addresses of all customers you are allowed to
|
|
|
|
|
* view, or specify id or loginname for one specific customer
|
|
|
|
|
@@ -331,7 +409,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
|
|
|
|
$result = [];
|
|
|
|
|
$query_fields = [];
|
|
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
|
SELECT m.`id`, m.`domainid`, m.`email`, m.`email_full`, m.`iscatchall`, m.`destination`, m.`popaccountid`, d.`domain`, u.`quota`, u.`imap`, u.`pop3`, u.`postfix`, u.`mboxsize`
|
|
|
|
|
SELECT m.`id`, m.`domainid`, m.`email`, m.`email_full`, m.`iscatchall`, m.`disablegreylist`, m.`destination`, m.`popaccountid`, d.`domain`, u.`quota`, u.`imap`, u.`pop3`, u.`postfix`, 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`)
|
|
|
|
|
|