Code

Updated glpi attachment download.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Jan 2008 11:05:06 +0000 (11:05 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Jan 2008 11:05:06 +0000 (11:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8563 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc
gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc

index 4225e9fce9f844dc6514248774ea9ee228f7ed0c..445c277faf9d28aa48658dec5365b53988c240d3 100644 (file)
@@ -172,6 +172,24 @@ class glpiAccount extends plugin
       return($smarty->fetch(get_template_path('glpi.tpl',TRUE,dirname(__FILE__))));
     } 
 
+    /* Download requested of attachment requested.
+     */
+    if(isset($_GET['get_attachment'])){
+      $atts = $this->handle->getAttachments();
+      if(isset($atts[$_GET['get_attachment']])){
+        $att = $atts[$_GET['get_attachment']];
+        $filename = CONFIG_DIR."/glpi/".$att['filename'];
+        if(file_exists($filename) && is_readable($filename)){
+          $str = file_get_contents($filename);
+          send_binary_content($str,$att['filename']);
+        }else{
+          print_red(_("Download of attachment failed. Attachment was not found on server."));
+        }
+      }else{
+        print_red(_("Download of attachment failed. Not a valid attachment id."));
+      }
+    }
+
     /*  All checks are ok
         Lets handle Posts, templates etc below ...
      */
@@ -613,7 +631,7 @@ class glpiAccount extends plugin
     $divlist = new divSelectBox("glpiAttachmentsList");
     $divlist-> SetHeight(130); 
     $atts = $this->getUsedAttachments(true);
-    $downlink = "<a href='?".$_GET['plug']."&get_attachment.php?id=%s' target='_blank'>%s</a>";
+    $downlink = "<a href='?plug=".$_GET['plug']."&get_attachment=%s'>%s</a>";
     $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
     foreach($atts as $id => $attachment){
       $divlist->AddEntry
index 9eee7eb168da38082825959bb6e7be275915cdbc..36f20d24d6bcdef04759890fdf419497e719f505 100644 (file)
@@ -189,6 +189,25 @@ class glpiPrinterAccount extends plugin
       return($smarty->fetch(get_template_path('glpiPrinter.tpl',TRUE,dirname(__FILE__))));
     } 
 
+    /* Download requested of attachment requested.
+     */
+    if(isset($_GET['get_attachment'])){
+      $atts = $this->handle->getAttachments();
+      if(isset($atts[$_GET['get_attachment']])){
+        $att = $atts[$_GET['get_attachment']];
+        $filename = CONFIG_DIR."/glpi/".$att['filename'];
+        if(file_exists($filename) && is_readable($filename)){
+          $str = file_get_contents($filename);
+          send_binary_content($str,$att['filename']);
+        }else{
+          print_red(_("Download of attachment failed. Attachment was not found on server."));
+        }
+      }else{
+        print_red(_("Download of attachment failed. Not a valid attachment id."));
+      }
+    }
+
+
     /*  All checks are ok
         Lets handle Posts, templates etc below ...
      */
@@ -581,7 +600,7 @@ class glpiPrinterAccount extends plugin
     $divlist = new divSelectBox("glpiAttachmentsList");
     $divlist-> SetHeight(120);
     $atts = $this->getUsedAttachments(true);
-    $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
+    $downlink = "<a href='?plug=".$_GET['plug']."&get_attachment=%s'>%s</a>";
     $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
     foreach($atts as $id => $attachment){
       $divlist->AddEntry