Code

Added some checks
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Sep 2010 12:17:22 +0000 (12:17 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Sep 2010 12:17:22 +0000 (12:17 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19832 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc
gosa-plugins/goto/admin/systems/goto/Config/class_TemplateEngine.inc

index 38388e14f565b291e5a63a502a6cc54cd1aea320..2f14d4e8bd693cb19090513d056afacb4127d63f 100644 (file)
@@ -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())!<br>";
+                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){
index 30767bc5b5a966c8d7da495725c45d1dad281f3e..fac61cbdec24b1ab0f424fcace04cc2b29f01eb9 100644 (file)
@@ -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,