Skip to content

Commit 03aed0a

Browse files
committed
change mail, site and dns zone when owner is changed on domains module
1 parent 596f0b8 commit 03aed0a

File tree

7 files changed

+84
-41
lines changed

7 files changed

+84
-41
lines changed

interface/lib/lang/en.lng

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,5 @@ $wb['strength_4'] = 'Strong';
149149
$wb['strength_5'] = 'Very Strong';
150150
$wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of "{strength}".';
151151
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
152-
$wb['domain_owner_changed'] = 'You have changed the owner of domain {domain}, please change website and mail domain owner for this domain accordingly.';
153152

154153
?>

interface/lib/lang/es.lng

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,4 @@ $wb['strength_5'] = 'Muy fuerte';
148148
$wb['weak_password_txt'] = 'La contraseña elegida no cumple las directrices de seguridad. Debe tener al menos {chars} caracteres y una fortaleza \"{strength}\".';
149149
$wb['weak_password_length_txt'] = 'La contraseña elegida no cumple las directrices de seguridad. Debe tener al menos {chars} caracteres.';
150150
$wb['Firewall'] = 'Cortafuegos';
151-
$wb['domain_owner_changed'] = 'Has cambiado el propietario del dominio {domain}, por favor cambia también el propietario del sitio web y dominio de correo de este dominio.';
152151
?>

interface/lib/plugins/mail_mail_domain_plugin.inc.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,6 @@ function mail_mail_domain_edit($event_name, $page_form) {
5050
$app->db->query("UPDATE mail_domain SET $updates WHERE domain_id = ".$page_form->id);
5151
}
5252

53-
// Spamfilter policy
54-
$policy_id = $app->functions->intval($page_form->dataRecord["policy"]);
55-
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->dataRecord["domain"])."'");
56-
if($policy_id > 0) {
57-
if($tmp_user["id"] > 0) {
58-
// There is already a record that we will update
59-
$app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
60-
} else {
61-
$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$page_form->id);
62-
// We create a new record
63-
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
64-
VALUES (".$_SESSION["s"]["user"]["userid"].", ".$app->functions->intval($tmp_domain["sys_groupid"]).", 'riud', 'riud', '', ".$app->functions->intval($page_form->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($page_form->dataRecord["domain"])."', '@".$app->db->quote($page_form->dataRecord["domain"])."', 'Y')";
65-
$app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
66-
unset($tmp_domain);
67-
}
68-
} else {
69-
if($tmp_user["id"] > 0) {
70-
// There is already a record but the user shall have no policy, so we delete it
71-
$app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]);
72-
}
73-
} // endif spamfilter policy
74-
7553
//** If the domain name or owner has been changed, change the domain and owner in all mailbox records
7654
if($page_form->oldDataRecord && ($page_form->oldDataRecord['domain'] != $page_form->dataRecord['domain'] ||
7755
(isset($page_form->dataRecord['client_group_id']) && $page_form->oldDataRecord['sys_groupid'] != $page_form->dataRecord['client_group_id']))) {

interface/web/client/domain_edit.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,44 @@ function onAfterUpdate() {
216216
if(isset($this->dataRecord["client_group_id"])) {
217217
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
218218
$app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
219-
$lng_text = $app->lng("domain_owner_changed");
220-
$_SESSION['show_warning_msg'] = str_replace("{domain}", $this->dataRecord["domain"], $lng_text);
219+
220+
$data = new tform_actions();
221+
$tform = $app->tform;
222+
$app->tform = new tform();
223+
224+
$app->tform->loadFormDef("../dns/form/dns_soa.tform.php");
225+
$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin LIKE '".$this->dataRecord['domain'].".'");
226+
if ($data->oldDataRecord) {
227+
$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
228+
$data->id = $data->dataRecord['id'];
229+
$app->plugin->raiseEvent("dns:dns_soa:on_after_update", $data);
230+
}
231+
232+
$app->tform->loadFormDef("../dns/form/dns_slave.tform.php");
233+
$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_slave WHERE origin LIKE '".$this->dataRecord['domain'].".'");
234+
if ($data->oldDataRecord) {
235+
$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
236+
$data->id = $data->dataRecord['id'];
237+
$app->plugin->raiseEvent("dns:dns_slave:on_after_update", $data);
238+
}
239+
240+
$app->tform->loadFormDef("../mail/form/mail_domain.tform.php");
241+
$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '".$this->dataRecord['domain']."'");
242+
if ($data->oldDataRecord) {
243+
$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
244+
$data->id = $data->dataRecord['domain_id'];
245+
$app->plugin->raiseEvent("mail:mail_domain:on_after_update", $data);
246+
}
247+
248+
$app->tform->loadFormDef("../sites/form/web_vhost_domain.tform.php");
249+
$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$this->dataRecord['domain']."'");
250+
if ($data->oldDataRecord) {
251+
$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
252+
$data->id = $data->dataRecord['domain_id'];
253+
$app->plugin->raiseEvent("sites:web_vhost_domain:on_after_update", $data);
254+
}
255+
256+
$app->tform = $tform;
221257
}
222258
}
223259

interface/web/client/domain_list.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646

4747
$app->uses('listform_actions');
4848

49-
if(isset($_SESSION['show_warning_msg'])) {
50-
$app->tpl->setVar('warning_msg', $_SESSION['show_warning_msg']);
51-
unset($_SESSION['show_warning_msg']);
52-
}
53-
5449
$app->listform_actions->SQLOrderBy = 'ORDER BY domain.domain';
5550
$app->listform_actions->onLoad();
5651

interface/web/client/templates/domain_list.htm

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ <h2><tmpl_var name="list_head_txt"></h2>
44
<div class="panel panel_list_domain">
55

66
<div class="pnl_toolsarea">
7-
<div>
8-
<tmpl_if name='warning_msg'>
9-
<div class="systemmonitor-state state-warning">
10-
<div class="status"></div>
11-
<div class="statusMsg">
12-
{tmpl_var name='warning_msg'}
13-
</div>
14-
</div>
15-
</tmpl_if>
16-
</div>
177
<fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
188
<div class="buttons">
199
<button class="button iconstxt icoAdd" type="button" onclick="loadContent('client/domain_edit.php');">

interface/web/mail/mail_domain_edit.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,27 @@ function onSubmit() {
255255
parent::onSubmit();
256256
}
257257

258+
function onAfterInsert() {
259+
global $app, $conf;
260+
261+
// Spamfilter policy
262+
$policy_id = $app->functions->intval($page_form->dataRecord["policy"]);
263+
if($policy_id > 0) {
264+
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->dataRecord["domain"])."'");
265+
if($tmp_user["id"] > 0) {
266+
// There is already a record that we will update
267+
$app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
268+
} else {
269+
$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$page_form->id);
270+
// We create a new record
271+
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
272+
VALUES (".$_SESSION["s"]["user"]["userid"].", ".$app->functions->intval($tmp_domain["sys_groupid"]).", 'riud', 'riud', '', ".$app->functions->intval($page_form->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($page_form->dataRecord["domain"])."', '@".$app->db->quote($page_form->dataRecord["domain"])."', 'Y')";
273+
$app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
274+
unset($tmp_domain);
275+
}
276+
} // endif spamfilter policy
277+
}
278+
258279
function onBeforeUpdate() {
259280
global $app, $conf;
260281

@@ -281,6 +302,31 @@ function onBeforeUpdate() {
281302
}
282303
}
283304

305+
function onAfterUpdate() {
306+
global $app, $conf;
307+
308+
// Spamfilter policy
309+
$policy_id = $app->functions->intval($page_form->dataRecord["policy"]);
310+
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->dataRecord["domain"])."'");
311+
if($policy_id > 0) {
312+
if($tmp_user["id"] > 0) {
313+
// There is already a record that we will update
314+
$app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
315+
} else {
316+
$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$page_form->id);
317+
// We create a new record
318+
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
319+
VALUES (".$_SESSION["s"]["user"]["userid"].", ".$app->functions->intval($tmp_domain["sys_groupid"]).", 'riud', 'riud', '', ".$app->functions->intval($page_form->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($page_form->dataRecord["domain"])."', '@".$app->db->quote($page_form->dataRecord["domain"])."', 'Y')";
320+
$app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
321+
unset($tmp_domain);
322+
}
323+
} else {
324+
if($tmp_user["id"] > 0) {
325+
// There is already a record but the user shall have no policy, so we delete it
326+
$app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]);
327+
}
328+
} // endif spamfilter policy
329+
}
284330
}
285331

286332
$page = new page_action;

0 commit comments

Comments
 (0)