Code

Added check to avoid attachments with same name
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Jan 2006 08:47:43 +0000 (08:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Jan 2006 08:47:43 +0000 (08:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2515 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_glpiAttachmentPool.inc

index 8a2da67d74eb07e6d80477e3824b467e81b66269..6ee839e4abc603e889f9d52dea4aa732b3286455 100644 (file)
@@ -311,7 +311,19 @@ class glpiAttachmentPool extends plugin
   {
     $message = array();
     if($this->edit){
   {
     $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);
       $this->name=trim($this->name);
+      foreach($att as $val){
+        if($val['name'] == $this->name){
+          $ok = false;
+        }
+      }
+      if(!$ok){
+        $message[] = _("This name is already in use.");
+      }
       if(empty($this->name)){
         $message[] = _("Please specify a valid name for this attachment.");
       }
       if(empty($this->name)){
         $message[] = _("Please specify a valid name for this attachment.");
       }