From 9f6318becf23b35039198053fbd52d1c43f44b80 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 21 May 2010 09:26:49 +0000 Subject: [PATCH] Updated property handling -Request plInfo for plugin classes only once. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18611 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_configRegistry.inc | 74 +++++++++++++--------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index a196a2ab6..5051d21b6 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -13,9 +13,30 @@ class configRegistry{ // Excludes property values defined in ldap public $ignoreLdapProperties = FALSE; + // Contains all classes with plInfo + public $classesWithInfo = array(); + function __construct($config) { $this->config = &$config; + + // Detect classes that have a plInfo method + global $class_mapping; + foreach ($class_mapping as $cname => $path){ + $cmethods = get_class_methods($cname); + if (is_array($cmethods) && in_array_ics('plInfo',$cmethods)){ + + // Get plugin definitions + $def = call_user_func(array($cname, 'plInfo'));; + + // Register Post Events (postmodfiy,postcreate,postremove,checkhook) + if(count($def)){ + $this->classesWithInfo[$cname] = $def; + } + } + } + + // (Re)Load properties $this->reload(); } @@ -102,36 +123,29 @@ class configRegistry{ $this->status = 'finished'; } - global $class_mapping; - foreach ($class_mapping as $cname => $path){ - $cmethods = get_class_methods($cname); - if (is_array($cmethods) && in_array_ics('plInfo',$cmethods)){ - - // Get plugin definitions - $def = call_user_func(array($cname, 'plInfo'));; - - // Register Post Events (postmodfiy,postcreate,postremove,checkhook) - if(count($def)){ - - $name = $cname; - $name = (isset($def['plShortName'])) ? $def['plShortName'] : $cname; - $name = (isset($def['plDescription'])) ? $def['plDescription'] : $cname; - - $this->classToName[$cname] = $name; - $data = array('name' => 'postcreate','type' => 'command'); - $this->register($cname, $data); - $data = array('name' => 'postremove','type' => 'command'); - $this->register($cname, $data); - $data = array('name' => 'postmodify','type' => 'command'); - $this->register($cname, $data); - $data = array('name' => 'check', 'type' => 'command'); - $this->register($cname, $data); - } - - if(isset($def['plProperties'])){ - foreach($def['plProperties'] as $property){ - $this->register($cname, $property); - } + // Register plugin properties. + foreach ($this->classesWithInfo as $cname => $def){ + + // Detect class name + $name = $cname; + $name = (isset($def['plShortName'])) ? $def['plShortName'] : $cname; + $name = (isset($def['plDescription'])) ? $def['plDescription'] : $cname; + + // Register post events + $this->classToName[$cname] = $name; + $data = array('name' => 'postcreate','type' => 'command'); + $this->register($cname, $data); + $data = array('name' => 'postremove','type' => 'command'); + $this->register($cname, $data); + $data = array('name' => 'postmodify','type' => 'command'); + $this->register($cname, $data); + $data = array('name' => 'check', 'type' => 'command'); + $this->register($cname, $data); + + // Register properties + if(isset($def['plProperties'])){ + foreach($def['plProperties'] as $property){ + $this->register($cname, $property); } } } -- 2.30.2