From 48f15fe6f5822040f2b4e04c59aef502e153192b Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Tue, 09 Jul 2013 04:18:40 -0400
Subject: [PATCH] - Implemented: Virtual columns (columns that are not in the db but shown in the list) can now be sorted if defined correctly

---
 server/server.php |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/server/server.php b/server/server.php
index 869a621..d728283 100644
--- a/server/server.php
+++ b/server/server.php
@@ -42,8 +42,16 @@
  */
 if ($app->dbmaster->connect_error == NULL) {
 	$server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']);
-
-	$conf['last_datalog_id'] = (int) $server_db_record['updated'];
+	
+	if(!is_array($server_db_record)) die('Unable to load the server configuration from database.');
+	
+	//* Get the number of the last processed datalog_id, if the id of the local server 
+	//* is > then the one of the remote system, then use the local ID as we might not have
+	//* reached the remote server during the last run then.
+	$local_server_db_record = $app->db->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']);
+	$conf['last_datalog_id'] = (int) max($server_db_record['updated'],$local_server_db_record['updated']);
+	unset($local_server_db_record);
+	
 	$conf['mirror_server_id'] = (int) $server_db_record['mirror_server_id'];
 
 	// Load the ini_parser
@@ -144,27 +152,26 @@
 
 	$tmp_num_records = $tmp_rec['number'];
 	unset($tmp_rec);
-
+	
+	//** Load required base-classes
+	$app->uses('modules,plugins,file,services,system');
+	//** Load the modules that are in the mods-enabled folder
+	$app->modules->loadModules('all');
+	//** Load the plugins that are in the plugins-enabled folder
+	$app->plugins->loadPlugins('all');
 	if ($tmp_num_records > 0) {
-		/*
-		  There is something to do, triggert by the database -> do it!
-		 */
-		// Write the Log
 		$app->log("Found $tmp_num_records changes, starting update process.", LOGLEVEL_DEBUG);
-		// Load required base-classes
-		$app->uses('modules,plugins,file,services');
-		// Load the modules that are in the mods-enabled folder
-		$app->modules->loadModules('all');
-		// Load the plugins that are in the plugins-enabled folder
-		$app->plugins->loadPlugins('all');
-		// Go through the sys_datalog table and call the processing functions
-		// from the modules that are hooked on to the table actions
+		//** Go through the sys_datalog table and call the processing functions
+		//** from the modules that are hooked on to the table actions
 		$app->modules->processDatalog();
-		// Restart services that need to after configuration
-		$app->services->processDelayedActions();
-		// All modules are already loaded and processed, so there is NO NEED to load the core once again...
-		$needStartCore = false;
 	}
+	//** Process actions from sys_remoteaction table
+	$app->modules->processActions();
+	//** Restart services that need to after configuration
+	$app->services->processDelayedActions();
+	//** All modules are already loaded and processed, so there is NO NEED to load the core once again...
+	$needStartCore = false;
+	
 } else {
 	if ($app->db->connect->connect_error == NULL) {
 		$app->log('Unable to connect to local server.' . $app->db->errorMessage, LOGLEVEL_WARN);
@@ -186,8 +193,8 @@
 	$app->uses('modules,plugins,file,services');
 	// Load the modules that are im the mods-core folder
 	$app->modules->loadModules('core');
-	// Load the plugins that are in the plugins-core folder
-	$app->plugins->loadPlugins('core');
+	// Load the plugins that are in the f folder
+	//$app->plugins->loadPlugins('core');
 }
 
 

--
Gitblit v1.9.1