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/client/templates/domain_list.htm | 10 ---
interface/lib/plugins/mail_mail_domain_plugin.inc.php | 22 -------
interface/web/mail/mail_domain_edit.php | 46 +++++++++++++++
interface/lib/lang/en.lng | 1
interface/web/client/domain_list.php | 5 -
interface/lib/lang/es.lng | 1
interface/web/client/domain_edit.php | 40 ++++++++++++
7 files changed, 84 insertions(+), 41 deletions(-)
diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng
index 1d47aeb..ec309d9 100644
--- a/interface/lib/lang/en.lng
+++ b/interface/lib/lang/en.lng
@@ -149,6 +149,5 @@
$wb['strength_5'] = 'Very Strong';
$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}".';
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
-$wb['domain_owner_changed'] = 'You have changed the owner of domain {domain}, please change website and mail domain owner for this domain accordingly.';
?>
diff --git a/interface/lib/lang/es.lng b/interface/lib/lang/es.lng
index e576357..38f6103 100644
--- a/interface/lib/lang/es.lng
+++ b/interface/lib/lang/es.lng
@@ -148,5 +148,4 @@
$wb['weak_password_txt'] = 'La contraseña elegida no cumple las directrices de seguridad. Debe tener al menos {chars} caracteres y una fortaleza \"{strength}\".';
$wb['weak_password_length_txt'] = 'La contraseña elegida no cumple las directrices de seguridad. Debe tener al menos {chars} caracteres.';
$wb['Firewall'] = 'Cortafuegos';
-$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.';
?>
diff --git a/interface/lib/plugins/mail_mail_domain_plugin.inc.php b/interface/lib/plugins/mail_mail_domain_plugin.inc.php
index e7958fe..961e46f 100644
--- a/interface/lib/plugins/mail_mail_domain_plugin.inc.php
+++ b/interface/lib/plugins/mail_mail_domain_plugin.inc.php
@@ -50,28 +50,6 @@
$app->db->query("UPDATE mail_domain SET $updates WHERE domain_id = ".$page_form->id);
}
- // 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
-
//** If the domain name or owner has been changed, change the domain and owner in all mailbox records
if($page_form->oldDataRecord && ($page_form->oldDataRecord['domain'] != $page_form->dataRecord['domain'] ||
(isset($page_form->dataRecord['client_group_id']) && $page_form->oldDataRecord['sys_groupid'] != $page_form->dataRecord['client_group_id']))) {
diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php
index a79ba85..221e8a2 100644
--- a/interface/web/client/domain_edit.php
+++ b/interface/web/client/domain_edit.php
@@ -216,8 +216,44 @@
if(isset($this->dataRecord["client_group_id"])) {
$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
$app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
- $lng_text = $app->lng("domain_owner_changed");
- $_SESSION['show_warning_msg'] = str_replace("{domain}", $this->dataRecord["domain"], $lng_text);
+
+ $data = new tform_actions();
+ $tform = $app->tform;
+ $app->tform = new tform();
+
+ $app->tform->loadFormDef("../dns/form/dns_soa.tform.php");
+ $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin LIKE '".$this->dataRecord['domain'].".'");
+ if ($data->oldDataRecord) {
+ $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+ $data->id = $data->dataRecord['id'];
+ $app->plugin->raiseEvent("dns:dns_soa:on_after_update", $data);
+ }
+
+ $app->tform->loadFormDef("../dns/form/dns_slave.tform.php");
+ $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_slave WHERE origin LIKE '".$this->dataRecord['domain'].".'");
+ if ($data->oldDataRecord) {
+ $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+ $data->id = $data->dataRecord['id'];
+ $app->plugin->raiseEvent("dns:dns_slave:on_after_update", $data);
+ }
+
+ $app->tform->loadFormDef("../mail/form/mail_domain.tform.php");
+ $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '".$this->dataRecord['domain']."'");
+ if ($data->oldDataRecord) {
+ $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+ $data->id = $data->dataRecord['domain_id'];
+ $app->plugin->raiseEvent("mail:mail_domain:on_after_update", $data);
+ }
+
+ $app->tform->loadFormDef("../sites/form/web_vhost_domain.tform.php");
+ $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$this->dataRecord['domain']."'");
+ if ($data->oldDataRecord) {
+ $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+ $data->id = $data->dataRecord['domain_id'];
+ $app->plugin->raiseEvent("sites:web_vhost_domain:on_after_update", $data);
+ }
+
+ $app->tform = $tform;
}
}
diff --git a/interface/web/client/domain_list.php b/interface/web/client/domain_list.php
index 4c6bdf9..622e52a 100644
--- a/interface/web/client/domain_list.php
+++ b/interface/web/client/domain_list.php
@@ -46,11 +46,6 @@
$app->uses('listform_actions');
-if(isset($_SESSION['show_warning_msg'])) {
- $app->tpl->setVar('warning_msg', $_SESSION['show_warning_msg']);
- unset($_SESSION['show_warning_msg']);
-}
-
$app->listform_actions->SQLOrderBy = 'ORDER BY domain.domain';
$app->listform_actions->onLoad();
diff --git a/interface/web/client/templates/domain_list.htm b/interface/web/client/templates/domain_list.htm
index 4bbb09a..3100660 100644
--- a/interface/web/client/templates/domain_list.htm
+++ b/interface/web/client/templates/domain_list.htm
@@ -4,16 +4,6 @@
<div class="panel panel_list_domain">
<div class="pnl_toolsarea">
- <div>
- <tmpl_if name='warning_msg'>
- <div class="systemmonitor-state state-warning">
- <div class="status"></div>
- <div class="statusMsg">
- {tmpl_var name='warning_msg'}
- </div>
- </div>
- </tmpl_if>
- </div>
<fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
<div class="buttons">
<button class="button iconstxt icoAdd" type="button" onclick="loadContent('client/domain_edit.php');">
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