From 62a11081e6b3c963f0223abb2aaaab5ff0e5a089 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 27 May 2007 11:20:08 -0400
Subject: [PATCH] Added plugin class for the server daemon and renamed the modules class.

---
 server/lib/classes/modules.inc.php |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/server/lib/classes/modules.inc.php b/server/lib/classes/modules.inc.php
index c0f3776..12b871e 100644
--- a/server/lib/classes/modules.inc.php
+++ b/server/lib/classes/modules.inc.php
@@ -37,8 +37,25 @@
 	*/
 	
 	function loadModules() {
-		global $app;
+		global $app, $conf;
 		
+		$modules_dir = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."mods-enabled".$conf["fs_div"]
+		
+		if (is_dir($modules_dir)) {
+			if ($dh = opendir($dir)) {
+				while (($file = readdir($dh)) !== false) {
+					if($file != '.' && $file != '..') {
+						$module_name = substr($file,0,-8);
+						include_once($modules_dir.$file);
+						$app->log("Loading Module: $module_name",LOGLEVEL_DEBUG);
+						$app->modules[$module_name] = new $module_name;
+						$app->modules[$module_name]->onLoad();
+					}
+				}
+			}
+		} else {
+			$app->log("Modules directory missing: $modules_dir",LOGLEVEL_ERROR);
+		}
 	}
 	
 	/*
@@ -79,7 +96,7 @@
 				$module_name = $hook["module"];
 				$function_name = $hook["function"];
 				// Claa the processing function of the module
-				call_user_method($function_name,$app->$module_name,$table_name,$action,$data);
+				call_user_method($function_name,$app->modules[$module_name],$table_name,$action,$data);
 				unset($module_name);
 				unset($function_name);
 			}

--
Gitblit v1.9.1