From d021ef61c76d5414f1111b829f6ee84c6b030432 Mon Sep 17 00:00:00 2001
From: Sergio Cambra <sergio@programatica.es>
Date: Wed, 30 Jul 2014 14:50:37 +0200
Subject: [PATCH] check dns use of domain before delete domain from  client

---
 interface/web/client/domain_del.php  | 12 ++++++++++++
 interface/web/client/lib/lang/en.lng |  2 ++
 interface/web/client/lib/lang/es.lng |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/interface/web/client/domain_del.php b/interface/web/client/domain_del.php
index 2ec8e86bae..9a02ac9578 100644
--- a/interface/web/client/domain_del.php
+++ b/interface/web/client/domain_del.php
@@ -62,6 +62,18 @@ class page_action extends tform_actions {
 		 */
 		$domain = $this->dataRecord['domain'];
 
+		$sql = "SELECT id FROM dns_soa WHERE origin = '" . $app->db->quote($domain.".") . "'";
+		$res = $app->db->queryOneRecord($sql);
+		if (is_array($res)){
+			$app->error($wb['error_domain_in dnsuse']);
+		}
+
+		$sql = "SELECT id FROM dns_slave WHERE origin = '" . $app->db->quote($domain.".") . "'";
+		$res = $app->db->queryOneRecord($sql);
+		if (is_array($res)){
+			$app->error($wb['error_domain_in dnsslaveuse']);
+		}
+
 		$sql = "SELECT domain_id FROM mail_domain WHERE domain = '" . $app->db->quote($domain) . "'";
 		$res = $app->db->queryOneRecord($sql);
 		if (is_array($res)){
diff --git a/interface/web/client/lib/lang/en.lng b/interface/web/client/lib/lang/en.lng
index d901b7a2e0..66f2b7d779 100644
--- a/interface/web/client/lib/lang/en.lng
+++ b/interface/web/client/lib/lang/en.lng
@@ -19,6 +19,8 @@ $wb['Edit Client Circle'] = 'Edit Client Circle';
 $wb['Domains'] = 'Domains';
 $wb['domain_txt'] = 'Domain';
 $wb['client_txt'] = 'Client';
+$wb['error_domain_in dnsuse'] = 'This domain cannot be deleted, because it is in use as dns zone';
+$wb['error_domain_in dnsslaveuse'] = 'This domain cannot be deleted, because it is in use as secondary dns zone';
 $wb['error_domain_in mailuse'] = 'This domain cannot be deleted, because it is in use as mail-domain';
 $wb['error_domain_in webuse'] = 'This domain cannot be deleted, because it is in use as web-domain';
 $wb['error_client_can_not_add_domain'] = 'You cannot add a new domain';
diff --git a/interface/web/client/lib/lang/es.lng b/interface/web/client/lib/lang/es.lng
index 338f098461..268db99a55 100644
--- a/interface/web/client/lib/lang/es.lng
+++ b/interface/web/client/lib/lang/es.lng
@@ -20,6 +20,8 @@ $wb['Edit Client Circle'] = 'Editar círculo de clientes';
 $wb['Domains'] = 'Dominios';
 $wb['domain_txt'] = 'Dominio';
 $wb['client_txt'] = 'Cliente';
+$wb['error_domain_in dnsuse'] = 'No se puede eliminar este dominio, porque está en uso como zona dns';
+$wb['error_domain_in dnsslaveuse'] = 'No se puede eliminar este dominio, porque está en uso como zona dns secundaria';
 $wb['error_domain_in mailuse'] = 'No se puede eliminar este dominio, porque está en uso como dominio de correo';
 $wb['error_domain_in webuse'] = 'No se puede eliminar este dominio, porque está en uso como sitio web';
 $wb['error_client_can_not_add_domain'] = 'No puedes añadir más dominios';
-- 
GitLab