Code

Fixed attachment for printer
[gosa.git] / plugins / admin / fai / class_faiTemplate.inc
index 79f08a61c15d2766b032ec5216387dffa0d195f0..cfe0f41e8e5cb1c9f9e732c3029fa0c8236f7f87 100644 (file)
@@ -64,20 +64,22 @@ class faiTemplate extends plugin
         }
 
         foreach($this->sub64coded as $codeIt){
-          $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]);
+          $this->SubObjects[$object['cn'][0]][$codeIt]= base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]);
         }       
 
-        $this->SubObjects[$object['cn'][0]]['FAItemplateFile'] =addslashes( $this->readBinary("FAItemplateFile",$object['dn']));
+        $this->SubObjects[$object['cn'][0]]['FAItemplateFile']= $this->readBinary("FAItemplateFile",$object['dn']);
        
-        $this->SubObjects[$object['cn'][0]]['status']      = "edited";
-        $this->SubObjects[$object['cn'][0]]['dn']          = $object['dn'];
+        $this->SubObjects[$object['cn'][0]]['status']= "edited";
+        $this->SubObjects[$object['cn'][0]]['dn']= $object['dn'];
       }
-      ksort($this->SubObjects);
     }
   }
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
@@ -88,20 +90,29 @@ class faiTemplate 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'];
+
+      $temp = $_POST['SubObject'][0];
+    
+      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$temp]);
+      $_SESSION['objectinfo'] = $this->SubObjects[$temp]['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 $temp){
+        if($this->SubObjects[$temp]['status'] == "edited"){
+          $this->SubObjects[$temp]['status']= "delete";
+        }else{
+          unset($this->SubObjects[$temp]);
+        }
       }
     }
 
@@ -130,10 +141,20 @@ class faiTemplate extends plugin
         $this->is_dialog=false;
         unset($this->dialog);
         $this->dialog=NULL;
-        ksort($this->SubObjects);
       }
     }
 
+    /* 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; 
@@ -173,7 +194,11 @@ class faiTemplate extends plugin
     $a_return=array();
     foreach($this->SubObjects as $obj){
       if($obj['status'] != "delete"){
+      
         if((isset($obj['description']))&&(!empty($obj['description']))){
+          if(strlen($obj['description']) > 40){
+            $obj['description'] = substr($obj['description'],0,40)."...";
+          }
           $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]";
         }else{
           $a_return[$obj['cn']]= $obj['cn'];