From: hickert Date: Thu, 21 Oct 2010 13:33:45 +0000 (+0000) Subject: Updated config management class X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e07d6f9b10e1dc584d909d29b51b045f8ae42385;p=gosa.git Updated config management class git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20111 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl b/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl index 5cc4b060b..31ff3628b 100644 --- a/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl +++ b/gosa-core/plugins/admin/newConfigManagement/DeviceConfig-list.tpl @@ -6,8 +6,8 @@ - - + + diff --git a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc index 054ad2e13..c6613a2f0 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc @@ -3,6 +3,8 @@ class ConfigManagementDataModel { private $data = array(); + private $typeToPath = array(); + private $idToPath = array(); function __construct() { @@ -12,36 +14,67 @@ class ConfigManagementDataModel $this->addItem('root', '','root', array()); } + function getDataModel() + { + return($this->data); + } + + + - function addItem($type, $base, $name, $values, $status = "") + function addItem($type, $path, $name, $values = array(), $status = "") { - if($base == ""){ + if($path == ""){ $parentItem = &$this->data['recursive']; $parentId = NULL; - }elseif(isset($this->data['linear'][$base])){ - $parentItem = &$this->data['linear'][$base]['children']; - $parentId = $this->data['linear'][$base]['id']; + $parentDn = ""; + }elseif(isset($this->data['linear'][$path])){ + $parentItem = &$this->data['linear'][$path]['children']; + $parentId = $this->data['linear'][$path]['id']; + $parentDn = $this->data['linear'][$path]['dn']; }else{ echo "No parent"; return(FALSE); } $this->currentID ++; - $entryBase = "{$base}/{$name}"; + $entryPath = "{$path}/{$name}"; + $entryDn = rtrim("cn={$name},{$parentDn}",','); $entryId = $this->currentID; - $entry['dn'] = $entryBase; + $entry['path'] = $entryPath; + $entry['dn'] = $entryDn; $entry['id'] = $entryId; $entry['parentId'] = $parentId; $entry['name'] = $name; - $entry['base'] = $base; + $entry['path'] = $entryPath; + $entry['parentPath'] = $path; + $entry['type'] = $type; $entry['status'] = $status; $entry['values'] = $values; $entry['children'] = array(); - $parentItem[$entryBase] = &$entry; - $this->data['linear'][$entryBase] = &$parentItem[$entryBase]; - return(TRUE); + $parentItem[$entryPath] = &$entry; + $this->data['linear'][$entryPath] = &$parentItem[$entryPath]; + + $this->idToPath[$entryId] = $entryPath; + $this->typeToPath[$type][$name] = $entryPath; + + return($entryId); + } + + function pathToDn($path) + { + + } + + function getItemsByType($type) + { + $res = array(); + foreach($this->typeToPath[$type] as $path){ + $res[$path] = $this->data['linear'][$path]; + } + return($res); } } diff --git a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc index b62e5a60f..2e0de2bed 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementListing.inc @@ -5,8 +5,8 @@ class ConfigManagementListing extends management private $base = ""; + private $distributionSelector = NULL; private $releaseSelector = NULL; - private $itemSelector = NULL; function __construct($config, $ui) @@ -15,32 +15,48 @@ class ConfigManagementListing extends management $this->storagePoints = array(""); $this->rebuildListing(); - - $this->releaseSelector = new ItemSelector(array('cn=/'=>'/'),"cn=/","cn=/"); - $this->itemSelector = new ItemSelector(array('cn=/'=>'/'),"cn=/","cn=/"); + $this->distributionSelector = new ItemSelector(array('cn=root'=>'root'),"cn=root","cn=root"); + $this->releaseSelector = new ItemSelector(array('cn=root'=>'root'),"cn=root","cn=root"); } - function setRelease($base) + function save_object() { - $this->releaseSelector->setBase($base); + $this->distributionSelector->update(); + $this->releaseSelector->update(); } - function setReleases ($releases) + function getSelectedDistribution() { - $this->releaseSelector->setBases($releases); + return($this->distributionSelector->getBase()); + } + + function getSelectedRelease() + { + return($this->releaseSelector->getBase()); } + function setDistribution($base) + { + $this->distributionSelector->setBase($base); + } - function setItem($base) + function setDistributions($distributions) { - $this->itemSelector->setBase($base); + $this->distributionSelector->setBases($distributions); + $this->distributionSelector->update(TRUE); } - function setItems ($items) + function setRelease($base) { - $this->itemSelector->setBases($items); + $this->releaseSelector->setBase($base); } - function setAllowedItems() {} + + function setReleases($releases) + { + $this->releaseSelector->setBases($releases); + $this->releaseSelector->update(TRUE); + } + function renderList() { session::set('DEVICE_ITEMS', array()); @@ -50,11 +66,8 @@ class ConfigManagementListing extends management $headpage->update(); $smarty = get_smarty(); - $this->releaseSelector->update(TRUE); - $this->itemSelector->update(TRUE); - + $smarty->assign("DISTRIBUTION", $this->distributionSelector->render()); $smarty->assign("RELEASE", $this->releaseSelector->render()); - $smarty->assign("ITEM", $this->itemSelector->render()); $display = $headpage->render(); return($this->getHeader().$display); @@ -80,19 +93,7 @@ class ConfigManagementListing extends management $headpage->setFilter($filter); parent::__construct($this->config, $this->ui, "services", $headpage); - - // Register default actions - $this->registerAction("new", "newEntry"); - $this->registerAction("edit", "openEntry"); // !! We forward 'edit' to 'open' to have a department like navigation. - $this->registerAction("editEntry", "editEntry"); - - $this->registerAction("saveItemChanges", "saveItemChanges"); - $this->registerAction("cancelItemEdit", "closeDialogs"); - $this->registerAction("cancelItemAdd", "closeDialogs"); - $this->registerAction("saveItemAdd", "saveItemAdd"); } - - } ?> diff --git a/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc index 3694b9d38..d5d08878f 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc @@ -8,59 +8,54 @@ class newConfigManagement extends plugin var $installationMethods = array(); + var $selectedDistribution; + function __construct($config, $dn) { $this->config = &$config; - $this->listing = new ConfigManagementListing($this->config, get_userinfo()); $this->dataModel = new ConfigManagementDataModel(); + // Load distributions + $rpc = $this->config->getRpcHandle(); + $res = $rpc->getDistributions(); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), sprintf(_("Failed to load distributions, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); + return(NULL); + } + foreach($res as $dist){ + $this->dataModel->addItem('Distribution','/root', $dist); + + // Load the releases for the current distribution + $releases = $rpc->getReleases($dist); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), sprintf(_("Failed to load releases, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); + return(NULL); + } + foreach($releases as $release){ + $this->dataModel->addItem('Release',"/root/{$dist}", $release); + + // Load packages + $packages = $rpc->getPackages($release); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), sprintf(_("Failed to load packages, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); + return(NULL); + } + foreach($packages as $package){ + $this->dataModel->addItem('Package',"/root/{$dist}/{$release}", $package['name'], $package); + } + } + } -# $dists = $this->getDistributions(); -# foreach($dists as $name => $dist){ -# -# -# $this->dataModel->addItem -# -# -# } -# -# -# -# -# -# // Get installation methods from the backend. -# $this->loadInstallationMethods(); } - - function getDistributions() + function save_object() { - return( - array( - 'debian' => - array('type' => 'deb', 'install_method' => 'puppet'), - 'suse' => - array('type' => 'rpm', 'install_method' => 'muppet') - )); + $this->listing->save_object(); + $this->selectedDistribution = $this->listing->getSelectedDistribution(); + $this->selectedRelease = $this->listing->getSelectedRelease(); } - - - - - - - - - - - - - - - - /*! \brief Intializes this plugin * All available installation methods will be loaded @@ -87,34 +82,52 @@ class newConfigManagement extends plugin $this->initFailed = TRUE; return; } + } - $this->getReleases(); + function execute() + { + $this->listing->setDistributions($this->getDistList()); + $this->listing->setReleases($this->getReleaseList()); + return($this->listing->renderList()); } - - - function getReleases() + function getReleaseList() { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getReleases(); - if(!$rpc->success()){ - $this->rpcError = TRUE; - $this->errorMessage = $rpc->get_error();; - return(NULL); + $res = array(); + $res = array("cn=root" => '/'); + if(isset($this->distributionMap[$this->selectedDistribution])){ + $dist = $this->distributionMap[$this->selectedDistribution]; + $list = $this->dataModel->getItemsByType('Release'); + $this->releaseMap = array(); + foreach($list as $base => $entry){ + if($entry['parentPath'] != $dist) continue; + $res["cn={$entry['name']},cn=root"] = $entry['name']; + $this->releaseMap["cn={$entry['name']},cn=root"] = $entry['path']; + } } return($res); } - - - function execute() + + + function getDistList() { - return($this->listing->renderList()); + $list = $this->dataModel->getItemsByType('Distribution'); + $res = array(); + $res = array("cn=root" => ''); + $this->distributionMap = array(); + foreach($list as $base => $entry){ + $res["cn={$entry['name']},cn=root"] = $entry['name']; + $this->distributionMap["cn={$entry['name']},cn=root"] = $entry['path']; + } + return($res); } + function remove_lock() - {} + { + } public static function plInfo() { @@ -131,8 +144,5 @@ class newConfigManagement extends plugin "plProvidedAcls"=> array() )); } - } - - ?> diff --git a/gosa-core/plugins/admin/newConfigManagement/main.inc b/gosa-core/plugins/admin/newConfigManagement/main.inc index 26ce1e362..0eea23740 100644 --- a/gosa-core/plugins/admin/newConfigManagement/main.inc +++ b/gosa-core/plugins/admin/newConfigManagement/main.inc @@ -18,6 +18,7 @@ if ( $cleanup ){ session::set('newConfigManagement',$newConfigManagement); } $newConfigManagement = session::get('newConfigManagement'); + $display= $newConfigManagement->save_object(); $display= $newConfigManagement->execute(); /* Reset requested? */
{$RELOAD}{t}Release{/t} {$RELEASE}{t}Item{/t} {$ITEM}{t}Release{/t} {$DISTRIBUTION}{t}Item{/t} {$RELEASE} {$ACTIONS} {$FILTER}