From e1f1c9511c9f6690c01c14ead7a9b2c80cdb7a7a Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 11 May 2010 05:29:35 +0000 Subject: [PATCH] Updated get_ou it receives values from the config registry now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18300 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/functions.inc | 84 ++++++++++----------------------- 1 file changed, 25 insertions(+), 59 deletions(-) diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index b66953840..2a27f7a66 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -1400,70 +1400,36 @@ function get_sub_department($value) * $ldap->cd($base); * \endcode * */ -function get_ou($name) +function get_ou($class,$name) { - global $config; + global $config; - $map = array( - "roleRDN" => "ou=roles,", - "ogroupRDN" => "ou=groups,", - "applicationRDN" => "ou=apps,", - "systemRDN" => "ou=systems,", - "serverRDN" => "ou=servers,ou=systems,", - "terminalRDN" => "ou=terminals,ou=systems,", - "workstationRDN" => "ou=workstations,ou=systems,", - "printerRDN" => "ou=printers,ou=systems,", - "phoneRDN" => "ou=phones,ou=systems,", - "componentRDN" => "ou=netdevices,ou=systems,", - "sambaMachineAccountRDN" => "ou=winstation,", - - "faxBlocklistRDN" => "ou=gofax,ou=systems,", - "systemIncomingRDN" => "ou=incoming,", - "aclRoleRDN" => "ou=aclroles,", - "phoneMacroRDN" => "ou=macros,ou=asterisk,ou=configs,ou=systems,", - "phoneConferenceRDN" => "ou=conferences,ou=asterisk,ou=configs,ou=systems,", - - "faiBaseRDN" => "ou=fai,ou=configs,ou=systems,", - "faiScriptRDN" => "ou=scripts,", - "faiHookRDN" => "ou=hooks,", - "faiTemplateRDN" => "ou=templates,", - "faiVariableRDN" => "ou=variables,", - "faiProfileRDN" => "ou=profiles,", - "faiPackageRDN" => "ou=packages,", - "faiPartitionRDN"=> "ou=disk,", - - "sudoRDN" => "ou=sudoers,", - - "deviceRDN" => "ou=devices,", - "mimetypeRDN" => "ou=mime,"); - - /* Preset ou... */ - if ($config->get_cfg_value("core",$name, "_not_set_") != "_not_set_"){ - $ou= $config->get_cfg_value("core",$name); - } elseif (isset($map[$name])) { - $ou = $map[$name]; - return($ou); - } else { - trigger_error("No department mapping found for type ".$name); - return ""; - } - - if ($ou != ""){ - if (!preg_match('/^[^=]+=[^=]+/', $ou)){ - $ou = @LDAP::convert("ou=$ou"); - } else { - $ou = @LDAP::convert("$ou"); + if(!$config->configRegistry->propertyExists($class,$name)){ + trigger_error("No department mapping found for type ".$name); + return ""; } - if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){ - return($ou); - }else{ - return("$ou,"); + $ou = $config->configRegistry->getPropertyValue($class,$name); + if ($ou != ""){ + if (!preg_match('/^[^=]+=[^=]+/', $ou)){ + $ou = @LDAP::convert("ou=$ou"); + } else { + $ou = @LDAP::convert("$ou"); + } + + if(preg_match("/".preg_quote($config->current['BASE'], '/')."$/",$ou)){ + return($ou); + }else{ + if(!preg_match("/,$/", $ou)){ + return("$ou,"); + }else{ + return($ou); + } + } + + } else { + return ""; } - - } else { - return ""; - } } -- 2.30.2