From: hickert Date: Wed, 1 Dec 2010 14:18:50 +0000 (+0000) Subject: Renamed plugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fd157d7dea15cb0cc7fb3507949a33013012f9f2;p=gosa.git Renamed plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20494 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-filter.xml b/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-filter.xml deleted file mode 100644 index 7a0c28d27..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-filter.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - true - Device - auto - default - - - - - - default - - - ConfigManagement - $ - - - cn - 0.5 - 3 - - - - diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-list.tpl b/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-list.tpl deleted file mode 100644 index e4c7373b2..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-list.tpl +++ /dev/null @@ -1,22 +0,0 @@ -
- -
-

{$HEADLINE} {$SIZELIMIT}

-
- - - - - - - - -
{$RELOAD}{t}Container{/t} {$CONTAINER}{t}Item{/t} {$ITEM}{$ACTIONS}{$FILTER}
-
-
- - {$LIST} -
- -
- diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-list.xml b/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-list.xml deleted file mode 100644 index 99bc644f8..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/DeviceConfig-list.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - false - false - false - true - - - 1 - - %TYPES% - - - - - |20px;c|||170px;r| - - - %{filter:objectType(dn,objectClass)} - - - - %{filter:departmentLink(row,dn,description)} - 2 - - - - %{filter:objectType(dn,objectClass)} - - - - - cn - string - %{filter:link(row,dn,"%s",cn,pid)} - true - - - - - description - string - %{filter:link(row,dn,"%s",description,pid)} - true - - - - - %{filter:actions(dn,row,objectClass)} - - -
- - - - %ITEMS% - - - remove - entry - images/lists/trash.png - - - - - - - - - editEntry - entry - images/lists/edit.png - - - - - remove - entry - images/lists/trash.png - - - - - -
diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-plugins/gosa-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc deleted file mode 100644 index a4cc53143..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc +++ /dev/null @@ -1,118 +0,0 @@ -data = array(); - $this->data['linear'] = array(); - $this->data['recursive'] = array(); - $this->addItem('root', '','root', array()); - } - - function getDataModel() - { - return($this->data); - } - - - - - function addItem($type, $path, $name, $values = array(), $status = "") - { - if($path == ""){ - $parentItem = &$this->data['recursive']; - $parentId = NULL; - $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 ++; - $entryPath = "{$path}/{$name}"; - $entryDn = rtrim("cn={$name},{$parentDn}",','); - $entryId = $this->currentID; - - $entry['path'] = $entryPath; - $entry['dn'] = $entryDn; - $entry['id'] = $entryId; - $entry['parentId'] = $parentId; - $entry['name'] = $name; - $entry['path'] = $entryPath; - $entry['parentPath'] = $path; - $entry['type'] = $type; - $entry['status'] = $status; - $entry['values'] = $values; - $entry['children'] = array(); - - $parentItem[$entryPath] = &$entry; - $this->data['linear'][$entryPath] = &$parentItem[$entryPath]; - - $this->idToPath[$entryId] = $entryPath; - $this->typeToPath[$type][$name] = $entryPath; - - return($entryId); - } - - function pathToDn($path) - { - - } - - function itemExistsByPath($path) - { - return(isset($this->data['linear'][$path])); - } - - function getItemByPath($path) - { - if(isset($this->data['linear'][$path])){ - return($this->data['linear'][$path]); - } - return(NULL); - } - - function setItemStatus($path, $status) - { - if(!$this->itemExistsByPath($path)){ - trigger_error("Invalid item path '{$path}'!"); - }else{ - $this->data['linear'][$path]['status'] = $status; - } - } - - function getItemsByType($types) - { - $res = array(); - foreach($this->data['linear'] as $path => $item){ - if(in_array($item['type'],$types)) $res[] = $item; - } - return($res); - } - - - function getItemById($id) - { - $path = NULL; - if(isset($this->idToPath[$id])){ - $path = $this->idToPath[$id]; - }else{ - return(NULL); - } - if(isset($this->data['linear'][$path])){ - return($this->data['linear'][$path]); - } - return(NULL); - } -} - -?> diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_ConfigManagementListing.inc b/gosa-plugins/gosa-ng/admin/newConfigManagement/class_ConfigManagementListing.inc deleted file mode 100644 index c1d4c93e4..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_ConfigManagementListing.inc +++ /dev/null @@ -1,232 +0,0 @@ -storagePoints = array(""); - $this->rebuildListing(); - - $this->containerSelector = new ItemSelector(array(),'/root','/root'); - $this->itemSelector = new ItemSelector(array(),'',''); - - $this->parent = &$parent; - } - - function save_object() - { - $this->containerSelector->update(); - $this->itemSelector->update(); - } - - function getSelectedContainer() - { - return($this->containerSelector->getBase()); - } - - function setContainer($dist) - { - return($this->containerSelector->setBase($dist)); - } - - function setItem($rel) - { - return($this->itemSelector->setBase($rel)); - } - - function getSelectedItem() - { - return($this->itemSelector->getBase()); - } - - - function setContainers($containers) - { - $this->containerSelector->setBases($containers); - $this->containerSelector->update(TRUE); - } - - function setItems($items) - { - $this->itemSelector->setBases($items); - $this->itemSelector->update(TRUE); - } - - - function renderList() - { - $headpage = $this->getHeadpage(); - $headpage->update(); - $smarty = get_smarty(); - $smarty->assign("CONTAINER", $this->containerSelector->render()); - $smarty->assign("ITEM", $this->itemSelector->render()); - $display = $headpage->render(); - return($this->getHeader().$display); - } - - - function setListingTypes($types) - { - $str = ""; - foreach($types as $typeData){ - $str.= "\n"; - foreach($typeData as $key => $value){ - $str .= "\n\t<{$key}>{$value}"; - } - $str.= "\n\n"; - - } - $this->objectTypeStr = $str; - } - - - function execute() - { - // Ensure that html posts and gets are kept even if we see a 'Entry islocked' dialog. - $vars = array('/^act$/','/^listing/','/^PID$/','/^FILTER_PID$/'); - session::set('LOCK_VARS_TO_USE',$vars); - - pathNavigator::registerPlugin($this); - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandler("",array()); - if($ret){ - return($this->getHeader().$ret); - } - - // Update filter - if ($this->filter) { - $this->filter->update(); - session::global_set(get_class($this)."_filter", $this->filter); - session::set('autocomplete', $this->filter); - } - - // Handle actions (POSTs and GETs) - $str = $this->handleActions($this->detectPostActions()); - if($str) return($this->getHeader().$str); - - $items = $this->parent->getItemsToBeDisplayed(); - session::set('CONFIG_ITEM', $items); - - // Open single dialog objects - if(is_object($this->dialogObject)){ - if(method_exists($this->dialogObject,'save_object')) $this->dialogObject->save_object(); - if(method_exists($this->dialogObject,'execute')){ - $display = $this->dialogObject->execute(); - $display.= $this->_getTabFooter(); - return($this->getHeader().$display); - } - } - - // Display tab object. - if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){ -# $this->tabObject->save_object(); - $display = $this->tabObject->execute(); - $display.= $this->_getTabFooter(); - return($this->getHeader().$display); - } - // Set current restore base for snapshot handling. - if(is_object($this->snapHandler)){ - $bases = array(); - foreach($this->storagePoints as $sp){ - $bases[] = $sp.$this->headpage->getBase(); - } - - // No bases specified? Try base - if(!count($bases)) $bases[] = $this->headpage->getBase(); - - $this->snapHandler->setSnapshotBases($bases); - } - - // Create statistic table entry - stats::log('management', $class = get_class($this), $this->getAclCategories(), $action = 'view', - $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); - - // Display list - $this->rebuildListing(); - $str = $this->renderList(); - return($str); - } - - - - function rebuildListing() - { - // Build filter - if (session::global_is_set(get_class($this)."_filter")){ - $filter= session::global_get(get_class($this)."_filter"); - } else { - $filter = new filter(get_template_path("DeviceConfig-filter.xml", true)); - $filter->setObjectStorage($this->storagePoints); - } - $this->setFilter($filter); - - // Load service xml file and fill in placeholders - $contents = file_get_contents(get_template_path("DeviceConfig-list.xml", true)); - $contents = preg_replace("/%TYPES%/", $this->objectTypeStr, $contents); - $contents = preg_replace("/%ITEMS%/", "", $contents); - - $headpage = new listing($contents,TRUE); - $headpage->setBase($this->base); - $headpage->setFilter($filter); - - parent::__construct($this->config, $this->ui, "services", $headpage); - - // Register default actions - $this->registerAction("new", "newEntry"); - $this->registerAction("editEntry", "editEntry"); - $this->registerAction("edit", "openEntry"); - $this->registerAction("apply", "applyChanges"); - $this->registerAction("save", "saveChanges"); - $this->registerAction("cancel", "cancelEdit"); - $this->registerAction("cancelDelete", "cancelEdit"); - $this->registerAction("remove", "removeEntryRequested"); - $this->registerAction("removeConfirmed", "removeEntryConfirmed"); - - $this->registerAction("config-filter","editFilter"); - $this->registerAction("saveFilter","saveFilter"); - $this->registerAction("cancelFilter","cancelFilter"); - - } - - function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") - { - $this->parent->removeEntry($target); - } - - function openEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") - { - $this->parent->openEntry($target); - } - - function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") - { - $this->parent->editEntry($target); - } - - - - - - - - - - - - - - - - -} - -?> diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_filterConfigManagement.inc b/gosa-plugins/gosa-ng/admin/newConfigManagement/class_filterConfigManagement.inc deleted file mode 100644 index 87697b819..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_filterConfigManagement.inc +++ /dev/null @@ -1,52 +0,0 @@ - 1); - $entry[] = 'cn'; - $entry['id'] = array($item['id'], 'count' => 1); - $entry[] = 'id'; - $entry['description'] = array($item['type'], 'count' => 1); - $entry[] = 'description'; - $entry['objectClass'] = array($item['type'],'count' => 1); - $entry[] = 'objectClass'; - $entry['count'] = 5; - $ret[] = $entry; - } - - if($recursive && isset($item['children']) && count($item['children'])){ - foreach($item['children'] as $item){ - filterDeviceItems::addEntry($ret, $item, $recursive,$filter); - } - } - - } -} - -?> diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/gosa-ng/admin/newConfigManagement/class_newConfigManagement.inc deleted file mode 100644 index 530e979fc..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/class_newConfigManagement.inc +++ /dev/null @@ -1,376 +0,0 @@ -config = &$config; - $this->listing = new ConfigManagementListing($this->config, get_userinfo(), $this); - - // 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 - $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['name'], $dist); - foreach($dist['releases'] as $release){ - $distPath = "/root/{$dist['name']}"; - $this->dataModel->addItem('Release',$distPath, $release['name'], $release); - - foreach($dist['components'] as $component){ - $comPath = "{$distPath}/{$release['name']}"; - $this->dataModel->addItem('Component',$comPath, $component['name'], $component); - } - } - } - } - - - /*! \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. - $cont = $this->listing->getSelectedContainer(); - $item = $this->listing->getSelectedItem(); - $this->setCurrentContainer($cont, $item); - } - - - /*! \brief Load extended sub-objecte like 'config items' or 'packages' - * for the given release path. - * @param String The release path to load sub-objects for. - * @return NULL - */ - function updateItemList($path) - { - // Fist get Item and check if it is an release - if($this->dataModel->itemExistsByPath($path)){ - $data = $this->dataModel->getItemByPath($path); - - // Only releases can contain config-items. - if($data['type'] == 'Release' && $data['status'] != "fetched"){ - - $rpc = $this->config->getRpcHandle(); - $res = $rpc->listConfigItems($data['name']); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), - sprintf(_("Failed to load distributions, error was '%s'!"), - $rpc->get_error()),ERROR_DIALOG); - }else{ - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getPackages($data['name']); - - return; - foreach($res as $itemPath => $type){ - - // Make names dataModel conform - $itemPath = $path.'/'.preg_replace("/^\//","/root", $itemPath); - $name = preg_replace("/^.*\//","",$itemPath); - $itemPath = preg_replace("/\/[^\/]*$/","", $itemPath); - $this->dataModel->addItem($type, $itemPath, $name); - } - $this->dataModel->setItemStatus($path, 'fetched'); - } - } - } - } - - - /*! \brief Sets the currently selected container and item path. - * @param String The path of the container to set. - * @param String The path of the item to set. - * @return - */ - function setCurrentContainer($cont, $item) - { - $this->selectedContainer = $cont; - $this->selectedItem = $item; - - // Get a list of all available container and items. - $distList = $this->getContainerList(); - $releaseList = $this->getItemList(); - - // Ensure that we've valid values selected. - if(!isset($releaseList[$this->selectedItem])){ - if(count($releaseList)){ - echo "Fallback"; - $this->selectedItem = key($releaseList); - }else{ - echo "Fallback 2"; - $this->selectedItem = ""; - } - } - - // Update list of items within the selected container. - $this->updateItemList($this->selectedContainer); - - // Transfer checked values back to the listing class. - $this->listing->setContainer($this->selectedContainer); - $this->listing->setItem($this->selectedItem); - $this->listing->setContainers($this->getContainerList()); - $this->listing->setItems($this->getItemList()); - } - - - /*! \brief Generate the HTML content for this plugin. - * Actually renders the listing widget.. - */ - function execute() - { - // Get the selected release and store it in a session variable - // to allow the configFilter to access it and display the - // packages and items. - $res = $this->listing->execute(); - $this->listing->setListingTypes($this->getListingTypes()); - - return($res); - } - - - /*! \brief Returns a list of items which will then be displayed - * in the management-list. - * (The management class calls this method from its execute()) - * @return Array A list of items/objects for the listing. - */ - function getItemsToBeDisplayed() - { - - $path = $this->selectedContainer.$this->selectedItem; - $item = $this->dataModel->getItemByPath($path); - return($item); - } - - - /*! \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 getItemList() - { - $data = $this->dataModel->getItemByPath($this->selectedContainer); - $res = array(); - $res[""] = array("name" => "/", "desc" => ""); - $res = array_merge($res,$this->__recurseItem($data, array('Component'))); - return($res); - - - if($data['type'] != 'Release'){ - }else{ - $res = array_merge($res,$this->__recurseItem($data, array('Component'),$this->selectedContainer)); - } - return($res); - } - - - /*! \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 getContainerList() - { - $data = $this->dataModel->getItemByPath('/root'); - $res = array(); - $res["/root"] = array("name" => "/", "desc" => ""); - $res = array_merge($res,$this->__recurseItem($data, array('Distribution','Release'))); - - print_a($res); - return($res); - } - - - /*! \brief Recursivly walks through an item and collects all path and name info. - * The reult can then be used to fill the ItemSelector. - * @param Array The Item to recurse. - * @param Array The type of of objects to collect. - * @param String The parent path prefix which should be removed. - * @return Array An array containing Array[path] = name - */ - function __recurseItem($item, $types, $parent = "") - { - $res = array(); - if(in_array($item['type'], $types)){ - $path = preg_replace("/".preg_quote($parent,'/')."/","",$item['path']); - $res[$path] = array('name' => $item['name'],'desc'=>$item['type']); - } - if(count($item['children'])){ - foreach($item['children'] as $child){ - $res = array_merge($res, $this->__recurseItem($child, $types, $parent)); - } - } - return($res); - } - - - /*! \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 Returns a info list about all items we can manage, - * this used to fill the listings settings. - * @return Array An array with item info. - */ - function getListingTypes() - { - $types= array(); - $types['Distribution']['objectClass'] = 'Distribution'; - $types['Distribution']['label'] = _('Distribution'); - $types['Distribution']['image'] = 'images/lists/edit.png'; - $types['Distribution']['category'] = 'Device'; - $types['Distribution']['class'] = 'Device'; - - $types['Release']['objectClass'] = 'Release'; - $types['Release']['label'] = _('Release'); - $types['Release']['image'] = 'images/lists/delete.png'; - $types['Release']['category'] = 'Device'; - $types['Release']['class'] = 'Device'; - - $types['Component']['objectClass'] = 'Component'; - $types['Component']['label'] = _('Component'); - $types['Component']['image'] = 'plugins/users/images/select_user.png'; - $types['Component']['category'] = 'Device'; - $types['Component']['class'] = 'Device'; - return($types); - } - - - /*! \brief Acts on edit requests and opens an edit dialog for the received item-id. - * (This action is received from the ConfigManagementListing class.) - * @param Array The items ids. (May contain multiple ids) - * @return - */ - function editEntry($ids) - { - foreach($ids as $id){ - echo "
Edit {$id}"; - } - } - - - /*! \brief Acts on remove requests. - * (This action is received from the ConfigManagementListing class.) - * @param Array The items ids. (May contain multiple ids) - * @return - */ - function removeEntry($ids) - { - foreach($ids as $id){ - echo "
Remove {$id}"; - } - } - - - /*! \brief Acts on open requests. - * (This action is received from the ConfigManagementListing class.) - * @param Array The items ids. (May contain multiple ids) - * @return - */ - function openEntry($ids) - { - $id = $ids[0]; - $item = $this->dataModel->getItemById($id); - if($item){ - if(in_array($item['type'], array('Distribution', 'Release'))){ - $this->setCurrentContainer($item['path'], $this->selectedItem); - }elseif(in_array($item['type'], array('Component'))){ - $next = preg_replace("/".preg_quote($this->selectedContainer,'/')."/","", $item['path']); - $this->setCurrentContainer($this->selectedContainer, $next); - }else{ - $this->editEntry(array($id)); - } - } - } - - - /*! \brief The plugins ACL and plugin-property definition. - * @return - */ - public static function plInfo() - { - return (array( - "plShortName" => _("Config management"), - "plDescription" => _("Config management"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array( - "newConfigManagement" => array("description" => _("Config management"), - "objectClass" => "FAKE_OC_newConfigManagement")), - "plProvidedAcls"=> array() - )); - } - - - /*! \brief - * @param - * @return - */ - function remove_lock() - { - } - - -} -?> diff --git a/gosa-plugins/gosa-ng/admin/newConfigManagement/main.inc b/gosa-plugins/gosa-ng/admin/newConfigManagement/main.inc deleted file mode 100644 index 0eea23740..000000000 --- a/gosa-plugins/gosa-ng/admin/newConfigManagement/main.inc +++ /dev/null @@ -1,34 +0,0 @@ -remove_lock(); - } -} - -/* Remove this plugin from session - */ -if ( $cleanup ){ - session::un_set('newConfigManagement'); -}else{ - - /* Create newConfigManagement object on demand */ - if (!session::is_set('newConfigManagement')){ - $newConfigManagement= new newConfigManagement ($config, $ui); - session::set('newConfigManagement',$newConfigManagement); - } - $newConfigManagement = session::get('newConfigManagement'); - $display= $newConfigManagement->save_object(); - $display= $newConfigManagement->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - session::un_set ('newConfigManagement'); - } - - /* Show and save dialog */ - session::set('newConfigManagement',$newConfigManagement); -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/gosa-ng/plugin.dsc b/gosa-plugins/gosa-ng/plugin.dsc deleted file mode 100644 index bf02f84af..000000000 --- a/gosa-plugins/gosa-ng/plugin.dsc +++ /dev/null @@ -1,8 +0,0 @@ -[gosa-plugin] -name = gosa-ng -description = "GOsa-ng implementations" -version = 2.7 -author = "Fabian Hickert " -maintainer = "GOsa packages maintainers group " -homepage = https://oss.gonicus.de/labs/gosa/ -depends = goto diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-filter.xml b/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-filter.xml new file mode 100644 index 000000000..7a0c28d27 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-filter.xml @@ -0,0 +1,26 @@ + + + + + true + Device + auto + default + - + + + + default + + + ConfigManagement + $ + + + cn + 0.5 + 3 + + + + diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.tpl b/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.tpl new file mode 100644 index 000000000..e4c7373b2 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.tpl @@ -0,0 +1,22 @@ +
+ +
+

{$HEADLINE} {$SIZELIMIT}

+
+ + + + + + + + +
{$RELOAD}{t}Container{/t} {$CONTAINER}{t}Item{/t} {$ITEM}{$ACTIONS}{$FILTER}
+
+
+ + {$LIST} +
+ +
+ diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.xml b/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.xml new file mode 100644 index 000000000..99bc644f8 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/DeviceConfig-list.xml @@ -0,0 +1,87 @@ + + + + + false + false + false + true + + + 1 + + %TYPES% + + + + + |20px;c|||170px;r| + + + %{filter:objectType(dn,objectClass)} + + + + %{filter:departmentLink(row,dn,description)} + 2 + + + + %{filter:objectType(dn,objectClass)} + + + + + cn + string + %{filter:link(row,dn,"%s",cn,pid)} + true + + + + + description + string + %{filter:link(row,dn,"%s",description,pid)} + true + + + + + %{filter:actions(dn,row,objectClass)} + + +
+ + + + %ITEMS% + + + remove + entry + images/lists/trash.png + + + + + + + + + editEntry + entry + images/lists/edit.png + + + + + remove + entry + images/lists/trash.png + + + + + +
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc new file mode 100644 index 000000000..a4cc53143 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementDataModel.inc @@ -0,0 +1,118 @@ +data = array(); + $this->data['linear'] = array(); + $this->data['recursive'] = array(); + $this->addItem('root', '','root', array()); + } + + function getDataModel() + { + return($this->data); + } + + + + + function addItem($type, $path, $name, $values = array(), $status = "") + { + if($path == ""){ + $parentItem = &$this->data['recursive']; + $parentId = NULL; + $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 ++; + $entryPath = "{$path}/{$name}"; + $entryDn = rtrim("cn={$name},{$parentDn}",','); + $entryId = $this->currentID; + + $entry['path'] = $entryPath; + $entry['dn'] = $entryDn; + $entry['id'] = $entryId; + $entry['parentId'] = $parentId; + $entry['name'] = $name; + $entry['path'] = $entryPath; + $entry['parentPath'] = $path; + $entry['type'] = $type; + $entry['status'] = $status; + $entry['values'] = $values; + $entry['children'] = array(); + + $parentItem[$entryPath] = &$entry; + $this->data['linear'][$entryPath] = &$parentItem[$entryPath]; + + $this->idToPath[$entryId] = $entryPath; + $this->typeToPath[$type][$name] = $entryPath; + + return($entryId); + } + + function pathToDn($path) + { + + } + + function itemExistsByPath($path) + { + return(isset($this->data['linear'][$path])); + } + + function getItemByPath($path) + { + if(isset($this->data['linear'][$path])){ + return($this->data['linear'][$path]); + } + return(NULL); + } + + function setItemStatus($path, $status) + { + if(!$this->itemExistsByPath($path)){ + trigger_error("Invalid item path '{$path}'!"); + }else{ + $this->data['linear'][$path]['status'] = $status; + } + } + + function getItemsByType($types) + { + $res = array(); + foreach($this->data['linear'] as $path => $item){ + if(in_array($item['type'],$types)) $res[] = $item; + } + return($res); + } + + + function getItemById($id) + { + $path = NULL; + if(isset($this->idToPath[$id])){ + $path = $this->idToPath[$id]; + }else{ + return(NULL); + } + if(isset($this->data['linear'][$path])){ + return($this->data['linear'][$path]); + } + return(NULL); + } +} + +?> diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc new file mode 100644 index 000000000..c1d4c93e4 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc @@ -0,0 +1,232 @@ +storagePoints = array(""); + $this->rebuildListing(); + + $this->containerSelector = new ItemSelector(array(),'/root','/root'); + $this->itemSelector = new ItemSelector(array(),'',''); + + $this->parent = &$parent; + } + + function save_object() + { + $this->containerSelector->update(); + $this->itemSelector->update(); + } + + function getSelectedContainer() + { + return($this->containerSelector->getBase()); + } + + function setContainer($dist) + { + return($this->containerSelector->setBase($dist)); + } + + function setItem($rel) + { + return($this->itemSelector->setBase($rel)); + } + + function getSelectedItem() + { + return($this->itemSelector->getBase()); + } + + + function setContainers($containers) + { + $this->containerSelector->setBases($containers); + $this->containerSelector->update(TRUE); + } + + function setItems($items) + { + $this->itemSelector->setBases($items); + $this->itemSelector->update(TRUE); + } + + + function renderList() + { + $headpage = $this->getHeadpage(); + $headpage->update(); + $smarty = get_smarty(); + $smarty->assign("CONTAINER", $this->containerSelector->render()); + $smarty->assign("ITEM", $this->itemSelector->render()); + $display = $headpage->render(); + return($this->getHeader().$display); + } + + + function setListingTypes($types) + { + $str = ""; + foreach($types as $typeData){ + $str.= "\n"; + foreach($typeData as $key => $value){ + $str .= "\n\t<{$key}>{$value}"; + } + $str.= "\n\n"; + + } + $this->objectTypeStr = $str; + } + + + function execute() + { + // Ensure that html posts and gets are kept even if we see a 'Entry islocked' dialog. + $vars = array('/^act$/','/^listing/','/^PID$/','/^FILTER_PID$/'); + session::set('LOCK_VARS_TO_USE',$vars); + + pathNavigator::registerPlugin($this); + + /* Display the copy & paste dialog, if it is currently open */ + $ret = $this->copyPasteHandler("",array()); + if($ret){ + return($this->getHeader().$ret); + } + + // Update filter + if ($this->filter) { + $this->filter->update(); + session::global_set(get_class($this)."_filter", $this->filter); + session::set('autocomplete', $this->filter); + } + + // Handle actions (POSTs and GETs) + $str = $this->handleActions($this->detectPostActions()); + if($str) return($this->getHeader().$str); + + $items = $this->parent->getItemsToBeDisplayed(); + session::set('CONFIG_ITEM', $items); + + // Open single dialog objects + if(is_object($this->dialogObject)){ + if(method_exists($this->dialogObject,'save_object')) $this->dialogObject->save_object(); + if(method_exists($this->dialogObject,'execute')){ + $display = $this->dialogObject->execute(); + $display.= $this->_getTabFooter(); + return($this->getHeader().$display); + } + } + + // Display tab object. + if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){ +# $this->tabObject->save_object(); + $display = $this->tabObject->execute(); + $display.= $this->_getTabFooter(); + return($this->getHeader().$display); + } + // Set current restore base for snapshot handling. + if(is_object($this->snapHandler)){ + $bases = array(); + foreach($this->storagePoints as $sp){ + $bases[] = $sp.$this->headpage->getBase(); + } + + // No bases specified? Try base + if(!count($bases)) $bases[] = $this->headpage->getBase(); + + $this->snapHandler->setSnapshotBases($bases); + } + + // Create statistic table entry + stats::log('management', $class = get_class($this), $this->getAclCategories(), $action = 'view', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); + + // Display list + $this->rebuildListing(); + $str = $this->renderList(); + return($str); + } + + + + function rebuildListing() + { + // Build filter + if (session::global_is_set(get_class($this)."_filter")){ + $filter= session::global_get(get_class($this)."_filter"); + } else { + $filter = new filter(get_template_path("DeviceConfig-filter.xml", true)); + $filter->setObjectStorage($this->storagePoints); + } + $this->setFilter($filter); + + // Load service xml file and fill in placeholders + $contents = file_get_contents(get_template_path("DeviceConfig-list.xml", true)); + $contents = preg_replace("/%TYPES%/", $this->objectTypeStr, $contents); + $contents = preg_replace("/%ITEMS%/", "", $contents); + + $headpage = new listing($contents,TRUE); + $headpage->setBase($this->base); + $headpage->setFilter($filter); + + parent::__construct($this->config, $this->ui, "services", $headpage); + + // Register default actions + $this->registerAction("new", "newEntry"); + $this->registerAction("editEntry", "editEntry"); + $this->registerAction("edit", "openEntry"); + $this->registerAction("apply", "applyChanges"); + $this->registerAction("save", "saveChanges"); + $this->registerAction("cancel", "cancelEdit"); + $this->registerAction("cancelDelete", "cancelEdit"); + $this->registerAction("remove", "removeEntryRequested"); + $this->registerAction("removeConfirmed", "removeEntryConfirmed"); + + $this->registerAction("config-filter","editFilter"); + $this->registerAction("saveFilter","saveFilter"); + $this->registerAction("cancelFilter","cancelFilter"); + + } + + function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") + { + $this->parent->removeEntry($target); + } + + function openEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") + { + $this->parent->openEntry($target); + } + + function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") + { + $this->parent->editEntry($target); + } + + + + + + + + + + + + + + + + +} + +?> diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_filterConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_filterConfigManagement.inc new file mode 100644 index 000000000..87697b819 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_filterConfigManagement.inc @@ -0,0 +1,52 @@ + 1); + $entry[] = 'cn'; + $entry['id'] = array($item['id'], 'count' => 1); + $entry[] = 'id'; + $entry['description'] = array($item['type'], 'count' => 1); + $entry[] = 'description'; + $entry['objectClass'] = array($item['type'],'count' => 1); + $entry[] = 'objectClass'; + $entry['count'] = 5; + $ret[] = $entry; + } + + if($recursive && isset($item['children']) && count($item['children'])){ + foreach($item['children'] as $item){ + filterDeviceItems::addEntry($ret, $item, $recursive,$filter); + } + } + + } +} + +?> diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc new file mode 100644 index 000000000..530e979fc --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc @@ -0,0 +1,376 @@ +config = &$config; + $this->listing = new ConfigManagementListing($this->config, get_userinfo(), $this); + + // 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 + $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['name'], $dist); + foreach($dist['releases'] as $release){ + $distPath = "/root/{$dist['name']}"; + $this->dataModel->addItem('Release',$distPath, $release['name'], $release); + + foreach($dist['components'] as $component){ + $comPath = "{$distPath}/{$release['name']}"; + $this->dataModel->addItem('Component',$comPath, $component['name'], $component); + } + } + } + } + + + /*! \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. + $cont = $this->listing->getSelectedContainer(); + $item = $this->listing->getSelectedItem(); + $this->setCurrentContainer($cont, $item); + } + + + /*! \brief Load extended sub-objecte like 'config items' or 'packages' + * for the given release path. + * @param String The release path to load sub-objects for. + * @return NULL + */ + function updateItemList($path) + { + // Fist get Item and check if it is an release + if($this->dataModel->itemExistsByPath($path)){ + $data = $this->dataModel->getItemByPath($path); + + // Only releases can contain config-items. + if($data['type'] == 'Release' && $data['status'] != "fetched"){ + + $rpc = $this->config->getRpcHandle(); + $res = $rpc->listConfigItems($data['name']); + if(!$rpc->success()){ + msg_dialog::display(_("Error"), + sprintf(_("Failed to load distributions, error was '%s'!"), + $rpc->get_error()),ERROR_DIALOG); + }else{ + $rpc = $this->config->getRpcHandle(); + $res = $rpc->getPackages($data['name']); + + return; + foreach($res as $itemPath => $type){ + + // Make names dataModel conform + $itemPath = $path.'/'.preg_replace("/^\//","/root", $itemPath); + $name = preg_replace("/^.*\//","",$itemPath); + $itemPath = preg_replace("/\/[^\/]*$/","", $itemPath); + $this->dataModel->addItem($type, $itemPath, $name); + } + $this->dataModel->setItemStatus($path, 'fetched'); + } + } + } + } + + + /*! \brief Sets the currently selected container and item path. + * @param String The path of the container to set. + * @param String The path of the item to set. + * @return + */ + function setCurrentContainer($cont, $item) + { + $this->selectedContainer = $cont; + $this->selectedItem = $item; + + // Get a list of all available container and items. + $distList = $this->getContainerList(); + $releaseList = $this->getItemList(); + + // Ensure that we've valid values selected. + if(!isset($releaseList[$this->selectedItem])){ + if(count($releaseList)){ + echo "Fallback"; + $this->selectedItem = key($releaseList); + }else{ + echo "Fallback 2"; + $this->selectedItem = ""; + } + } + + // Update list of items within the selected container. + $this->updateItemList($this->selectedContainer); + + // Transfer checked values back to the listing class. + $this->listing->setContainer($this->selectedContainer); + $this->listing->setItem($this->selectedItem); + $this->listing->setContainers($this->getContainerList()); + $this->listing->setItems($this->getItemList()); + } + + + /*! \brief Generate the HTML content for this plugin. + * Actually renders the listing widget.. + */ + function execute() + { + // Get the selected release and store it in a session variable + // to allow the configFilter to access it and display the + // packages and items. + $res = $this->listing->execute(); + $this->listing->setListingTypes($this->getListingTypes()); + + return($res); + } + + + /*! \brief Returns a list of items which will then be displayed + * in the management-list. + * (The management class calls this method from its execute()) + * @return Array A list of items/objects for the listing. + */ + function getItemsToBeDisplayed() + { + + $path = $this->selectedContainer.$this->selectedItem; + $item = $this->dataModel->getItemByPath($path); + return($item); + } + + + /*! \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 getItemList() + { + $data = $this->dataModel->getItemByPath($this->selectedContainer); + $res = array(); + $res[""] = array("name" => "/", "desc" => ""); + $res = array_merge($res,$this->__recurseItem($data, array('Component'))); + return($res); + + + if($data['type'] != 'Release'){ + }else{ + $res = array_merge($res,$this->__recurseItem($data, array('Component'),$this->selectedContainer)); + } + return($res); + } + + + /*! \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 getContainerList() + { + $data = $this->dataModel->getItemByPath('/root'); + $res = array(); + $res["/root"] = array("name" => "/", "desc" => ""); + $res = array_merge($res,$this->__recurseItem($data, array('Distribution','Release'))); + + print_a($res); + return($res); + } + + + /*! \brief Recursivly walks through an item and collects all path and name info. + * The reult can then be used to fill the ItemSelector. + * @param Array The Item to recurse. + * @param Array The type of of objects to collect. + * @param String The parent path prefix which should be removed. + * @return Array An array containing Array[path] = name + */ + function __recurseItem($item, $types, $parent = "") + { + $res = array(); + if(in_array($item['type'], $types)){ + $path = preg_replace("/".preg_quote($parent,'/')."/","",$item['path']); + $res[$path] = array('name' => $item['name'],'desc'=>$item['type']); + } + if(count($item['children'])){ + foreach($item['children'] as $child){ + $res = array_merge($res, $this->__recurseItem($child, $types, $parent)); + } + } + return($res); + } + + + /*! \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 Returns a info list about all items we can manage, + * this used to fill the listings settings. + * @return Array An array with item info. + */ + function getListingTypes() + { + $types= array(); + $types['Distribution']['objectClass'] = 'Distribution'; + $types['Distribution']['label'] = _('Distribution'); + $types['Distribution']['image'] = 'images/lists/edit.png'; + $types['Distribution']['category'] = 'Device'; + $types['Distribution']['class'] = 'Device'; + + $types['Release']['objectClass'] = 'Release'; + $types['Release']['label'] = _('Release'); + $types['Release']['image'] = 'images/lists/delete.png'; + $types['Release']['category'] = 'Device'; + $types['Release']['class'] = 'Device'; + + $types['Component']['objectClass'] = 'Component'; + $types['Component']['label'] = _('Component'); + $types['Component']['image'] = 'plugins/users/images/select_user.png'; + $types['Component']['category'] = 'Device'; + $types['Component']['class'] = 'Device'; + return($types); + } + + + /*! \brief Acts on edit requests and opens an edit dialog for the received item-id. + * (This action is received from the ConfigManagementListing class.) + * @param Array The items ids. (May contain multiple ids) + * @return + */ + function editEntry($ids) + { + foreach($ids as $id){ + echo "
Edit {$id}"; + } + } + + + /*! \brief Acts on remove requests. + * (This action is received from the ConfigManagementListing class.) + * @param Array The items ids. (May contain multiple ids) + * @return + */ + function removeEntry($ids) + { + foreach($ids as $id){ + echo "
Remove {$id}"; + } + } + + + /*! \brief Acts on open requests. + * (This action is received from the ConfigManagementListing class.) + * @param Array The items ids. (May contain multiple ids) + * @return + */ + function openEntry($ids) + { + $id = $ids[0]; + $item = $this->dataModel->getItemById($id); + if($item){ + if(in_array($item['type'], array('Distribution', 'Release'))){ + $this->setCurrentContainer($item['path'], $this->selectedItem); + }elseif(in_array($item['type'], array('Component'))){ + $next = preg_replace("/".preg_quote($this->selectedContainer,'/')."/","", $item['path']); + $this->setCurrentContainer($this->selectedContainer, $next); + }else{ + $this->editEntry(array($id)); + } + } + } + + + /*! \brief The plugins ACL and plugin-property definition. + * @return + */ + public static function plInfo() + { + return (array( + "plShortName" => _("Config management"), + "plDescription" => _("Config management"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array( + "newConfigManagement" => array("description" => _("Config management"), + "objectClass" => "FAKE_OC_newConfigManagement")), + "plProvidedAcls"=> array() + )); + } + + + /*! \brief + * @param + * @return + */ + function remove_lock() + { + } + + +} +?> diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/main.inc b/gosa-plugins/goto-ng/admin/newConfigManagement/main.inc new file mode 100644 index 000000000..0eea23740 --- /dev/null +++ b/gosa-plugins/goto-ng/admin/newConfigManagement/main.inc @@ -0,0 +1,34 @@ +remove_lock(); + } +} + +/* Remove this plugin from session + */ +if ( $cleanup ){ + session::un_set('newConfigManagement'); +}else{ + + /* Create newConfigManagement object on demand */ + if (!session::is_set('newConfigManagement')){ + $newConfigManagement= new newConfigManagement ($config, $ui); + session::set('newConfigManagement',$newConfigManagement); + } + $newConfigManagement = session::get('newConfigManagement'); + $display= $newConfigManagement->save_object(); + $display= $newConfigManagement->execute(); + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + session::un_set ('newConfigManagement'); + } + + /* Show and save dialog */ + session::set('newConfigManagement',$newConfigManagement); +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto-ng/plugin.dsc b/gosa-plugins/goto-ng/plugin.dsc new file mode 100644 index 000000000..bf02f84af --- /dev/null +++ b/gosa-plugins/goto-ng/plugin.dsc @@ -0,0 +1,8 @@ +[gosa-plugin] +name = gosa-ng +description = "GOsa-ng implementations" +version = 2.7 +author = "Fabian Hickert " +maintainer = "GOsa packages maintainers group " +homepage = https://oss.gonicus.de/labs/gosa/ +depends = goto