From 8a4a057376d8371aa976f3f37b178cd738c4eb59 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Sun, 21 Feb 2016 12:27:11 -0500
Subject: [PATCH] Merge branch 'stable-3.1'

---
 interface/web/sites/shell_user_edit.php |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/interface/web/sites/shell_user_edit.php b/interface/web/sites/shell_user_edit.php
index 1370d22..2b606c2 100644
--- a/interface/web/sites/shell_user_edit.php
+++ b/interface/web/sites/shell_user_edit.php
@@ -95,6 +95,12 @@
 		} else {
 			$app->tpl->setVar("edit_disabled", 0);
 		}
+		
+		if($this->dataRecord['chroot'] == 'jailkit'){
+			$app->tpl->setVar("is_jailkit", true);
+		} else {
+			$app->tpl->setVar("is_jailkit", false);
+		}
 
 		parent::onShowEnd();
 	}
@@ -164,9 +170,13 @@
 		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]);
 
 		$server_id = $app->functions->intval($web["server_id"]);
-		$dir = $app->db->quote($web["document_root"]);
-		$uid = $app->db->quote($web["system_user"]);
-		$gid = $app->db->quote($web["system_group"]);
+		if($this->dataRecord['chroot'] == 'jailkit'){
+			$dir = $app->db->quote($web["document_root"]);
+		} else {
+			$dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
+		}
+		$uid = $web["system_user"];
+		$gid = $web["system_group"];
 		
 		// Check system user and group
 		if($app->functions->is_allowed_user($uid) == false || $app->functions->is_allowed_group($gid) == false) {
@@ -218,7 +228,18 @@
 	function onAfterUpdate() {
 		global $app, $conf;
 
+		if(isset($this->dataRecord['chroot'])){
+			$shell_user = $app->db->queryOneRecord("SELECT * FROM shell_user WHERE shell_user_id = ".$this->id);
+			$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
+			$dir = $shell_user['dir'];
+			if($this->dataRecord['chroot'] == 'jailkit'){
+				$dir = $app->db->quote($web["document_root"]);
+			} else {
+				if($this->oldDataRecord['chroot'] == 'jailkit') $dir = $app->db->quote($web["document_root"].'/home/'.$this->dataRecord['username']);
+			}
 
+			if($dir != $shell_user['dir']) $app->db->query("UPDATE shell_user SET dir = '$dir' WHERE shell_user_id = ".$this->id);
+		}
 	}
 
 }

--
Gitblit v1.9.1