Code

Added checks to filterEditor.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Mar 2010 08:35:57 +0000 (08:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Mar 2010 08:35:57 +0000 (08:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16364 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_filterEditor.inc
gosa-core/include/class_filterEditorEntry.inc

index 521eab71cd7d3bda99a4dcac48e5f26df596e6af..92a0621e9bb2cf253dca2a2e9e77c7164cb59b7a 100644 (file)
@@ -87,18 +87,28 @@ class filterEditor extends plugin
       $this->dialog->save_object();
       $msgs = $this->dialog->check();
       if(count($msgs)){
-        msg_dialog::display_checks($msgs);
+        msg_dialog::displayChecks($msgs);
       }else{
         $orig_name = $this->dialog->getOriginalName();
         $new_name = $this->dialog->getCurrentName();
 
-        // Remove old entry
-        if($orig_name != "") unset($this->filters[$orig_name]);
-
-        $this->filters[$new_name] = $this->dialog->save();
-        $this->dialog = NULL;
-        $this->filterWidget->setListData($this->filters, $this->convertFilterList());
-        $this->filterWidget->update();
+        // The object was renamed and
+        if($orig_name != $new_name && isset($this->filters[$new_name])){
+          $msgs = array(msgPool::duplicated(_("Name")));
+          msg_dialog::displayChecks($msgs);
+        }else{
+
+          // Remove old entry if filter was renamed
+          if($orig_name != "" && isset($this->filters[$orig_name])){
+            unset($this->filters[$orig_name]);
+          }
+          
+          // Now append the new filter object.
+          $this->filters[$new_name] = $this->dialog->save();
+          $this->dialog = NULL;
+          $this->filterWidget->setListData($this->filters, $this->convertFilterList());
+          $this->filterWidget->update();
+        }
       }
     }
 
index e1ca3012f0b4b84ce3952b804304524a7f698743..76e0bcb249df248bc933c6a3e4f06ab06a3d3ceb 100644 (file)
@@ -106,6 +106,26 @@ class filterEditEntry extends plugin
     }
   }
 
+  
+  /*! \brief    Validate user input 
+   *  @return   Array   An Array containing potential error messages
+   */
+  function check()
+  {
+    $msgs = plugin::check();
+  
+    // Check if the name is given
+    if(empty($this->name)){
+      $msgs[] = msgPool::required(_("Name"));
+    }elseif(preg_match("/[^a-z0-9\-_ ]/i", $this->name)){
+      
+      // Check for a valid name, no special chars here - in particular no ; 
+      $msgs[] = msgPool::invalid(_("Name"), $this->name,"/[a-z0-9\-_ ]/i");
+    }  
+
+    return($msgs);
+  }
+
 
   /*! \brief    Transforms the entered values into a filter object (array) which is useable
    *             for the filterEditor overview dialog.