summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f50687)
raw | patch | inline | side by side (parent: 2f50687)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 22 Oct 2010 07:35:18 +0000 (07:35 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 22 Oct 2010 07:35:18 +0000 (07:35 +0000) |
-Updated handling of the dataModel
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20121 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20121 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc | patch | blob | history | |
gosa-core/plugins/admin/newConfigManagement/class_newConfigManagement.inc | patch | blob | history |
diff --git a/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-core/plugins/admin/newConfigManagement/class_ConfigManagementDataModel.inc
index c6613a2f067b7477bbda3cf8e3baadcd16704005..dcb5d598ae5870899c8ad8faccaf1e0db09169c8 100644 (file)
}
+ 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 7cea340d67fe3031b7672a06090dad52acfaa7c3..f1eb09d3afb6dd0a2419e227c4f6fae3f5afa0c5 100644 (file)
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
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);
$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();
}
+ /*! \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');
{
}
+
+ /*! \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(