From 6dfc1f8aef2d75f5ca8fe694fb8ef27ef885b12c Mon Sep 17 00:00:00 2001
From: vogelor <vogelor@ispconfig3>
Date: Sat, 1 May 2010 22:15:28 +0000
Subject: [PATCH] Added a new module called "domain". With this module you can
 manage all domains (web + mail). Per default this module is not active. To
 activate it, you have to change the System Interface Config -> domains -> use
 the domain module. You also have to activate the domain-module for the admin
 (and for every client if you want). Important: you can not use this module if
 you have reseller!

---
 install/sql/ispconfig3.sql                    |  16 ++
 install/tpl/system.ini.master                 |   6 +-
 interface/lib/lang/de.lng                     |   1 +
 interface/lib/lang/en.lng                     |   1 +
 .../web/admin/form/system_config.tform.php    |  25 +++
 .../web/admin/lib/lang/de_system_config.lng   |   3 +
 .../web/admin/lib/lang/en_system_config.lng   |   4 +-
 interface/web/admin/system_config_edit.php    |  26 ++-
 .../templates/system_config_domains_edit.htm  |  35 ++++
 interface/web/domain/domain_del.php           |  82 ++++++++++
 interface/web/domain/domain_edit.php          | 154 ++++++++++++++++++
 interface/web/domain/domain_list.php          |  51 ++++++
 interface/web/domain/domain_new_client.php    |  45 +++++
 interface/web/domain/form/domain.tform.php    | 111 +++++++++++++
 interface/web/domain/lib/admin.conf.php       |  29 ++++
 interface/web/domain/lib/lang/de.lng          |  14 ++
 .../web/domain/lib/lang/de_domain_list.lng    |   5 +
 interface/web/domain/lib/lang/en.lng          |  13 ++
 .../web/domain/lib/lang/en_domain_list.lng    |   5 +
 interface/web/domain/lib/module.conf.php      |  47 ++++++
 interface/web/domain/list/domain.list.php     |  84 ++++++++++
 .../web/domain/templates/domain_edit.htm      |  40 +++++
 .../web/domain/templates/domain_list.htm      |  59 +++++++
 interface/web/mail/mail_domain_edit.php       |  21 ++-
 .../web/mail/templates/mail_domain_edit.htm   |  10 +-
 .../web/sites/templates/web_domain_edit.htm   |  10 +-
 interface/web/sites/web_domain_edit.php       |  19 +++
 .../themes/default/css/navigation/nav_top.css |   5 +
 .../web/themes/default/icons/x64/domain.png   | Bin 0 -> 4248 bytes
 29 files changed, 911 insertions(+), 10 deletions(-)
 create mode 100644 interface/web/admin/templates/system_config_domains_edit.htm
 create mode 100644 interface/web/domain/domain_del.php
 create mode 100644 interface/web/domain/domain_edit.php
 create mode 100644 interface/web/domain/domain_list.php
 create mode 100644 interface/web/domain/domain_new_client.php
 create mode 100644 interface/web/domain/form/domain.tform.php
 create mode 100644 interface/web/domain/lib/admin.conf.php
 create mode 100644 interface/web/domain/lib/lang/de.lng
 create mode 100644 interface/web/domain/lib/lang/de_domain_list.lng
 create mode 100644 interface/web/domain/lib/lang/en.lng
 create mode 100644 interface/web/domain/lib/lang/en_domain_list.lng
 create mode 100644 interface/web/domain/lib/module.conf.php
 create mode 100644 interface/web/domain/list/domain.list.php
 create mode 100644 interface/web/domain/templates/domain_edit.htm
 create mode 100644 interface/web/domain/templates/domain_list.htm
 create mode 100644 interface/web/themes/default/icons/x64/domain.png

diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 07919e3f7..e0a3a925b 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -262,6 +262,22 @@ CREATE TABLE `dns_template` (
   PRIMARY KEY  (`template_id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1;
 
+--
+-- Tabellenstruktur für Tabelle `domain`
+--
+
+CREATE TABLE `domain` (
+  `domain_id` int(11) unsigned NOT NULL auto_increment,
+  `sys_userid` int(11) unsigned NOT NULL default '0',
+  `sys_groupid` int(11) unsigned NOT NULL default '0',
+  `sys_perm_user` varchar(5) NOT NULL default '',
+  `sys_perm_group` varchar(5) NOT NULL default '',
+  `sys_perm_other` varchar(5) NOT NULL default '',
+  `domain` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`domain_id`),
+  UNIQUE KEY `domain` (`domain`)
+) ENGINE=MyISAM;
+
 -- --------------------------------------------------------
 
 -- 
diff --git a/install/tpl/system.ini.master b/install/tpl/system.ini.master
index f59a0b82b..4459ca2b9 100644
--- a/install/tpl/system.ini.master
+++ b/install/tpl/system.ini.master
@@ -20,4 +20,8 @@ shelluser_prefix=[CLIENTNAME]
 dblist_phpmyadmin_link=y
 phpmyadmin_url=
 
-[tools]
\ No newline at end of file
+[tools]
+
+[domains]
+use_domain_module=n
+new_domain_html=Please contact our support to create a new domain for you.
diff --git a/interface/lib/lang/de.lng b/interface/lib/lang/de.lng
index e9882f559..9d2a67029 100644
--- a/interface/lib/lang/de.lng
+++ b/interface/lib/lang/de.lng
@@ -32,4 +32,5 @@ $wb['top_menu_dns'] = 'DNS';
 $wb['top_menu_tools'] = 'Tools';
 $wb['top_menu_help'] = 'Support';
 $wb['top_menu_billing'] = 'Billing';
+$wb['top_menu_domain'] = 'Domänen';
 ?>
diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng
index be14f7de9..da7caf12f 100644
--- a/interface/lib/lang/en.lng
+++ b/interface/lib/lang/en.lng
@@ -32,5 +32,6 @@ $wb['top_menu_dns'] = 'DNS';
 $wb['top_menu_tools'] = 'Tools';
 $wb['top_menu_help'] = 'Help';
 $wb['top_menu_billing'] = 'Billing';
+$wb['top_menu_domain'] = 'Domains';
 $wb['toolsarea_head_txt'] = 'Tools';
 ?>
diff --git a/interface/web/admin/form/system_config.tform.php b/interface/web/admin/form/system_config.tform.php
index 13e55f7af..db0d35383 100644
--- a/interface/web/admin/form/system_config.tform.php
+++ b/interface/web/admin/form/system_config.tform.php
@@ -162,6 +162,31 @@ $form["tabs"]['mail'] = array (
 	)
 );
 
+$form["tabs"]['domains'] = array (
+	'title' 	=> "Domains",
+	'width' 	=> 70,
+	'template' 	=> "templates/system_config_domains_edit.htm",
+	'fields' 	=> array (
+	##################################
+	# Begin Datatable fields
+	##################################
+		'use_domain_module' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'CHECKBOX',
+			'default'	=> 'n',
+			'value'		=> array(0 => 'n',1 => 'y')
+		),
+		'new_domain_html' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> ''
+		),
+	##################################
+	# ENDE Datatable fields
+	##################################
+	)
+);
 
 
 ?>
\ No newline at end of file
diff --git a/interface/web/admin/lib/lang/de_system_config.lng b/interface/web/admin/lib/lang/de_system_config.lng
index 2c10f2567..a4e618217 100644
--- a/interface/web/admin/lib/lang/de_system_config.lng
+++ b/interface/web/admin/lib/lang/de_system_config.lng
@@ -12,4 +12,7 @@ $wb['dblist_phpmyadmin_link_txt'] = 'Link zu phpMyAdmin in der Datenbankliste';
 $wb['mailboxlist_webmail_link_txt'] = 'Link zu Webmail in der Mailboxliste';
 $wb['webmail_url_txt'] = 'Webmail URL';
 $wb['phpmyadmin_url_txt'] = 'PHPMyAdmin URL';
+$wb['use_domain_module_txt'] = 'Neue Domains können nur über das Modul Domains angelegt werden';
+$wb['use_domain_module_hint'] = 'Wenn Sie dieses Modul verwenden, können Kunden beim Anlegen neuer E-Mail-Domains und neuer Websites lediglich eine Auswahl der vom Administrator für sie angelegter Domains treffen, sie können keine freie Eingabe ausführen.<br>Sollten Sie diesen Wert ändern, so müssen Sie sich danach ab- und wieder neu anmelden, um die Änderungen sichtbar zu machen.';
+$wb['new_domain_txt'] = 'HTML-Text zum Erstellen einer neuen Domäne';
 ?>
diff --git a/interface/web/admin/lib/lang/en_system_config.lng b/interface/web/admin/lib/lang/en_system_config.lng
index 450222722..3cb319cb2 100644
--- a/interface/web/admin/lib/lang/en_system_config.lng
+++ b/interface/web/admin/lib/lang/en_system_config.lng
@@ -13,5 +13,7 @@ $wb['dblist_phpmyadmin_link_txt'] = 'Link to phpmyadmin in DB list';
 $wb['mailboxlist_webmail_link_txt'] = 'Link to webmail in Mailbox list';
 $wb['webmail_url_txt'] = 'Webmail URL';
 $wb['phpmyadmin_url_txt'] = 'PHPMyAdmin URL';
-
+$wb['use_domain_module_txt'] = 'Use the domain-module to add new domains';
+$wb['use_domain_module_hint'] = 'If you use this module, your customers can only select one of the domains the admin creates for them. They can not free edit the domain-field.You have to re-login after changing this value, to make the changes visible.';
+$wb['new_domain_txt'] = 'HTML to create a new domain';
 ?>
\ No newline at end of file
diff --git a/interface/web/admin/system_config_edit.php b/interface/web/admin/system_config_edit.php
index 6107f20e4..f6a4c05d0 100644
--- a/interface/web/admin/system_config_edit.php
+++ b/interface/web/admin/system_config_edit.php
@@ -49,7 +49,8 @@ $app->uses('tpl,tform,tform_actions');
 $app->load('tform_actions');
 
 class page_action extends tform_actions {
-	
+
+
 	function onShowEdit() {
 		global $app, $conf;
 		
@@ -62,7 +63,11 @@ class page_action extends tform_actions {
 			$server_id = $this->id;
 		
 			$this->dataRecord = $app->getconf->get_global_config($section);
-			
+			if ($section == 'domains'){
+				if (isset($this->dataRecord['use_domain_module'])){
+					$_SESSION['use_domain_module_old_value'] = $this->dataRecord['use_domain_module'];
+				}
+			}
 		}
 		
 		$record = $app->tform->getHTML($this->dataRecord, $this->active_tab,'EDIT');
@@ -86,6 +91,23 @@ class page_action extends tform_actions {
 		
 		$sql = "UPDATE sys_ini SET config = '".$app->db->quote($server_config_str)."' WHERE sysini_id = 1";
 		$app->db->query($sql);
+
+		/*
+		 * If we should use the domain-module, we have to insert all existing domains into the table
+		 * (only the first time!)
+		 */
+		if (($section == 'domains') && 
+				($_SESSION['use_domain_module_old_value'] == '') &&
+				($server_config_array['domains']['use_domain_module'] == 'y')){
+			$sql = "REPLACE INTO domain (sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain ) " .
+				"SELECT sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain " .
+				"FROM mail_domain";
+			$app->db->query($sql);
+			$sql = "REPLACE INTO domain (sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain ) " .
+				"SELECT sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain " .
+				"FROM web_domain";
+			$app->db->query($sql);
+		}
 	}
 	
 }
diff --git a/interface/web/admin/templates/system_config_domains_edit.htm b/interface/web/admin/templates/system_config_domains_edit.htm
new file mode 100644
index 000000000..9e4d09a70
--- /dev/null
+++ b/interface/web/admin/templates/system_config_domains_edit.htm
@@ -0,0 +1,35 @@
+<h2><tmpl_var name="list_head_txt"></h2>
+<p><tmpl_var name="list_desc_txt"></p>
+
+<div class="panel panel_system_config">
+  
+  <div class="pnl_formsarea">
+    <fieldset class="inlineLabels">
+      <div class="ctrlHolder">
+		  <div style="float:left;width:100%">
+				<p class="label" style="width:270px">{tmpl_var name='use_domain_module_txt'}</p>
+					<div class="multiField">
+						{tmpl_var name='use_domain_module'}
+					</div>
+		  </div>
+				<div style="float:left;width:500px;margin-top:20px">{tmpl_var name='use_domain_module_hint'}</div>
+			</div>
+      <div class="ctrlHolder">
+				<p class="label">{tmpl_var name='new_domain_txt'}</p>
+					<div class="multiField">
+					    <textarea name="new_domain_html" id="new_domain_html" style="width: 500px; height: 250px">
+						{tmpl_var name='new_domain_html'}
+						</textarea>
+					</div>
+	</div>
+    </fieldset>
+
+    <input type="hidden" name="id" value="{tmpl_var name='id'}">
+
+    <div class="buttonHolder buttons">
+      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/system_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
+      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/users_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
+    </div>
+  </div>
+  
+</div>
diff --git a/interface/web/domain/domain_del.php b/interface/web/domain/domain_del.php
new file mode 100644
index 000000000..f47f2f9d8
--- /dev/null
+++ b/interface/web/domain/domain_del.php
@@ -0,0 +1,82 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/******************************************
+* Begin Form configuration
+******************************************/
+
+$list_def_file = "list/domain.list.php";
+$tform_def_file = "form/domain.tform.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+//* Check permissions for module
+$app->auth->check_module_permissions('domain');
+
+// Loading classes
+$app->uses('tpl,tform,tform_actions');
+$app->load('tform_actions');
+
+//* load language file
+$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng';
+include($lng_file);
+
+class page_action extends tform_actions {
+
+	function onBeforeDelete() {
+		global $app; $conf;
+		
+		/*
+		 * We can only delete domains if they are NOT in use
+		 */
+		$domain = $this->dataRecord['domain'];
+
+		$sql = "SELECT domain_id FROM mail_domain WHERE domain = '" . $app->db->quote($domain) . "'";
+		$res = $app->db->queryOneRecord($sql);
+		if (is_array($res)){
+			$app->error($wb['error_domain_in mailuse']);
+		}
+		
+		$sql = "SELECT domain_id FROM web_domain WHERE domain = '" . $app->db->quote($domain) . "'";
+		$res = $app->db->queryOneRecord($sql);
+		if (is_array($res)){
+			$app->error($wb['error_domain_in webuse']);
+		}
+	}
+}
+
+$page = new page_action;
+$page->onDelete();
+
+?>
\ No newline at end of file
diff --git a/interface/web/domain/domain_edit.php b/interface/web/domain/domain_edit.php
new file mode 100644
index 000000000..8e6e63841
--- /dev/null
+++ b/interface/web/domain/domain_edit.php
@@ -0,0 +1,154 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+/******************************************
+* Begin Form configuration
+******************************************/
+
+$tform_def_file = "form/domain.tform.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+//* Check permissions for module
+$app->auth->check_module_permissions('domain');
+
+// Loading classes
+$app->uses('tpl,tform,tform_actions');
+$app->load('tform_actions');
+
+//* load language file
+$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng';
+include($lng_file);
+
+class page_action extends tform_actions {
+
+	function onShowNew() {
+		global $app, $conf, $wb;
+
+		// Only admins can add domains, so we don't need any check
+
+		$app->tpl->setVar($wb);
+
+		parent::onShowNew();
+	}
+
+	function onShowEnd() {
+		global $app, $conf, $wb;
+
+		if($_SESSION["s"]["user"]["typ"] == 'admin') {
+			// Getting Clients of the user
+			$sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
+			$clients = $app->db->queryAllRecords($sql);
+			$client_select = '';
+			if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>";
+			$tmp_data_record = $app->tform->getDataRecord($this->id);
+			if(is_array($clients)) {
+				foreach( $clients as $client) {
+					$selected = ($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
+					$client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
+				}
+			}
+			$app->tpl->setVar("client_group_id",$client_select);
+
+		}
+
+		if($this->id > 0) {
+			//* we are editing a existing record
+			$app->tpl->setVar("edit_disabled", 1);
+		} else {
+			$app->tpl->setVar("edit_disabled", 0);
+		}
+
+		$app->tpl->setVar($wb);
+
+		parent::onShowEnd();
+	}
+
+	function onSubmit() {
+		global $app, $conf, $wb;
+
+		if($_SESSION["s"]["user"]["typ"] == 'admin') {
+			if ($this->id == 0) {
+				/*
+				 * We create a new record
+				*/
+				// Check if the user is empty
+				if(isset($this->dataRecord['client_group_id']) && $this->dataRecord['client_group_id'] == 0) {
+					$app->tform->errorMessage .= $wb['error_client_group_id_empty'];
+				}
+				//* make sure that the email domain is lowercase
+				if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]);
+			}
+			else {
+				/*
+				 * We edit a existing one, but there is nothing to edit
+				*/
+				$this->dataRecord = $app->tform->getDataRecord($this->id);
+			}
+		} else {
+			if($this->id > 0) {
+				/*
+				 * Clients may not edit anything, so we reset the old data
+				*/
+				$this->dataRecord = $app->tform->getDataRecord($this->id);
+			} else {
+				/*
+				 * clients may not create a new domain
+				*/
+				$app->error($wb['error_client_can_not_add_domain']);
+			}
+		}
+
+		$app->tpl->setVar($wb);
+
+		parent::onSubmit();
+	}
+
+	function onAfterInsert() {
+		global $app, $conf;
+
+		// make sure that the record belongs to the client group and not the admin group when admin inserts it
+		// also make sure that the user can not delete domain created by a admin
+		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
+			$client_group_id = intval($this->dataRecord["client_group_id"]);
+			$app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
+		}
+	}
+}
+
+$page = new page_action;
+$page->onLoad();
+
+?>
\ No newline at end of file
diff --git a/interface/web/domain/domain_list.php b/interface/web/domain/domain_list.php
new file mode 100644
index 000000000..381285e36
--- /dev/null
+++ b/interface/web/domain/domain_list.php
@@ -0,0 +1,51 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+/******************************************
+* Begin Form configuration
+******************************************/
+
+$list_def_file = "list/domain.list.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+
+//* Check permissions for module
+$app->auth->check_module_permissions('domain');
+
+$app->uses('listform_actions');
+
+$app->listform_actions->onLoad();
+
+?>
\ No newline at end of file
diff --git a/interface/web/domain/domain_new_client.php b/interface/web/domain/domain_new_client.php
new file mode 100644
index 000000000..3d9a9c410
--- /dev/null
+++ b/interface/web/domain/domain_new_client.php
@@ -0,0 +1,45 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+//* Check permissions for module
+$app->auth->check_module_permissions('domain');
+
+/*
+ * Just get the html and return it
+ */
+$app->uses('ini_parser,getconf');
+$settings = $app->getconf->get_global_config('domains');
+if ($settings['use_domain_module'] == 'y') {
+	echo $settings[new_domain_html];
+}
+
+?>
diff --git a/interface/web/domain/form/domain.tform.php b/interface/web/domain/form/domain.tform.php
new file mode 100644
index 000000000..9cd542284
--- /dev/null
+++ b/interface/web/domain/form/domain.tform.php
@@ -0,0 +1,111 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+	Form Definition
+
+	Tabledefinition
+
+	Datatypes:
+	- INTEGER (Forces the input to Int)
+	- DOUBLE
+	- CURRENCY (Formats the values to currency notation)
+	- VARCHAR (no format check, maxlength: 255)
+	- TEXT (no format check)
+	- DATE (Dateformat, automatic conversion to timestamps)
+
+	Formtype:
+	- TEXT (Textfield)
+	- TEXTAREA (Textarea)
+	- PASSWORD (Password textfield, input is not shown when edited)
+	- SELECT (Select option field)
+	- RADIO
+	- CHECKBOX
+	- CHECKBOXARRAY
+	- FILE
+
+	VALUE:
+	- Wert oder Array
+
+	Hint:
+	The ID field of the database table is not part of the datafield definition.
+	The ID field must be always auto incement (int or bigint).
+
+
+*/
+
+$form["title"] 			= "Domain";
+$form["description"] 	= "";
+$form["name"] 			= "domain";
+$form["action"]			= "domain_edit.php";
+$form["db_table"]		= "domain";
+$form["db_table_idx"]	= "domain_id";
+$form["db_history"]		= "yes";
+$form["tab_default"]	= "domain";
+$form["list_default"]	= "domain_list.php";
+$form["auth"]			= 'yes'; // yes / no
+
+$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
+$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
+$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
+$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
+$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
+
+$form["tabs"]['domain'] = array (
+	'title' 	=> "Domain",
+	'width' 	=> 100,
+	'template' 	=> "templates/domain_edit.htm",
+	'fields' 	=> array (
+	##################################
+	# Begin Datatable fields
+	##################################
+		'domain' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
+														'errmsg'=> 'domain_error_empty'),
+										1 => array (	'type'	=> 'UNIQUE',
+														'errmsg'=> 'domain_error_unique'),
+										2 => array (	'type'	=> 'REGEX',
+														'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z]{2,10}$/',
+														'errmsg'=> 'domain_error_regex'),
+									),
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
+	##################################
+	# ENDE Datatable fields
+	##################################
+	)
+);
+
+
+?>
\ No newline at end of file
diff --git a/interface/web/domain/lib/admin.conf.php b/interface/web/domain/lib/admin.conf.php
new file mode 100644
index 000000000..5e6466221
--- /dev/null
+++ b/interface/web/domain/lib/admin.conf.php
@@ -0,0 +1,29 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+?>
\ No newline at end of file
diff --git a/interface/web/domain/lib/lang/de.lng b/interface/web/domain/lib/lang/de.lng
new file mode 100644
index 000000000..728683a74
--- /dev/null
+++ b/interface/web/domain/lib/lang/de.lng
@@ -0,0 +1,14 @@
+<?php
+$wb['Domains'] = 'Domänen';
+$wb['domain_txt'] = 'Domäne';
+$wb['client_txt'] = 'Kunde';
+$wb['domain_error_empty'] = 'Der Domänen-Name darf nicht leer sein';
+$wb['domain_error_unique'] = 'Die Domäne existiert bereits';
+$wb['domain_error_regex'] = 'Dieser Domänen-Name ist nicht gültig';
+$wb['error_domain_in mailuse'] = 'Diese Domäne kann nicht gelöscht werden, da sie zur Zeit noch als E-mail - Domäne verwendet wird';
+$wb['error_domain_in webuse'] = 'Diese Domäne kann nicht gelöscht werden, da sie zur Zeit noch als Web - Domäne verwendet wird';
+$wb['error_client_can_not_add_domain'] = 'Sie haben nicht das Recht, eine neue Domäne anzulegen';
+$wb['error_client_group_id_empty'] = 'Sie müssen einen Kunden auswählen<br>';
+$wb['list_head_txt'] = 'Domänen';
+$wb['domain_txt'] = 'Domäne';
+?>
diff --git a/interface/web/domain/lib/lang/de_domain_list.lng b/interface/web/domain/lib/lang/de_domain_list.lng
new file mode 100644
index 000000000..70f3b2f32
--- /dev/null
+++ b/interface/web/domain/lib/lang/de_domain_list.lng
@@ -0,0 +1,5 @@
+<?php
+$wb['list_head_txt'] = 'Domänen';
+$wb['add_new_record_txt'] = 'Neue Domäne hinzufügen';
+$wb['domain_txt'] = 'Domäne';
+?>
\ No newline at end of file
diff --git a/interface/web/domain/lib/lang/en.lng b/interface/web/domain/lib/lang/en.lng
new file mode 100644
index 000000000..f2fdc9992
--- /dev/null
+++ b/interface/web/domain/lib/lang/en.lng
@@ -0,0 +1,13 @@
+<?php
+$wb['Domains'] = 'Domains';
+$wb['domain_txt'] = 'Domain';
+$wb['client_txt'] = 'Client';
+$wb['domain_error_empty'] = 'The domain-name is empty';
+$wb['domain_error_unique'] = 'The domain already exists';
+$wb['domain_error_regex'] = 'This domain-name is not allowed';
+$wb['error_domain_in mailuse'] = 'This domain can not be deleted, because it is in use as mail-domain';
+$wb['error_domain_in webuse'] = 'This domain can not be deleted, because it is in use as web-domain';
+$wb['error_client_can_not_add_domain'] = 'You can not add a new domain';
+$wb['domain_txt'] = 'Domain';
+$wb['error_client_group_id_empty'] = 'You have to select a customer<br>';
+?>
diff --git a/interface/web/domain/lib/lang/en_domain_list.lng b/interface/web/domain/lib/lang/en_domain_list.lng
new file mode 100644
index 000000000..161fd504e
--- /dev/null
+++ b/interface/web/domain/lib/lang/en_domain_list.lng
@@ -0,0 +1,5 @@
+<?php
+$wb['list_head_txt'] = 'Domains';
+$wb['add_new_record_txt'] = 'Add new Domain';
+$wb['domain_txt'] = 'Domain';
+?>
\ No newline at end of file
diff --git a/interface/web/domain/lib/module.conf.php b/interface/web/domain/lib/module.conf.php
new file mode 100644
index 000000000..ae01afd4d
--- /dev/null
+++ b/interface/web/domain/lib/module.conf.php
@@ -0,0 +1,47 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$module['name'] 		= 'domain';
+$module['title'] 		= 'top_menu_domain';
+$module['template'] 	= 'module.tpl.htm';
+$module['startpage'] 	= 'domain/domain_list.php';
+$module['tab_width']    = '';
+
+
+$items = array();
+
+$items[] = array( 'title' 	=> 'Domains',
+				  'target' 	=> 'content',
+				  'link'	=> 'domain/domain_list.php');
+
+$module['nav'][] = array(	'title'	=> 'Domains',
+							'open' 	=> 1,
+							'items'	=> $items);
+
+?>
\ No newline at end of file
diff --git a/interface/web/domain/list/domain.list.php b/interface/web/domain/list/domain.list.php
new file mode 100644
index 000000000..bd96addf2
--- /dev/null
+++ b/interface/web/domain/list/domain.list.php
@@ -0,0 +1,84 @@
+<?php
+/*
+Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+	Datatypes:
+	- INTEGER
+	- DOUBLE
+	- CURRENCY
+	- VARCHAR
+	- TEXT
+	- DATE
+*/
+
+
+
+// Name of the list
+$liste["name"] 				= "domain";
+
+// Database table
+$liste["table"] 			= "domain";
+
+// Index index field of the database table
+$liste["table_idx"]			= "domain_id";
+
+// Search Field Prefix
+$liste["search_prefix"] 	= "search_";
+
+// Records per page
+$liste["records_per_page"] 	= 15;
+
+// Script File of the list
+$liste["file"]				= "domain_list.php";
+
+// Script file of the edit form
+$liste["edit_file"]			= "domain_edit.php";
+
+// Script File of the delete script
+$liste["delete_file"]		= "domain_del.php";
+
+// Paging Template
+$liste["paging_tpl"]		= "templates/paging.tpl.htm";
+
+// Enable auth
+$liste["auth"]				= "yes";
+
+
+/*****************************************************
+* Suchfelder
+*****************************************************/
+$liste["item"][] = array(	'field'		=> "domain",
+							'datatype'	=> "VARCHAR",
+							'formtype'	=> "TEXT",
+							'op'		=> "like",
+							'prefix'	=> "%",
+							'suffix'	=> "%",
+							'width'		=> "",
+							'value'		=> "");
+?>
\ No newline at end of file
diff --git a/interface/web/domain/templates/domain_edit.htm b/interface/web/domain/templates/domain_edit.htm
new file mode 100644
index 000000000..12b3aa96f
--- /dev/null
+++ b/interface/web/domain/templates/domain_edit.htm
@@ -0,0 +1,40 @@
+<p><tmpl_var name="list_desc_txt"></p>
+
+<div class="panel panel_domain">
+
+  <div class="pnl_formsarea">
+    <fieldset class="inlineLabels">
+      <div class="ctrlHolder">
+      	<label for="domain">{tmpl_var name='domain_txt'}</label>
+      	<tmpl_if name="edit_disabled">
+        <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" disabled="disabled" />
+		<tmpl_else>
+        <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
+		</tmpl_if>
+      </div>
+      <tmpl_if name="is_admin">
+      <div class="ctrlHolder">
+      	<label for="client_group_id">{tmpl_var name='client_txt'}</label>
+      	<tmpl_if name="edit_disabled">
+			<select name="client_group_id" id="client_group_id" class="selectInput" disabled="disabled">
+					{tmpl_var name='client_group_id'}
+				</select>
+		<tmpl_else>
+        <select name="client_group_id" id="client_group_id" class="selectInput">
+					{tmpl_var name='client_group_id'}
+				</select>
+		</tmpl_if>
+      </div>
+		</tmpl_if>
+    </fieldset>
+
+    <input type="hidden" name="id" value="{tmpl_var name='id'}">
+    <input type="hidden" name="type" value="local">
+
+    <div class="buttonHolder buttons">
+      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','domain/domain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
+      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('domain/domain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
+    </div>
+  </div>
+  
+</div>
diff --git a/interface/web/domain/templates/domain_list.htm b/interface/web/domain/templates/domain_list.htm
new file mode 100644
index 000000000..b8533840e
--- /dev/null
+++ b/interface/web/domain/templates/domain_list.htm
@@ -0,0 +1,59 @@
+<h2><tmpl_var name="list_head_txt"></h2>
+<p><tmpl_var name="list_desc_txt"></p>
+
+<div class="panel panel_list_domain">
+
+  <div class="pnl_toolsarea">
+    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
+      <div class="buttons">
+        <tmpl_if name="is_admin">
+        <button class="iconstxt icoAdd" type="button" onClick="loadContent('domain/domain_edit.php');">
+          <span>{tmpl_var name="add_new_record_txt"}</span>
+        </button>
+		<tmpl_else>
+        <button class="iconstxt icoAdd" type="button" onClick="loadContent('domain/domain_new_client.php');">
+          <span>{tmpl_var name="add_new_record_txt"}</span>
+        </button>
+   		</tmpl_if>
+	  </div>
+    </fieldset>
+  </div>
+
+  <div class="pnl_listarea">
+    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
+      <table class="list">
+        <thead>
+          <tr>
+            <th class="tbl_col_domain" scope="col"><tmpl_var name="domain_txt"></th>
+            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
+          </tr>
+          <tr>
+            <td class="tbl_col_domain"><input type="text" name="search_domain" value="{tmpl_var name='search_domain'}" /></td>
+            <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','domain/domain_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
+          </tr>
+        </thead>
+        <tbody>
+          <tmpl_loop name="records">
+          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
+            <td class="tbl_col_domain"><a href="#" onClick="loadContent('domain/domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="domain"}</a></td>
+            <td class="tbl_col_buttons">
+				<tmpl_if name="is_admin">
+              <div class="buttons icons16">    
+                <a class="icons16 icoDelete" href="javascript: del_record('domain/domain_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
+              </div>
+				</tmpl_if>
+            </td>
+          </tr>
+          </tmpl_loop>
+        </tbody>
+
+        <tfoot>
+          <tr>
+            <td class="tbl_footer tbl_paging" colspan="4"><tmpl_var name="paging"></td>
+          </tr>
+        </tfoot>
+      </table>
+    </fieldset>
+  </div>
+
+</div>
diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php
index 847c2c337..bfd38ca64 100644
--- a/interface/web/mail/mail_domain_edit.php
+++ b/interface/web/mail/mail_domain_edit.php
@@ -62,7 +62,7 @@ class page_action extends tform_actions {
 				$app->error('Reseller: '.$app->tform->wordbook["limit_maildomain_txt"]);
 			}
 		}
-		
+
 		parent::onShowNew();
 	}
 	
@@ -116,7 +116,24 @@ class page_action extends tform_actions {
 
 		}
 		
-		
+		/*
+		 * Now we have to check, if we should use the domain-module to select the domain
+		 * or not
+		 */
+		$app->uses('ini_parser,getconf');
+		$settings = $app->getconf->get_global_config('domains');
+		if ($settings['use_domain_module'] == 'y'){
+			$client_group_id = $_SESSION["s"]["user"]["default_group"];
+			$sql = "SELECT domain FROM domain WHERE sys_groupid =" . $client_group_id;
+			$domains = $app->db->queryAllRecords($sql);
+			$domain_select = '';
+			if(is_array($domains)) {
+				foreach( $domains as $domain) {
+					$domain_select .= "<option value=" . $domain['domain'] . ">" . $domain['domain'] . "</option>\r\n";
+				}
+			}
+			$app->tpl->setVar("domain_option",$domain_select);
+		}
 		
 		
 		// Get the spamfilter policys for the user
diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm
index a104827f8..3e5da39ab 100644
--- a/interface/web/mail/templates/mail_domain_edit.htm
+++ b/interface/web/mail/templates/mail_domain_edit.htm
@@ -39,8 +39,14 @@
       
       <div class="ctrlHolder">
       	<label for="domain">{tmpl_var name='domain_txt'}</label>
-        <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
-			</div>
+        <tmpl_if name="domain_option">
+			<select name="domain" id="domain" class="selectInput">
+					{tmpl_var name='domain_option'}
+			</select>
+		<tmpl_else>
+	        <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
+        </tmpl_if>
+	  </div>
       <div class="ctrlHolder">
       	<label for="policy">{tmpl_var name='policy_txt'}</label>
         <select name="policy" id="policy" class="selectInput">
diff --git a/interface/web/sites/templates/web_domain_edit.htm b/interface/web/sites/templates/web_domain_edit.htm
index c2c48f671..d69a3f993 100644
--- a/interface/web/sites/templates/web_domain_edit.htm
+++ b/interface/web/sites/templates/web_domain_edit.htm
@@ -43,8 +43,14 @@
       </div>
       <div class="ctrlHolder">
       	<label for="domain">{tmpl_var name='domain_txt'}</label>
-        <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
-			</div>
+        <tmpl_if name="domain_option">
+			<select name="domain" id="domain" class="selectInput">
+					{tmpl_var name='domain_option'}
+			</select>
+		<tmpl_else>
+	        <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
+        </tmpl_if>
+		</div>
       <div class="ctrlHolder">
       	<label for="hd_quota">{tmpl_var name='hd_quota_txt'}</label>
         <input name="hd_quota" id="hd_quota" value="{tmpl_var name='hd_quota'}" size="7" maxlength="7" type="text" class="textInput formLengthLimit" />&nbsp;MB
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index 1874b446e..c96fda9f3 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -206,6 +206,25 @@ class page_action extends tform_actions {
 		$tmp_txt = ($this->dataRecord['traffic_quota_lock'] == 'y')?'<b>('.$app->tform->lng('traffic_quota_exceeded_txt').')</b>':'';
 		$app->tpl->setVar("traffic_quota_exceeded_txt", $tmp_txt);
 		
+		/*
+		 * Now we have to check, if we should use the domain-module to select the domain
+		 * or not
+		 */
+		$app->uses('ini_parser,getconf');
+		$settings = $app->getconf->get_global_config('domains');
+		if ($settings['use_domain_module'] == 'y'){
+			$client_group_id = $_SESSION["s"]["user"]["default_group"];
+			$sql = "SELECT domain FROM domain WHERE sys_groupid =" . $client_group_id;
+			$domains = $app->db->queryAllRecords($sql);
+			$domain_select = '';
+			if(is_array($domains)) {
+				foreach( $domains as $domain) {
+					$domain_select .= "<option value=" . $domain['domain'] . ">" . $domain['domain'] . "</option>\r\n";
+				}
+			}
+			$app->tpl->setVar("domain_option",$domain_select);
+		}
+		
 		parent::onShowEnd();
 	}
 	
diff --git a/interface/web/themes/default/css/navigation/nav_top.css b/interface/web/themes/default/css/navigation/nav_top.css
index bbb4482f2..3104e266b 100644
--- a/interface/web/themes/default/css/navigation/nav_top.css
+++ b/interface/web/themes/default/css/navigation/nav_top.css
@@ -90,4 +90,9 @@
 	.topnav- {
 		background-image: url('../../icons/x64/login.png') !important;
 	}
+
+	.topnav-domain {
+		background-image: url('../../icons/x64/domain.png') !important;
+	}
+
 }
\ No newline at end of file
diff --git a/interface/web/themes/default/icons/x64/domain.png b/interface/web/themes/default/icons/x64/domain.png
new file mode 100644
index 0000000000000000000000000000000000000000..03ac2d91830b798a2640f78a822caca795310605
GIT binary patch
literal 4248
zcmV;J5NGd+P)<h;3K|Lk000e1NJLTq002M$002M;1^@s6s%dfF00001b5ch_0Itp)
z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igSz
z6F3s}YprGg01y~SL_t(|+U=TIkX%=J$A9PE+xzq^8fkXP(r6?sTQ-s`W3UhgZ+O9q
zg4trpP=qB#K~*Y&A}Pp27FQ|{$qRW%5wca1hg1?ss4Nh$6SjbaEo{ryGW+ywJ<~nC
z-F?4#=&P|MMoYJZOI7iy8jW6lbMN`z?|kclH`kl%&Gr9ziJS7RK1~M!pCV)*AqfHj
zkpLu#P?$8tzw)2%e*-2EUJoa3!p$cM`8Q<oFpAvVKp6jA_`ehR%!R+lkKDfm%7EW4
zr`&V`_&kBk!;FkT?<SN$5QRQOAtHp(bqHt53Y)xN1D*#?0`+z|<t97;Pm@YQPY+*t
z*Kf0b^KKe$10R<qeU&dh`^OlH1d+%Cw*u#Zdb`}sCBP>bCE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