From 475a2aaa7d72c9b450de7d91f4ff4f05078e0915 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 5 May 2011 14:08:06 +0000 Subject: [PATCH] Updated listing and creation of distributions git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20781 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../TemplateEngine/class_TemplateEngine.inc | 2 +- .../class_newConfigManagement.inc | 87 ++++++++++--------- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc index a1dcbf40b..e41f61f1f 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc @@ -121,7 +121,7 @@ class TemplateEngine // Check if we've to disable this item. if(isset($item['disable']) && $item['disable'] || - isset($item['initiallyEditableOnly']) && $item['initiallyEditableOnly']){ + (isset($item['initiallyEditableOnly']) && $item['initiallyEditableOnly'] && !$this->is_new)){ $this->widgets[$name]->setEnabled(FALSE); } } diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc index 65172d44d..d4f646b56 100644 --- a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -172,54 +172,57 @@ class newConfigManagement extends plugin $this->errorMessage = sprintf(_("Failed to load distributions: %s"), $rpc->get_error()); return(FALSE); }else{ - foreach($res as $dist){ - - // Simple strings - $values = array(); - foreach(array('origin','installation_method', 'installation_method','debian_security', - 'debian_volatile', 'name', 'mirror_sources', 'managed', 'path') as $attr){ - $values[$attr] = $dist[$attr]; - } + if(is_array($res)){ - // Boxed strings - foreach(array('type') as $attr){ - $values[$attr] = $dist[$attr]['name']; - } + foreach($res as $dist){ + + // Simple strings + $values = array(); + foreach(array('origin','installation_method', 'installation_method','debian_security', + 'debian_volatile', 'name', 'mirror_sources', 'managed', 'path') as $attr){ + $values[$attr] = $dist[$attr]; + } + + // Boxed strings + foreach(array('type') as $attr){ + $values[$attr] = $dist[$attr]['name']; + } - // Arrays - foreach(array('releases', 'architectures', 'components', 'sections') as $attr){ - $values[$attr] = array(); - if(is_array($dist[$attr])){ - foreach($dist[$attr] as $aEntry){ - $values[$attr][] = $aEntry['name']; + // Arrays + foreach(array('releases', 'architectures', 'components', 'sections') as $attr){ + $values[$attr] = array(); + if(is_array($dist[$attr])){ + foreach($dist[$attr] as $aEntry){ + $values[$attr][] = $aEntry['name']; + } } } - } - - $this->dataModel->addItem('Distribution','/root', $dist['name'], $values); + + $this->dataModel->addItem('Distribution','/root', $dist['name'], $values); - if(isset($dist['releases'])){ + if(isset($dist['releases'])){ - // Sort releases by name length - $sort = array(); - foreach($dist['releases'] as $id => $release){ - $sort[strlen($release['name']) . $release['name']] = $id; - } - uksort($sort, "strnatcasecmp"); - - // Append release tags - foreach($sort as $id){ - $release = $dist['releases'][$id]; - $rPath = $release['name']; - $rPath = "/root/{$dist['name']}/$rPath"; - $rName = preg_replace("/^.*\//","", $rPath); - $rPath = preg_replace("/\/[^\/]*$/","", $rPath); - $values = array('name' => $rName); - - if(!$this->dataModel->itemExistsByPath($rPath)){ - trigger_error("Invalid release name '{$rName}' in path '{$rPath}' received! Skipping entry!"); - }else{ - $id = $this->dataModel->addItem('Release',$rPath, $rName, $values); + // Sort releases by name length + $sort = array(); + foreach($dist['releases'] as $id => $release){ + $sort[strlen($release['name']) . $release['name']] = $id; + } + uksort($sort, "strnatcasecmp"); + + // Append release tags + foreach($sort as $id){ + $release = $dist['releases'][$id]; + $rPath = $release['name']; + $rPath = "/root/{$dist['name']}/$rPath"; + $rName = preg_replace("/^.*\//","", $rPath); + $rPath = preg_replace("/\/[^\/]*$/","", $rPath); + $values = array('name' => $rName); + + if(!$this->dataModel->itemExistsByPath($rPath)){ + trigger_error("Invalid release name '{$rName}' in path '{$rPath}' received! Skipping entry!"); + }else{ + $id = $this->dataModel->addItem('Release',$rPath, $rName, $values); + } } } } -- 2.30.2