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/domain_edit.php |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 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;

--
Gitblit v1.9.1