Code

Speeding up profile display
[gosa.git] / plugins / admin / fai / class_faiVariable.inc
index d2e74c469157d5d3883ae8c8c546c3985ae782e4..244c950393613b6e8b9852132e0891bf266ece14 100644 (file)
@@ -25,7 +25,7 @@ class faiVariable extends plugin
 
   /* Attributes to initialise for each subObject */
   var $subAttributes    = array("cn","description","FAIvariableContent"); 
-  var $sub64coded       = array("FAIvariableContent");  
+  var $sub64coded       = array();  
 
   /* Specific attributes */
   var $cn               = "";       // The class name for this object
@@ -75,6 +75,9 @@ class faiVariable extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
@@ -85,18 +88,29 @@ class faiVariable extends plugin
       $this->is_dialog=true;
     }
 
+    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']]);
+
+      $var = $_POST['SubObject'][0];
+    
+      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]);
+      $_SESSION['objectinfo'] = $this->SubObjects[$var]['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 $var){
+        if($this->SubObjects[$var]['status'] == "edited"){
+          $this->SubObjects[$var]['status']= "delete";
+        }else{
+          unset($this->SubObjects[$var]);
+        }
       }
     }
 
@@ -128,6 +142,17 @@ class faiVariable 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; 
@@ -201,10 +226,12 @@ class faiVariable extends plugin
    */
   function save_object()
   {
-    plugin::save_object();
-    foreach($this->attributes as $attrs){
-      if(isset($_POST[$attrs])){
-        $this->$attrs = $_POST[$attrs];
+    if(isset($_POST['FAIvariable_posted'])){
+      plugin::save_object();
+      foreach($this->attributes as $attrs){
+        if(isset($_POST[$attrs])){
+          $this->$attrs = $_POST[$attrs];
+        }
       }
     }
   }