add safety when unsetting isemaildomain flag in domain, fixes #1305
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -319,7 +319,7 @@ if ($page == 'domains' || $page == 'overview') {
|
|||||||
$alias_check = $alias_check['count'];
|
$alias_check = $alias_check['count'];
|
||||||
|
|
||||||
$domain_emails_result_stmt = Database::prepare("
|
$domain_emails_result_stmt = Database::prepare("
|
||||||
SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders`
|
SELECT `email`, `email_full`, `destination`, `popaccountid`
|
||||||
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
|
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
|
||||||
");
|
");
|
||||||
Database::pexecute($domain_emails_result_stmt, [
|
Database::pexecute($domain_emails_result_stmt, [
|
||||||
@@ -593,6 +593,23 @@ if ($page == 'domains' || $page == 'overview') {
|
|||||||
}
|
}
|
||||||
echo 0;
|
echo 0;
|
||||||
exit();
|
exit();
|
||||||
|
} elseif ($action == 'jqEmaildomainNote') {
|
||||||
|
$domainid = intval(Request::post('id'));
|
||||||
|
$newval = intval(Request::post('newval'));
|
||||||
|
try {
|
||||||
|
$json_result = Domains::getLocal($userinfo, [
|
||||||
|
'id' => $domainid
|
||||||
|
])->get();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
if ((int)$newval == 0 && $newval != $result['isemaildomain']) {
|
||||||
|
echo json_encode(['changed' => true, 'info' => lng('admin.emaildomainwarning')]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
echo 0;
|
||||||
|
exit();
|
||||||
} elseif ($action == 'import') {
|
} elseif ($action == 'import') {
|
||||||
if (Request::post('send') == 'send') {
|
if (Request::post('send') == 'send') {
|
||||||
$separator = Validate::validate(Request::post('separator'), 'separator');
|
$separator = Validate::validate(Request::post('separator'), 'separator');
|
||||||
|
|||||||
@@ -1063,6 +1063,9 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
* (default yes), 3 = always, default 0 (never)
|
* (default yes), 3 = always, default 0 (never)
|
||||||
* @param bool $isemaildomain
|
* @param bool $isemaildomain
|
||||||
* optional, allow email usage with this domain, default 0 (false)
|
* optional, allow email usage with this domain, default 0 (false)
|
||||||
|
* @param bool $emaildomainverified
|
||||||
|
* optional, when setting $isemaildomain to false, this needs to be set to true to confirm the action in case email addresses exist for this domain,
|
||||||
|
* default 0 (false)
|
||||||
* @param bool $email_only
|
* @param bool $email_only
|
||||||
* optional, restrict domain to email usage, default 0 (false)
|
* optional, restrict domain to email usage, default 0 (false)
|
||||||
* @param int $selectserveralias
|
* @param int $selectserveralias
|
||||||
@@ -1190,6 +1193,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
$subcanemaildomain = $this->getParam('subcanemaildomain', true, $result['subcanemaildomain']);
|
$subcanemaildomain = $this->getParam('subcanemaildomain', true, $result['subcanemaildomain']);
|
||||||
$isemaildomain = $this->getBoolParam('isemaildomain', true, $result['isemaildomain']);
|
$isemaildomain = $this->getBoolParam('isemaildomain', true, $result['isemaildomain']);
|
||||||
|
$emaildomainverified = $this->getBoolParam('emaildomainverified', true, 0);
|
||||||
$email_only = $this->getBoolParam('email_only', true, $result['email_only']);
|
$email_only = $this->getBoolParam('email_only', true, $result['email_only']);
|
||||||
$p_serveraliasoption = $this->getParam('selectserveralias', true, -1);
|
$p_serveraliasoption = $this->getParam('selectserveralias', true, -1);
|
||||||
$speciallogfile = $this->getBoolParam('speciallogfile', true, $result['speciallogfile']);
|
$speciallogfile = $this->getBoolParam('speciallogfile', true, $result['speciallogfile']);
|
||||||
@@ -1273,7 +1277,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
// count where we are used in email-accounts
|
// count where we are used in email-accounts
|
||||||
$domain_emails_result_stmt = Database::prepare("
|
$domain_emails_result_stmt = Database::prepare("
|
||||||
SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders`
|
SELECT `email`, `email_full`, `destination`, `popaccountid`
|
||||||
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
|
FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid` = :customerid AND `domainid` = :id
|
||||||
");
|
");
|
||||||
Database::pexecute($domain_emails_result_stmt, [
|
Database::pexecute($domain_emails_result_stmt, [
|
||||||
@@ -1296,6 +1300,10 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($emails > 0 && (int)$isemaildomain == 0 && (int)$result['isemaildomain'] == 1 && (int)$emaildomainverified == 0) {
|
||||||
|
Response::standardError('emaildomainstillhasaddresses', '', true);
|
||||||
|
}
|
||||||
|
|
||||||
// handle change of customer (move domain from customer to customer)
|
// handle change of customer (move domain from customer to customer)
|
||||||
if ($customerid > 0 && $customerid != $result['customerid'] && Settings::Get('panel.allow_domain_change_customer') == '1') {
|
if ($customerid > 0 && $customerid != $result['customerid'] && Settings::Get('panel.allow_domain_change_customer') == '1') {
|
||||||
// check whether target customer has enough resources
|
// check whether target customer has enough resources
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class User
|
|||||||
]);
|
]);
|
||||||
$customer['emails_used_new'] = (int)$customer_emails['number_emails'];
|
$customer['emails_used_new'] = (int)$customer_emails['number_emails'];
|
||||||
|
|
||||||
$customer_emails_result_stmt = Database::prepare('SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '`
|
$customer_emails_result_stmt = Database::prepare('SELECT `email`, `email_full`, `destination`, `popaccountid` FROM `' . TABLE_MAIL_VIRTUAL . '`
|
||||||
WHERE `customerid` = :cid');
|
WHERE `customerid` = :cid');
|
||||||
Database::pexecute($customer_emails_result_stmt, [
|
Database::pexecute($customer_emails_result_stmt, [
|
||||||
"cid" => $customer['customerid']
|
"cid" => $customer['customerid']
|
||||||
|
|||||||
@@ -213,6 +213,10 @@ return [
|
|||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
'value' => '0'
|
'value' => '0'
|
||||||
],
|
],
|
||||||
|
'emaildomainverified' => [
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => '0'
|
||||||
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'section_bssl' => [
|
'section_bssl' => [
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ return [
|
|||||||
'apiguide' => 'API Guide',
|
'apiguide' => 'API Guide',
|
||||||
'domain_duplicate' => 'Domain duplizieren',
|
'domain_duplicate' => 'Domain duplizieren',
|
||||||
'domain_duplicate_named' => '%s duplizieren',
|
'domain_duplicate_named' => '%s duplizieren',
|
||||||
|
'emaildomainwarning' => '<div id="emaildomainnote" class="invalid-feedback">ACHTUNG: Durch die Änderung dieser Einstellung löschen Sie alle bestehenden E-Mail-Adressen und -Konten unwiderruflich.</div>',
|
||||||
],
|
],
|
||||||
'apikeys' => [
|
'apikeys' => [
|
||||||
'no_api_keys' => 'Keine API Keys gefunden',
|
'no_api_keys' => 'Keine API Keys gefunden',
|
||||||
@@ -976,6 +977,7 @@ return [
|
|||||||
'invalidpgppublickey' => 'Der angegebene PGP Public Key ist ungültig',
|
'invalidpgppublickey' => 'Der angegebene PGP Public Key ist ungültig',
|
||||||
'invalid_validtime' => 'Wert der valid_time in Sekunden muss zwischen 10 und 120 liegen.',
|
'invalid_validtime' => 'Wert der valid_time in Sekunden muss zwischen 10 und 120 liegen.',
|
||||||
'customerphpenabledbutnoconfig' => 'Kunde hat PHP aktiviert aber keine PHP-Konfiguration wurde gewählt.',
|
'customerphpenabledbutnoconfig' => 'Kunde hat PHP aktiviert aber keine PHP-Konfiguration wurde gewählt.',
|
||||||
|
'emaildomainstillhasaddresses' => 'Maildomain-Flag kann nicht deaktiviert werden, da für diese Domain noch E-Mail-Adressen vorhanden sind.',
|
||||||
],
|
],
|
||||||
'extras' => [
|
'extras' => [
|
||||||
'description' => 'Hier können Sie zusätzliche Extras einrichten, wie zum Beispiel einen Verzeichnisschutz.<br />Die Änderungen sind erst nach einer kurzen Zeit wirksam.',
|
'description' => 'Hier können Sie zusätzliche Extras einrichten, wie zum Beispiel einen Verzeichnisschutz.<br />Die Änderungen sind erst nach einer kurzen Zeit wirksam.',
|
||||||
|
|||||||
@@ -519,6 +519,7 @@ return [
|
|||||||
'backups' => [
|
'backups' => [
|
||||||
'backups' => 'Backups',
|
'backups' => 'Backups',
|
||||||
],
|
],
|
||||||
|
'emaildomainwarning' => '<div id="emaildomainnote" class="invalid-feedback">WARNING: By changing this setting you will delete all existing e-mail addresses and -accounts permanently.</div>',
|
||||||
],
|
],
|
||||||
'apcuinfo' => [
|
'apcuinfo' => [
|
||||||
'clearcache' => 'Clear APCu cache',
|
'clearcache' => 'Clear APCu cache',
|
||||||
@@ -1048,6 +1049,7 @@ return [
|
|||||||
'invalidpgppublickey' => 'The PGP Public Key is not valid',
|
'invalidpgppublickey' => 'The PGP Public Key is not valid',
|
||||||
'invalid_validtime' => 'Valid time in seconds can only be between 10 and 120',
|
'invalid_validtime' => 'Valid time in seconds can only be between 10 and 120',
|
||||||
'customerphpenabledbutnoconfig' => 'Customer has PHP activated but no PHP-configuration was selected.',
|
'customerphpenabledbutnoconfig' => 'Customer has PHP activated but no PHP-configuration was selected.',
|
||||||
|
'emaildomainstillhasaddresses' => 'Cannot deactivate mail-domain flag, as there are still email-addresses for this domain.',
|
||||||
],
|
],
|
||||||
'extras' => [
|
'extras' => [
|
||||||
'description' => 'Here you can add some extras, for example directory protection.<br />The system will need some time to apply the new settings after every change.',
|
'description' => 'Here you can add some extras, for example directory protection.<br />The system will need some time to apply the new settings after every change.',
|
||||||
|
|||||||
Reference in New Issue
Block a user