From c957b3217a79b146db3d6e71fac7f5dd81beb965 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 23 Jan 2008 11:05:06 +0000 Subject: [PATCH] Updated glpi attachment download. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8563 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../services/glpi/class_glpiAccount.inc | 20 +++++++++++++++++- .../glpi/class_glpiPrinterAccount.inc | 21 ++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc index 4225e9fce..445c277fa 100644 --- a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc +++ b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc @@ -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 = "%s"; + $downlink = "%s"; $del_link = ""; foreach($atts as $id => $attachment){ $divlist->AddEntry diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc index 9eee7eb16..36f20d24d 100644 --- a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc +++ b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc @@ -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 = "%s"; + $downlink = "%s"; $del_link = ""; foreach($atts as $id => $attachment){ $divlist->AddEntry -- 2.30.2