commit | author | age
|
b0711a
|
1 |
<?php |
T |
2 |
/* |
|
3 |
Copyright (c) 2012, Till Brehm, ISPConfig UG |
|
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_user_spamfilter.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'; |
b0711a
|
43 |
|
T |
44 |
//* Check permissions for module |
|
45 |
$app->auth->check_module_permissions('mailuser'); |
|
46 |
|
|
47 |
// Loading classes |
|
48 |
$app->uses('tpl,tform,tform_actions'); |
|
49 |
$app->load('tform_actions'); |
|
50 |
|
|
51 |
class page_action extends tform_actions { |
7fe908
|
52 |
|
b0711a
|
53 |
function onShow() { |
f798aa
|
54 |
global $app; |
FT |
55 |
|
604c0c
|
56 |
$this->id = $app->functions->intval($_SESSION['s']['user']['mailuser_id']); |
7fe908
|
57 |
|
b0711a
|
58 |
parent::onShow(); |
7fe908
|
59 |
|
b0711a
|
60 |
} |
7fe908
|
61 |
|
b0711a
|
62 |
function onSubmit() { |
T |
63 |
global $app; |
7fe908
|
64 |
|
604c0c
|
65 |
$this->id = $app->functions->intval($_SESSION['s']['user']['mailuser_id']); |
7fe908
|
66 |
|
b0711a
|
67 |
parent::onSubmit(); |
7fe908
|
68 |
|
b0711a
|
69 |
} |
7fe908
|
70 |
|
b0711a
|
71 |
function onAfterUpdate() { |
T |
72 |
global $app, $conf; |
7fe908
|
73 |
|
b0711a
|
74 |
$rec = $app->tform->getDataRecord($this->id); |
7fe908
|
75 |
$email_parts = explode('@', $rec['email']); |
b0711a
|
76 |
$email_domain = $email_parts[1]; |
cc7a82
|
77 |
$domain = $app->db->queryOneRecord("SELECT sys_userid, sys_groupid, server_id FROM mail_domain WHERE domain = ?", $email_domain); |
7fe908
|
78 |
|
b0711a
|
79 |
// Spamfilter policy |
65ea2e
|
80 |
$policy_id = $app->functions->intval($this->dataRecord["policy"]); |
cc7a82
|
81 |
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = ?", $rec["email"]); |
b0711a
|
82 |
if($policy_id > 0) { |
T |
83 |
if($tmp_user["id"] > 0) { |
|
84 |
// There is already a record that we will update |
3a11d2
|
85 |
$app->db->datalogUpdate('spamfilter_users', array("policy_id" => $policy_id), 'id', $tmp_user["id"]); |
b0711a
|
86 |
} else { |
T |
87 |
// We create a new record |
3a11d2
|
88 |
$insert_data = array( |
MC |
89 |
"sys_userid" => $domain["sys_userid"], |
|
90 |
"sys_groupid" => $domain["sys_groupid"], |
|
91 |
"sys_perm_user" => 'riud', |
|
92 |
"sys_perm_group" => 'riud', |
|
93 |
"sys_perm_other" => '', |
|
94 |
"server_id" => $domain["server_id"], |
|
95 |
"priority" => 10, |
|
96 |
"policy_id" => $policy_id, |
|
97 |
"email" => $rec["email"], |
|
98 |
"fullname" => $rec["email"], |
|
99 |
"local" => 'Y' |
|
100 |
); |
b0711a
|
101 |
$app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); |
T |
102 |
} |
|
103 |
}else { |
|
104 |
if($tmp_user["id"] > 0) { |
|
105 |
// There is already a record but the user shall have no policy, so we delete it |
|
106 |
$app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]); |
|
107 |
} |
|
108 |
} // endif spamfilter policy |
|
109 |
} |
7fe908
|
110 |
|
b0711a
|
111 |
function onShowEnd() { |
T |
112 |
global $app, $conf; |
7fe908
|
113 |
|
b0711a
|
114 |
$rec = $app->tform->getDataRecord($this->id); |
T |
115 |
$app->tpl->setVar("email", $rec['email']); |
7fe908
|
116 |
|
b0711a
|
117 |
// Get the spamfilter policys for the user |
cc7a82
|
118 |
$tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = ?", $rec['email']); |
b0711a
|
119 |
$sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r'); |
T |
120 |
$policys = $app->db->queryAllRecords($sql); |
|
121 |
$policy_select = "<option value='0'>".$app->tform->lng("no_policy")."</option>"; |
|
122 |
if(is_array($policys)) { |
|
123 |
foreach( $policys as $p) { |
|
124 |
$selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':''; |
|
125 |
$policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n"; |
|
126 |
} |
|
127 |
} |
7fe908
|
128 |
$app->tpl->setVar("policy", $policy_select); |
b0711a
|
129 |
unset($policys); |
T |
130 |
unset($policy_select); |
|
131 |
unset($tmp_user); |
7fe908
|
132 |
|
b0711a
|
133 |
parent::onShowEnd(); |
T |
134 |
} |
7fe908
|
135 |
|
MC |
136 |
|
b0711a
|
137 |
} |
T |
138 |
|
|
139 |
$app->tform_actions = new page_action; |
|
140 |
$app->tform_actions->onLoad(); |
|
141 |
|
|
142 |
?> |