From 9bb4006654f6f2a3099b168f854ed91f35457eac Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 28 Sep 2010 12:17:22 +0000 Subject: [PATCH] Added some checks git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19832 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../goto/Config/class_DeviceConfig.inc | 23 +++++++++++++++++-- .../goto/Config/class_TemplateEngine.inc | 5 +--- 2 files changed, 22 insertions(+), 6 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 38388e14f..2f14d4e8b 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc @@ -77,6 +77,7 @@ class DeviceConfig extends management ); $this->addItem('PuppetModule','test2', array( + 'dependency' => '', 'version' => 1, 'name' => 'Firefox', 'description' => 'Test Module') @@ -85,13 +86,13 @@ class DeviceConfig extends management $this->addItem('PuppetTemplate','temp1', array( 'name' => 'temp1', - 'file' => 'kekse.tpl') + 'data' => 'kekse.tpl') ); $this->setCurrentItem('temp1'); $this->addItem('PuppetTemplate','tep1', array( 'name' => 'tep1', - 'file' => 'kekse.tpl') + 'data' => 'kekse.tpl') ); $this->setCurrentItem('root'); @@ -210,6 +211,19 @@ class DeviceConfig extends management */ function addItem($type,$name, $values) { + if(!isset($this->itemConfig[$type])){ + echo "Invalid type {$type}, skipping item!"; + return; + } + + $allValuesSet = TRUE; + foreach($this->itemConfig[$type]['options'] as $oName => $option){ + if(!isset($values[$oName])){ + echo "Missing value for option {$oName}! Skipping addItem({$type},{$name},array())!
"; + return; + } + } + $current = &$this->currentItem; $this->idToName[] = $name; $new = array( @@ -231,6 +245,11 @@ class DeviceConfig extends management { // Do nothing if we're already where we wanted to switch to. if($this->currentItemName == $item) return; + + if(!isset($this->currentItemValues[$item])){ + echo "Invalid item name {$name}! Skipping selection!"; + return; + } // Save eventually changed values if($this->currentItem){ diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc index 30767bc5b..fac61cbde 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc @@ -84,10 +84,7 @@ class TemplateEngine } // Prepare the value for the widget - $value = $item['value']; - if(isset($values[$name])){ - $value = $values[$name]; - } + $value = $values[$name]; // Create the new widget. $this->widgets[$name] = new $widgetClassName($this->config, $name, -- 2.30.2