From 03aed0af9e6066b0c3b3468b0fabe78ff63666ef Mon Sep 17 00:00:00 2001 From: Sergio Cambra <sergio@programatica.es> Date: Fri, 04 Jul 2014 11:53:59 -0400 Subject: [PATCH] change mail, site and dns zone when owner is changed on domains module --- interface/web/mail/mail_domain_edit.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php index 81b6f2a..d7c8d7c 100644 --- a/interface/web/mail/mail_domain_edit.php +++ b/interface/web/mail/mail_domain_edit.php @@ -255,6 +255,27 @@ parent::onSubmit(); } + function onAfterInsert() { + global $app, $conf; + + // Spamfilter policy + $policy_id = $app->functions->intval($page_form->dataRecord["policy"]); + if($policy_id > 0) { + $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->dataRecord["domain"])."'"); + if($tmp_user["id"] > 0) { + // There is already a record that we will update + $app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]); + } else { + $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$page_form->id); + // We create a new record + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) + 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')"; + $app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); + unset($tmp_domain); + } + } // endif spamfilter policy + } + function onBeforeUpdate() { global $app, $conf; @@ -281,6 +302,31 @@ } } + function onAfterUpdate() { + global $app, $conf; + + // Spamfilter policy + $policy_id = $app->functions->intval($page_form->dataRecord["policy"]); + $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->dataRecord["domain"])."'"); + if($policy_id > 0) { + if($tmp_user["id"] > 0) { + // There is already a record that we will update + $app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]); + } else { + $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$page_form->id); + // We create a new record + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) + 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')"; + $app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); + unset($tmp_domain); + } + } else { + if($tmp_user["id"] > 0) { + // There is already a record but the user shall have no policy, so we delete it + $app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]); + } + } // endif spamfilter policy + } } $page = new page_action; -- Gitblit v1.9.1