From 6b15d5f4e18578acb46be3babc46b7a9d3a9299c Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Mon, 14 Dec 2015 10:14:45 -0500
Subject: [PATCH] - added {DOCROOT_CLIENT} to directive placeholders (non-symlink docroot) - made placeholders visible for apache, too - added event raise at formdef loading (on_before_formdef and on_after_formdef) - added possibility to put plugin files into module/lib/plugin.d/ directory

---
 interface/lib/classes/plugin.inc.php |   59 +++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/interface/lib/classes/plugin.inc.php b/interface/lib/classes/plugin.inc.php
index aaaf567..6a6ff70 100644
--- a/interface/lib/classes/plugin.inc.php
+++ b/interface/lib/classes/plugin.inc.php
@@ -43,35 +43,50 @@
 
 
 		if(isset($_SESSION['s']['plugin_cache'])) unset($_SESSION['s']['plugin_cache']);
-
-		$plugins_dir = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
+		
+		$plugin_dirs = array();
+		$plugin_dirs[] = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
+		
+		if(is_dir(ISPC_WEB_PATH)) {
+			if($dh = opendir(ISPC_WEB_PATH)) {
+				while(($file = readdir($dh)) !== false) {
+					if($file !== '.' && $file !== '..' && is_dir($file) && is_dir(ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d';
+				}
+				closedir($dh);
+			}
+		}
+		
 		$_SESSION['s']['plugin_cache'] = array();
 		$tmp_plugins = array();
-
-		if (is_dir($plugins_dir)) {
-			if ($dh = opendir($plugins_dir)) {
-				//** Go trough all files in the plugin dir
-				while (($file = readdir($dh)) !== false) {
-					if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') {
-						$plugin_name = substr($file, 0, -8);
-						$tmp_plugins[$plugin_name] = $file;
+		
+		for($d = 0; $d < count($plugin_dirs); $d++) {
+			$plugins_dir = $plugin_dirs[$d];
+			if (is_dir($plugins_dir)) {
+				if ($dh = opendir($plugins_dir)) {
+					//** Go trough all files in the plugin dir
+					while (($file = readdir($dh)) !== false) {
+						if($file !== '.' && $file !== '..' && substr($file, -8, 8) == '.inc.php') {
+							$plugin_name = substr($file, 0, -8);
+							$tmp_plugins[$plugin_name] = $file;
+						}
 					}
-				}
-				//** sort the plugins by name
-				ksort($tmp_plugins);
+					closedir($dh);
+					//** sort the plugins by name
+					ksort($tmp_plugins);
 
-				//** load the plugins
-				foreach($tmp_plugins as $plugin_name => $file) {
-					include_once $plugins_dir.$file;
-					if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
-					$app->loaded_plugins[$plugin_name] = new $plugin_name;
-					$app->loaded_plugins[$plugin_name]->onLoad();
+					//** load the plugins
+					foreach($tmp_plugins as $plugin_name => $file) {
+						include_once $plugins_dir.$file;
+						if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
+						$app->loaded_plugins[$plugin_name] = new $plugin_name;
+						$app->loaded_plugins[$plugin_name]->onLoad();
+					}
+				} else {
+					$app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
 				}
 			} else {
-				$app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
+				$app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
 			}
-		} else {
-			$app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
 		}
 
 	}

--
Gitblit v1.9.1