From eac88333c4335a25a501b3badd76e558fb68f708 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 24 Nov 2005 11:06:41 -0500
Subject: [PATCH] Mail alias
---
interface/web/sites/mail_alias_list.php | 26 ++++
interface/lib/classes/tform_actions.inc.php | 10 +
interface/lib/classes/tform.inc.php | 1
interface/web/sites/lib/module.conf.php | 10
interface/web/sites/list/mail_alias.list.php | 69 +++++++++++
interface/web/sites/mail_alias_edit.php | 99 ++++++++++++++++
interface/web/sites/mail_box_edit.php | 2
interface/web/sites/form/mail_alias.tform.php | 57 +++------
interface/web/sites/mail_alias_del.php | 54 +++++++++
9 files changed, 282 insertions(+), 46 deletions(-)
diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index a2609fb..54bbce1 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -216,6 +216,7 @@
$querystring = str_replace("{GROUPS}",$_SESSION["s"]["user"]["groups"],$querystring);
$table_idx = $this->formDef['db_table_idx'];
$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring);
+ $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
// Getting the records
$tmp_records = $app->db->queryAllRecords($querystring);
diff --git a/interface/lib/classes/tform_actions.inc.php b/interface/lib/classes/tform_actions.inc.php
index 7d40956..c46537e 100644
--- a/interface/lib/classes/tform_actions.inc.php
+++ b/interface/lib/classes/tform_actions.inc.php
@@ -233,7 +233,15 @@
}
}
- header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]);
+ //header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]);
+ if($_SESSION["s"]["form"]["return_to"] != '') {
+ $list_name = $_SESSION["s"]["form"]["return_to"];
+ $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"];
+ unset($_SESSION["s"]["form"]["return_to"]);
+ header($redirect);
+ } else {
+ header("Location: ".$liste["file"]);
+ }
exit;
}
diff --git a/interface/web/sites/form/mail_alias.tform.php b/interface/web/sites/form/mail_alias.tform.php
index 05671ce..a4a4f3d 100644
--- a/interface/web/sites/form/mail_alias.tform.php
+++ b/interface/web/sites/form/mail_alias.tform.php
@@ -40,8 +40,8 @@
$form["db_table"] = "mail_redirect";
$form["db_table_idx"] = "redirect_id";
$form["db_history"] = "yes";
-$form["tab_default"] = "mailbox";
-$form["list_default"] = "mail_box_list.php";
+$form["tab_default"] = "alias";
+$form["list_default"] = "mail_alias_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
@@ -50,10 +50,10 @@
$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"]['mailbox'] = array (
- 'title' => "Mailbox",
+$form["tabs"]['alias'] = array (
+ 'title' => "Email alias",
'width' => 100,
- 'template' => "templates/mail_box_mailbox_edit.htm",
+ 'template' => "templates/mail_alias_edit.htm",
'fields' => array (
##################################
# Begin Datatable fields
@@ -79,14 +79,22 @@
'width' => '30',
'maxlength' => '255'
),
- 'cryptpwd' => array (
+ 'destination' => array (
'datatype' => 'VARCHAR',
- 'formtype' => 'PASSWORD',
- 'encryption'=> 'CRYPT',
+ 'formtype' => 'SELECT',
'default' => '',
- 'value' => '',
- 'width' => '30',
- 'maxlength' => '255'
+ 'datasource' => array ( 'type' => 'SQL',
+ 'querystring' => 'SELECT email FROM mail_box WHERE {AUTHSQL} ORDER BY email',
+ 'keyfield' => 'email',
+ 'valuefield' => 'email'
+ ),
+ 'value' => ''
+ ),
+ 'type' => array (
+ 'datatype' => 'VARCHAR',
+ 'formtype' => 'SELECT',
+ 'default' => '',
+ 'value' => array('alias' => 'Alias','forward'=>'Forward')
),
'active' => array (
'datatype' => 'INTEGER',
@@ -100,33 +108,6 @@
)
);
-$form["tabs"]['autoresponder'] = array (
- 'title' => "Autoresponder",
- 'width' => 100,
- 'template' => "templates/mail_box_autoresponder_edit.htm",
- 'fields' => array (
- ##################################
- # Begin Datatable fields
- ##################################
- 'autoresponder_text' => array (
- 'datatype' => 'TEXT',
- 'formtype' => 'TEXTAREA',
- 'default' => '',
- 'value' => '',
- 'cols' => '30',
- 'rows' => '15'
- ),
- 'autoresponder' => 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/module.conf.php b/interface/web/sites/lib/module.conf.php
index 5a06587..a36f049 100644
--- a/interface/web/sites/lib/module.conf.php
+++ b/interface/web/sites/lib/module.conf.php
@@ -42,19 +42,19 @@
array (
'title' => 'Email Alias',
'target' => 'content',
- 'link' => '',
+ 'link' => 'sites/mail_alias_list.php',
),
5 =>
array (
'title' => 'Email Forward',
'target' => 'content',
- 'link' => '',
+ 'link' => 'sites/mail_forward_list.php',
),
6 =>
array (
'title' => 'Email Catchall',
'target' => 'content',
- 'link' => '',
+ 'link' => 'sites/mail_catchall_list.php',
),
),
),
@@ -68,13 +68,13 @@
array (
'title' => 'Email Whitelist',
'target' => 'content',
- 'link' => '',
+ 'link' => 'sites/mail_whitelist_list.php',
),
1 =>
array (
'title' => 'Email Blacklist',
'target' => 'content',
- 'link' => '',
+ 'link' => 'sites/mail_blacklist_list.php',
),
),
),
diff --git a/interface/web/sites/list/mail_alias.list.php b/interface/web/sites/list/mail_alias.list.php
new file mode 100644
index 0000000..4f32455
--- /dev/null
+++ b/interface/web/sites/list/mail_alias.list.php
@@ -0,0 +1,69 @@
+<?php
+
+/*
+ Datatypes:
+ - INTEGER
+ - DOUBLE
+ - CURRENCY
+ - VARCHAR
+ - TEXT
+ - DATE
+*/
+
+
+
+// Name of the list
+$liste["name"] = "mail_alias";
+
+// Database table
+$liste["table"] = "mail_redirect";
+
+// Index index field of the database table
+$liste["table_idx"] = "redirect_id";
+
+// Search Field Prefix
+$liste["search_prefix"] = "search_";
+
+// Records per page
+$liste["records_per_page"] = 15;
+
+// Script File of the list
+$liste["file"] = "mail_alias_list.php";
+
+// Script file of the edit form
+$liste["edit_file"] = "mail_alias_edit.php";
+
+// Script File of the delete script
+$liste["delete_file"] = "mail_alias_del.php";
+
+// Paging Template
+$liste["paging_tpl"] = "templates/paging.tpl.htm";
+
+// Enable auth
+$liste["auth"] = "yes";
+
+
+/*****************************************************
+* Suchfelder
+*****************************************************/
+
+$liste["item"][] = array( 'field' => "email",
+ '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_alias_del.php b/interface/web/sites/mail_alias_del.php
new file mode 100644
index 0000000..03b95ca
--- /dev/null
+++ b/interface/web/sites/mail_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_alias.list.php";
+$tform_def_file = "form/mail_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_alias_edit.php b/interface/web/sites/mail_alias_edit.php
new file mode 100644
index 0000000..1927eb8
--- /dev/null
+++ b/interface/web/sites/mail_alias_edit.php
@@ -0,0 +1,99 @@
+<?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_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');
+$app->load('tform_actions');
+
+class page_action extends tform_actions {
+
+ function onShowEnd() {
+ global $app, $conf;
+
+ $email = $this->dataRecord["email"];
+ $email_parts = explode("@",$email);
+ $app->tpl->setVar("email_local_part",$email_parts[0]);
+
+ // Getting Domains of the user
+ $sql = "SELECT domain FROM mail_domain WHERE type = 'local' AND ".$app->tform->getAuthSQL('r');
+ $domains = $app->db->queryAllRecords($sql);
+ $domain_select = '';
+ foreach( $domains as $domain) {
+ $selected = ($domain["domain"] == $email_parts[1])?'SELECTED':'';
+ $domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
+ }
+ $app->tpl->setVar("email_domain",$domain_select);
+
+ parent::onShowEnd();
+ }
+
+ function onSubmit() {
+ global $app, $conf;
+
+ // Check if Domain belongs to user
+ $domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
+ if($domain["domain"] != $_POST["email_domain"]) $app->tform->errorMessage .= $app->tform->wordbook["no_domain_perm"];
+
+ // compose the email field
+ $this->dataRecord["email"] = $_POST["email_local_part"]."@".$_POST["email_domain"];
+ // Set the server id of the mailbox = server ID of mail domain.
+ $this->dataRecord["server_id"] = $domain["server_id"];
+
+ unset($this->dataRecord["email_local_part"]);
+ unset($this->dataRecord["email_domain"]);
+
+ parent::onSubmit();
+ }
+
+}
+
+$page = new page_action;
+$page->onLoad();
+
+?>
\ No newline at end of file
diff --git a/interface/web/sites/mail_alias_list.php b/interface/web/sites/mail_alias_list.php
new file mode 100644
index 0000000..d3646fc
--- /dev/null
+++ b/interface/web/sites/mail_alias_list.php
@@ -0,0 +1,26 @@
+<?php
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+/******************************************
+* Begin Form configuration
+******************************************/
+
+$list_def_file = "list/mail_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/mail_box_edit.php b/interface/web/sites/mail_box_edit.php
index e01137a..715964f 100644
--- a/interface/web/sites/mail_box_edit.php
+++ b/interface/web/sites/mail_box_edit.php
@@ -51,8 +51,6 @@
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
-die(print_r($_SESSION));
-
class page_action extends tform_actions {
function onShowEnd() {
--
Gitblit v1.9.1