Code

Upps
[gosa.git] / plugins / admin / fai / class_faiTemplateEntry.inc
index b387581e79768eed81e4311c7ce6be97361d0789..57eee41245f8440b826e34ff19138ea7672279f2 100644 (file)
@@ -32,7 +32,7 @@ class faiTemplateEntry extends plugin
   {
     plugin::plugin ($config, $dn);
 
-    if($dn != "new"){
+    if((isset($object['cn'])) && (!empty($object['cn']))){
       $this->orig_cn= $object['cn'];
       $this->dn=$object['dn'];
       foreach($object as $name=>$value){
@@ -46,7 +46,7 @@ class faiTemplateEntry extends plugin
 
     }else{
       $this->status = "new";
-      $this->orig_cn       = false;
+      $this->orig_cn= false;
     }
 
     $this->user = explode( '.', $this->FAIowner );
@@ -62,8 +62,8 @@ class faiTemplateEntry extends plugin
 
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+    /* Call parent execute */
+    plugin::execute();
 
     /* Fill templating stuff */
     $smarty     = get_smarty();
@@ -75,17 +75,26 @@ class faiTemplateEntry extends plugin
         $this->FAItemplateFile = $str;
 
         /* If we don't have a filename set it from upload filename. */
-        if( 0 == strlen( $this->FAItemplatePath ) )
+        if( 0 == strlen( $this->FAItemplatePath )){
           $this->FAItemplatePath = $_FILES['FAItemplateFile']['name'];
+        }
+
+        $_SESSION['binary']     = $this->FAItemplateFile;
+        $_SESSION['binarytype'] = 'octet-stream';
+        $_SESSION['binaryfile'] = basename( $this->FAItemplatePath );
       }
-    
     }
     
     $status= _("no file uploaded yet");
+
+    $bStatus = false; // Hide download icon on default 
+    
     if(strlen($this->FAItemplateFile)){
       $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile));
+      $bStatus = true;  // Display download icon 
     }
     $smarty->assign("status",$status);
+    $smarty->assign("bStatus",$bStatus);
 
     /* Magic quotes GPC, escapes every ' " \, to solve some security risks 
      * If we post the escaped strings they will be escaped again