Code

A set of multibyte string fixes
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 13 Apr 2006 14:02:48 +0000 (14:02 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 13 Apr 2006 14:02:48 +0000 (14:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3044 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_config.inc
include/class_ldap.inc
include/functions.inc

index 4b26e2607cf4838403bbfe4c9af436481e77fbf8..0a8e35a4223b361f24c04604796fbf788fdbc1fd 100644 (file)
@@ -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.="&nbsp;";
-                               }
-                               $ret[$entries['ENTRY']]=$a."&nbsp;".$name;
-                       }       
-                       /* For debugging        
-                       if(isset($entries['ENTRY'])){
-                               $a = "";
-                               for($i = 0 ; $i < $depth ; $i ++){
-                                       $a.="&nbsp;|";
-                               }
-                       
-                               if(!isset($entries['SUB'])){
-                                       $ret[$entries['ENTRY']]=$a."-&nbsp;".$name;
-                               }else{
-                                       $ret[$entries['ENTRY']]=$a."#"."&nbsp;".$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.="&nbsp;";
+                         }
+                         $ret[$entries['ENTRY']]=$a."&nbsp;".$name;
+                 }     
+                 /* For debugging      
+                    if(isset($entries['ENTRY'])){
+                    $a = "";
+                    for($i = 0 ; $i < $depth ; $i ++){
+                    $a.="&nbsp;|";
+                    }
+
+                    if(!isset($entries['SUB'])){
+                    $ret[$entries['ENTRY']]=$a."-&nbsp;".$name;
+                    }else{
+                    $ret[$entries['ENTRY']]=$a."#"."&nbsp;".$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
index ad98c710bc000e74412c8fdcf86dc01b83bbc6e3..8f64c9a8d0a5302e71d6d83fac044e82eb0623e7 100644 (file)
@@ -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";
 
index 807fbb63643b06dd9d7fea8fba6b3d5e11b9c10a..09f90acced0c579ef6888a8d1d886a979fe7db78 100644 (file)
@@ -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)