From cdda6b98d785f103d9be6643a99a882c0d65b64c Mon Sep 17 00:00:00 2001
From: fantu <fantu@ispconfig3>
Date: Sun, 21 Dec 2008 04:51:07 -0500
Subject: [PATCH] fix parse error

---
 server/plugins-available/shelluser_jailkit_plugin.inc.php |   93 +++++++++++++++++++++++++++++++---------------
 1 files changed, 62 insertions(+), 31 deletions(-)

diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
index 6a35f95..e1ca813 100755
--- a/server/plugins-available/shelluser_jailkit_plugin.inc.php
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -1,7 +1,7 @@
 <?php
 
 /*
-Copyright (c) 2008, Till Brehm, projektfarm Gmbh
+Copyright (c) 2007, Till Brehm, projektfarm Gmbh
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification,
@@ -34,6 +34,19 @@
 	var $plugin_name = 'shelluser_jailkit_plugin';
 	var $class_name = 'shelluser_jailkit_plugin';
 	
+	//* This function is called during ispconfig installation to determine
+	//  if a symlink shall be created for this plugin.
+	function onInstall() {
+		global $conf;
+		
+		if($conf['services']['web'] == true) {
+			return true;
+		} else {
+			return false;
+		}
+		
+	}
+	
 		
 	/*
 	 	This function is called when the plugin is loaded
@@ -57,22 +70,30 @@
 	function insert($event_name,$data) {
 		global $app, $conf;
 		
-		/**
-		 * Setup Jailkit Chroot System If Enabled 
-		 */
-		if ($data['new']['chroot'] == "jailkit")
-		{
-			// load the server configuration options
-			$app->uses("getconf");
-			$this->data = $data;
-			$this->app = $app;
-			$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
-			
-			$this->_setup_jailkit_chroot();
-			$this->_add_jailkit_user();
-		}
+		$app->uses('system');
 		
-		$app->log("Jalikit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
+		if($app->system->is_user($data['new']['username'])) {
+		
+			/**
+		 	* Setup Jailkit Chroot System If Enabled 
+		 	*/
+			if ($data['new']['chroot'] == "jailkit")
+			{
+				// load the server configuration options
+				$app->uses("getconf");
+				$this->data = $data;
+				$this->app = $app;
+				$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+			
+				$this->_setup_jailkit_chroot();
+				$this->_add_jailkit_user();
+			}
+		
+			$app->log("Jalikit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
+			
+		} else {
+			$app->log("Jalikit Plugin -> insert username:".$data['new']['username']." skipped, the user does not exist.",LOGLEVEL_WARN);
+		}
 		
 	}
 	
@@ -80,22 +101,30 @@
 	function update($event_name,$data) {
 		global $app, $conf;
 		
-		/**
-		 * Setup Jailkit Chroot System If Enabled 
-		 */
-		if ($data['new']['chroot'] == "jailkit")
-		{
-			// load the server configuration options
-			$app->uses("getconf");
-			$this->data = $data;
-			$this->app = $app;
-			$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
-			
-			$this->_setup_jailkit_chroot();
-			$this->_add_jailkit_user();
-		}
+		$app->uses('system');
 		
-		$app->log("Jalikit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
+		if($app->system->is_user($data['new']['username'])) {
+		
+			/**
+		 	* Setup Jailkit Chroot System If Enabled 
+		 	*/
+			if ($data['new']['chroot'] == "jailkit")
+			{
+				// load the server configuration options
+				$app->uses("getconf");
+				$this->data = $data;
+				$this->app = $app;
+				$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+			
+				$this->_setup_jailkit_chroot();
+				$this->_add_jailkit_user();
+			}
+		
+			$app->log("Jalikit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
+			
+		} else {
+			$app->log("Jalikit Plugin -> update username:".$data['new']['username']." skipped, the user does not exist.",LOGLEVEL_WARN);
+		}
 		
 	}
 	
@@ -106,6 +135,8 @@
 	function delete($event_name,$data) {
 		global $app, $conf;
 		
+		$app->uses('system');
+		
 		if ($data['old']['chroot'] == "jailkit")
 		{
 			$app->uses("getconf");

--
Gitblit v1.9.1