Code

Cache password methods
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 5 May 2008 06:04:55 +0000 (06:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 5 May 2008 06:04:55 +0000 (06:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10753 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/password-methods/class_password-methods.inc

index 07b346f0996441b0ba7b71172e905295409e9323..d0495b09f85264865e585e8d746d9371be9862ac 100644 (file)
@@ -37,53 +37,46 @@ class passwordMethod
   }
 
 
-  // Loads Methods in annother way as  get_available_methods do, (For setup ..)
-  // and loads them,.
-  #FIXME: This stopped working after moving around pw-methods
-  function get_available_methods_if_not_loaded($path_to_load="../include")
-  {
-    $oh = opendir($path_to_load);
-    $i = 0; 
-    $ret = false;
-    while ($file = readdir($oh)) {
-      $one = strtolower($file); 
-      if((strstr($one,"class_password-methods-" ))&&($one[0]!=".")){
-        require_once($file);
-      }
-    }
-    return(passwordMethod::get_available_methods());
-  }
-
-
   // this function returns all loaded classes for password encryption
   static function get_available_methods()
   {
     global $class_mapping, $config;
     $ret =false;
     $i =0;
-    foreach($class_mapping as $class => $path) {
-      if(preg_match('/passwordMethod/i', $class) && !preg_match("/^passwordMethod$/i", $class)){
-        $name = preg_replace ("/passwordMethod/i", "", $class);
-        $test = new $class($config, "");
-        if($test->is_available()) {
-          $plugs= $test->get_hash_name();
-          if (!is_array($plugs)){
-            $plugs= array($plugs);
-          }
 
-          foreach ($plugs as $plugname){
-            $ret['name'][$i]= $plugname;
-            $ret['class'][$i]=$class;
-            $ret[$i]['name']= $plugname;
-            $ret[$i]['class']= $class;
-            $ret[$plugname]=$class;                    
-            $i++;
+    /* Only */
+    if(!session::is_set("passwordMethod::get_available_methods")){
+      foreach($class_mapping as $class => $path) {
+        if(preg_match('/passwordMethod/i', $class) && !preg_match("/^passwordMethod$/i", $class)){
+          $name = preg_replace ("/passwordMethod/i", "", $class);
+          $test = new $class($config, "");
+          if($test->is_available()) {
+            $plugs= $test->get_hash_name();
+            if (!is_array($plugs)){
+              $plugs= array($plugs);
+            }
+
+            foreach ($plugs as $plugname){
+
+              $cfg = $test->is_configurable();
+
+              $ret['name'][$i]= $plugname;
+              $ret['class'][$i]=$class;
+              $ret['is_configurable'][$i]= $cfg;
+              $ret['object'][$i]= $test;
+              $ret[$i]['name']  = $plugname;
+              $ret[$i]['class'] = $class;
+              $ret[$i]['object']= $test;
+              $ret[$i]['is_configurable']= $cfg;
+              $ret[$plugname]=$class;                    
+              $i++;
+            }
           }
         }
       }
+      session::set("passwordMethod::get_available_methods",$ret);
     }
-
-    return($ret);
+    return(session::get("passwordMethod::get_available_methods"));
   }