Code

Renamed add/remove buttons
[gosa.git] / plugins / admin / systems / class_glpiAttachmentPool.inc
index 40a7c3e13bad835e9e00768eb51a9d0bf88046a2..25c39880cf02135af620abad071c9e72134c6f3c 100644 (file)
@@ -113,6 +113,7 @@ class glpiAttachmentPool extends plugin
 
       }else{
         $this->parent->handle->deleteAttachment($this->delAttach);
+        @unlink("/etc/gosa/glpi/".$this->filename);
         $attach     = $this->parent->handle->getAttachments();
       }
     }
@@ -133,16 +134,20 @@ class glpiAttachmentPool extends plugin
               print_red(_("Missing directory '/etc/gosa/glpi/' to store glpi uploads."));
             }else{
               $filen = "/etc/gosa/glpi/".$FILE['name'];
-              $fh = fopen($filen,"w");
-              if(!$fh){
-                print_red(sprintf(_("Can't create file '%s'."),$filen));
+              if(file_exists($filen)){
+                print_red(_("There is already a file with the same name uploaded."));
               }else{
-                $str = file_get_contents($FILE['tmp_name']);
-                fwrite($fh,$str,strlen($str));
-                fclose($fh);
-                $this->mime     = $FILE['type'];   
-                $this->filename = $FILE['name'];   
-              }
+                $fh = fopen($filen,"w");
+                if(!$fh){
+                  print_red(sprintf(_("Can't create file '%s'."),$filen));
+                }else{
+                  $str = file_get_contents($FILE['tmp_name']);
+                  fwrite($fh,$str,strlen($str));
+                  fclose($fh);
+                  $this->mime     = $FILE['type'];   
+                  $this->filename = $FILE['name'];   
+                }
+              } // File already exists
             }
           } // Check if any error occured
         } // check if valid filename was uploaded
@@ -260,8 +265,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']);