Code

Removed whitespace before updatebase
[gosa.git] / plugins / admin / systems / class_glpiAttachmentPool.inc
index 8a2da67d74eb07e6d80477e3824b467e81b66269..40a7c3e13bad835e9e00768eb51a9d0bf88046a2 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();
@@ -311,7 +323,26 @@ class glpiAttachmentPool extends plugin
   {
     $message = array();
     if($this->edit){
+    
+      /* check if given name is already in use */
+      $att = $this->parent->handle->getAttachments();
+      $ok = true;
       $this->name=trim($this->name);
+
+      foreach($att as $val){
+        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){
+        $message[] = _("This name is already in use.");
+      }
       if(empty($this->name)){
         $message[] = _("Please specify a valid name for this attachment.");
       }