diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc
index c6d3197b41bc4dd0f4016c60152874cc70a4a864..a72f7005c957413499578d32658c73b95107ef7f 100644 (file)
/* Remove Attachment fro 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']))){
foreach($_POST['Attachments'] as $entry){
if(isset($this->usedAttachments[$entry])){
/* Assign used Attachments
*/
- $smarty->assign("Attachments", $this->getUsedAttachments());
- $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments()));
+ $divlist = new divSelectBox("glpiAttachmentsList");
+ $divlist-> SetHeight(120);
+ $atts = $this->getUsedAttachments(true);
+ $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
+ $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
+ 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());
/* Handle contact person
Assign name ... to smarty, if set
*/
}
$tmp = $this->handle->getComputerInformations($this->dn);
$this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
- $this->handle->addAttachmentsToComputer($this->usedAttachments,$tmp[0]['ID']);
}
}
/* 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);