commit | author | age
|
45f11e
|
1 |
<?php |
T |
2 |
/* |
0b52bc
|
3 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
45f11e
|
4 |
All rights reserved. |
T |
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_transport.tform.php"; |
|
36 |
|
|
37 |
/****************************************** |
|
38 |
* End Form configuration |
|
39 |
******************************************/ |
|
40 |
|
7fe908
|
41 |
require_once '../../lib/config.inc.php'; |
MC |
42 |
require_once '../../lib/app.inc.php'; |
45f11e
|
43 |
|
910093
|
44 |
//* Check permissions for module |
T |
45 |
$app->auth->check_module_permissions('mail'); |
45f11e
|
46 |
|
965795
|
47 |
|
45f11e
|
48 |
// Loading classes |
T |
49 |
$app->uses('tpl,tform,tform_actions'); |
965795
|
50 |
$app->load('tform_actions'); |
45f11e
|
51 |
|
965795
|
52 |
class page_action extends tform_actions { |
7fe908
|
53 |
|
965795
|
54 |
function onShowNew() { |
T |
55 |
global $app, $conf; |
7fe908
|
56 |
|
965795
|
57 |
// we will check only users, not admins |
T |
58 |
if($_SESSION["s"]["user"]["typ"] == 'user') { |
3cebc3
|
59 |
if(!$app->tform->checkClientLimit('limit_mailrouting')) { |
T |
60 |
$app->error($app->tform->wordbook["limit_mailrouting_txt"]); |
|
61 |
} |
|
62 |
if(!$app->tform->checkResellerLimit('limit_mailrouting')) { |
|
63 |
$app->error('Reseller: '.$app->tform->wordbook["limit_mailrouting_txt"]); |
965795
|
64 |
} |
T |
65 |
} |
7fe908
|
66 |
|
965795
|
67 |
parent::onShowNew(); |
T |
68 |
} |
7fe908
|
69 |
|
0b52bc
|
70 |
function onShowEnd() { |
T |
71 |
global $app, $conf; |
7fe908
|
72 |
|
f63b73
|
73 |
$types = array('smtp' => 'smtp', 'uucp' => 'uucp', 'slow' => 'slow', 'error' => 'error', 'custom' => 'custom', '' => 'null'); |
7fe908
|
74 |
$tmp_parts = explode(":", $this->dataRecord["transport"]); |
MC |
75 |
if(!empty($this->id) && !stristr($this->dataRecord["transport"], ':')) { |
66c3bc
|
76 |
$rec["type"] = 'custom'; |
0b52bc
|
77 |
} else { |
66c3bc
|
78 |
if(empty($this->id) && empty($tmp_parts[0])) { |
T |
79 |
$rec["type"] = 'smtp'; |
|
80 |
} else { |
f63b73
|
81 |
$rec["type"] = $types[$tmp_parts[0]] ? $tmp_parts[0] : 'custom'; |
66c3bc
|
82 |
} |
0b52bc
|
83 |
} |
f63b73
|
84 |
if($rec["type"] == 'custom') { |
SC |
85 |
$dest = $this->dataRecord["transport"]; |
|
86 |
} elseif(!empty($tmp_parts[2])) { |
d89b69
|
87 |
$dest = @$tmp_parts[1].':'.@$tmp_parts[2]; |
96cdd0
|
88 |
} elseif(!empty($tmp_parts[1]) || $this->dataRecord["transport"] == ":") { |
d89b69
|
89 |
$dest = $tmp_parts[1]; |
66c3bc
|
90 |
} else { |
T |
91 |
$dest = $this->dataRecord["transport"]; |
d89b69
|
92 |
} |
7fe908
|
93 |
if(@substr($dest, 0, 1) == '[') { |
0b52bc
|
94 |
$rec["mx"] = 'checked="CHECKED"'; |
7fe908
|
95 |
$rec["destination"] = @str_replace(']', '', @str_replace('[', '', $dest)); |
0b52bc
|
96 |
} else { |
T |
97 |
$rec["mx"] = ''; |
d89b69
|
98 |
$rec["destination"] = @$dest; |
0b52bc
|
99 |
} |
7fe908
|
100 |
|
0b52bc
|
101 |
$type_select = ''; |
T |
102 |
if(is_array($types)) { |
|
103 |
foreach( $types as $key => $val) { |
|
104 |
$selected = ($key == $rec["type"])?'SELECTED':''; |
|
105 |
$type_select .= "<option value='$key' $selected>$val</option>\r\n"; |
|
106 |
} |
|
107 |
} |
|
108 |
$rec["type"] = $type_select; |
|
109 |
$app->tpl->setVar($rec); |
|
110 |
unset($type); |
|
111 |
unset($types); |
7fe908
|
112 |
|
0b52bc
|
113 |
parent::onShowEnd(); |
T |
114 |
} |
67fbfc
|
115 |
|
V |
116 |
function onBeforeUpdate() { |
|
117 |
global $app, $conf; |
|
118 |
|
|
119 |
//* Check if the server has been changed |
|
120 |
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway |
|
121 |
if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
|
122 |
$rec = $app->db->queryOneRecord("SELECT server_id from mail_transport WHERE transport_id = ".$this->id); |
|
123 |
if($rec['server_id'] != $this->dataRecord["server_id"]) { |
|
124 |
//* Add a error message and switch back to old server |
|
125 |
$app->tform->errorMessage .= $app->lng('The Server can not be changed.'); |
|
126 |
$this->dataRecord["server_id"] = $rec['server_id']; |
|
127 |
} |
|
128 |
unset($rec); |
|
129 |
} |
|
130 |
} |
|
131 |
|
965795
|
132 |
function onSubmit() { |
T |
133 |
global $app, $conf; |
7fe908
|
134 |
|
965795
|
135 |
// Check the client limits, if user is not the admin |
T |
136 |
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin |
|
137 |
// Get the limits of the client |
604c0c
|
138 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
cc7a82
|
139 |
$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); |
965795
|
140 |
|
0b52bc
|
141 |
// Check if the user may add another transport. |
965795
|
142 |
if($this->id == 0 && $client["limit_mailrouting"] >= 0) { |
cc7a82
|
143 |
$tmp = $app->db->queryOneRecord("SELECT count(transport_id) as number FROM mail_transport WHERE sys_groupid = ?", $client_group_id); |
965795
|
144 |
if($tmp["number"] >= $client["limit_mailrouting"]) { |
T |
145 |
$app->tform->errorMessage .= $app->tform->wordbook["limit_mailrouting_txt"]."<br>"; |
|
146 |
} |
|
147 |
unset($tmp); |
|
148 |
} |
|
149 |
} // end if user is not admin |
7fe908
|
150 |
|
0b52bc
|
151 |
//* Compose transport field |
T |
152 |
if($this->dataRecord["mx"] == 'y') { |
7fe908
|
153 |
if(stristr($this->dataRecord["destination"], ':')) { |
MC |
154 |
$tmp_parts = explode(":", $this->dataRecord["destination"]); |
d89b69
|
155 |
$transport = '['.$tmp_parts[0].']:'.$tmp_parts[1]; |
T |
156 |
} else { |
|
157 |
$transport = '['.$this->dataRecord["destination"].']'; |
|
158 |
} |
0b52bc
|
159 |
} else { |
T |
160 |
$transport = $this->dataRecord["destination"]; |
|
161 |
} |
7fe908
|
162 |
|
66c3bc
|
163 |
if($this->dataRecord["type"] == 'custom') { |
T |
164 |
$this->dataRecord["transport"] = $transport; |
|
165 |
} else { |
|
166 |
$this->dataRecord["transport"] = $this->dataRecord["type"].':'.$transport; |
|
167 |
} |
7fe908
|
168 |
|
0b52bc
|
169 |
unset($this->dataRecord["type"]); |
T |
170 |
unset($this->dataRecord["mx"]); |
|
171 |
unset($this->dataRecord["destination"]); |
7fe908
|
172 |
|
965795
|
173 |
parent::onSubmit(); |
T |
174 |
} |
7fe908
|
175 |
|
965795
|
176 |
} |
T |
177 |
|
|
178 |
$page = new page_action; |
|
179 |
$page->onLoad(); |
45f11e
|
180 |
|
7fe908
|
181 |
?> |