From f5a365f5ce54675a7b990f4a6cfa02485f1926cc Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 25 Jun 2008 08:01:11 +0000 Subject: [PATCH] Updated config object and convert_department dn. -Support l,dc,o,ou aso. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11432 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_config.inc | 27 +++++++++------------------ gosa-core/include/functions.inc | 16 ++++------------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/gosa-core/include/class_config.inc b/gosa-core/include/class_config.inc index db862c0f8..e800b61a9 100644 --- a/gosa-core/include/class_config.inc +++ b/gosa-core/include/class_config.inc @@ -672,31 +672,22 @@ class config { } } - /* remove base from dn */ - $val2 = str_replace($base,"",$val); - - /* Get every single ou */ - $str = preg_replace("/ou=/","|ou=",$val2); - $elements = array_reverse(split("\|",$str)); - - /* Save last array position */ - $last = &$arr; - - /* Get array depth */ - $cnt = count($elements); + /* Split dn into single department pieces. + */ + $elements = array_reverse(split(",",preg_replace("/".normalizePreg($base)."$/","",$val))); /* Add last ou element of current dn to our array */ + $last = &$arr; foreach($elements as $key => $ele){ - /* skip enpty */ + /* skip empty */ if(empty($ele)) continue; /* Extract department name */ - $elestr = preg_replace("/^ou=/","", $ele); - $elestr = preg_replace("/,$/","",$elestr); + $elestr = trim(preg_replace("/^[^=]*+=/","", $ele),","); /* Add to array */ - if($key == ($cnt-2)){ + if($key == (count($elements)-1)){ $last[$elestr]['ENTRY'] = $val; } @@ -708,13 +699,13 @@ class config { /* Add base entry */ $ret["/"]["ENTRY"] = $base; $ret["/"]["SUB"] = $arr; - $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size); } /* Creates display friendly output from make_idepartments */ - function generateDepartmentArray($arr,$depth = -1,$max_size){ + function generateDepartmentArray($arr,$depth = -1,$max_size) + { $ret = array(); $depth ++; diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 102bc4f65..e9444fbf3 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -1108,7 +1108,6 @@ function &get_smarty() function convert_department_dn($dn, $base = NULL) { global $config; - $dep= ""; if($base == NULL){ $base = $config->current['BASE']; @@ -1119,21 +1118,14 @@ function convert_department_dn($dn, $base = NULL) $dn = preg_replace("/".normalizePreg($base)."$/i","",$dn); if(empty($dn)) return("/"); - foreach (split(',', $dn) as $rdn){ - - /* We're only interested in organizational units... */ - if (substr($rdn,0,3) == 'ou='){ - $dep= substr($rdn,3)."/$dep"; - } - /* ... and location objects */ - if (substr($rdn,0,2) == 'l='){ - $dep= substr($rdn,2)."/$dep"; - } + $dep= ""; + foreach (split(',', $dn) as $rdn){ + $dep = preg_replace("/^[^=]+=/","",$rdn)."/".$dep; } /* Return and remove accidently trailing slashes */ - return rtrim($dep, "/"); + return(trim($dep, "/")); } -- 2.30.2