Skip to content

Commit eac8833

Browse files
committed
Mail alias
1 parent a01f0ec commit eac8833

File tree

9 files changed

+282
-46
lines changed

9 files changed

+282
-46
lines changed

interface/lib/classes/tform.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ function getDatasourceData($field, $record) {
216216
$querystring = str_replace("{GROUPS}",$_SESSION["s"]["user"]["groups"],$querystring);
217217
$table_idx = $this->formDef['db_table_idx'];
218218
$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring);
219+
$querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
219220

220221
// Getting the records
221222
$tmp_records = $app->db->queryAllRecords($querystring);

interface/lib/classes/tform_actions.inc.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,15 @@ function onDelete() {
233233
}
234234
}
235235

236-
header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]);
236+
//header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]);
237+
if($_SESSION["s"]["form"]["return_to"] != '') {
238+
$list_name = $_SESSION["s"]["form"]["return_to"];
239+
$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"];
240+
unset($_SESSION["s"]["form"]["return_to"]);
241+
header($redirect);
242+
} else {
243+
header("Location: ".$liste["file"]);
244+
}
237245
exit;
238246

239247
}

interface/web/sites/form/mail_alias.tform.php

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
$form["db_table"] = "mail_redirect";
4141
$form["db_table_idx"] = "redirect_id";
4242
$form["db_history"] = "yes";
43-
$form["tab_default"] = "mailbox";
44-
$form["list_default"] = "mail_box_list.php";
43+
$form["tab_default"] = "alias";
44+
$form["list_default"] = "mail_alias_list.php";
4545
$form["auth"] = 'yes'; // yes / no
4646

4747
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
@@ -50,10 +50,10 @@
5050
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
5151
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
5252

53-
$form["tabs"]['mailbox'] = array (
54-
'title' => "Mailbox",
53+
$form["tabs"]['alias'] = array (
54+
'title' => "Email alias",
5555
'width' => 100,
56-
'template' => "templates/mail_box_mailbox_edit.htm",
56+
'template' => "templates/mail_alias_edit.htm",
5757
'fields' => array (
5858
##################################
5959
# Begin Datatable fields
@@ -79,44 +79,24 @@
7979
'width' => '30',
8080
'maxlength' => '255'
8181
),
82-
'cryptpwd' => array (
82+
'destination' => array (
8383
'datatype' => 'VARCHAR',
84-
'formtype' => 'PASSWORD',
85-
'encryption'=> 'CRYPT',
84+
'formtype' => 'SELECT',
8685
'default' => '',
87-
'value' => '',
88-
'width' => '30',
89-
'maxlength' => '255'
90-
),
91-
'active' => array (
92-
'datatype' => 'INTEGER',
93-
'formtype' => 'CHECKBOX',
94-
'default' => '1',
95-
'value' => '1'
86+
'datasource' => array ( 'type' => 'SQL',
87+
'querystring' => 'SELECT email FROM mail_box WHERE {AUTHSQL} ORDER BY email',
88+
'keyfield' => 'email',
89+
'valuefield' => 'email'
90+
),
91+
'value' => ''
9692
),
97-
##################################
98-
# ENDE Datatable fields
99-
##################################
100-
)
101-
);
102-
103-
$form["tabs"]['autoresponder'] = array (
104-
'title' => "Autoresponder",
105-
'width' => 100,
106-
'template' => "templates/mail_box_autoresponder_edit.htm",
107-
'fields' => array (
108-
##################################
109-
# Begin Datatable fields
110-
##################################
111-
'autoresponder_text' => array (
112-
'datatype' => 'TEXT',
113-
'formtype' => 'TEXTAREA',
93+
'type' => array (
94+
'datatype' => 'VARCHAR',
95+
'formtype' => 'SELECT',
11496
'default' => '',
115-
'value' => '',
116-
'cols' => '30',
117-
'rows' => '15'
97+
'value' => array('alias' => 'Alias','forward'=>'Forward')
11898
),
119-
'autoresponder' => array (
99+
'active' => array (
120100
'datatype' => 'INTEGER',
121101
'formtype' => 'CHECKBOX',
122102
'default' => '1',
@@ -129,4 +109,5 @@
129109
);
130110

131111

112+
132113
?>

interface/web/sites/lib/module.conf.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@
4242
array (
4343
'title' => 'Email Alias',
4444
'target' => 'content',
45-
'link' => '',
45+
'link' => 'sites/mail_alias_list.php',
4646
),
4747
5 =>
4848
array (
4949
'title' => 'Email Forward',
5050
'target' => 'content',
51-
'link' => '',
51+
'link' => 'sites/mail_forward_list.php',
5252
),
5353
6 =>
5454
array (
5555
'title' => 'Email Catchall',
5656
'target' => 'content',
57-
'link' => '',
57+
'link' => 'sites/mail_catchall_list.php',
5858
),
5959
),
6060
),
@@ -68,13 +68,13 @@
6868
array (
6969
'title' => 'Email Whitelist',
7070
'target' => 'content',
71-
'link' => '',
71+
'link' => 'sites/mail_whitelist_list.php',
7272
),
7373
1 =>
7474
array (
7575
'title' => 'Email Blacklist',
7676
'target' => 'content',
77-
'link' => '',
77+
'link' => 'sites/mail_blacklist_list.php',
7878
),
7979
),
8080
),
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/*
4+
Datatypes:
5+
- INTEGER
6+
- DOUBLE
7+
- CURRENCY
8+
- VARCHAR
9+
- TEXT
10+
- DATE
11+
*/
12+
13+
14+
15+
// Name of the list
16+
$liste["name"] = "mail_alias";
17+
18+
// Database table
19+
$liste["table"] = "mail_redirect";
20+
21+
// Index index field of the database table
22+
$liste["table_idx"] = "redirect_id";
23+
24+
// Search Field Prefix
25+
$liste["search_prefix"] = "search_";
26+
27+
// Records per page
28+
$liste["records_per_page"] = 15;
29+
30+
// Script File of the list
31+
$liste["file"] = "mail_alias_list.php";
32+
33+
// Script file of the edit form
34+
$liste["edit_file"] = "mail_alias_edit.php";
35+
36+
// Script File of the delete script
37+
$liste["delete_file"] = "mail_alias_del.php";
38+
39+
// Paging Template
40+
$liste["paging_tpl"] = "templates/paging.tpl.htm";
41+
42+
// Enable auth
43+
$liste["auth"] = "yes";
44+
45+
46+
/*****************************************************
47+
* Suchfelder
48+
*****************************************************/
49+
50+
$liste["item"][] = array( 'field' => "email",
51+
'datatype' => "VARCHAR",
52+
'formtype' => "TEXT",
53+
'op' => "like",
54+
'prefix' => "%",
55+
'suffix' => "%",
56+
'width' => "",
57+
'value' => "");
58+
59+
$liste["item"][] = array( 'field' => "destination",
60+
'datatype' => "VARCHAR",
61+
'formtype' => "TEXT",
62+
'op' => "like",
63+
'prefix' => "%",
64+
'suffix' => "%",
65+
'width' => "",
66+
'value' => "");
67+
68+
69+
?>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$list_def_file = "list/mail_alias.list.php";
36+
$tform_def_file = "form/mail_alias.tform.php";
37+
38+
/******************************************
39+
* End Form configuration
40+
******************************************/
41+
42+
require_once('../../lib/config.inc.php');
43+
require_once('../../lib/app.inc.php');
44+
45+
// Checke Berechtigungen für Modul
46+
if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
47+
header("Location: ../index.php");
48+
exit;
49+
}
50+
51+
$app->uses("tform_actions");
52+
$app->tform_actions->onDelete();
53+
54+
?>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/*
3+
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/mail_alias.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once('../../lib/config.inc.php');
42+
require_once('../../lib/app.inc.php');
43+
44+
// Checking module permissions
45+
if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
46+
header("Location: ../index.php");
47+
exit;
48+
}
49+
50+
// Loading classes
51+
$app->uses('tpl,tform,tform_actions');
52+
$app->load('tform_actions');
53+
54+
class page_action extends tform_actions {
55+
56+
function onShowEnd() {
57+
global $app, $conf;
58+
59+
$email = $this->dataRecord["email"];
60+
$email_parts = explode("@",$email);
61+
$app->tpl->setVar("email_local_part",$email_parts[0]);
62+
63+
// Getting Domains of the user
64+
$sql = "SELECT domain FROM mail_domain WHERE type = 'local' AND ".$app->tform->getAuthSQL('r');
65+
$domains = $app->db->queryAllRecords($sql);
66+
$domain_select = '';
67+
foreach( $domains as $domain) {
68+
$selected = ($domain["domain"] == $email_parts[1])?'SELECTED':'';
69+
$domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
70+
}
71+
$app->tpl->setVar("email_domain",$domain_select);
72+
73+
parent::onShowEnd();
74+
}
75+
76+
function onSubmit() {
77+
global $app, $conf;
78+
79+
// Check if Domain belongs to user
80+
$domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
81+
if($domain["domain"] != $_POST["email_domain"]) $app->tform->errorMessage .= $app->tform->wordbook["no_domain_perm"];
82+
83+
// compose the email field
84+
$this->dataRecord["email"] = $_POST["email_local_part"]."@".$_POST["email_domain"];
85+
// Set the server id of the mailbox = server ID of mail domain.
86+
$this->dataRecord["server_id"] = $domain["server_id"];
87+
88+
unset($this->dataRecord["email_local_part"]);
89+
unset($this->dataRecord["email_domain"]);
90+
91+
parent::onSubmit();
92+
}
93+
94+
}
95+
96+
$page = new page_action;
97+
$page->onLoad();
98+
99+
?>

0 commit comments

Comments
 (0)