Code

Added robustness to tabs::save()
[gosa.git] / gosa-core / include / functions.inc
index 4f7236ae5ca02b5e6d145a2752aeef9a5789e1d4..85a2eb328e669e85f8a63f9179ad6249c62a4f90 100644 (file)
@@ -24,6 +24,7 @@
 define ("CONFIG_DIR", "/etc/gosa");
 define ("CONFIG_FILE", "gosa.conf");
 define ("CONFIG_TEMPLATE_DIR", "../contrib/");
+define ("TEMP_DIR","/var/cache/gosa/tmp");
 
 /* Define get_list flags */
 define("GL_NONE",         0);
@@ -2365,6 +2366,16 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA
   if($languages_in_own_language){
 
     $old_lang = setlocale(LC_ALL, 0);
+
+    /* If the locale wasn't correclty set before, there may be an incorrect
+        locale returned. Something like this: 
+          C_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC ...
+        Extract the locale name from this string and use it to restore old locale.
+     */
+    if(preg_match("/LC_CTYPE/",$old_lang)){
+      $old_lang = preg_replace("/^.*LC_CTYPE=([^;]*).*$/","\\1",$old_lang);
+    }
+    
     foreach($tmp as $key => $name){
       $lang = $key.".UTF-8";
       setlocale(LC_ALL, $lang);
@@ -2458,9 +2469,9 @@ function change_password ($dn, $password, $mode=0, $hash= "")
 
     /* Extract used hash */
     if ($hash == ""){
-      $test = passwordMethod::get_method($attrs['userPassword'][0]);
+      $test = passwordMethod::get_method($attrs['userPassword'][0],$dn);
     } else {
-      $test = new $available[$hash]($config);
+      $test = new $available[$hash]($config,$dn);
       $test->set_hash($hash);
     }
 
@@ -2514,7 +2525,9 @@ function change_password ($dn, $password, $mode=0, $hash= "")
   } else {
 
     /* Run backend method for change/create */
-    $test->set_password($password);
+    if(!$test->set_password($password)){
+      return(FALSE);
+    }
 
     /* Find postmodify entries for this class */
     $command= $config->search("password", "POSTMODIFY",array('menu'));
@@ -2533,6 +2546,7 @@ function change_password ($dn, $password, $mode=0, $hash= "")
       }
     }
   }
+  return(TRUE);
 }