Code

Updated listing and creation of distributions
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 May 2011 14:08:06 +0000 (14:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 May 2011 14:08:06 +0000 (14:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20781 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateEngine.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc

index a1dcbf40b72ab0c256a4d737dd9836b5c65cc830..e41f61f1f21176d31370d5f5561a2d9b70b8119d 100644 (file)
@@ -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);
                 }
             }
index 65172d44d761e3d76c109b3410ebf99d749c0dc4..d4f646b5646a0af97595a092a47d841f971606c7 100644 (file)
@@ -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);
+                            }
                         }
                     }
                 }