From dd0fc9255b9c19ed6c8914bc718c59bf508cbe3c Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 23 Nov 2005 04:36:44 -0500
Subject: [PATCH] Added Domain Alias in email Module.

---
 interface/web/sites/mail_domain_alias_edit.php             |   56 ++++++++
 interface/web/sites/list/mail_domain_alias.list.php        |   77 +++++++++++
 interface/web/sites/templates/mail_domain_alias_list.htm   |   29 ++++
 interface/web/sites/lib/module.conf.php                    |    2 
 interface/web/sites/lib/lang/en_mail_domain_alias_list.lng |   12 +
 interface/web/sites/mail_domain_alias_del.php              |   54 +++++++
 interface/lib/classes/listform_actions.inc.php             |    5 
 interface/web/sites/form/mail_domain_alias.tform.php       |  117 ++++++++++++++++
 interface/web/sites/mail_domain_alias_list.php             |   25 +++
 9 files changed, 374 insertions(+), 3 deletions(-)

diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php
index 4b13692..0df5391 100644
--- a/interface/lib/classes/listform_actions.inc.php
+++ b/interface/lib/classes/listform_actions.inc.php
@@ -40,6 +40,7 @@
 	var $id;
 	var $idx_key;
 	var $DataRowColor;
+	var $SQLExtWhere = '';
 	
 	function onLoad() {
 		global $app, $conf, $list_def_file;
@@ -98,9 +99,9 @@
 		// Generate the search sql
 		if($app->listform->listDef["auth"] != 'no') {
 			if($_SESSION["s"]["user"]["typ"] == "admin") {
-				$sql_where = "";
+				$sql_where = $this->SQLExtWhere;
 			} else {
-				$sql_where = $app->tform->getAuthSQL('r')." and";
+				$sql_where = $this->SQLExtWhere ." ". $app->tform->getAuthSQL('r')." and";
 			}
 		}
 
diff --git a/interface/web/sites/form/mail_domain_alias.tform.php b/interface/web/sites/form/mail_domain_alias.tform.php
new file mode 100644
index 0000000..e50d0f6
--- /dev/null
+++ b/interface/web/sites/form/mail_domain_alias.tform.php
@@ -0,0 +1,117 @@
+<?php
+
+/*
+	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"] 			= "Mail DomainAlias";
+$form["description"] 	= "";
+$form["name"] 			= "mail_domain_alias";
+$form["action"]			= "mail_domain_alias_edit.php";
+$form["db_table"]		= "mail_domain";
+$form["db_table_idx"]	= "domain_id";
+$form["db_history"]		= "yes";
+$form["tab_default"]	= "domain";
+$form["list_default"]	= "mail_domain_alias_list.php";
+$form["auth"]			= '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/mail_domain_alias_edit.htm",
+	'fields' 	=> array (
+	##################################
+	# Begin Datatable fields
+	##################################
+		'server_id' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'SELECT',
+			'default'	=> '',
+			'datasource'	=> array ( 	'type'	=> 'SQL',
+										'querystring' => 'SELECT server_id,server_name FROM server WHERE 1 ORDER BY server_name',
+										'keyfield'=> 'server_id',
+										'valuefield'=> 'server_name'
+									 ),
+			'value'		=> ''
+		),
+		'domain' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
+														'errmsg'=> 'domain_error_empty'),
+										1 => array (	'type'	=> 'UNIQUE',
+														'errmsg'=> 'domain_error_unique'),
+									),
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
+		'destination' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
+														'errmsg'=> 'destination_error_empty'),
+										1 => array (	'type'	=> 'UNIQUE',
+														'errmsg'=> 'destination_error_unique'),
+									),
+			'default'	=> '',
+			'value'		=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255'
+		),
+		'type' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'SELECT',
+			'default'	=> '',
+			'value'		=> array('alias' => 'alias','local' => 'local','relay'=>'relay','manual_relay'=>'manual Relay')
+		),
+		'active' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'CHECKBOX',
+			'default'	=> '1',
+			'value'		=> '1'
+		),
+	##################################
+	# ENDE Datatable fields
+	##################################
+	)
+);
+
+
+?>
\ No newline at end of file
diff --git a/interface/web/sites/lib/lang/en_mail_domain_alias_list.lng b/interface/web/sites/lib/lang/en_mail_domain_alias_list.lng
new file mode 100644
index 0000000..c5851cc
--- /dev/null
+++ b/interface/web/sites/lib/lang/en_mail_domain_alias_list.lng
@@ -0,0 +1,12 @@
+<?php
+$wb["list_head_txt"] = 'mail_domain_alias';
+$wb["server_id_txt"] = 'server_id';
+$wb["domain_txt"] = 'domain';
+$wb["destination_txt"] = 'destination';
+$wb["page_txt"] = 'Page';
+$wb["page_of_txt"] = 'of';
+$wb["page_next_txt"] = 'Next';
+$wb["page_back_txt"] = 'Back';
+$wb["delete_txt"] = 'Delete';
+$wb["filter_txt"] = 'Filter';
+?>
\ No newline at end of file
diff --git a/interface/web/sites/lib/module.conf.php b/interface/web/sites/lib/module.conf.php
index 392881c..325b7c2 100644
--- a/interface/web/sites/lib/module.conf.php
+++ b/interface/web/sites/lib/module.conf.php
@@ -24,7 +24,7 @@
         array (
           'title' => 'Domain Alias',
           'target' => 'content',
-          'link' => '',
+          'link' => 'sites/mail_domain_alias_list.php',
         ),
         2 => 
         array (
diff --git a/interface/web/sites/list/mail_domain_alias.list.php b/interface/web/sites/list/mail_domain_alias.list.php
new file mode 100644
index 0000000..8859008
--- /dev/null
+++ b/interface/web/sites/list/mail_domain_alias.list.php
@@ -0,0 +1,77 @@
+<?php
+
+/*
+	Datatypes:
+	- INTEGER
+	- DOUBLE
+	- CURRENCY
+	- VARCHAR
+	- TEXT
+	- DATE
+*/
+
+
+
+// Name of the list
+$liste["name"] 				= "mail_domain_alias";
+
+// Database table
+$liste["table"] 			= "mail_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"]				= "mail_domain_alias_list.php";
+
+// Script file of the edit form
+$liste["edit_file"]			= "mail_domain_alias_edit.php";
+
+// Script File of the delete script
+$liste["delete_file"]		= "mail_domain_alias_del.php";
+
+// Paging Template
+$liste["paging_tpl"]		= "templates/paging.tpl.htm";
+
+// Enable auth
+$liste["auth"]				= "yes";
+
+
+/*****************************************************
+* Suchfelder
+*****************************************************/
+
+$liste["item"][] = array(	'field'		=> "server_id",
+							'datatype'	=> "VARCHAR",
+							'formtype'	=> "TEXT",
+							'op'		=> "like",
+							'prefix'	=> "%",
+							'suffix'	=> "%",
+							'width'		=> "",
+							'value'		=> "");
+
+$liste["item"][] = array(	'field'		=> "domain",
+							'datatype'	=> "VARCHAR",
+							'formtype'	=> "TEXT",
+							'op'		=> "like",
+							'prefix'	=> "%",
+							'suffix'	=> "%",
+							'width'		=> "",
+							'value'		=> "");
+
+$liste["item"][] = array(	'field'		=> "destination",
+							'datatype'	=> "VARCHAR",
+							'formtype'	=> "TEXT",
+							'op'		=> "like",
+							'prefix'	=> "%",
+							'suffix'	=> "%",
+							'width'		=> "",
+							'value'		=> "");
+
+?>
\ No newline at end of file
diff --git a/interface/web/sites/mail_domain_alias_del.php b/interface/web/sites/mail_domain_alias_del.php
new file mode 100644
index 0000000..fab6d19
--- /dev/null
+++ b/interface/web/sites/mail_domain_alias_del.php
@@ -0,0 +1,54 @@
+<?php
+
+/*
+Copyright (c) 2005, Till Brehm, projektfarm Gmbh
+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/mail_domain_alias.list.php";
+$tform_def_file = "form/mail_domain_alias.tform.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+// Checke Berechtigungen f�r Modul
+if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
+	header("Location: ../index.php");
+	exit;
+}
+
+$app->uses("tform_actions");
+$app->tform_actions->onDelete();
+
+?>
\ No newline at end of file
diff --git a/interface/web/sites/mail_domain_alias_edit.php b/interface/web/sites/mail_domain_alias_edit.php
new file mode 100644
index 0000000..7fedf35
--- /dev/null
+++ b/interface/web/sites/mail_domain_alias_edit.php
@@ -0,0 +1,56 @@
+<?php
+/*
+Copyright (c) 2005, Till Brehm, projektfarm Gmbh
+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/mail_domain_alias.tform.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+// Checking module permissions
+if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
+	header("Location: ../index.php");
+	exit;
+}
+
+// Loading classes
+$app->uses('tpl,tform,tform_actions');
+
+// let tform_actions handle the page
+$app->tform_actions->onLoad();
+
+?>
\ No newline at end of file
diff --git a/interface/web/sites/mail_domain_alias_list.php b/interface/web/sites/mail_domain_alias_list.php
new file mode 100644
index 0000000..b948cb0
--- /dev/null
+++ b/interface/web/sites/mail_domain_alias_list.php
@@ -0,0 +1,25 @@
+<?php
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+/******************************************
+* Begin Form configuration
+******************************************/
+
+$list_def_file = "list/mail_domain_alias.list.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+// Checking module permissions
+if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
+	header("Location: ../index.php");
+	exit;
+}
+
+$app->uses('listform_actions');
+$app->listform_actions->onLoad();
+
+
+?>
\ No newline at end of file
diff --git a/interface/web/sites/templates/mail_domain_alias_list.htm b/interface/web/sites/templates/mail_domain_alias_list.htm
new file mode 100644
index 0000000..357250a
--- /dev/null
+++ b/interface/web/sites/templates/mail_domain_alias_list.htm
@@ -0,0 +1,29 @@
+<form name="myform" action="mail_domain_alias_list.php" method="POST">
+<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
+<table width="100%" border="0" cellspacing="0" cellpadding="4">
+  <tr>
+    <td class="tblHead"><tmpl_var name="server_id_txt"></td>
+    <td class="tblHead"><tmpl_var name="domain_txt"></td>
+    <td class="tblHead"><tmpl_var name="destination_txt"></td>
+    <td class="tblHead">&nbsp;</td>
+  </tr>
+  <tr>
+    <td class="frmText11"><input type="text" name="search_server_id" value="{tmpl_var name='search_server_id'}" class="text" /></td>
+    <td class="frmText11"><input type="text" name="search_domain" value="{tmpl_var name='search_domain'}" class="text" /></td>
+    <td class="frmText11"><input type="text" name="search_destination" value="{tmpl_var name='search_destination'}" class="text" /></td>
+    <td class="frmText11" align="right"><input name="Filter" type="submit" id="Filter" value="{tmpl_var name="filter_txt"}"></td>
+  </tr>
+  <tmpl_loop name="records">
+  <tr bgcolor="{tmpl_var name="bgcolor"}">
+    <td class="frmText11"><a href="mail_domain_alias_edit.php?id={tmpl_var name='id'}" class="frmText11">{tmpl_var name="server_id"}</a></td>
+    <td class="frmText11"><a href="mail_domain_alias_edit.php?id={tmpl_var name='id'}" class="frmText11">{tmpl_var name="domain"}</a></td>
+    <td class="frmText11"><a href="mail_domain_alias_edit.php?id={tmpl_var name='id'}" class="frmText11">{tmpl_var name="destination"}</a></td>
+    <td class="frmText11" align="right">[<a href="javascript: del_record('mail_domain_alias_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}');" class="frmText11">{tmpl_var name='delete_txt'}</a>]</td>
+  </tr>
+  </tmpl_loop>
+
+  <tr>
+  	<td colspan="4" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
+  </tr>
+</table>
+</form>
\ No newline at end of file

--
Gitblit v1.9.1