From cb1aa5f1b8ad3bd0d9584ed026f46fda0fb4a7f0 Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Wed, 22 Aug 2012 12:19:06 -0400
Subject: [PATCH] - Added remoting functions for vhost subdomains - Added plugin for vhost subdomains to catch onafterinsert/update

---
 interface/lib/classes/remoting.inc.php |   73 +++++++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index c498fcf..2eff849 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -1341,11 +1341,11 @@
 		}
 		
 		$data = $app->db->queryOneRecord("SELECT server_id FROM ftp_user WHERE username = '".$app->db->quote($ftp_user)."'");
-		file_put_contents('/tmp/test.txt', serialize($data));
+		//file_put_contents('/tmp/test.txt', serialize($data));
         if(!isset($data['server_id'])) return false;
 		
         $server = $this->server_get($session_id, $data['server_id'], 'server');
-        file_put_contents('/tmp/test2.txt', serialize($server));
+        //file_put_contents('/tmp/test2.txt', serialize($server));
         
 		return $server;
 	}
@@ -1474,6 +1474,75 @@
 		return $affected_rows;
 	}
 	
+	// ----------------------------------------------------------------------------------------------------------
+	
+	//* Get record details
+	public function sites_web_vhost_subdomain_get($session_id, $primary_id)
+    {
+		global $app;
+		
+		if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) {
+			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+			return false;
+		}
+		$app->uses('remoting_lib');
+		$app->remoting_lib->loadFormDef('../sites/form/web_vhost_subdomain.tform.php');
+		return $app->remoting_lib->getDataRecord($primary_id);
+	}
+	
+	//* Add a record
+	public function sites_web_vhost_subdomain_add($session_id, $client_id, $params)
+	{
+		global $app;
+		if(!$this->checkPerm($session_id, 'sites_web_subdomain_add')) {
+			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+			return false;
+		}
+		
+		//* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin
+		if($params['document_root'] == '') $params['document_root'] = '-';
+		if($params['system_user'] == '') $params['system_user'] = '-';
+		if($params['system_group'] == '') $params['system_group'] = '-';
+		
+		//* Set a few defaults for nginx servers
+		if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
+		if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
+		if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
+		if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
+		
+		$domain_id = $this->insertQuery('../sites/form/web_vhost_subdomain.tform.php',$client_id,$params, 'sites:web_vhost_subdomain:on_after_insert');
+        return $domain_id;
+    }
+	
+	//* Update a record
+	public function sites_web_vhost_subdomain_update($session_id, $client_id, $primary_id, $params)
+    {
+		if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) {
+			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+			return false;
+		}
+		
+		//* Set a few defaults for nginx servers
+		if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
+		if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
+		if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
+		if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
+		
+		$affected_rows = $this->updateQuery('../sites/form/web_vhost_subdomain.tform.php',$client_id,$primary_id,$params, 'sites:web_vhost_subdomain:on_after_insert');
+		return $affected_rows;
+	}
+	
+	//* Delete a record
+	public function sites_web_vhost_subdomain_delete($session_id, $primary_id)
+    {
+		if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) {
+			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+			return false;
+		}
+		$affected_rows = $this->deleteQuery('../sites/form/web_vhost_subdomain.tform.php',$primary_id);
+		return $affected_rows;
+	}
+	
 	// -----------------------------------------------------------------------------------------------
 	
 	//* Get record details

--
Gitblit v1.9.1