Code

Some page reload fixes,
[gosa.git] / plugins / admin / fai / class_faiVariable.inc
index 6c47c6f331a88586f864c9d90a614bdf7eb3f8d6..f6c4a5562658d6e832de1c1d3d5d1dc7c93c3d56 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,20 +88,29 @@ class faiVariable extends plugin
       $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'];
+
+      $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]);
+        }
       }
     }
 
@@ -130,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; 
@@ -150,15 +173,15 @@ class faiVariable extends plugin
       /* Magic quotes GPC, escapes every ' " \, to solve some security risks
      * If we post the escaped strings they will be escaped again
      */
+
     foreach($this->attributes as $attrs){
       if(get_magic_quotes_gpc()){
-        $smarty->assign($attrs,stripslashes($this->$attrs));
+        $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs))));
       }else{
-        $smarty->assign($attrs,($this->$attrs));
+        $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs)));
       }
     }
 
-
     $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE));
     return($display);
   }
@@ -233,7 +256,9 @@ class faiVariable extends plugin
     if($ldap->count()!=0){
       /* Write FAIscript to ldap*/
       $ldap->cd($this->dn);
-      $ldap->modify($this->attrs);
+      $this->cleanup();
+$ldap->modify ($this->attrs); 
+
     }else{
       /* Write FAIscript to ldap*/
       $ldap->cd(preg_replace('/^[^,]+,[^,]+,/', '', $this->dn));
@@ -291,7 +316,9 @@ class faiVariable extends plugin
         $this->handle_post_events("remove");
       }elseif($obj['status'] == "edited"){
         $ldap->cd($sub_dn);
-        $ldap->modify($tmp);
+        $this->cleanup();
+$ldap->modify ($tmp); 
+
         $this->handle_post_events("modify");
       }elseif($obj['status']=="new"){