From dbf29d9979fe779e8801685c0132dbee681e15cf Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Tue, 01 Jul 2014 12:39:22 -0400
Subject: [PATCH] Merge branch 'master' of http://git.ispconfig.org/Cambra/ispconfig3 into Cambra/ispconfig3-master

---
 interface/web/client/templates/domain_list.htm |   10 ++++++++++
 interface/lib/classes/auth.inc.php             |    2 +-
 interface/web/client/templates/domain_edit.htm |    8 +-------
 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           |   30 ++++++++++++++++++++++++++----
 7 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php
index 706dd04..070662f 100644
--- a/interface/lib/classes/auth.inc.php
+++ b/interface/lib/classes/auth.inc.php
@@ -50,7 +50,7 @@
 
 		$userid = $app->functions->intval($userid);
 		$client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
-		if($client['limit_client'] > 0) {
+		if($client['limit_client'] != 0) {
 			return true;
 		} else {
 			return false;
diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng
index ec309d9..1d47aeb 100644
--- a/interface/lib/lang/en.lng
+++ b/interface/lib/lang/en.lng
@@ -149,5 +149,6 @@
 $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 38f6103..e576357 100644
--- a/interface/lib/lang/es.lng
+++ b/interface/lib/lang/es.lng
@@ -148,4 +148,5 @@
 $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/web/client/domain_edit.php b/interface/web/client/domain_edit.php
index cca5c2d..a79ba85 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) {
@@ -165,9 +166,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"];
 			}
 		} else {
 			if($this->id > 0) {
@@ -199,6 +201,26 @@
 		}
 	}
 
+	function onAfterUpdate() {
+		global $app, $conf;
+
+		if($_SESSION["s"]["user"]["typ"] != 'admin' && isset($this->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
+			$client = $app->db->queryOneRecord("SELECT client.client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+			$group = $app->db->queryOneRecord("SELECT sys_group.groupid FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." AND sys_group.groupid = ".$this->dataRecord["client_group_id"]." ORDER BY client.company_name, client.contact_name, sys_group.name";
+			$this->dataRecord["client_group_id"] = $group["groupid"];
+                }
+
+		// 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(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);
+		}
+	}
+
 }
 
 $page = new page_action;
diff --git a/interface/web/client/domain_list.php b/interface/web/client/domain_list.php
index 622e52a..4c6bdf9 100644
--- a/interface/web/client/domain_list.php
+++ b/interface/web/client/domain_list.php
@@ -46,6 +46,11 @@
 
 $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_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>
 
diff --git a/interface/web/client/templates/domain_list.htm b/interface/web/client/templates/domain_list.htm
index 3100660..4bbb09a 100644
--- a/interface/web/client/templates/domain_list.htm
+++ b/interface/web/client/templates/domain_list.htm
@@ -4,6 +4,16 @@
 <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');">

--
Gitblit v1.9.1