From e9bb05d44d4672f7dc29a78cc7bb98cebc96abc6 Mon Sep 17 00:00:00 2001
From: Sergio Cambra <sergio@programatica.es>
Date: Wed, 25 Jun 2014 02:46:34 -0400
Subject: [PATCH] change domain owner
---
interface/web/client/templates/domain_edit.htm | 8 +-------
interface/web/client/domain_edit.php | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php
index cca5c2d..735ec0b 100644
--- a/interface/web/client/domain_edit.php
+++ b/interface/web/client/domain_edit.php
@@ -147,9 +147,10 @@
}
else {
/*
- * We edit a existing one, but there is nothing to edit
+ * We edit a existing one, but domain name can't be changed
*/
- $this->dataRecord = $app->tform->getDataRecord($this->id);
+ $oldData = $app->tform->getDataRecord($this->id);
+ $this->dataRecord["domain"] = $oldData["domain"];
}
} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
if ($this->id == 0) {
@@ -199,6 +200,17 @@
}
}
+ function onAfterUpdate() {
+ global $app, $conf;
+
+ // make sure that the record belongs to the client group and not the admin group when admin inserts it
+ // also make sure that the user can not delete domain created by a admin
+ if($_SESSION["s"]["user"]["typ"] == 'admin' && 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);
+ }
+ }
+
}
$page = new page_action;
diff --git a/interface/web/client/templates/domain_edit.htm b/interface/web/client/templates/domain_edit.htm
index aaafa6e..551dbbe 100644
--- a/interface/web/client/templates/domain_edit.htm
+++ b/interface/web/client/templates/domain_edit.htm
@@ -7,22 +7,16 @@
<div class="ctrlHolder">
<label for="domain">{tmpl_var name='domain_txt'}</label>
<tmpl_if name="edit_disabled">
- <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" disabled="disabled" />
+ <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" readonly="readonly" />
<tmpl_else>
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
</tmpl_if>
</div>
<div class="ctrlHolder">
<label for="client_group_id">{tmpl_var name='client_txt'}</label>
- <tmpl_if name="edit_disabled">
- <select name="client_group_id" id="client_group_id" class="selectInput" disabled="disabled">
- {tmpl_var name='client_group_id'}
- </select>
- <tmpl_else>
<select name="client_group_id" id="client_group_id" class="selectInput">
{tmpl_var name='client_group_id'}
</select>
- </tmpl_if>
</div>
</fieldset>
--
Gitblit v1.9.1