Code

Updated strings
[gosa.git] / gosa-core / include / class_ldap.inc
index 1f2baab3e41cfef1fa6d308329bb6b7b27c4fcd6..3d6649cc716b60777c4dd761b50b0d7ed845e125 100644 (file)
@@ -230,7 +230,7 @@ class LDAP{
       if($this->max_ldap_query_time){
         $diff = microtime(true) - $start;
         if($diff > $this->max_ldap_query_time){
-          msg_dialog::display(_("Performance warning"), sprintf(_("LDAP performance is poor: last query took about %.2fs!"), $diff), WARNING_DIALOG);
+          msg_dialog::display(_("Performance warning"), sprintf(_("LDAP performance is poor: last query took %.2fs!"), $diff), WARNING_DIALOG);
         }
       }
 
@@ -263,7 +263,7 @@ class LDAP{
       if($this->max_ldap_query_time){
         $diff = microtime(true) - $start;
         if($diff > $this->max_ldap_query_time){
-          msg_dialog::display(_("Performance warning"), sprintf(_("LDAP performance is poor: last query took about %.2fs!"), $diff), WARNING_DIALOG);
+          msg_dialog::display(_("Performance warning"), sprintf(_("LDAP performance is poor: last query took %.2fs!"), $diff), WARNING_DIALOG);
         }
       }
 
@@ -662,7 +662,8 @@ class LDAP{
 
       } else {
         $type= preg_replace('/^([^=]+)=.*$/', '\\1', $cdn);
-        $param= preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn);
+        $param= LDAP::fix(preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn));
+        $param=preg_replace(array('/\\\\,/','/\\\\"/'),array(',','"'),$param);
 
         $na= array();
 
@@ -672,7 +673,7 @@ class LDAP{
           /* Get name of first matching objectClass */
           $ocname= "";
           foreach($classes as $class){
-            if (isset($class['MUST']) && $class['MUST'] == "$type"){
+            if (isset($class['MUST']) && in_array($type, $class['MUST'])){
 
               /* Look for first classes that is structural... */
               if (isset($class['STRUCTURAL'])){
@@ -689,7 +690,7 @@ class LDAP{
 
           /* Bail out, if we've nothing to do... */
           if ($ocname == ""){
-            msg_dialog::display(_("Internal error"), sprintf(_("Cannot automatically create subtrees with RDN '%s': no object class found!"),$type), FATAL_ERROR_DIALOG);
+            msg_dialog::display(_("Internal error"), sprintf(_("Cannot automatically create subtrees with RDN '%s': no object class found"),$type), FATAL_ERROR_DIALOG);
             exit();
           }
 
@@ -708,8 +709,11 @@ class LDAP{
             $na['objectClass'][]= 'locality';
           }
           $na[$type]= $param;
+
+          // Fill in MUST values - but do not overwrite existing ones.
           if (is_array($classes[$ocname]['MUST'])){
             foreach($classes[$ocname]['MUST'] as $attr){
+              if(isset($na[$attr]) && !empty($na[$attr])) continue;
               $na[$attr]= "filled";
             }
           }
@@ -824,9 +828,9 @@ class LDAP{
     } else {
       $adderror= $this->get_additional_error();
       if ($adderror != ""){
-        $error= $this->error." (".$this->get_additional_error().", ".sprintf(_("while operating on '%s' using LDAP server '%s'"), $this->basedn, $this->hostname).")";
+        $error= $this->error." (".$this->get_additional_error().", ".sprintf(_("while operating on %s using LDAP server %s"), "<b>".$this->basedn."</b>", "<b>".$this->hostname."</b>").")";
       } else {
-        $error= $this->error." (".sprintf(_("while operating on LDAP server %s"), $this->hostname).")";
+        $error= $this->error." (".sprintf(_("while operating on LDAP server %s"), "<b>".$this->hostname."</b>").")";
       }
       return $error;
     }
@@ -1048,7 +1052,7 @@ class LDAP{
 
       /* Every block must begin with a dn */
       if($dn != "dn") {
-        $error= sprintf(_("This is not a valid DN: '%s'. A block for import should begin with 'dn: ...' in line %s"), $line, $current_line);
+        $error= sprintf(_("Invalid DN '%s': block to be imported should start with 'dn: ...' in line %s"), $line, "<b>".$current_line."</b>");
         return -2;  
       }
 
@@ -1077,7 +1081,7 @@ class LDAP{
      
       /* If we can't Import, return with a file error */
       if(!$this->import_single_entry($srp, $single,$usemodify,$usermdir) ) {
-        $error= sprintf(_("Error while importing dn: '%s', please check your LDIF from line %s on!"), $line,
+        $error= sprintf(_("Error while importing DN '%s': please check LDIF from line %s on!"), $line,
                         $current_line);
         return UNKNOWN_TOKEN_IN_LDIF_FILE;      }
     }
@@ -1294,7 +1298,11 @@ class LDAP{
                     break;
 
           case ')': if ($name != ""){
-                      $objectclasses[$ocname][$name]= $this->value2container($value);
+                      $v = $this->value2container($value);
+                      if(in_array($name, array('MUST', 'MAY')) && !is_array($v)){
+                        $v = array($v);
+                      }
+                      $objectclasses[$ocname][$name]= $v;
                     }
                     $name= "";
                     $value= "";
@@ -1309,7 +1317,11 @@ class LDAP{
           case 'MUST':
           case 'MAY':
                     if ($name != ""){
-                      $objectclasses[$ocname][$name]= $this->value2container($value);
+                      $v = $this->value2container($value);
+                      if(in_array($name, array('MUST', 'MAY')) && !is_array($v)){
+                        $v = array($v);
+                      }
+                      $objectclasses[$ocname][$name]= $v;
                     }
                     $name= $chunk;
                     $value= "";