From: cajus Date: Thu, 13 Apr 2006 14:02:48 +0000 (+0000) Subject: A set of multibyte string fixes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=023f157c39e2350050f38e1743ec6363eab0ab80;p=gosa.git A set of multibyte string fixes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3044 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_config.inc b/include/class_config.inc index 4b26e2607..0a8e35a42 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -468,8 +468,7 @@ class config { $this->idepartments= array(); - /* Create multidimensional array, with all departments. - */ + /* Create multidimensional array, with all departments. */ foreach ($this->departments as $key => $val){ /* remove base from dn */ @@ -512,59 +511,59 @@ class config { $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size); } - /* Creates display friendly output from make_idepartments */ - function generateDepartmentArray($arr,$depth = -1,$max_size){ - $ret = array(); - $depth ++; - - /* Walk through array */ - foreach($arr as $name => $entries){ - - /* If this department is the last in the current tree position - * remove it, to avoid generating output for it */ - if(count($entries['SUB'])==0){ - unset($entries['SUB']); - } - - /* Fix name, if it contains a replace tag */ - $name= @ldap::fix($name); - - /* Check if current name is too long, then cut it */ - if(strlen($name)> $max_size){ - $name = substr($name,0,($max_size-3))." ..."; - } - - /* Append the name to the list */ - 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; - } - } - */ - - /* recursive add of subdepartments */ - if(isset($entries['SUB'])){ - $ret = array_merge($ret,$this->generateDepartmentArray($entries['SUB'],$depth,$max_size)); - } - } - - return($ret); - } + /* Creates display friendly output from make_idepartments */ + function generateDepartmentArray($arr,$depth = -1,$max_size){ + $ret = array(); + $depth ++; + + /* Walk through array */ + foreach($arr as $name => $entries){ + + /* If this department is the last in the current tree position + * remove it, to avoid generating output for it */ + if(count($entries['SUB'])==0){ + unset($entries['SUB']); + } + + /* Fix name, if it contains a replace tag */ + $name= @ldap::fix($name); + + /* Check if current name is too long, then cut it */ + if(mb_strlen($name, 'UTF-8')> $max_size){ + $name = mb_substr($name,0,($max_size-3), 'UTF-8')." ..."; + } + + /* Append the name to the list */ + 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; + } + } + */ + + /* recursive add of subdepartments */ + 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 diff --git a/include/class_ldap.inc b/include/class_ldap.inc index ad98c710b..8f64c9a8d 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -600,9 +600,12 @@ class LDAP{ if ($target == $this->basedn){ return; } -echo "FIXME"; - $l= array_reverse(explode(",", preg_replace("/,".$this->basedn."/", "", $target))); + + $real_path= substr($target, 0, strlen($target) - strlen($this->basedn) -1 ); + $l= array_reverse(ldap_explode_dn($real_path,0)); + unset($l['count']); $cdn= $this->basedn; + foreach ($l as $part){ $cdn= "$part,$cdn"; diff --git a/include/functions.inc b/include/functions.inc index 807fbb636..09f90acce 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -782,7 +782,7 @@ function convert_department_dn($dn) } /* Return and remove accidently trailing slashes */ - return rtrim($dep, "/"); + return @ldap::fix(rtrim($dep, "/")); } function convert_department_dn2($dn)