From 19417e01cfecf33bff037531ca8e98dcedf151e1 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 25 Jan 2006 09:13:24 +0000 Subject: [PATCH] Fixed attachment for printer git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2574 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/class_glpiPrinterAccount.inc | 51 +++++++++++++++---- plugins/admin/systems/glpiPrinter.tpl | 5 +- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/plugins/admin/systems/class_glpiPrinterAccount.inc b/plugins/admin/systems/class_glpiPrinterAccount.inc index 2fbffd147..af76ba9cc 100644 --- a/plugins/admin/systems/class_glpiPrinterAccount.inc +++ b/plugins/admin/systems/class_glpiPrinterAccount.inc @@ -382,6 +382,17 @@ class glpiPrinterAccount extends plugin /* Remove Attachment from this tab */ + $once = true; + foreach($_POST as $name => $value){ + if((preg_match("/^delAttachment_/",$name))&&($once)){ + $once= false; + $name = preg_replace("/^delAttachment_/","",$name); + $entry = preg_replace("/_.*$/","",$name); + if(isset($this->usedAttachments[$entry])){ + unset($this->usedAttachments[$entry]); + } + } + } if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments']))){ if(isset($this->usedAttachments[$_POST['Attachments']])){ unset($this->usedAttachments[$_POST['Attachments']]); @@ -493,6 +504,25 @@ class glpiPrinterAccount extends plugin /* Assign used Attachments */ + + $divlist = new divSelectBox("glpiAttachmentsList"); + $divlist-> SetHeight(150); + $atts = $this->getUsedAttachments(true); + $downlink = "%s"; + $del_link = ""; + foreach($atts as $id => $attachment){ + $divlist->AddEntry + ( + array( + array("string"=>$attachment['name']), + array("string"=>$attachment['mime']), + array("string"=>sprintf($downlink,$id,$attachment['filename'])), + array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"), + ) + ); + } + + $smarty->assign("AttachmentsDiv" ,$divlist->DrawList()); $smarty->assign("Attachments", $this->getUsedAttachments()); $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments())); @@ -621,22 +651,25 @@ class glpiPrinterAccount extends plugin } /* Return used attachments */ - function getUsedAttachments() + function getUsedAttachments($divlist = false) { $atts =$this->handle->getAttachments(); $ret = array(); foreach($atts as $entry){ if(in_array($entry['ID'],$this->usedAttachments)){ + if($divlist){ + $ret[$entry['ID']] = $entry; + }else{ + $cm =""; + if(isset($entry['comment'])){ + $cm=" [".$entry['comment']."]"; + } + if(isset($entry['mime'])){ + $cm.=" -".$entry['mime'].""; + } - $cm =""; - if(isset($entry['comment'])){ - $cm=" [".$entry['comment']."]"; + $ret[$entry['ID']]= $entry['name'].$cm; } - if(isset($entry['mime'])){ - $cm.=" -".$entry['mime'].""; - } - - $ret[$entry['ID']]= $entry['name'].$cm; } } return($ret); diff --git a/plugins/admin/systems/glpiPrinter.tpl b/plugins/admin/systems/glpiPrinter.tpl index 835a00eca..960420b76 100644 --- a/plugins/admin/systems/glpiPrinter.tpl +++ b/plugins/admin/systems/glpiPrinter.tpl @@ -92,11 +92,8 @@
- + {$AttachmentsDiv} -
-- 2.30.2