Skip to content

Commit 0b52bcb

Browse files
committed
Optimized transports form.
1 parent 5bf366b commit 0b52bcb

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

interface/web/mail/lib/lang/en_mail_transport.lng

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
$wb["server_id_txt"] = 'Server';
33
$wb["domain_txt"] = 'Domain';
4-
$wb["transport_txt"] = 'Transport';
4+
$wb["destination_txt"] = 'Destination';
5+
$wb["type_txt"] = 'Type';
6+
$wb["mx_txt"] = 'No MX lookup';
57
$wb["sort_order_txt"] = 'Sort by';
68
$wb["active_txt"] = 'Active';
79
$wb["btn_save_txt"] = 'Save';

interface/web/mail/mail_transport_edit.php

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
3+
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
44
All rights reserved.
55
66
Redistribution and use in source and binary forms, with or without modification,
@@ -42,7 +42,7 @@
4242
require_once('../../lib/app.inc.php');
4343

4444
// Checking module permissions
45-
if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
45+
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
4646
header("Location: ../index.php");
4747
exit;
4848
}
@@ -64,7 +64,7 @@ function onShowNew() {
6464
$client_group_id = $_SESSION["s"]["user"]["default_group"];
6565
$client = $app->db->queryOneRecord("SELECT limit_mailrouting FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
6666

67-
// Check if the user may add another mailbox.
67+
// Check if the user may add another transport.
6868
if($client["limit_mailrouting"] >= 0) {
6969
$tmp = $app->db->queryOneRecord("SELECT count(transport_id) as number FROM mail_transport WHERE sys_groupid = $client_group_id");
7070
if($tmp["number"] >= $client["limit_mailrouting"]) {
@@ -76,6 +76,39 @@ function onShowNew() {
7676
parent::onShowNew();
7777
}
7878

79+
function onShowEnd() {
80+
global $app, $conf;
81+
82+
$tmp_parts = explode(":",$this->dataRecord["transport"]);
83+
if(empty($this->id) && empty($tmp_parts[0])) {
84+
$rec["type"] = 'smtp';
85+
} else {
86+
$rec["type"] = $tmp_parts[0];
87+
}
88+
if(@substr($tmp_parts[1],0,1) == '[') {
89+
$rec["mx"] = 'checked="CHECKED"';
90+
$rec["destination"] = @substr($tmp_parts[1],1,-1);
91+
} else {
92+
$rec["mx"] = '';
93+
$rec["destination"] = @$tmp_parts[1];
94+
}
95+
96+
$types = array('smtp' => 'smtp','uucp' => 'uucp','slow' => 'slow', 'error' => 'error', '' => 'null');
97+
$type_select = '';
98+
if(is_array($types)) {
99+
foreach( $types as $key => $val) {
100+
$selected = ($key == $rec["type"])?'SELECTED':'';
101+
$type_select .= "<option value='$key' $selected>$val</option>\r\n";
102+
}
103+
}
104+
$rec["type"] = $type_select;
105+
$app->tpl->setVar($rec);
106+
unset($type);
107+
unset($types);
108+
109+
parent::onShowEnd();
110+
}
111+
79112
function onSubmit() {
80113
global $app, $conf;
81114

@@ -85,7 +118,7 @@ function onSubmit() {
85118
$client_group_id = $_SESSION["s"]["user"]["default_group"];
86119
$client = $app->db->queryOneRecord("SELECT limit_mailrouting FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
87120

88-
// Check if the user may add another mailbox.
121+
// Check if the user may add another transport.
89122
if($this->id == 0 && $client["limit_mailrouting"] >= 0) {
90123
$tmp = $app->db->queryOneRecord("SELECT count(transport_id) as number FROM mail_transport WHERE sys_groupid = $client_group_id");
91124
if($tmp["number"] >= $client["limit_mailrouting"]) {
@@ -95,6 +128,17 @@ function onSubmit() {
95128
}
96129
} // end if user is not admin
97130

131+
//* Compose transport field
132+
if($this->dataRecord["mx"] == 'y') {
133+
$transport = '['.$this->dataRecord["destination"].']';
134+
} else {
135+
$transport = $this->dataRecord["destination"];
136+
}
137+
$this->dataRecord["transport"] = $this->dataRecord["type"].':'.$transport;
138+
unset($this->dataRecord["type"]);
139+
unset($this->dataRecord["mx"]);
140+
unset($this->dataRecord["destination"]);
141+
98142
parent::onSubmit();
99143
}
100144

interface/web/mail/templates/mail_transport_edit.htm

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,19 @@
1212
<td class="frmText11"><input name="domain" type="text" class="text" value="{tmpl_var name='domain'}" size="30" maxlength="255"></td>
1313
</tr>
1414
<tr>
15-
<td class="frmText11">{tmpl_var name='transport_txt'}:</td>
16-
<td class="frmText11"><input name="transport" type="text" class="text" value="{tmpl_var name='transport'}" size="30" maxlength="255"></td>
15+
<td class="frmText11">{tmpl_var name='type_txt'}:</td>
16+
<td class="frmText11">
17+
<select name="type" class="text">
18+
{tmpl_var name='type'}
19+
</select></td>
20+
</tr>
21+
<tr>
22+
<td class="frmText11">{tmpl_var name='mx_txt'}:</td>
23+
<td class="frmText11"><input name="mx" value="y" {tmpl_var name='mx'} type="checkbox"></td>
24+
</tr>
25+
<tr>
26+
<td class="frmText11">{tmpl_var name='destination_txt'}:</td>
27+
<td class="frmText11"><input name="destination" type="text" class="text" value="{tmpl_var name='destination'}" size="30" maxlength="255"></td>
1728
</tr>
1829
<tr>
1930
<td class="frmText11">{tmpl_var name='sort_order_txt'}:</td>

0 commit comments

Comments
 (0)