diff --git a/admin_domains.php b/admin_domains.php index b4706d76..41f36d40 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -147,6 +147,14 @@ if($page == 'domains' if(isset($_POST['send']) && $_POST['send'] == 'send') { + /* + * check for APS packages used with this domain, #110 + */ + if(domainHasApsInstances($id)) + { + standard_error('domains_cantdeletedomainwithapsinstances'); + } + $query = 'SELECT `id` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE (`id`="' . (int)$id . '" OR `parentdomainid`="' . (int)$id . '") AND `isemaildomain`="1"'; $subResult = $db->query($query); $idString = array(); diff --git a/customer_domains.php b/customer_domains.php index 5ebab6af..cb809bbe 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -183,6 +183,14 @@ elseif($page == 'domains') } } + /* + * check for APS packages used with this domain, #110 + */ + if(domainHasApsInstances($id)) + { + standard_error('domains_cantdeletedomainwithapsinstances'); + } + $log->logAction(USR_ACTION, LOG_INFO, "deleted subdomain '" . $idna_convert->decode($result['domain']) . "'"); $result = $db->query("DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); $result = $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `subdomains_used`=`subdomains_used`-1 WHERE `customerid`='" . (int)$userinfo['customerid'] . "'"); diff --git a/lib/functions/aps/function.domainHasApsInstances.php b/lib/functions/aps/function.domainHasApsInstances.php new file mode 100644 index 00000000..7b00d50b --- /dev/null +++ b/lib/functions/aps/function.domainHasApsInstances.php @@ -0,0 +1,46 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Language + * @version $Id$ + */ + +/** + * Function domainHasApsInstances + * + * Checks if a given domain id + * is used for APS instances + * (if APS enabled, else always false) + * + * @param int domain-id + * + * @return boolean + */ + +function domainHasApsInstances($domainid = 0) +{ + global $db, $settings; + + if($settings['aps']['aps_active'] == '1') + { + if($domainid > 0) + { + $instances = $db->query_first("SELECT COUNT(`ID`) AS `count` FROM `" . TABLE_APS_SETTINGS . "` WHERE `Name`='main_domain' AND `Value`='" . (int)$domainid . "'"); + if((int)$instances['count'] != 0) + { + return true; + } + } + } + return false; +} diff --git a/lng/english.lng.php b/lng/english.lng.php index de0d4848..569f08ce 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1354,5 +1354,6 @@ $lng['mysql']['sendinfomail'] = 'Send data via email to me'; $lng['customer']['mysql_add']['infomail_subject'] = '[Froxlor] New database created'; $lng['customer']['mysql_add']['infomail_body']['pma'] = "\nYou can access your databases using phpMyAdmin via {URI}\n"; $lng['customer']['mysql_add']['infomail_body']['main'] = "Hello {CUST_NAME},\n\nyou have just added a new database. Here is the entered information:\n\nDatabasename: {DB_NAME}\nPassword: {DB_PASS}\nDescription: {DB_DESC}\n{PMA_URI}\nYours sincerely, the Froxlor-Team"; +$lng['error']['domains_cantdeletedomainwithapsinstances'] = 'You cannot delete a domain which is used by an installed APS package. You have to uninstall it first.'; ?> diff --git a/lng/german.lng.php b/lng/german.lng.php index 47700d52..53bab005 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1335,4 +1335,6 @@ $lng['mysql']['sendinfomail'] = 'Send data via email to me'; $lng['customer']['mysql_add']['infomail_subject'] = '[Froxlor] Neue Datenbank erstellt'; $lng['customer']['mysql_add']['infomail_body']['pma'] = "\nDie Datenbank kann mit phpMyAdmin via {URI} verwaltet werden.\n"; $lng['customer']['mysql_add']['infomail_body']['main'] = "Hallo {CUST_NAME},\n\ndu hast gerade eine neue Datenbank angelegt. Hier die angegebenen Informationen:\n\nDatenbankname: {DB_NAME}\nPasswort: {DB_PASS}\nBeschreibung: {DB_DESC}\n{PMA_URI}\nVielen Dank, das Froxlor-Team"; +$lng['error']['domains_cantdeletedomainwithapsinstances'] = 'Sie können keine Domain löschen, die noch von APS Paketen verwendet wird. Löschen Sie zuerst alle installierten APS Pakete dieser Domain.'; + ?>