Code

Attachmentpool dialog fixed
[gosa.git] / plugins / admin / systems / class_glpiAttachmentPool.inc
index 6ee839e4abc603e889f9d52dea4aa732b3286455..bddbe307344d16f6f2e706c8beb1d9b7794146f9 100644 (file)
@@ -98,7 +98,19 @@ class glpiAttachmentPool extends plugin
 
     if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
       if($this->parent->handle->is_attachmentUsed($this->delAttach)){
-        print_red(_("Can't delete this attachment, it is still in use."));
+        $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach);
+        
+        $names = "";
+        foreach($tmp as $name){
+          $names .= ", ".$name;
+        }
+        $names = preg_replace("/^, /","",$names);
+        $names = trim($names);
+        if(count($tmp) == 3){
+          $names .= " ...";
+        }
+        print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names));
+
       }else{
         $this->parent->handle->deleteAttachment($this->delAttach);
         $attach     = $this->parent->handle->getAttachments();
@@ -248,8 +260,8 @@ class glpiAttachmentPool extends plugin
     $smarty->assign("search_image",     get_template_path('images/search.png'));
     $smarty->assign("searchu_image",    get_template_path('images/search_user.png'));
     $smarty->assign("tree_image",       get_template_path('images/tree.png'));
-    $smarty->assign("infoimage",        get_template_path('images/info.png'));
-    $smarty->assign("launchimage",      get_template_path('images/launch.png'));
+    $smarty->assign("infoimage",        get_template_path('images/info_small.png'));
+    $smarty->assign("launchimage",      get_template_path('images/small_filter.png'));
     $smarty->assign("apply",            apply_filter());
     $smarty->assign("alphabet",         generate_alphabet());
     $smarty->assign("attachment_regex", $_SESSION['GlpiAttachmentFilter']['filter']);
@@ -316,9 +328,16 @@ class glpiAttachmentPool extends plugin
       $att = $this->parent->handle->getAttachments();
       $ok = true;
       $this->name=trim($this->name);
+
       foreach($att as $val){
-        if($val['name'] == $this->name){
-          $ok = false;
+        if(!isset($this->entry['ID'])){
+          if($val['name'] == $this->name){
+            $ok = false;
+          }
+        }else{
+          if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){
+            $ok = false;
+          }
         }
       }
       if(!$ok){