From: hickert Date: Fri, 22 Oct 2010 07:35:18 +0000 (+0000) Subject: Updated new Config Management X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a0c6b5a5a57800952932e3d38af215921e79acb5;p=gosa.git Updated new Config Management -Updated handling of the dataModel git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20121 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc index c6613a2f0..dcb5d598a 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc @@ -68,11 +68,19 @@ class ConfigManagementDataModel } + function getItemByPath($path) + { + if(isset($this->data['linear'][$path])){ + return($this->data['linear'][$path]); + } + return(NULL); + } + function getItemsByType($type) { $res = array(); - foreach($this->typeToPath[$type] as $path){ - $res[$path] = $this->data['linear'][$path]; + foreach($this->data['linear'] as $path => $item){ + if($item['type'] == $type) $res[] = $item; } return($res); } diff --git a/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc index 7cea340d6..f1eb09d3a 100644 --- a/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc +++ b/gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc @@ -6,14 +6,31 @@ class newConfigManagement extends plugin var $plHeadline = "Config management"; var $plDescription = "Config management"; - var $installationMethods = array(); - var $selectedDistribution; + var $selectedRelease; + + var $dataModel = NULL; + var $listing = NULL; + + /*! \brief Initialize the plugin and finally update the data model. + */ function __construct($config, $dn) { $this->config = &$config; $this->listing = new ConfigManagementListing($this->config, get_userinfo()); + + // Request an update of the data model + $this->updateDataModel(); + } + + + /*! \brief Updates all distributions, releases, packages and items in the dataModel + * Load information from the backend. + */ + function updateDataModel() + { + // Recreate the data model, to have a clean and fresh instance. $this->dataModel = new ConfigManagementDataModel(); // Load distributions @@ -44,20 +61,41 @@ class newConfigManagement extends plugin foreach($packages as $package){ $this->dataModel->addItem('Package',"/root/{$dist}/{$release}", $package['name'], $package); } + + // Load items + $items = $rpc->listConfigItems($release); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), sprintf(_("Failed to load items, error was '%s'!"), $rpc->get_error()),ERROR_DIALOG); + return(NULL); + } + foreach($items as $package){ + $this->dataModel->addItem('Item',"/root/{$dist}/{$release}", $package['name'], $package); + } } } } + + /*! \brief Keep track of posted values and populate those + * which are interesting for us. + * Inspects the _POST and _GET values. + */ function save_object() { + // Update the listing class, this is necessary to get post + // actions from it. $this->listing->save_object(); + + // Get the selected distribution and release from the listing widget. $this->selectedDistribution = $this->listing->getSelectedDistribution(); $this->selectedRelease = $this->listing->getSelectedRelease(); - + + // Get a list of all available distributions and releases. $distList = $this->getDistList(); $releaseList = $this->getReleaseList(); + // Ensure that we've valid values selected. if(!isset($releaseList[$this->selectedRelease])){ if(count($releaseList)){ $this->selectedRelease = key($releaseList); @@ -65,55 +103,34 @@ class newConfigManagement extends plugin $this->selectedRelease = ""; } } + + // Transfer checked values back to the listing class. $this->listing->setDistribution($this->selectedDistribution); $this->listing->setRelease($this->selectedRelease); $this->listing->setDistributions($this->getDistList()); $this->listing->setReleases($this->getReleaseList()); } - - /*! \brief Intializes this plugin - * All available installation methods will be loaded - */ - function loadInstallationMethods() - { - // Reset erros - $this->rpcError = $this->initFailed = FALSE; - - // Load configuration via rpc. - $rpc = $this->config->getRpcHandle(); - - // Populate install methods on success. - $res = $rpc->getSupportedInstallMethods(); - if(!$rpc->success()){ - $this->rpcError = TRUE; - $this->errorMessage = $rpc->get_error();; - return; - } - $this->installationMethods = $res; - if(!count($this->installationMethods)){ - $this->errorMessage = _("No selectable install methods returned!"); - msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG); - $this->initFailed = TRUE; - return; - } - } - + /*! \brief Generate the HTML content for this plugin. + * Actually renders the listing widget.. + */ function execute() { - $list = $this->dataModel->getItemsByType('Package'); - $rel = $this->selectedRelease; - $displayEntries = array(); - foreach($list as $entry){ - if($entry['parentPath'] == $rel){ - $displayEntries[] = $entry; - } - } + // Get the selected release and store it in a session variable + // to allow the configFilter to access it and display the + // packages and items. + $item = $this->dataModel->getItemByPath($this->selectedRelease); + print_a($item); + return($this->listing->renderList()); } + /*! \brief Returns a simply list of all releases of the CURRENT distribution. + * This list will then be used to generate the entries of the + * ItemSelectors in the listing class. + */ function getReleaseList() { $res = array(); @@ -127,6 +144,10 @@ class newConfigManagement extends plugin } + /*! \brief Returns a simply list of all distributions. + * This list will then be used to generate the entries of the + * ItemSelectors in the listing class. + */ function getDistList() { $list = $this->dataModel->getItemsByType('Distribution'); @@ -142,6 +163,35 @@ class newConfigManagement extends plugin { } + + /*! \brief Intializes this plugin + * All available installation methods will be loaded + */ + function loadInstallationMethods() + { + // Reset erros + $this->rpcError = $this->initFailed = FALSE; + + // Load configuration via rpc. + $rpc = $this->config->getRpcHandle(); + + // Populate install methods on success. + $res = $rpc->getSupportedInstallMethods(); + if(!$rpc->success()){ + $this->rpcError = TRUE; + $this->errorMessage = $rpc->get_error();; + return; + } + $this->installationMethods = $res; + if(!count($this->installationMethods)){ + $this->errorMessage = _("No selectable install methods returned!"); + msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG); + $this->initFailed = TRUE; + return; + } + } + + public static function plInfo() { return (array(