From 193c69a93e2941e51439fab9e03dc32eedb4bb44 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 10 Mar 2010 08:35:57 +0000 Subject: [PATCH] Added checks to filterEditor. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16364 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_filterEditor.inc | 26 +++++++++++++------ gosa-core/include/class_filterEditorEntry.inc | 20 ++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/gosa-core/include/class_filterEditor.inc b/gosa-core/include/class_filterEditor.inc index 521eab71c..92a0621e9 100644 --- a/gosa-core/include/class_filterEditor.inc +++ b/gosa-core/include/class_filterEditor.inc @@ -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(); + } } } diff --git a/gosa-core/include/class_filterEditorEntry.inc b/gosa-core/include/class_filterEditorEntry.inc index e1ca3012f..76e0bcb24 100644 --- a/gosa-core/include/class_filterEditorEntry.inc +++ b/gosa-core/include/class_filterEditorEntry.inc @@ -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. -- 2.30.2