Commit 03aed0af authored by Sergio's avatar Sergio
Browse files

change mail, site and dns zone when owner is changed on domains module

parent 596f0b87
......@@ -149,6 +149,5 @@ $wb['strength_4'] = 'Strong';
$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.';
?>
......@@ -148,5 +148,4 @@ $wb['strength_5'] = 'Muy fuerte';
$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.';
?>
......@@ -50,28 +50,6 @@ class mail_mail_domain_plugin {
$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']))) {
......
......@@ -216,8 +216,44 @@ class page_action extends tform_actions {
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;
}
}
......
......@@ -46,11 +46,6 @@ $app->auth->check_module_permissions('client');
$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();
......
......@@ -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');">
......
......@@ -255,6 +255,27 @@ class page_action extends tform_actions {
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 @@ class page_action extends tform_actions {
}
}
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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment