summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f056a9)
raw | patch | inline | side by side (parent: 8f056a9)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 13 Jan 2006 13:20:02 +0000 (13:20 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 13 Jan 2006 13:20:02 +0000 (13:20 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2478 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_config.inc | patch | blob | history |
index 84f9b176406c77c57cee97603b4e32ecd22916fe..505e48563419643602371fb225a97313a773d4e0 100644 (file)
--- a/include/class_config.inc
+++ b/include/class_config.inc
function make_idepartments($max_size= 28)
{
+ global $config;
+ $base = $config->current['BASE'];
+
+ $arr = array();
+
$this->idepartments= array();
foreach ($this->departments as $key => $val){
- if (strlen($key) > $max_size){
- $this->idepartments[$val]= substr($key, 0, $max_size/2 - 3)."...".substr($key, -$max_size/2);
- } else {
- $this->idepartments[$val]= $key;
+
+ $val2 = str_replace($base,"",$val);
+
+ $str = preg_replace("/ou=/","|ou=",$val2);
+ $elements = array_reverse(split("\|",$str));
+
+ $last = &$arr;
+ $cnt = count($elements);
+ foreach($elements as $key => $ele){
+
+ if(empty($ele)) continue;
+ $elestr = preg_replace("/^ou=/","", $ele);
+ $elestr = preg_replace("/,$/","",$elestr);
+ if($key == ($cnt-2)){
+ $last[$elestr]['ENTRY'] = $val;
+ }
+ $last = &$last[$elestr]['SUB'];
}
}
-
- asort($this->idepartments);
+ $ret["/"]["ENTRY"] = $base;
+ $ret["/"]["SUB"] = $arr;
+
+ $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size);
}
+ function generateDepartmentArray($arr,$depth = -1,$max_size){
+ $ret = array();
+ $depth ++;
+
+ foreach($arr as $name => $entries){
+
+ if(count($entries['SUB'])==0){
+ unset($entries['SUB']);
+ }
+ if(strlen($name)> $max_size){
+ $name = substr($name,0,($max_size-3))." ...";
+ }
+
+ if(isset($entries['ENTRY'])){
+ $a = "";
+ for($i = 0 ; $i < $depth ; $i ++){
+ $a.=" ";
+ }
+ $ret[$entries['ENTRY']]=$a." ".$name;
+ }
+ /* For debugging
+ if(isset($entries['ENTRY'])){
+ $a = "";
+ for($i = 0 ; $i < $depth ; $i ++){
+ $a.=" |";
+ }
+
+ if(!isset($entries['SUB'])){
+ $ret[$entries['ENTRY']]=$a."- ".$name;
+ }else{
+ $ret[$entries['ENTRY']]=$a."#"." ".$name;
+ }
+ }
+ */
+ if(isset($entries['SUB'])){
+ $ret = array_merge($ret,$this->generateDepartmentArray($entries['SUB'],$depth,$max_size));
+ }
+ }
+
+ return($ret);
+ }
+
/* This function returns all available Shares defined in this ldap
* There are two ways to call this function, if listboxEntry is true
* only name and path are attached to the array, in it is false, the whole