From c7db99e6c5d049026b7b07ea63fe999d2f995bd1 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 1 Oct 2010 13:46:18 +0000 Subject: [PATCH] Updated list widget git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19885 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../goto/Config/class_DeviceConfig.inc | 66 +++++++++++-------- .../goto/Config/class_TemplateWidget_list.inc | 18 ++++- 2 files changed, 57 insertions(+), 27 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc index 03a2a075a..4e8a19342 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc @@ -202,6 +202,36 @@ class DeviceConfig extends management } + /*! \brief Removes a given item ID. + * @param String The 'id' of the item we want to remove. + * @return + */ + function removeItem($id, &$data = NULL) + { + if($data === NULL){ + $data = &$this->allConfiguredItems; + } + + // Remove the item and its children + if(isset($data[$id])){ + foreach($data[$id]['children'] as $cid => $item){ + $this->removeItem($cid, $data); + } + unset($data[$id]); + } + + // Remove to current id from sub entries + foreach($data as $key => $item){ + $this->removeItem($id, $data[$key]['children']); + } + } + + + /*! \brief Initiate item edit. + * An action send from the management list. + * @param See management::editEntry + * @return + */ function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { @@ -216,6 +246,8 @@ class DeviceConfig extends management } + /*! \brief Save changes for the currently edited item. + */ function saveItemChanges() { // Save eventually changed values @@ -235,6 +267,8 @@ class DeviceConfig extends management } + /*! \brief React on open requests from the management list + */ function openEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { @@ -400,6 +434,9 @@ class DeviceConfig extends management } + /*! \brief Saves newly created items and adds them as child to + * the currently selected item. + */ function saveItemAdd() { if(!$this->dialogObject instanceOf AddItemDialog) return; @@ -434,10 +471,6 @@ class DeviceConfig extends management */ function save_object() { - if($this->dialogObject){ - $this->TemplateEngine->save_object(); - } - // Add sub-module requested. if(isset($_POST['addSubModule']) && isset($_POST['subModule'])){ $sub = get_post('subModule'); @@ -461,7 +494,9 @@ class DeviceConfig extends management $this->setSelectedListItemID($id); } - + + /* \brief Updates the currenlty seleted item in the management list + */ function setSelectedListItemID($id) { $this->base = $this->mappingBaseToID[$id]; @@ -510,27 +545,6 @@ class DeviceConfig extends management } - function removeItem($id, &$data = NULL) - { - if($data === NULL){ - $data = &$this->allConfiguredItems; - } - - // Remove the item and its children - if(isset($data[$id])){ - foreach($data[$id]['children'] as $cid => $item){ - $this->removeItem($cid, $data); - } - unset($data[$id]); - } - - // Remove to current id from sub entries - foreach($data as $key => $item){ - $this->removeItem($id, $data[$key]['children']); - } - } - - // Inject user actions function detectPostActions() { diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_list.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_list.inc index 0d21145d8..358fed7aa 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_list.inc +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_list.inc @@ -39,8 +39,24 @@ class TemplateWidget_list extends TemplateWidget if(isset($_POST["{$this->postName}_Add"]) && isset($_POST["{$this->postName}_Input"])){ $input = get_post("{$this->postName}_Input"); - $this->value[] = $input; + + if(!empty($input) && !empty($this->syntax) && !preg_match("/".$this->syntax."/", $input)){ + msg_dialog::displayChecks(array(msgPool::invalid($this->display, $input, "/".$this->syntax."/"))); + }elseif(!empty($input)){ + $this->value[] = $input; + } + } + } + + /*! \brief Check the value entry using the provieded syntax. + * @return Array Returns a list of errors + */ + function check() + { + if($this->required && empty($this->value)){ + return(array(msgPool::required($this->display))); } + return(array()); } } -- 2.30.2