major refactoring of almost all files

This commit is contained in:
envoyr
2022-04-28 20:48:00 +02:00
parent a2e95b960f
commit 4f4c71d79b
285 changed files with 21716 additions and 18766 deletions

View File

@@ -1,59 +1,84 @@
<?php
namespace Froxlor\Api\Commands;
use Froxlor\Database\Database;
use Froxlor\Settings;
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package API
* @since 0.10.0
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you can also view it online at
* https://files.froxlor.org/misc/COPYING.txt
*
* @copyright the authors
* @author Froxlor team <team@froxlor.org>
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
*/
class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntity
namespace Froxlor\Api\Commands;
use Exception;
use Froxlor\Api\ApiCommand;
use Froxlor\Api\ResourceEntity;
use Froxlor\Cron\TaskId;
use Froxlor\Database\Database;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\Idna\IdnaWrapper;
use Froxlor\Settings;
use Froxlor\System\Cronjob;
use Froxlor\System\Crypt;
use Froxlor\UI\Response;
use Froxlor\User;
use Froxlor\Validate\Check;
use Froxlor\Validate\Validate;
/**
* @since 0.10.0
*/
class EmailAccounts extends ApiCommand implements ResourceEntity
{
/**
* add a new email account for a given email-address either by id or emailaddr
*
* @param int $id
* optional email-address-id of email-address to add the account for
* optional email-address-id of email-address to add the account for
* @param string $emailaddr
* optional email-address to add the account for
* optional email-address to add the account for
* @param int $customerid
* optional, required when called as admin (if $loginname is not specified)
* 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)
* optional, required when called as admin (if $customerid is not specified)
* @param string $email_password
* password for the account
* password for the account
* @param string $alternative_email
* optional email address to send account information to, default is the account that is being created
* optional email address to send account information to, default is the account that is being created
* @param int $email_quota
* optional quota if enabled in MB, default 0
* optional quota if enabled in MB, default 0
* @param bool $sendinfomail
* optional, sends the welcome message to the new account (needed for creation, without the user won't be able to login before any mail is received), default 1 (true)
* optional, sends the welcome message to the new account (needed for creation, without the user won't
* be able to login before any mail is received), default 1 (true)
*
* @access admin, customer
* @throws \Exception
* @return string json-encoded array
* @throws Exception
*/
public function add()
{
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'email')) {
throw new \Exception("You cannot access this resource", 405);
throw new Exception("You cannot access this resource", 405);
}
if ($this->getUserDetail('email_accounts_used') < $this->getUserDetail('email_accounts') || $this->getUserDetail('email_accounts') == '-1') {
// parameter
$id = $this->getParam('id', true, 0);
$ea_optional = $id > 0;
@@ -64,44 +89,44 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$sendinfomail = $this->getBoolParam('sendinfomail', true, 1);
// validation
$quota = \Froxlor\Validate\Validate::validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', array(), true);
$quota = Validate::validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', [], true);
// get needed customer info to reduce the email-account-counter by one
$customer = $this->getCustomerData('email_accounts');
// check for imap||pop3 == 1, see #1298
if ($customer['imap'] != '1' && $customer['pop3'] != '1') {
\Froxlor\UI\Response::standard_error('notallowedtouseaccounts', '', true);
Response::standardError('notallowedtouseaccounts', '', true);
}
// get email address
$result = $this->apiCall('Emails.get', array(
$result = $this->apiCall('Emails.get', [
'id' => $id,
'emailaddr' => $emailaddr
));
]);
$id = $result['id'];
$idna_convert = new \Froxlor\Idna\IdnaWrapper();
$idna_convert = new IdnaWrapper();
$email_full = $result['email_full'];
$username = $email_full;
$password = \Froxlor\Validate\Validate::validate($email_password, 'password', '', '', array(), true);
$password = \Froxlor\System\Crypt::validatePassword($password, true);
$password = Validate::validate($email_password, 'password', '', '', [], true);
$password = Crypt::validatePassword($password, true);
if ($result['popaccountid'] != 0) {
throw new \Exception("Email address '" . $email_full . "' has already an account assigned.", 406);
throw new Exception("Email address '" . $email_full . "' has already an account assigned.", 406);
}
if (\Froxlor\Validate\Check::checkMailAccDeletionState($email_full)) {
\Froxlor\UI\Response::standard_error(array(
if (Check::checkMailAccDeletionState($email_full)) {
Response::standardError([
'mailaccistobedeleted'
), $email_full, true);
], $email_full, true);
}
// alternative email address to send info to
if (Settings::Get('panel.sendalternativemail') == 1) {
$alternative_email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($alternative_email, 'alternative_email', '', '', array(), true));
if (! empty($alternative_email) && ! \Froxlor\Validate\Validate::validateEmail($alternative_email)) {
\Froxlor\UI\Response::standard_error('alternativeemailiswrong', $alternative_email, true);
$alternative_email = $idna_convert->encode(Validate::validate($alternative_email, 'alternative_email', '', '', [], true));
if (!empty($alternative_email) && !Validate::validateEmail($alternative_email)) {
Response::standardError('alternativeemailiswrong', $alternative_email, true);
}
} else {
$alternative_email = '';
@@ -110,7 +135,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
// validate quota if enabled
if (Settings::Get('system.mail_quota_enabled') == 1) {
if ($customer['email_quota'] != '-1' && ($quota == 0 || ($quota + $customer['email_quota_used']) > $customer['email_quota'])) {
\Froxlor\UI\Response::standard_error('allocatetoomuchquota', $quota, true);
Response::standardError('allocatetoomuchquota', $quota, true);
}
} else {
// disable
@@ -118,18 +143,18 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
}
if ($password == $email_full) {
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
Response::standardError('passwordshouldnotbeusername', '', true);
}
// encrypt the password
$cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password);
$cryptPassword = Crypt::makeCryptPassword($password);
$email_user = substr($email_full, 0, strrpos($email_full, "@"));
$email_domain = substr($email_full, strrpos($email_full, "@") + 1);
$maildirname = trim(Settings::Get('system.vmail_maildirname'));
// Add trailing slash to Maildir if needed
$maildirpath = $maildirname;
if (! empty($maildirname) && substr($maildirname, - 1) != "/") {
if (!empty($maildirname) && substr($maildirname, -1) != "/") {
$maildirpath .= "/";
}
@@ -149,7 +174,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
`imap` = :imap,
`pop3` = :pop3
");
$params = array(
$params = [
"cid" => $customer['customerid'],
"email" => $email_full,
"username" => $username,
@@ -162,7 +187,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
"quota" => $quota,
"imap" => $customer['imap'],
"pop3" => $customer['pop3']
);
];
if (Settings::Get('system.mailpwcleartext') == '1') {
$params["password"] = $password;
}
@@ -175,12 +200,12 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `destination` = :destination, `popaccountid` = :popaccountid
WHERE `customerid`= :cid AND `id`= :id
");
$params = array(
"destination" => \Froxlor\FileDir::makeCorrectDestination($result['destination']),
$params = [
"destination" => FileDir::makeCorrectDestination($result['destination']),
"popaccountid" => $popaccountid,
"cid" => $customer['customerid'],
"id" => $id
);
];
Database::pexecute($stmt, $params, true, true);
// update customer usage
@@ -189,22 +214,22 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
if ($sendinfomail) {
// replacer array for mail to create account on server
$replace_arr = array(
$replace_arr = [
'EMAIL' => $email_full,
'USERNAME' => $username,
'PASSWORD' => htmlentities(htmlentities($password)),
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($customer),
'SALUTATION' => User::getCorrectUserSalutation($customer),
'NAME' => $customer['name'],
'FIRSTNAME' => $customer['firstname'],
'COMPANY' => $customer['company'],
'CUSTOMER_NO' => $customer['customernumber']
);
];
// get the customers admin
$stmt = Database::prepare("SELECT `name`, `email` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`= :adminid");
$admin = Database::pexecute_first($stmt, array(
$admin = Database::pexecute_first($stmt, [
"adminid" => $customer['adminid']
));
]);
// get template for mail subject
$mail_subject = $this->getMailTemplate($customer, 'mails', 'pop_success_subject', $replace_arr, lng('mails.pop_success.subject'));
@@ -214,7 +239,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$_mailerror = false;
$mailerr_msg = "";
try {
$this->mailer()->setFrom($admin['email'], \Froxlor\User::getCorrectUserSalutation($admin));
$this->mailer()->setFrom($admin['email'], User::getCorrectUserSalutation($admin));
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
@@ -223,20 +248,20 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
\Froxlor\UI\Response::standard_error('errorsendingmail', $email_full, true);
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
Response::standardError('errorsendingmail', $email_full, true);
}
$this->mailer()->clearAddresses();
// customer wants to send the e-mail to an alternative email address too
if (Settings::Get('panel.sendalternativemail') == 1 && ! empty($alternative_email)) {
if (Settings::Get('panel.sendalternativemail') == 1 && !empty($alternative_email)) {
// get template for mail subject
$mail_subject = $this->getMailTemplate($customer, 'mails', 'pop_success_alternative_subject', $replace_arr, lng('mails.pop_success_alternative.subject'));
// get template for mail body
@@ -244,38 +269,38 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$_mailerror = false;
try {
$this->mailer()->setFrom($admin['email'], \Froxlor\User::getCorrectUserSalutation($admin));
$this->mailer()->setFrom($admin['email'], User::getCorrectUserSalutation($admin));
$this->mailer()->Subject = $mail_subject;
$this->mailer()->AltBody = $mail_body;
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($idna_convert->encode($alternative_email), \Froxlor\User::getCorrectUserSalutation($customer));
$this->mailer()->addAddress($idna_convert->encode($alternative_email), User::getCorrectUserSalutation($customer));
$this->mailer()->send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
\Froxlor\UI\Response::standard_error(array(
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
Response::standardError([
'errorsendingmail'
), $alternative_email, true);
], $alternative_email, true);
}
$this->mailer()->clearAddresses();
}
}
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] added email account for '" . $result['email_full'] . "'");
$result = $this->apiCall('Emails.get', array(
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] added email account for '" . $result['email_full'] . "'");
$result = $this->apiCall('Emails.get', [
'emailaddr' => $result['email_full']
));
]);
return $this->response($result);
}
throw new \Exception("No more resources available", 406);
throw new Exception("No more resources available", 406);
}
/**
@@ -284,35 +309,35 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
*/
public function get()
{
throw new \Exception('You cannot directly get an email account. You need to call Emails.get()', 303);
throw new Exception('You cannot directly get an email account. You need to call Emails.get()', 303);
}
/**
* update email-account entry for given email-address by either id or email-address
*
* @param int $id
* optional, the email-address-id
* optional, the email-address-id
* @param string $emailaddr
* optional, the email-address to update
* optional, the email-address to update
* @param int $customerid
* optional, required when called as admin (if $loginname is not specified)
* 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)
* optional, required when called as admin (if $customerid is not specified)
* @param int $email_quota
* optional, update quota
* optional, update quota
* @param string $email_password
* optional, update password
* optional, update password
* @param bool $deactivated
* optional, admin-only
* optional, admin-only
*
* @access admin, customer
* @throws \Exception
* @return string json-encoded array
* @throws Exception
*/
public function update()
{
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'email')) {
throw new \Exception("You cannot access this resource", 405);
throw new Exception("You cannot access this resource", 405);
}
// parameter
@@ -321,14 +346,14 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$emailaddr = $this->getParam('emailaddr', $ea_optional, '');
// validation
$result = $this->apiCall('Emails.get', array(
$result = $this->apiCall('Emails.get', [
'id' => $id,
'emailaddr' => $emailaddr
));
]);
$id = $result['id'];
if (empty($result['popaccountid']) || $result['popaccountid'] == 0) {
throw new \Exception("Email address '" . $result['email_full'] . "' has no account assigned.", 406);
throw new Exception("Email address '" . $result['email_full'] . "' has no account assigned.", 406);
}
$password = $this->getParam('email_password', true, '');
@@ -339,19 +364,19 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$customer = $this->getCustomerData();
// validation
$quota = \Froxlor\Validate\Validate::validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', array(), true);
$quota = Validate::validate($quota, 'email_quota', '/^\d+$/', 'vmailquotawrong', [], true);
$upd_query = "";
$upd_params = array(
$upd_params = [
"id" => $result['popaccountid'],
"cid" => $customer['customerid']
);
if (! empty($password)) {
];
if (!empty($password)) {
if ($password == $result['email_full']) {
\Froxlor\UI\Response::standard_error('passwordshouldnotbeusername', '', true);
Response::standardError('passwordshouldnotbeusername', '', true);
}
$password = \Froxlor\System\Crypt::validatePassword($password, true);
$cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($password);
$password = Crypt::validatePassword($password, true);
$cryptPassword = Crypt::makeCryptPassword($password);
$upd_query .= (Settings::Get('system.mailpwcleartext') == '1' ? "`password` = :password, " : '') . "`password_enc`= :password_enc";
$upd_params['password_enc'] = $cryptPassword;
if (Settings::Get('system.mailpwcleartext') == '1') {
@@ -362,9 +387,9 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
if (Settings::Get('system.mail_quota_enabled') == 1) {
if ($quota != $result['quota']) {
if ($customer['email_quota'] != '-1' && ($quota == 0 || ($quota + $customer['email_quota_used'] - $result['quota']) > $customer['email_quota'])) {
\Froxlor\UI\Response::standard_error('allocatetoomuchquota', $quota, true);
Response::standardError('allocatetoomuchquota', $quota, true);
}
if (! empty($upd_query)) {
if (!empty($upd_query)) {
$upd_query .= ", ";
}
$upd_query .= "`quota` = :quota";
@@ -377,7 +402,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
if ($this->isAdmin()) {
if (($deactivated == true && strtolower($result['postfix']) == 'y') || ($deactivated == false && strtolower($result['postfix']) == 'n')) {
if (! empty($upd_query)) {
if (!empty($upd_query)) {
$upd_query .= ", ";
}
$upd_query .= "`postfix` = :postfix, `imap` = :imap, `pop3` = :pop3";
@@ -388,7 +413,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
}
// build update query
if (! empty($upd_query)) {
if (!empty($upd_query)) {
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_MAIL_USERS . "` SET " . $upd_query . " WHERE `id` = :id AND `customerid`= :cid
");
@@ -400,10 +425,10 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
Admins::increaseUsage($customer['adminid'], 'email_quota_used', '', ($quota - $result['quota']));
}
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] updated email account '" . $result['email_full'] . "'");
$result = $this->apiCall('Emails.get', array(
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] updated email account '" . $result['email_full'] . "'");
$result = $this->apiCall('Emails.get', [
'emailaddr' => $result['email_full']
));
]);
return $this->response($result);
}
@@ -413,7 +438,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
*/
public function listing()
{
throw new \Exception('You cannot directly list email accounts. You need to call Emails.listing()', 303);
throw new Exception('You cannot directly list email accounts. You need to call Emails.listing()', 303);
}
/**
@@ -422,31 +447,31 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
*/
public function listingCount()
{
throw new \Exception('You cannot directly count email accounts. You need to call Emails.listingCount()', 303);
throw new Exception('You cannot directly count email accounts. You need to call Emails.listingCount()', 303);
}
/**
* delete email-account entry for given email-address by either id or email-address
*
* @param int $id
* optional, the email-address-id
* optional, the email-address-id
* @param string $emailaddr
* optional, the email-address to delete the account for
* optional, the email-address to delete the account for
* @param int $customerid
* optional, required when called as admin (if $loginname is not specified)
* 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)
* optional, required when called as admin (if $customerid is not specified)
* @param bool $delete_userfiles
* optional, default false
* optional, default false
*
* @access admin, customer
* @throws \Exception
* @return string json-encoded array
* @throws Exception
*/
public function delete()
{
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'email')) {
throw new \Exception("You cannot access this resource", 405);
throw new Exception("You cannot access this resource", 405);
}
// parameter
@@ -456,14 +481,14 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$delete_userfiles = $this->getBoolParam('delete_userfiles', true, 0);
// validation
$result = $this->apiCall('Emails.get', array(
$result = $this->apiCall('Emails.get', [
'id' => $id,
'emailaddr' => $emailaddr
));
]);
$id = $result['id'];
if (empty($result['popaccountid']) || $result['popaccountid'] == 0) {
throw new \Exception("Email address '" . $result['email_full'] . "' has no account assigned.", 406);
throw new Exception("Email address '" . $result['email_full'] . "' has no account assigned.", 406);
}
// get needed customer info to reduce the email-account-counter by one
@@ -473,10 +498,10 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$stmt = Database::prepare("
DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid`= :cid AND `id`= :id
");
Database::pexecute($stmt, array(
Database::pexecute($stmt, [
"cid" => $customer['customerid'],
"id" => $result['popaccountid']
), true, true);
], true, true);
// update mail-virtual entry
$result['destination'] = str_replace($result['email_full'], '', $result['destination']);
@@ -484,29 +509,29 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$stmt = Database::prepare("
UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `destination` = :dest, `popaccountid` = '0' WHERE `customerid`= :cid AND `id`= :id
");
$params = array(
"dest" => \Froxlor\FileDir::makeCorrectDestination($result['destination']),
$params = [
"dest" => FileDir::makeCorrectDestination($result['destination']),
"cid" => $customer['customerid'],
"id" => $id
);
];
Database::pexecute($stmt, $params, true, true);
$result['popaccountid'] = 0;
if (Settings::Get('system.mail_quota_enabled') == '1' && $customer['email_quota'] != '-1') {
$quota = (int) $result['quota'];
$quota = (int)$result['quota'];
} else {
$quota = 0;
}
if ($delete_userfiles) {
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::DELETE_EMAIL_DATA, $customer['loginname'], $result['email_full']);
Cronjob::inserttask(TaskId::DELETE_EMAIL_DATA, $customer['loginname'], $result['email_full']);
}
// decrease usage for customer
Customers::decreaseUsage($customer['customerid'], 'email_accounts_used');
Customers::decreaseUsage($customer['customerid'], 'email_quota_used', '', $quota);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email account for '" . $result['email_full'] . "'");
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email account for '" . $result['email_full'] . "'");
return $this->response($result);
}
}