Code

Updated
[gosa.git] / plugins / admin / fai / class_faiHook.inc
index 0cc84fbeb619af9ee609c3f173665037a3a77705..aaf7f74e0c86d5d6ecf05b3615d3c5532bd5ae85 100644 (file)
@@ -77,8 +77,25 @@ class faiHook extends plugin
     }
   }
 
+  function getUsedFAItask($cn)
+  {
+    $ret = array();
+    foreach($this->SubObjects as $name => $class){
+      if($class['cn'] == $cn){
+        continue;
+      } 
+      if($class['status'] != "delete"){
+        $ret[$class['FAItask']] = $class['FAItask'];
+      }
+    }
+    return($ret);
+  }
+
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
@@ -86,23 +103,31 @@ class faiHook extends plugin
     /* Add new sub object */
     if(isset($_POST['AddSubObject'])){
       $this->dialog= new $this->subClassName($this->config,"new");
+      $this->dialog->parent = &$this;
       $this->is_dialog=true;
     }
-
-    $_SESSION['objectinfo']= $this->dn;
+  
+    if($this->dn != "new"){
+      $_SESSION['objectinfo']= $this->dn;
+    }
     /* Edit selected Sub Object */
     if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
-      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]);
-      $_SESSION['objectinfo'] = $this->SubObjects[$_POST['SubObject']]['dn'];
+      $hook = $_POST['SubObject'][0];
+    
+      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$hook]);
+      $this->dialog->parent = &$this;
+      $_SESSION['objectinfo'] = $this->SubObjects[$hook]['dn'];
       $this->is_dialog=true;
     }
     
     /* Remove Sub object */
     if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){
-      if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){
-        $this->SubObjects[$_POST['SubObject']]['status']= "delete";
-      }else{
-        unset($this->SubObjects[$_POST['SubObject']]);
+      foreach($_POST['SubObject'] as $hook){
+        if($this->SubObjects[$hook]['status'] == "edited"){
+          $this->SubObjects[$hook]['status']= "delete";
+        }else{
+          unset($this->SubObjects[$hook]);
+        }
       }
     }
 
@@ -144,6 +169,17 @@ class faiHook extends plugin
       }
     }
 
+    /* Sort entries */
+    $tmp = $keys = array();
+    foreach($this->SubObjects as $key => $entry){
+      $keys[$key]=$key;
+    }
+    natcasesort($keys);
+    foreach($keys as $key){
+      $tmp[$key]=$this->SubObjects[$key];
+    }
+    $this->SubObjects = $tmp;
+
     /* Cancel Dialog */
     if(isset($_POST['CancelSubObject'])){
       $this->is_dialog=false; 
@@ -172,7 +208,6 @@ class faiHook extends plugin
       }
     }
 
-
     $display.= $smarty->fetch(get_template_path('faiHook.tpl', TRUE));
     return($display);
   }