From: hickert Date: Tue, 25 Oct 2011 13:17:22 +0000 (+0000) Subject: removed devices and config management X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=54a8881d071c681c6b67da0d9f8ab78d8acd13c7;p=gosa.git removed devices and config management git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@21032 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/admin/ConfigManagement/AddItemDialog.tpl b/gosa-plugins/goto/admin/ConfigManagement/AddItemDialog.tpl deleted file mode 100644 index 859ce16e7..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/AddItemDialog.tpl +++ /dev/null @@ -1,21 +0,0 @@ - -

{t}Add item{/t}

- -{t}Please specify a name for the item to add. This name has to be unique within the item configuration.{/t} -
- -
- -

- {$itemCfg.name} -  {$itemCfg.description} -

- -{t}Name{/t}:  - -
- -
- - -
- diff --git a/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-filter.xml b/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-filter.xml deleted file mode 100644 index 183ddd4ce..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-filter.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - true - Device - auto - default - - - - - - default - - - DeviceItems - $ - - - cn - 0.5 - 3 - - - - diff --git a/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-list.tpl b/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-list.tpl deleted file mode 100644 index 813a1f533..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-list.tpl +++ /dev/null @@ -1,21 +0,0 @@ -
- -
-

{$HEADLINE} {$SIZELIMIT}

-
- - - - - - - -
{$RELOAD}{t}Base{/t} {$RELEASE}{$ACTIONS}{$FILTER}
-
-
- - {$LIST} -
- -
- diff --git a/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-list.xml b/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig-list.xml deleted file mode 100644 index 99bc644f8..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/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/goto/admin/ConfigManagement/DeviceConfig.tpl b/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig.tpl deleted file mode 100644 index 0bb627e8c..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/DeviceConfig.tpl +++ /dev/null @@ -1,12 +0,0 @@ -

{t}Device Config{/t}

-{$navigationList} - - -
- -{$containerName} ({$containerDescription}) - -

-{$template} -

- diff --git a/gosa-plugins/goto/admin/ConfigManagement/TemplateEngine.tpl b/gosa-plugins/goto/admin/ConfigManagement/TemplateEngine.tpl deleted file mode 100644 index e60c5ae1c..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/TemplateEngine.tpl +++ /dev/null @@ -1,11 +0,0 @@ -

Bla

- -{$template} - -
- -
- - -
- diff --git a/gosa-plugins/goto/admin/ConfigManagement/TemplateWidget_textEditor.tpl b/gosa-plugins/goto/admin/ConfigManagement/TemplateWidget_textEditor.tpl deleted file mode 100644 index 4427b4a4e..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/TemplateWidget_textEditor.tpl +++ /dev/null @@ -1,12 +0,0 @@ -{if $write_protect} - {t}The text is write protected due to its encoding. Editing may break it!{/t} -
- -{/if} - -
-   - -
diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_AddItemDialog.inc b/gosa-plugins/goto/admin/ConfigManagement/class_AddItemDialog.inc deleted file mode 100644 index 461508f5f..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_AddItemDialog.inc +++ /dev/null @@ -1,61 +0,0 @@ -config = $config; - $this->itemCfg = $itemCfg; - $this->itemType = $itemType; - } - - function execute() - { - $smarty = get_smarty(); - $smarty->assign('itemCfg', set_post($this->itemCfg)); - $smarty->assign('itemName', set_post($this->itemName)); - return($smarty->fetch(get_template_path('goto/Config/AddItemDialog.tpl', TRUE))); - } - - function getItemCfg() - { - return($this->itemCfg); - } - - function getName() - { - return($this->itemName); - } - - function getItemType() - { - return($this->itemType); - } - - function save_object() - { - if(isset($_POST['itemName'])){ - $this->itemName = get_post('itemName'); - } - } - - function check() - { - $message = array(); - if(empty($this->itemName)){ - $message[] = msgPool::required(_("Name")); - }else - if(!tests::is_uid($this->itemName)){ - $message[] = msgPool::invalid(_("Name")); - } - return($message); - } -} - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_ConfigManagement.inc b/gosa-plugins/goto/admin/ConfigManagement/class_ConfigManagement.inc deleted file mode 100644 index aa435fe70..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_ConfigManagement.inc +++ /dev/null @@ -1,638 +0,0 @@ -TemplateEngine = new TemplateEngine($config); - $this->TemplateEngine->setTemplate('puppet.tpl'); - $this->config = $config; - - // Set storage points - We do not have any - We just create a fake list which lists all items - $this->storagePoints = array(""); - - // Try to initialize - $this->init(); - $this->setInstallMethod('puppet'); - $this->rebuildListing(); - } - - - /*! \brief Sets the installation method to the given method. - * Updates the template engine and adds the initial root - * object for the selected method. - * @param The method to use. - * @return TRUE on success else FALSE. - */ - function setInstallMethod($str) - { - if(!isset($this->allItemConfigurations[$str])){ - $this->itemConfig = array(); - $this->invalidInstallMethod =TRUE; - $this->errorMessage = sprintf(_("Invalid installation method %s selected!"), bold($str)); - msg_dialog::display(_("Setup"), $this->errorMessage, ERROR_DIALOG); - return(FALSE); - }else{ - - $this->itemConfig = $this->allItemConfigurations[$str]['items']; - $this->invalidInstallMethod =FALSE; - $this->TemplateEngine->load($this->itemConfig); - - // Detect root item, its name is / - $root = NULL; - foreach($this->itemConfig as $key => $item){ - if($item['name'] == '/') { - $root = $key; - break; - } - } - if(!$root){ - $this->errorMessage = sprintf(_("Installation method %s is invalid: no root object found!"), bold($str)); - msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG); - $this->initFailed = TRUE; - $this->itemConfig = array(); - return(FALSE); - } - - // Set current item to 'root', this is the minimum to get things running. - $idRoot = $this->addItem($root,'root',array()); - $this->rootItemID = $idRoot; - $this->setCurrentItem($idRoot); - $this->setSelectedListItemID($idRoot); - $this->rebuildListing(); - return(TRUE); - } - } - - - /*! \brief Intializes this plugin - * All available installation methods will be loaded - * and populated. - */ - function init() - { - // 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->allItemConfigurations = $res; - if(!count($this->allItemConfigurations)){ - $this->errorMessage = _("No selectable install methods available!"); - msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG); - $this->initFailed = TRUE; - return; - } - } - - - /*! \brief Add a new child-item to the currently selected one. - * - * @param String type The 'type' of the new object, eg. 'KickstartTemplate' - * @param String name The 'name' of the new object. - * @param Array values The initial values for this object. - * @return - */ - function addItem($type,$name, $values = array()) - { - if(!isset($this->itemConfig[$type])){ - echo "Invalid type {$type}, skipping item!
"; - return; - } - - // Add missing values with the item-type defaults. - $allValuesSet = TRUE; - foreach($this->itemConfig[$type]['options'] as $oName => $oValue){ - if(!isset($values[$oName])){ - $values[$oName] = (isset($oValue['default']))?$oValue['default']:""; - } - } - - // Get the currently selected entry, its the parent for the newly - // added one. - $current = &$this->currentItem; - - // Create a FAKE base to be able to use the management lists - // which are currently ldap and thus dn based. - $base = (isset($current['base']))? ",".$current['base'] : ''; - $base = "{$type}={$name}{$base}"; - - - if(isset($this->mappingBaseToID[$base])){ - echo "Cannot add entry, dn already in use! {$base}
"; - return(null); - } - - // Get next free item slot. - $id = ($this->lastItemID ++); - $new = array( - 'base' => $base, - 'children' => array(), - 'id' => $id, - 'type' => $type, - 'name' => $name, - 'values' => $values); - - // Append the entry to the list of all items. - $this->allConfiguredItems[$id] = $new; - - // Create a child referenc, this creates some kind of entry tree. - $current['children'][$id] = &$this->allConfiguredItems[$id]; - - // Add entries to the list of base and id mappings - // this allows us to easily detect the base for an id and vice versa. - $this->mappingBaseToID[$id] = $base; - $this->mappingBaseToID[$base] = $id; - return($id); - } - - - /*! \brief Selects an item as active. - * All further add and remove actions will be performed - * on the obejcts children. - * @param String The 'id' of the item we want to select. - * @return - */ - function setCurrentItem($item) - { - if(!isset($this->allConfiguredItems[$item])){ - echo "Invalid item name {$name}! Skipping selection!"; - return; - } - - // Set the new item info. - $this->currentItem = &$this->allConfiguredItems[$item]; - $this->currentItemType = $this->currentItem['type']; - $this->currentItemDescriptor = $this->itemConfig[$this->currentItem['type']]; - } - - - /*! \brief Removes a given item ID. - * @param String The 'id' of the item we want to remove. - * @return - */ - function removeItem($id, &$data = NULL) - { - if($data === NULL){ - $data = &$this->allConfiguredItems; - } - - // Remove the item and its children - if(isset($data[$id])){ - foreach($data[$id]['children'] as $cid => $item){ - $this->removeItem($cid, $data); - } - unset($data[$id]); - } - - // Remove to current id from sub entries - foreach($data as $key => $item){ - $this->removeItem($id, $data[$key]['children']); - } - } - - - /*! \brief Initiate item edit. - * An action send from the management list. - * @param See management::editEntry - * @return - */ - function editEntry($action="",$target=array(),$all=array(), - $altTabClass ="", $altTabType = "", $altAclCategory="") - { - $this->setCurrentItem($target[0]); - $this->dialogObject = $this->TemplateEngine; - $this->skipFooter = TRUE; - $this->dialog = TRUE; - - // Update the template engine to use another type of item and - // some other values. - $this->TemplateEngine->setValues($this->currentItemType,$this->currentItem['values']); - } - - - /*! \brief Save changes for the currently edited item. - */ - function saveItemChanges() - { - // Save eventually changed values - if($this->currentItem){ - - // Check if everything is fine. - $msgs = $this->TemplateEngine->save_object(); - $msgs = $this->TemplateEngine->check(); - if(count($msgs)){ - msg_dialog::displayChecks($msgs); - }else{ - foreach($this->TemplateEngine->getWidgets() as $widget){ - $this->currentItem['values'][$widget->getName()] = $widget->getValue(); - } - $this->closeDialogs(); - } - } - } - - - /*! \brief React on open requests from the management list - */ - function openEntry($action="",$target=array(),$all=array(), - $altTabClass ="", $altTabType = "", $altAclCategory="") - { - $this->setSelectedListItemID($target[0]); - } - - - /*! \brief Overridden render method of class mangement. - * this allows us to add a release selection box. - */ - function renderList() - { - // In case of an error abort here. - if($this->rpcError || $this->initFailed || $this->invalidInstallMethod){ - $smarty = get_smarty(); - $smarty->assign('initFailed', $this->initFailed); - $smarty->assign('rpcError', $this->rpcError); - $smarty->assign('invalidInstallMethod', $this->invalidInstallMethod); - $smarty->assign('error', $this->errorMessage); - return($smarty->fetch(get_template_path('failed.tpl', TRUE))); - } - - // Collect item container list to be able to render the fake-base selector - if(!$this->itemContainerSelector){ - $this->itemContainerSelector = new releaseSelector( - $this->getContainerList(), - $this->base, - $this->allConfiguredItems[$this->rootItemID]['base']); - }else{ - $this->itemContainerSelector->setBases($this->getContainerList()); - } - $this->itemContainerSelector->update(true); - $this->itemContainerSelector->setBase($this->base); - - session::set('DEVICE_ITEMS', $this->allConfiguredItems); - $this->rebuildListing(); - $filter = $this->getFilter(); - $headpage = $this->getHeadpage(); - - $headpage->update(); - $smarty = get_smarty(); - $smarty->assign("RELEASE", $this->itemContainerSelector->render()); - $display = $headpage->render(); - return($this->getHeader().$display); - } - - - /*! \brief Build up a list of items useable for the itemSelector. - */ - function getContainerList($array = NULL) - { - $array = ($array == NULL)?$this->allConfiguredItems[$this->rootItemID]: $array; - $ret[$array['base']] = $array['type']; - if(count($array['children'])){ - foreach($array['children'] as $subItem){ - $ret = array_merge($ret, $this->getContainerList($subItem)); - } - } - return($ret); - } - - - /*! \brief Update the management class and tell her which - * items are available for the itemSelector (baseSelector). - */ - 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)); - - // Build up device-list configuration - $types =""; - $images = array(); - $images[] = 'images/lists/edit.png'; - $images[] = 'images/caps.png'; - $images[] = 'images/lists/trash.png'; - $images[] = 'images/filter.png'; - $images[] = 'images/find.png'; - $i = 0; - foreach($this->itemConfig as $type => $item){ - $desc = $item['description']; - $img = $images[$i++]; - $types .= - " ". - " ". - " {$type}". - " Device". - " dummy". - " {$img}". - " "; - } - $contents = preg_replace("/%TYPES%/", $types, $contents); - - - $items = ""; - $i = 0; - foreach($this->addableContainerItems as $item){ - $desc = $this->itemConfig[$item]['description']; - $img = $images[$i++]; - $items .= - "". - " add_{$item}". - " entry". - " {$img}". - " ". - ""; - } - - if(!empty($items)){ - $items = - - "". - " sub". - " images/lists/element.png[new]". - " ". - " {$items}". - ""; - } - - $contents = preg_replace("/%ITEMS%/", $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("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"); - foreach($this->itemConfig as $name => $item){ - $this->registerAction("add_{$name}", "newEntry"); - } - } - - - /*! \brief This method intiates the object creation. - * - * @param String 'action' The name of the action which was the used as trigger. - * @param Array 'target' A list of object dns, which should be affected by this method. - * @param Array 'all' A combination of both 'action' and 'target'. - */ - function newEntry($action="",$target=array(),$all=array(), - $altTabClass ="", $altTabType = "", $altAclCategory="") - { - $toAdd = preg_replace("/^add_/", "",$action); - $itemToAdd = $this->itemConfig[$toAdd]; - - $this->dialogObject = new AddItemDialog($this->config,$toAdd,$itemToAdd); - $this->dialog = true; - } - - - /*! \brief Saves newly created items and adds them as child to - * the currently selected item. - */ - function saveItemAdd() - { - if(!$this->dialogObject instanceOf AddItemDialog) return; - - $msgs = $this->dialogObject->save_object(); - $msgs = $this->dialogObject->check(); - if(count($msgs)){ - msg_dialog::displayChecks($msgs); - }else{ - $itemName = $this->dialogObject->getName(); - $itemCfg = $this->dialogObject->getItemCfg(); - $itemType = $this->dialogObject->getItemType(); - - $this->setCurrentItem($this->mappingBaseToID[$this->base]); - - $this->addItem($itemType, $itemName); - $this->closeDialogs(); - -# $this->setCurrentItem($itemName); -# $this->dialogObject = $this->TemplateEngine; -# $this->skipFooter = TRUE; -# $this->dialog = TRUE; - - } - } - - - /*! \brief Keep track of posted values, some may be interesting for us. - * Tell the template engine to take care of posted values too. - * @param String - * @return - */ - function save_object() - { - if(isset($_POST['retryInit'])){ - $this->init(); - return; - } - - // Do nothing else in case of an error - if($this->rpcError || $this->initFailed) return; - - // Add sub-module requested. - if(isset($_POST['addSubModule']) && isset($_POST['subModule'])){ - $sub = get_post('subModule'); - if(in_array_strict($sub, $this->currentItemDescriptor['container'])){ - - // Check if this is a valid item - if(!isset($this->itemConfig[$sub])) { - echo "Invalid item type '{$sub}'!"; - $values = array(); - }else{ - $values = $this->itemConfig[$sub]['options']; - } - $name = 'test'.rand(0,99999); - $this->addItem($sub,$name,$values); - } - } - - // Get the selected item-id from the item list and populate it. - if($this->itemContainerSelector){ - $this->itemContainerSelector->update(); - $id = $this->mappingBaseToID[$this->itemContainerSelector->getBase()]; - $this->setSelectedListItemID($id); - } - } - - - /* \brief Updates the currenlty seleted item in the management list - */ - function setSelectedListItemID($id) - { - $this->base = $this->mappingBaseToID[$id]; - $type = $this->allConfiguredItems[$id]['type']; - $this->addableContainerItems = $this->itemConfig[$type]['container']; - } - - - /*! \brief Forward plugin acls - */ - function set_acl_base($base) - { - $this->acl_base = $base; - } - - - /*! \brief Forward plugin acls - */ - function set_acl_category($category) - { - $this->acl_category = $category; - } - - function save() - { - foreach($this->allConfiguredItems as $name => $item){ - foreach($item['values'] as $oName => $oValue){ - if(!is_array($oValue)) $oValue = array($oValue); - foreach($oValue as $val){ - echo "
{$name} -- {$item['type']}: {$oName}: {$val}"; - } - } - } - } - - - /*! \brief Initiates the removal for the given entries - * and displays a confirmation dialog. - * - * @param String 'action' The name of the action which was the used as trigger. - * @param Array 'target' A list of object dns, which should be affected by this method. - * @param Array 'all' A combination of both 'action' and 'target'. - */ - protected function removeEntryRequested($action="",$target=array(),$all=array()) - { - foreach($target as $id){ - $this->removeItem($id); - } - } - - - // Inject user actions - function detectPostActions() - { - if($this->rpcError || $this->initFailed) return(array('action' => '')); - - $action = management::detectPostActions(); - if(isset($_POST['saveItemEdit'])) $action['action'] = "saveItemChanges"; - if(isset($_POST['saveItemAdd'])) $action['action'] = "saveItemAdd"; - if(isset($_POST['cancelItemEdit'])) $action['action'] = "cancelItemEdit"; - if(isset($_POST['cancelItemAdd'])) $action['action'] = "cancelItemAdd"; - return($action); - } - - - function closeDialogs() - { - parent::closeDialogs(); - $this->dialog = false; - } - - - function check() - { - return(array()); - } - - function getRootItemId() - { - return($this->rootItemID); - } - - - public static function plInfo() - { - return (array( - "plShortName" => _("Config management"), - "plDescription" => _("Config management"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array( - "ConfigManagement" => array("description" => _("Config management"), - "objectClass" => "FAKE_OC_ConfigManagement")), - "plProvidedAcls"=> array() - )); - } -} -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateEngine.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateEngine.inc deleted file mode 100644 index 9de96538f..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateEngine.inc +++ /dev/null @@ -1,161 +0,0 @@ -config = &$config; - } - - - /*! \brief Load/Sets the instruction-set to use for the current - * device configuration. - * A device configruation tells us what options - * an item can have and what children. - * @param Array The instruction set to use. - */ - function load($array) - { - $this->data = $array; - } - - - /*! \brief Set the template which will be used to generate - * the HTML content for this configuration session. - * @param String A template filename. - */ - function setTemplate($tmpl) - { - $this->template = $tmpl; - } - - - /*! \brief Returns the list of widgets which are currently used - * by the template engine to render the plugin. - * @return Array A list of widgets. - */ - function getWidgets() - { - return($this->widgets); - } - - function getItemType() - { - return($this->itemType); - } - - - /*! \brief Sets the current item type we want to render - * E.g. 'KickstartTemplate' and the corresponding values. - * - * @param String The name of the item we want to render now. - * @param Array The initial value. - */ - function setValues($name, $values) - { - // Set the current item type and reset the widget list. - $this->itemType = $name; - $this->widgets = array(); - - // Do nothing if something seems to be wrong. - if(!isset($this->data[$this->itemType])){ - echo "Undefined item type '{$name}'!
"; - return; - } - - // Get the options provided by the item and create widget for them. - $data = $this->data[$this->itemType]; - if(isset($data['options']) && count($data['options'])){ - foreach($data['options'] as $name => $item){ - $widgetClassName = "TemplateWidget_{$item['type']}"; - - // Check if the widget is available, if it is not, use a default (string). - if(!class_available($widgetClassName)){ - echo "Unknown widget class {$widgetClassName}! Falling back to default widget.
"; - $widgetClassName = "TemplateWidget_string"; - } - - // Prepare the value for the widget - if(!isset($values[$name])) $values[$name] = $item['default']; - - $value = $values[$name]; - $syntax = (isset($item['syntax']))? $item['syntax']: ""; - $providedValues = (isset($item['values']))? $item['values']: array(); - - // Create the new widget. - $this->widgets[$name] = new $widgetClassName($this->config, $name, - $value, - $item['description'], - $syntax, - $item['required'], - $item['type'], - $item['display'], - $providedValues); - } - } - } - - - function execute(){ - return($this->render()); - } - - - /*! \brief Creates the HTML content for the given list of widgets - * @return String The HTML content. - */ - function render() - { - $smarty = get_smarty(); - $smarty->assign("type", $this->itemType); - - // Tell smarty the HTML-content for each widget and the name that should be - // displayed. - foreach($this->widgets as $widget){ - $smarty->assign($widget->getName(), $widget->render()); - $smarty->assign($widget->getName()."Name", $widget->getDisplayName()); - } - $template = $smarty->fetch(get_template_path("goto/Config/{$this->template}", TRUE)); - - $smarty->assign('template', $template); - return($smarty->fetch(get_template_path("goto/Config/TemplateEngine.tpl", TRUE))); - } - - - /*! \brief Keep track of posted values. - */ - function save_object() - { - foreach($this->widgets as $widget){ - $widget->save_object(); - } - } - - - /*! \brief Check widget values and return a list of errors. - */ - function check() - { - $msgs = array(); - foreach($this->widgets as $widget){ - $msgs = array_merge($msgs, $widget->check()); - } - return($msgs); - } -} - - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget.inc deleted file mode 100644 index 45f4fae03..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget.inc +++ /dev/null @@ -1,122 +0,0 @@ -config = &$config; - $this->name = $name; - $this->value = $value; - $this->description = $description; - $this->required = $required; - $this->type = $type; - $this->syntax = $syntax; - $this->values = $values; - $this->display = $display; - $class = get_class(); - $this->postName = "{$class}_{$this->name}"; - } - - - /*! \brief Returns the display-name for the current widget. - * @return String The display-name for the widget, this - * name will usually be rendered infront of input fields. - */ - function getDisplayName() - { - $must = ($this->required)?"*":""; - return($this->display.$must); - } - - - /*! \brief Returns the description for the widget. - */ - function getDescription() - { - return($this->description); - } - - - /*! \brief Generates the HTML code for the widget. - * @return The HTML content for the widget. - */ - function render() - { - return(""); - } - - - /*! \brief Keep track of posted values. - */ - function save_object() - { - if(isset($_POST[$this->postName])){ - $this->value = get_post($this->postName); - } - } - - - /*! \brief Returns the current value. - * @return Mixed The widgets value. - */ - function getValue() - { - return($this->value); - } - - - /*! \brief Returns the name of the widget. - * @param String The widgets name. - */ - function getName() - { - return($this->name); - } - - - /*! \brief Sets a new value for the widget. - * @param String The new value. - */ - function setValue($value) - { - $this->value = $value; - } - - - /*! \brief Check the value entry using the provieded syntax. - * @return Array Returns a list of errors - */ - function check() - { - if($this->required && empty($this->value)){ - return(array(msgPool::required($this->display))); - } - if(!empty($this->value) && !empty($this->syntax) && !preg_match("/".$this->syntax."/", $this->value)){ - return(array(msgPool::invalid($this->display, $this->value, "/".$this->syntax."/"))); - } - return(array()); - } -} -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_checkbox.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_checkbox.inc deleted file mode 100644 index cd6cb1b0f..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_checkbox.inc +++ /dev/null @@ -1,19 +0,0 @@ -postName}' "; - if($this->value) $str .= " checked "; - $str .= ">"; - return($str); - } - - function save_object() - { - $this->value = isset($_POST[$this->postName]); - } -} -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_combobox.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_combobox.inc deleted file mode 100644 index d0a306926..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_combobox.inc +++ /dev/null @@ -1,22 +0,0 @@ -postName}'>"; - foreach($this->values as $name => $value){ - if($name == $this->value){ - $str .= "\n"; - }else{ - $str .= "\n"; - } - } - $str .= ""; - return($str); - } -} -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_file.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_file.inc deleted file mode 100644 index 1e41cd9be..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_file.inc +++ /dev/null @@ -1,34 +0,0 @@ -description); - if(mb_strlen($this->value) == 0){ - $ret = ""._("No file uploaded yet").""; - $ret.= "
- postName}\" - name=\"{$this->postName}\" - type=\"file\" - size=\"20\" - maxlength=\"255\" - accept=\"*.*\"> "; - $ret.= ""; - }else{ - $ret = ""._("File uploaded").": ".mb_strlen($this->value)." "._("Bytes"); - $ret.= " "; - } - return($ret); - } - - function save_object() - { - if(isset($_POST["{$this->postName}_Upload"]) && isset($_FILES[$this->postName]['tmp_name'])){ - $this->value = file_get_contents(gosa_file_name($_FILES[$this->postName]['tmp_name'])); - } - if(isset($_POST["{$this->postName}_Remove"])) $this->value =""; - } -} - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_fixedList.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_fixedList.inc deleted file mode 100644 index a0e9bd023..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_fixedList.inc +++ /dev/null @@ -1,86 +0,0 @@ -listWidget= new sortableListing($this->value); - $this->listWidget->setEditable(false); - $this->listWidget->setDeleteable(true); - $this->listWidget->setColspecs(array('*')); - $this->listWidget->setWidth("100%"); - $this->listWidget->setHeight("70px"); - $this->listWidget->setAcl("rwcdm"); - } - - function getAvailableOptions() - { - $tmp = array(); - foreach($this->values as $key => $name){ - if(!in_array_strict($key, $this->value)){ - $tmp[$key]=$name; - } - } - return($tmp); - } - - function render() - { - $str = ""; - - // Build up list data - $data = $this->value; - foreach($this->value as $key => $name){ - $lData[$key] = array('data' => array($this->values[$name])); - } - $this->listWidget->setListData($data, $lData); - $this->listWidget->update(); - $str .= $this->listWidget->render(); - $str .= ""; - $str .= ""; - return($str); - } - - function save_object() - { - $this->listWidget->save_object(); - $action = $this->listWidget->getAction(); - if($action['action'] == 'delete'){ - $id = $this->listWidget->getKey($action['targets'][0]); - unset($this->value[$id]); - $this->value = array_values($this->value); - } - - if(isset($_POST["{$this->postName}_Add"]) && isset($_POST["{$this->postName}_Input"])){ - $input = get_post("{$this->postName}_Input"); - - if(!empty($input) && !empty($this->syntax) && !preg_match("/".$this->syntax."/", $input)){ - msg_dialog::displayChecks(array(msgPool::invalid($this->display, $input, "/".$this->syntax."/"))); - }elseif(!empty($input)){ - $this->value[] = $input; - } - } - } - - /*! \brief Check the value entry using the provieded syntax. - * @return Array Returns a list of errors - */ - function check() - { - if($this->required && empty($this->value)){ - return(array(msgPool::required($this->display))); - } - return(array()); - } -} - - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_list.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_list.inc deleted file mode 100644 index d95da2c57..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_list.inc +++ /dev/null @@ -1,64 +0,0 @@ -listWidget= new sortableListing($this->value); - $this->listWidget->setEditable(false); - $this->listWidget->setDeleteable(true); - $this->listWidget->setColspecs(array('*')); - $this->listWidget->setWidth("100%"); - $this->listWidget->setHeight("70px"); - $this->listWidget->setAcl("rwcdm"); - } - - - function render() - { - $str = ""; - $this->listWidget->setListData($this->value); - $this->listWidget->update(); - $str .= $this->listWidget->render(); - $str .= ""; - $str .= ""; - return($str); - } - - function save_object() - { - $this->listWidget->save_object(); - $action = $this->listWidget->getAction(); - if($action['action'] == 'delete'){ - $id = $this->listWidget->getKey($action['targets'][0]); - unset($this->value[$id]); - $this->value = array_values($this->value); - } - - if(isset($_POST["{$this->postName}_Add"]) && isset($_POST["{$this->postName}_Input"])){ - $input = get_post("{$this->postName}_Input"); - - if(!empty($input) && !empty($this->syntax) && !preg_match("/".$this->syntax."/", $input)){ - msg_dialog::displayChecks(array(msgPool::invalid($this->display, $input, "/".$this->syntax."/"))); - }elseif(!empty($input)){ - $this->value[] = $input; - } - } - } - - /*! \brief Check the value entry using the provieded syntax. - * @return Array Returns a list of errors - */ - function check() - { - if($this->required && empty($this->value)){ - return(array(msgPool::required($this->display))); - } - return(array()); - } -} - - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_string.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_string.inc deleted file mode 100644 index 2bf3ccca0..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_string.inc +++ /dev/null @@ -1,18 +0,0 @@ -description); - $value = set_post($this->value); - - $name = " name=\"{$this->postName}\" "; - $value = " value=\"{$value}\" "; - $title = (empty($this->description))?"": " title=\"{$desc}\""; - - return(""); - } -} - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_textEditor.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_textEditor.inc deleted file mode 100644 index 7c824f4f1..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_textEditor.inc +++ /dev/null @@ -1,75 +0,0 @@ -mb_extension = function_exists("mb_detect_encoding"); - if($this->mb_extension){ - $this->enc_before_edit = mb_detect_encoding($this->value); - if($this->enc_before_edit != "ASCII"){ - $this->write_protect = TRUE; - } - } - } - - - function render() - { - $smarty = get_smarty(); - $smarty->assign("postName", set_post($this->postName)); - $smarty->assign("write_protect", set_post($this->write_protect)); - $smarty->assign("value", set_post($this->value)); - return($smarty->fetch(get_template_path("TemplateWidget_textEditor.tpl", TRUE, dirname(__FILE__)))); - } - - - function save_object() - { - TemplateWidget::save_object(); - if(isset($_POST['editAnyway'])) $this->write_protect = FALSE; - - if(isset($_POST['ImportUpload'])){ - if(($_FILES['ImportFile']['error']!=0)){ - msg_dialog::display(_("Error"), msgPool::incorrectUpload(), ERROR_DIALOG); - }elseif(($_FILES['ImportFile']['size']==0)){ - msg_dialog::display(_("Error"), msgPool::incorrectUpload(_("file is empty")), ERROR_DIALOG); - }else{ - $str = file_get_contents(gosa_file_name($_FILES['ImportFile']['tmp_name'])); - $this->value = $str; - - // Check encoding again - if($this->mb_extension){ - $this->enc_before_edit = mb_detect_encoding($this->value); - if($this->enc_before_edit != "ASCII"){ - $this->write_protect = TRUE; - } - } - } - } - $this->enc_after_edit = mb_detect_encoding($this->value); - } - - - /*! \brief Check the value entry using the provieded syntax. - * @return Array Returns a list of errors - */ - function check() - { - $msgs = TemplateWidget::check(); - if($this->mb_extension && !$this->write_protect && $this->enc_after_edit !== $this->enc_before_edit ){ - $msg = sprintf(_("The text encoding has changed from %s to %s. Do you really want to save?"), - bold($this->enc_before_edit),bold($this->enc_after_edit)); - $msgs[] = $msg; - $this->enc_before_edit = $this->enc_after_edit; - } - return($msgs); - } -} -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_textarea.inc b/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_textarea.inc deleted file mode 100644 index 030dd1156..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_TemplateWidget_textarea.inc +++ /dev/null @@ -1,16 +0,0 @@ -description); - return(""); - } - -} - -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/class_filterDeviceItems.inc b/gosa-plugins/goto/admin/ConfigManagement/class_filterDeviceItems.inc deleted file mode 100644 index d6dd7c912..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/class_filterDeviceItems.inc +++ /dev/null @@ -1,57 +0,0 @@ - $item){ - if($item['base'] == $base){ - $data = $item['children']; - break;; - } - } - - // Prepare filter, strip out regex regex related chars, except for * - $filter = preg_replace('/\*/','____STAR____', $filter); - $filter = preg_quote($filter,'/'); - $filter = preg_replace('/____STAR____/','.*', $filter); - - // Add entries - $ret = array(); - foreach($data as $item){ - filterDeviceItems::addEntry($ret, $item, $scope == 'sub', $filter); - } - return($ret); - } - - static function addEntry(&$ret, $item, $recursive = FALSE, $filter) - { - if(preg_match("/".$filter."/",$item['name'])){ - $entry = array(); - $entry['dn'] = $item['id']; - $entry[] = 'dn'; - $entry['cn'] = array($item['name'], 'count' => 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/admin/ConfigManagement/failed.tpl b/gosa-plugins/goto/admin/ConfigManagement/failed.tpl deleted file mode 100644 index 94a4eb220..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/failed.tpl +++ /dev/null @@ -1,12 +0,0 @@ -{if $rpcError} -

{t}Error{/t}

- {msgPool type=rpcError p1=$error} - -{elseif $initFailed} -

{t}Communication failed{/t}

- {msgPool type=rpcError p1=$error} - -{elseif $invalidInstallMethod} -

{t}Configuration error{/t}

- {msgPool type=rpcError p1=$error} -{/if} diff --git a/gosa-plugins/goto/admin/ConfigManagement/main.inc b/gosa-plugins/goto/admin/ConfigManagement/main.inc deleted file mode 100644 index b003a0872..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/main.inc +++ /dev/null @@ -1,56 +0,0 @@ -remove_lock(); - } -} - -/* Remove this plugin from session - */ -if ( $cleanup ){ - session::un_set('ConfigManagement'); -}else{ - - /* Create ConfigManagement object on demand */ - if (!session::is_set('ConfigManagement')){ - $ConfigManagement= new ConfigManagement ($config, $ui); - session::set('ConfigManagement',$ConfigManagement); - } - $ConfigManagement = session::get('ConfigManagement'); - $display= $ConfigManagement->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - session::un_set ('ConfigManagement'); - } - - /* Show and save dialog */ - session::set('ConfigManagement',$ConfigManagement); -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/goto/admin/ConfigManagement/puppet.tpl b/gosa-plugins/goto/admin/ConfigManagement/puppet.tpl deleted file mode 100644 index 8b8d95b56..000000000 --- a/gosa-plugins/goto/admin/ConfigManagement/puppet.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{if $type == 'PuppetModule'} - - - - - -
- - - - - - - - - - - - - -
{$nameName}{$name}
{$descriptionName}{$description}
{$versionName}{$version}
-
- {$dependencyName}:
- {$dependency} -
-{/if} -{if $type == 'PuppetTemplate'} - - - - - - - - - -
{$nameName}{$name}
{$dataName}{$data}
- -{/if} diff --git a/gosa-plugins/goto/admin/systems/goto/Device/AddPartitionDialog.tpl b/gosa-plugins/goto/admin/systems/goto/Device/AddPartitionDialog.tpl deleted file mode 100644 index 0b565031c..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/AddPartitionDialog.tpl +++ /dev/null @@ -1,287 +0,0 @@ -{if $error} - -

- {$errorMsg} -

- - -
-
- -
- -
- -{else} - -

{t}Type{/t}

- - {t}Disk{/t}
- {t}Physical partition{/t}
- {t}Raid device{/t}
- {t}LVM Volume group{/t}
- {t}LVM Volume{/t}
- -
- - {if $selected_type==4} - -

{t}LVM Volume{/t}

- - - - - - - - - - - - - - - - - - - - - - - - - -
{t}Volume name{/t} - -
{t}Volume group{/t} - -
{t}Mount point{/t} - {if $v_fsType == "swap"} - - {else} - - {/if} -
{t}File system type{/t} - -
{t}Size{/t} - -
{t}Encrypt{/t}
- - {elseif $selected_type==3} - -

{t}LVM Volume group{/t}

- - - - - - - - - -
{t}Volume group name{/t} - -
{t}Use LVM partitions{/t} - {foreach from=$freeLvmPartitions item=item key=key} -  {$item} - {if isset($deviceUsage.part[$item])}    {$deviceUsage.part[$item].size} {t}MB{/t} - {elseif isset($deviceUsage.raid[$item])}    {$deviceUsage.raid[$item].size} {t}MB{/t}{/if} -
- {/foreach} -
- - {elseif $selected_type==2} -

{t}Add raid device{/t}

- - - - - - - - - - - - - - - - - - - - - - - - - - -
{t}Mount point{/t} - {if $r_fsType == "swap" || $r_fsType == "pv"} - - {else} - - {/if} -
{t}File system type{/t} - -
{t}Raid level{/t} - -
{t}Use raid partitions{/t} - {foreach from=$freeRaidPartitions item=item key=key} -  {$item} - {if isset($deviceUsage.part[$item])}   {$deviceUsage.part[$item].size} {t}MB{/t} - {elseif isset($deviceUsage.raid[$item])}   {$deviceUsage.raid[$item].size} {t}MB{/t}{/if} -
- {/foreach} -
{t}Number of spares{/t} - -
{t}Encrypt{/t}
- - {elseif $selected_type==1} - - - - - - - -
-

{t}Add Partition{/t}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"} - - {else} - - {/if} - - - - {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"} - - {else} - - {/if} - -
{t}Mount point{/t} - {if $p_fsType == "raid" || $p_fsType == "swap" || $p_fsType == "pv"} - - {else} - - {/if} -
{t}File system type{/t} - -
{t}Allowable drives{/t} - -
{t}Size{/t} - -
{t}Force to be primary partition{/t}
{t}Bootable{/t}
{t}Encrypt{/t}
{t}Format{/t}
-
- -

{t}Additional size options{/t}

- - - - - - - - - - - - - -
{t}Fixed size{/t}
{t}Fill to maximum allowable size{/t}
{t}Fill all space up to{/t} -  {t}MB{/t} -
-
- {elseif $selected_type==0} -

{t}Add disk{/t}

- - - - - -
{t}Disk name{/t} - -
- {/if} - -
-
- -
- - -
- -{/if} diff --git a/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl b/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl deleted file mode 100644 index 0a966a195..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - -
- -

{t}Device{/t}

- - - - - - - - - - - - - -
{if $registeredRequired}{$must}{/if} - {render acl=$cnACL} - - {/render} -
- {render acl=$descriptionACL} - - {/render} -
-
- {t}Base{/t} -
-
- {render acl=$baseACL} - {$base} - {/render} -
-
-

{t}Orgaizational data{/t}

- - - - - - - - - - - - - - - - - - - -
- {render acl=$ouACL} - - {/render} -
- {render acl=$oACL} - - {/render} -
- {render acl=$lACL} - - {/render} -
- {render acl=$serialNumberACL} - - {/render} -
-
-
-
-

{t}Registration{/t}

- - - - - - - - - -
- {render acl=$deviceUUIDACL} - - {/render} - {render acl=$deviceUUIDACL} - {image path="images/lists/reload.png" action="reloadUUID"} - {/render} -
- - {render acl=$deviceTypeACL} - - {/render} -
-
- - - - - - - - - -
- - {render acl=$deviceStatusACL} - - {/render} -
- - {render acl=$managerACL} - - {/render} - - {image path="images/lists/edit.png" action="editManager" acl=$managerACL} - {if $manager!=""} - {image path="images/info_small.png" title="{$manager}" acl=$managerACL} - {image path="images/lists/trash.png" action="removeManager" acl=$managerACL} - {/if} -
-
-
-

{t}Network settings{/t}

- - - - - - - - - -
- - {render acl=$ipHostNumberACL} - - {/render} -
- - {render acl=$macAddressACL} - - {/render} -
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/DeviceConfig.tpl b/gosa-plugins/goto/admin/systems/goto/Device/DeviceConfig.tpl deleted file mode 100644 index f5439f66e..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/DeviceConfig.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{if $error} - -

- {$errorMsg} -

- - -{else} - - - - - - - - - - - - -
-

{t}Assignable items{/t}

- {$assignableElementsList} -
-

{t}Assigned items{/t}

- {$usedElementsList} -
-
-
-

{t}Parameters{/t}

- {$parameterList} -
- -{/if} diff --git a/gosa-plugins/goto/admin/systems/goto/Device/DevicePartition.tpl b/gosa-plugins/goto/admin/systems/goto/Device/DevicePartition.tpl deleted file mode 100644 index 750d3d151..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/DevicePartition.tpl +++ /dev/null @@ -1,23 +0,0 @@ -

{t}Device partition{/t}

- -{if $error} - -

- {$errorMsg} -

- - -{else} - - {$list} - - - -
- -
-
- - -
-{/if} diff --git a/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc b/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc deleted file mode 100644 index 0378c5617..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc +++ /dev/null @@ -1,56 +0,0 @@ -by_object['Device']; - $uuid = $baseobject->deviceUUID; - $orig_uuid = $baseobject->orig_deviceUUID; - - - $rdn = get_ou('Device','GOsaDeviceRDN'); - $cn = preg_replace('/,/', '\,', $baseobject->cn); - $cn = preg_replace('/"/', '\"', $cn); - - $dnCn = "cn=".$cn.",".$rdn.$baseobject->base; - $dnUuid= "deviceUUID=".$uuid.",".$rdn.$baseobject->base; - - // Save object using the 'cn' in the dn and then move it to 'uuid'; - $moveToUUID = FALSE; - if(!empty($uuid) && empty($orig_uuid) && $baseobject->orig_dn != "new"){ - $moveToUUID = TRUE; - } - - // Detect target dn - $this->dn = (empty($uuid)) ? $dnCn : $dnUuid; - - if($moveToUUID) $this->dn = $dnCn; - - // Populate values - foreach ($this->by_object as $key => $obj){ - $this->by_object[$key]->dn= $this->dn; - $this->by_object[$key]->cn= $baseobject->cn; - } - - // Object moved? - if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){ - $baseobject->update_acls($baseobject->orig_dn,$this->dn); - $baseobject->move($baseobject->orig_dn,$this->dn); - $baseobject->orig_dn = $this->dn; - } - - // Save now - tabs::save(); - - if($moveToUUID){ - $this->dn = (empty($uuid)) ? $dnCn : $dnUuid; - $baseobject->update_acls($baseobject->orig_dn,$this->dn); - $baseobject->move($baseobject->orig_dn,$this->dn); - } - - } -} - -?> diff --git a/gosa-plugins/goto/admin/systems/goto/Device/InstallRecipe.tpl b/gosa-plugins/goto/admin/systems/goto/Device/InstallRecipe.tpl deleted file mode 100644 index 0750f4d8c..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/InstallRecipe.tpl +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - -
-

{t}Installation type{/t}

- - - - - - - - - - - - - -
- {render acl=$installTemplateACL} - - {/render} -
- {render acl=$installReleaseACL} - - {/render} -
- {render acl=$installConfigManagementACL} - - {/render} -
-
-

{t}Partition table{/t}

- - - - - -
- {render acl=$installPartitionTableACL} - - {/render} -
-
- -
- - - - - - - - - - - - -
-

{t}Bootstrap settings{/t}

- - - - - - - - - - -
- {render acl=$installMirrorACL} - - {/render} -
- {render acl=$installKernelPackageACL} - - {/render} -
-
-

{t}Login{/t}

- - - - - -
- {render acl=$installRootEnabledACL} - - {/render} -   - {render acl=$installRootPasswordHashACL} - - {/render} -
-

-

{t}Locale{/t}

- - - - - - - - - - -
- {render acl=$installKeyboardlayoutACL} - - {/render} -
- {render acl=$installSystemLocaleACL} - - {/render} -
-
-

{t}Time{/t}

- - - - - - - - - - - - -
- {render acl=$installTimeUTCACL} - - - {/render} -
- {render acl=$installTimezoneACL} - - {/render} -
- {t}NTP server{/t} - {render acl=$installNTPServerACL} - {$installNTPServerList} - {/render} - {render acl=$installNTPServerACL} - - {/render} - {render acl=$installNTPServerACL} - - {/render} -
-
- - diff --git a/gosa-plugins/goto/admin/systems/goto/Device/SetPassword.tpl b/gosa-plugins/goto/admin/systems/goto/Device/SetPassword.tpl deleted file mode 100644 index fb351dbdd..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/SetPassword.tpl +++ /dev/null @@ -1,17 +0,0 @@ -

{t}Set root-user password{/t}

- -
- -

- {t}Password{/t}:   - -

- -
- -
- - -
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc deleted file mode 100644 index 4124bcde3..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_AddPartitionDialog.inc +++ /dev/null @@ -1,482 +0,0 @@ -partitionObject = &$partitionObject; - $this->config = &$config; - } - - function init() - { - // Load remote partition information - $map = array( - "fsTypes" => "getFsTypes", - "raidLevel" => "getRaidLevels", - "disks" => "getDisks", - "partitions" => "getPartitions", - "raidDevices" => "getRaidDevices", - "volumeGroups" => "getVolumeGroups", - "freeLvmPartitions" => "getUnassignedPhysicalVolumes", - "freeRaidPartitions" => "getUnassignedRaidPartitions"); - foreach($map as $target => $func){ - $this->$target = @$this->partitionObject->$func(); - if(!$this->partitionObject->success()){ - $this->errorMsg = $this->partitionObject->getError(); - return; - } - } - - // Prepare list of filesystem types - $this->fsTypeList = array(); - foreach($this->partitionObject->getFsTypes() as $type){ - $this->fsTypeList[$type] = $type; - } - $this->fsTypeList['pv'] = _('Physical volume (LVM)'); - $this->fsTypeList['raid'] = _('Software raid'); - - // Prepare list of available raid level - $this->raidLevelList = array(); - foreach($this->raidLevel as $lvl){ - $this->raidLevelList[$lvl] = sprintf(_("Raid %s"), $lvl); - } - - // Prepare list of volume groups - $this->volumeGroupList = array(); - foreach($this->volumeGroups as $vg){ - $this->volumeGroupList[$vg['name']] = $vg['name']; - } - - // Prepare list of disks - $this->diskList = array(); - foreach($this->disks as $disk){ - $this->diskList[$disk['device']] = $disk['device']; - } - - // Select first disk as default. - $this->p_used_disk = key($this->diskList); - - // Preselect partition creation if we've already created a disk - if(count($this->disks)){ - $this->selected_type = PARTITION; - } - - $this->initialized = TRUE; - } - - - /*! \brief Generates the HTML output for this plugin. - * @return String HTML content of the plugin. - */ - function execute() - { - $smarty = get_smarty(); - - if(!$this->initialized){ - $this->init(); - if(!$this->initialized){ - $smarty->assign("error", TRUE); - $smarty->assign("errorMsg", $this->errorMsg); - return($smarty->fetch(get_template_path("goto/Device/AddPartitionDialog.tpl", TRUE))); - } - } - - // Assign base attributes - foreach($this->attributes as $attr){ - $smarty->assign($attr, $this->$attr); - } - - // Assign partition attributes. - $fsTypes = $this->fsTypeList; - $attrs = $bool_attrs = array(); - switch($this->selected_type){ - case PARTITION: { - $attrs = $this->p_attributes; - $bool_attrs = array("p_forcePrimary", "p_encrypt", "p_format", "p_bootable"); - break; - } - case RAID_DEVICE: { - $attrs = $this->r_attributes; - - // Do not allow to create raid devices in raid devices. - unset($fsTypes['raid']); - $bool_attrs = array("r_encrypt"); - break; - } - case VOLUME_GROUP: { - $attrs = $this->vg_attributes; - break; - } - case VOLUME: { - $attrs = $this->v_attributes; - unset($fsTypes['raid']); - unset($fsTypes['pv']); - $bool_attrs = array("v_encrypt"); - break; - } - case DISK: { - $attrs = $this->d_attributes; - break; - } - } - - // Assign properties to smarty. - foreach($attrs as $attr){ - $smarty->assign($attr, $this->$attr); - } - foreach($bool_attrs as $attr){ - $smarty->assign("{$attr}_selected", $this->$attr != FALSE); - } - - $smarty->assign("deviceUsage", $this->partitionObject->getDeviceUsage()); - $smarty->assign('fsTypes', $fsTypes); - $smarty->assign('raidLevelList', $this->raidLevelList); - $smarty->assign('freeRaidPartitions', $this->freeRaidPartitions); - $smarty->assign('disks', $this->diskList); - $smarty->assign('volumeGroupList', $this->volumeGroupList); - $smarty->assign('freeLvmPartitions', $this->freeLvmPartitions); - $smarty->assign("error", FALSE); - return($smarty->fetch(get_template_path("goto/Device/AddPartitionDialog.tpl", TRUE))); - } - - - /*! \brief Saves posted values. - */ - function save_object() - { - // Assign partition attributes. - $attrs = $bool_attrs = array(); - switch($this->selected_type){ - case PARTITION: { - $attrs = $this->p_attributes; - $bool_attrs = array("p_forcePrimary", "p_encrypt", "p_format", "p_bootable"); - break; - } - case RAID_DEVICE: { - $attrs = $this->r_attributes; - $bool_attrs = array("r_encrypt"); - $this->r_partitions = array(); - foreach($this->freeRaidPartitions as $key => $part){ - if(isset($_POST['r_partition_'.$key])){ - $this->r_partitions[] = $part; - } - } - break; - } - case VOLUME_GROUP: { - $attrs = $this->vg_attributes; - $this->vg_partitions = array(); - foreach($this->freeLvmPartitions as $key => $part){ - if(isset($_POST['vg_partition_'.$key])){ - $this->vg_partitions[] = $part; - } - } - break; - } - case VOLUME: { - $attrs = $this->v_attributes; - $bool_attrs = array("v_encrypt"); - break; - } - case DISK: { - $attrs = $this->d_attributes; - break; - } - } - - // Get posted string values - $attrs = array_merge($attrs, $this->attributes); - foreach($attrs as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = get_post($attr); - } - } - - // Get boolean values - foreach($bool_attrs as $attr){ - $this->$attr = isset($_POST[$attr]); - } - } - - - /*! \brief Converts a given size string to its size-value in MB. - * E.g. '200TB' => '209715200' MB - */ - function convertSize($size) - { - $map = array(); - $map['/mb/i'] = 1; - $map['/m/i'] = 1; - $map['/gb/i'] = 1024; - $map['/g/i'] = 1024; - $map['/tb/i'] = 1024; - $map['/t/i'] = 1024; - $map['/pb/i'] = 1024; - $map['/p/i'] = 1024; - foreach($map as $key => $multiplicator){ - if(preg_match($key, $size)){ - $size = intval(preg_replace("/[^0-9]/", "", $size)); - return($size * $multiplicator); - } - } - return(intval(preg_replace("/[^0-9]/", "", $size))); - } - - - /*! \brief Stores the changes back to the remote table model. - * @return TRUE on success else false. - */ - function save() - { - if($this->selected_type == DISK){ - - // Get volume group properties - $name = $this->d_name; - @$this->partitionObject->addDisk($name); - - // Display potential errors - if(!$this->partitionObject->success()){ - $msg = sprintf(_("Failed to add '%s': %s"), _("Disk"), $this->partitionObject->getError()); - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - return($this->partitionObject->success()); - - }elseif($this->selected_type == VOLUME_GROUP){ - - // Get volume group properties - $devices = $this->vg_partitions; - $name = $this->vg_name; - @$this->partitionObject->addVolumeGroup($name, $devices, $format=TRUE, $use_existing=FALSE, NULL); - - // Display potential errors - if(!$this->partitionObject->success()){ - $msg = sprintf(_("Failed to add '%s': %s"), _("Volume group"), $this->partitionObject->getError()); - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - return($this->partitionObject->success()); - - }elseif($this->selected_type == VOLUME){ - - // Get volume properties - $name = $this->v_name; - $fsType = $this->v_fsType; - $fsOptions = $this->v_fsOptions; - $group = $this->v_group; - $target = $this->v_mountPoint; - $size = $this->convertSize($this->v_size); - $encrypt = $this->v_encrypt; - - $maxSize = NULL; - $grow = FALSE; - $format = TRUE; - $use_existing = FALSE; - - if($fsType == "swap"){ - $target = "swap"; - } - - @$this->partitionObject->addVolume($target, $name, $group, $size, $maxSize, - $grow, $format, $use_existing, $fsType, $fsOptions); - - // Display potential errors - if(!$this->partitionObject->success()){ - $msg = sprintf(_("Failed to add '%s': %s"), _("Volume"), $this->partitionObject->getError()); - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - return($this->partitionObject->success()); - - }elseif($this->selected_type == RAID_DEVICE){ - - // Get raid device properties - $devices = $this->r_partitions; - $fsType = $this->r_fsType; - $raidLevel = intval($this->r_raidLevel); - $spares = $this->r_spares; - $encrypt = $this->r_encrypt; - - $name = $this->partitionObject->getNextRaidDevice(); - - // Check selected target - $partitions = $this->partitions; - $raids = $this->raidDevices; - $usedTargets = array(); - foreach($partitions as $part){ - $usedTargets[] = $part['target']; - } - foreach($raids as $part){ - $usedTargets[] = $part['target']; - } - if($fsType == "pv"){ - $target = $this->partitionObject->getNextPhysicalVolumeName(); - $fsType = $fsOptions = NULL; - }else{ - $target = $this->r_mountPoint; - $fsType = $this->r_fsType; - $fsOptions = $this->r_fsOptions; - } - if($fsType == "swap"){ - $target = "swap"; - } - - @$this->partitionObject->addRaidDevice($target, $name, $raidLevel, $spares, $fsType,$fsOptions, - TRUE, FALSE, $devices); - - // Display potential errors - if(!$this->partitionObject->success()){ - $msg = sprintf(_("Failed to add '%s': %s"), _("Raid device"), $this->partitionObject->getError()); - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - return($this->partitionObject->success()); - - }elseif($this->selected_type == PARTITION){ - - // Get all currently used partitions - $partitions = $this->partitions; - $raids = $this->raidDevices; - $usedTargets = array(); - foreach($partitions as $part){ - $usedTargets[] = $part['target']; - } - foreach($raids as $part){ - $usedTargets[] = $part['target']; - } - - // Collect options - $size = $this->convertSize($this->p_size); - $maxSize = NULL; - if($this->p_size_options == 1){ - $maxSize = $this->p_size_max_value; - } - $grow = $this->p_size_options == 2; - - $format = $this->p_format == 1; - $boot = $this->p_bootable == 1; - $primary = $this->p_forcePrimary; - $fsType = $this->p_fsType; - $fsOptions = ""; - $encrypt = $this->p_encrypt; - $passphrase = ""; - $disk = $this->p_used_disk; - - // We've to create a raid disk - if($this->p_fsType == "raid"){ - $target = $this->partitionObject->getNextRaidName(); - $fsType = $fsOptions = NULL; - $encrypt = $format = FALSE; - }else - - // We've to create a raid disk - if($this->p_fsType == "pv"){ - $target = $this->partitionObject->getNextPhysicalVolumeName(); - $fsType = $fsOptions = NULL; - $encrypt = $format = FALSE; - }else{ - - // Add normal-physical partition - $target = $this->p_mountPoint; - if($fsType == "swap"){ - $target = "swap"; - $encrypt = $format = FALSE; - } - } - - // Add partition to remote model - @$this->partitionObject->addPartition($target,$size, $maxSize, $grow, $format, $boot, $primary, - $fsType, $fsOptions , $encrypt, $passphrase, $disk); - - // Display potential errors - if(!$this->partitionObject->success()){ - $msg = sprintf(_("Failed to add '%s': %s"), _("Partition"), $this->partitionObject->getError()); - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - return($this->partitionObject->success()); - } - } -} -?> diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc deleted file mode 100644 index 30d276a34..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc +++ /dev/null @@ -1,333 +0,0 @@ - array('macAddress'), - 'registeredDevice' => array('deviceStatus','deviceUUID','manager','deviceType'), - 'ipHost' => array('ipHostNumber')); - - public $cn = ""; - public $serialNumber = ""; - public $seeAlso = ""; - public $owner = ""; - public $ou = ""; - public $o = ""; - public $l = ""; - public $description = ""; - public $manager = ""; - public $deviceUUID = ""; - public $deviceStatus = ""; - public $deviceType = ""; - public $ipHostNumber = ""; - public $macAddress = ""; - - public $base = ""; - public $orig_dn =""; - - private $resolvedNamesCache = array(); - - public $ignore_account = TRUE; - - - /*! \brief Constructs the device object and keep some - * initial values. - */ - function __construct(&$config, $dn) - { - plugin::plugin($config, $dn); - $this->orig_dn = $this->dn; - - // Initialize the object base - if ($this->dn == "new"){ - $ui= get_userinfo(); - $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=dummy,".session::global_get("CurrentMainBase"):$ui->dn); - } else { - $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("Device", "GOsaDeviceRDN"), '/')."/i", "", $this->dn); - } - - // Prepare the base selector - $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base); - $this->baseSelector->setSubmitButton(false); - $this->baseSelector->setHeight(300); - $this->baseSelector->update(true); - - $this->orig_deviceUUID = $this->deviceUUID; - } - - - /*! \brief Generate a fake uuid, it is not a real uuid. - * @return String A fake uuid. - */ - function genFakeUuid() - { - $strfmt = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - for($i=0;$idialog instanceOf singleUserSelect) return($this->dialog->execute()); - - $smarty = get_smarty(); - - // Assign ACL settings - $plInfo = $this->plInfo(); - foreach($plInfo['plProvidedAcls'] as $name => $desc){ - $smarty->assign("{$name}ACL", $this->getacl($name)); - } - - // Assign just user names instead of the complete dn. - $smarty->assign("owner_name", $this->getUserName($this->owner)); - $smarty->assign("manager_name", $this->getUserName($this->manager)); - $smarty->assign("base", $this->baseSelector->render()); - - // Assign attribute values - foreach($this->attributes as $attr){ - $smarty->assign($attr, set_post($this->$attr)); - } - - // If one attribute of the registered device is given, all others are required too. - $str = $this->manager.$this->deviceUUID.$this->deviceStatus; - $smarty->assign("registeredRequired", !empty($str)); - return($smarty->fetch(get_template_path('goto/Device/Device.tpl', TRUE))); - } - - - /*! \brief Validate the user input. - */ - function check() - { - $message = plugin::check(); - - // If one of the registered user attributes is set, - // the others have to be set too. - $str = $this->manager.$this->deviceUUID.$this->deviceStatus; - if(!empty($str)){ - if(empty($this->deviceStatus)){ - $message[] = msgPool::required(_("Status")); - } - if(empty($this->manager)){ - $message[] = msgPool::required(_("Manager")); - } - if(empty($this->deviceUUID)){ - $message[] = msgPool::required(_("Device UUID")); - } - } - - // Check ip-address - if (!empty($this->ipHostNumber) && !tests::is_ip($this->ipHostNumber)){ - $message[]= msgPool::invalid(_("IP address"), "", "", "192.168.1.10"); - } - - // Check if there a cn given - if (empty($this->cn)){ - $message[]= msgPool::required(_("Name")); - } - - // Check mac-address - if (!empty($this->macAddress) && !tests::is_mac($this->macAddress)){ - $message[]= msgPool::invalid(_("MAC address"), "", "", "00:0C:7F:31:33:F1"); - } - - return($message); - } - - - /*! \brief Detect an object's name by querying the ldap - * for the object's cn. - * @param String The object's dn to query for. - */ - function getUserName($dn) - { - // First asked the cache if we've already queried this name. - if(isset($this->resolvedNamesCache[$dn])) { - return($this->resolvedNamesCache[$dn]); - } - - // Try to detect the object's name via ldap search. - $ldap = $this->config->get_ldap_link(); - $this->resolvedNamesCache[$dn] = ""; - if(!empty($dn)){ - $ldap->cat($dn, array('cn')); - if($ldap->count()){ - $attrs = $ldap->fetch(); - $this->resolvedNamesCache[$dn] = $attrs['cn'][0]; - return( $attrs['cn'][0]); - }else{ - $this->resolvedNamesCache[$dn] = "("._("unknown")."!): ".$dn; - } - } - return($this->resolvedNamesCache[$dn]); - } - - - /*! \brief Detects and stores relevant values which where - * currently transmitted via $_GET/$_POST. - */ - function save_object() - { - plugin::save_object(); - - // Change owner requested, initiate a user selection dialog. - if(isset($_POST['editOwner'])){ - $this->currentUserSelect = "owner"; - $this->dialog = new singleUserSelect($this->config, get_userinfo()); - } - - // Change manager requested, initiate a user selection dialog. - if(isset($_POST['editManager'])){ - $this->currentUserSelect = "manager"; - $this->dialog = new singleUserSelect($this->config, get_userinfo()); - } - - // Remove owner initiated - if(isset($_POST['removeManager'])) $this->manager = ""; - if(isset($_POST['removeOwner'])) $this->owner = ""; - - // The user selection dialog has send that it has finished its job. - // Store the posted user-dn as manager or owner. - if($this->dialog && $this->dialog instanceOf singleUserSelect && count($this->dialog->detectPostActions())){ - $users = $this->dialog->detectPostActions(); - if(isset($users['action']) && $users['action'] == 'userSelected' && isset($users['targets']) && count($users['targets'])){ - $headpage = $this->dialog->getHeadpage(); - $dn = $users['targets'][0]; - $attr = $this->currentUserSelect; - $this->$attr = $dn; - $this->dialog = NULL; - } - } - - // User selection canceled - if(isset($_POST['add_users_cancel'])){ - $this->dialog = NULL; - } - - // Regenerate a new uuid - if(isset($_POST['reloadUUID'])) $this->deviceUUID = $this->genFakeUuid(); - - // Update the base - if ($this->acl_is_moveable($this->base)){ - if (!$this->baseSelector->update()) { - msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG); - } - if ($this->base != $this->baseSelector->getBase()) { - $this->base= $this->baseSelector->getBase(); - $this->is_modified= TRUE; - } - } - - } - - - /*! \brief Save the modified object back to the ldap. - */ - function save() - { - plugin::save(); - - // Append and remove dynmic object classes - foreach($this->dynClasses as $oc => $attrs){ - $this->attrs['objectClass'] = array_remove_entries(array($oc), $this->attrs['objectClass']); - foreach($attrs as $attr){ - if(isset($this->attrs[$attr]) && !empty($this->attrs[$attr])){ - $this->attrs['objectClass'][] = $oc; - break; - } - } - } - - $this->cleanup(); - $ldap=$this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->create_missing_trees(preg_replace("/^[^,]*+,/","",$this->dn)); - $ldap->cd($this->dn); - - // Perform action modify/create - if($this->initially_was_account){ - $ldap->modify($this->attrs); - new log("modify","Device/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - if (!$ldap->success()){ - msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class())); - }else{ - $this->handle_post_events("modify"); - } - }else{ - $ldap->add($this->attrs); - new log("create","Device/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - if (!$ldap->success()){ - msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_ADD, get_class())); - }else{ - $this->handle_post_events("add"); - } - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Device"), - "plDescription" => _("Device"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => - array( - "Device" => array( - "description" => _("Device"), - "objectClass" => "Device") - ), - "plProvidedAcls" => - array( - "base" => _("Base"), - "cn" => _("Name"), - "serialNumber" => _("Serial number"), - "seeAlso" => _("See also"), - "owner" => _("Owner"), - "ou" => _("Organizational Unit"), - "o" => _("Organization"), - "l" => _("Location"), - "description" => _("Description"), - "manager" => _("Manager"), - "deviceUUID" => _("UUID"), - "deviceStatus" => _("Status"), - "deviceType" => _("Type"), - "macAddress" => _("MAC address"), - "ipHostNumber" => _("IP address") - ), - "plProperties" => - array( - array( - "name" => "GOsaDeviceRDN", - "type" => "rdn", - "default" => "ou=devices,ou=systems,", - "description" => _("RDN for device storage."), - "check" => "gosaProperty::isRdn", - "migrate" => "migrate_GOsaDeviceRDN", - "group" => "plugin", - "mandatory" => FALSE - ), - - ) - ) - ); - } -} - -?> diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_DeviceConfig.inc deleted file mode 100644 index 8ee75a170..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_DeviceConfig.inc +++ /dev/null @@ -1,335 +0,0 @@ -is_account = $this->initially_was_account = FALSE; - $this->_device = &$parent; - $this->deviceUUID = $parent->deviceUUID; - - // Create assignable Elements list. - $this->assignableElementsList = new sortableListing(); - $this->assignableElementsList->setDeleteable(FALSE); - $this->assignableElementsList->setEditable(TRUE); - $this->assignableElementsList->setWidth("100%"); - $this->assignableElementsList->setHeight("200px"); - $this->assignableElementsList->setHeader(array(_("Name"),_("Description"),_("Add"))); - $this->assignableElementsList->setColspecs(array('*','*','20')); - $this->assignableElementsList->setAcl($this->getacl('')); - - // Create used Elements list. - $this->usedElementsList = new sortableListing(); - $this->usedElementsList->setDeleteable(TRUE); - $this->usedElementsList->setInstantDelete(FALSE); - $this->usedElementsList->setEditable(FALSE); - $this->usedElementsList->setWidth("100%"); - $this->usedElementsList->setHeight("200px"); - $this->usedElementsList->setHeader(array(_("Name"), _("Description"), _("Remove"))); - $this->usedElementsList->setColspecs(array('*','*','20')); - $this->usedElementsList->setAcl($this->getacl('')); - - // Create parameter Elements list. - $this->parameterList = new sortableListing(); - $this->parameterList->setDeleteable(FALSE); - $this->parameterList->setInstantDelete(FALSE); - $this->parameterList->setEditable(FALSE); - $this->parameterList->setWidth("100%"); - $this->parameterList->setHeight("200px"); - $this->parameterList->setHeader(array(_("Name"), _("Description"), _("Value"))); - $this->parameterList->setColspecs(array('*','*','350px')); - $this->parameterList->setAcl($this->getacl('')); - } - - - function check() - { - } - - - /*! \brief Generates the HTML output for the plugin - */ - function execute() - { - // Initialize to plugin - if(!$this->initialized){ - - // Load config settings for the current device. - $rpc = $this->config->getRpcHandle(); - $res = $rpc->systemGetConfigParameters($this->deviceUUID); - if(!$rpc->success()){ - $smarty = get_smarty(); - $smarty->assign("error", TRUE); - $smarty->assign("errorMsg", msgPool::rpcError($rpc->get_error())); - return($smarty->fetch(get_template_path('goto/Device/DeviceConfig.tpl', TRUE))); - }else{ - - // Initialization completed. - $this->initialized = TRUE; - $this->is_account = $this->initially_was_account = isset($res['item']); - if(isset($res['var'])) $this->parameterValues = $res['var']; - if(isset($res['item'])) $this->usedElements = $res['item']; - } - } - - // Load assignable elements. - $rpc = $this->config->getRpcHandle(); - $release = $this->parent->by_object['InstallRecipe']->installRelease; - $release = preg_replace("/^[^\/]+\//","", $release); - $assignableElements = $rpc->listAssignableElements($release); - if(!$rpc->success()){ - $smarty = get_smarty(); - $smarty->assign("error", TRUE); - $smarty->assign("errorMsg", msgPool::rpcError($rpc->get_error())); - return($smarty->fetch(get_template_path('goto/Device/DeviceConfig.tpl', TRUE))); - }else{ - $this->assignableElements = $assignableElements; - } - - // Log account access - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","Device/".get_class($this),$this->dn); - } - - /*************** - Handle account state - ***************/ - - // Allow to add or remove the distribution list extension - if(isset($_POST['modify_state'])){ - if($this->is_account && $this->acl_is_removeable()){ - $this->is_account= FALSE; - }elseif(!$this->is_account && $this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - - // Show account status-changer - $display = ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove config mangement"), - msgPool::featuresEnabled(_("Config management"))); - } else { - $display= $this->show_enable_header(_("Add Config management"), - msgPool::featuresDisabled(_("Config management"))); - return ($display); - } - } - - /*************** - Create the HTML content with its lists - ***************/ - - // Fill list of assignable elements - $data = $lData = array();; - foreach($this->assignableElements as $name => $element){ - - // skip already assigned elements - if(in_array_strict($name, $this->usedElements)) continue; - - // Create the list elements. - $data[$name] = $element; - $desc = (isset($element['description'])) ? $element['description'] : ''; - $lData[$name] = array('data' => array($name, $desc)); - - } - $this->assignableElementsList->setListData($data, $lData); - $this->assignableElementsList->update(); - - // Build list of assigned Elements - $data = $lData = array();; - foreach($this->usedElements as $name){ - - // check if the assgined element is still available, if not mark it in red. - if(isset($this->assignableElements[$name])){ - $element = $this->assignableElements[$name]; - $data[$name] = $element; - $desc = (isset($element['description'])) ? $element['description'] : ''; - }else{ - $element = NULL; - $data[$name] = $element; - $desc = ""._("Unknown config item").""; - } - $lData[$name] = array('data' => array($name, $desc)); - } - $this->usedElementsList->setListData($data, $lData); - $this->usedElementsList->update(); - - // Build up parameter list - $data = $lData = array();; - foreach($this->usedElements as $name){ - - // Skip parameters for not existent items. - if(!isset($this->assignableElements[$name]['parameter'])) continue; - - // Build up the parameter list using the 'TemplateWidget_string' class. - $parameter = $this->assignableElements[$name]['parameter']; - foreach($parameter as $param => $desc){ - $data[$param] = NULL; - $value = (isset($this->parameterValues[$param])) ? $this->parameterValues[$param] : ""; - - // Create template widget on demand. - if(!isset($this->parameterWidgets[$param])){ - $this->parameterWidgets[$param] = new TemplateWidget_stringLong($this->config, $param, $value, - $desc, '', FALSE, 'string', $param); - - $this->parameterWidgets[$param]->setWriteable(preg_match("/w/",$this->getacl(''))); - $this->parameterWidgets[$param]->setReadable(preg_match("/r/",$this->getacl(''))); - } - $w = $this->parameterWidgets[$param]; - $lData[$param] = array('data' => array($w->getDisplayName(),$desc, $w->render())); - } - } - $this->parameterList->setListData($data, $lData); - $this->parameterList->update(); - - // Build up smarty template. - $smarty = get_smarty(); - $smarty->assign("error", FALSE); - $smarty->assign("assignableElementsList", $this->assignableElementsList->render()); - $smarty->assign("usedElementsList", $this->usedElementsList->render()); - $smarty->assign("parameterList", $this->parameterList->render()); - return($display.$smarty->fetch(get_template_path('goto/Device/DeviceConfig.tpl', TRUE))); - } - - - /*! \brief Act on posted values. - * And keep track of posted values. - */ - function save_object() - { - // Get posted parameter values - foreach($this->parameterWidgets as $name => $w){ - if($w->isWriteable()){ - $w->save_object(); - $this->parameterValues[$name] = $w->getValue(); - } - } - - if(preg_match("/w/", $this->getacl(''))){ - - // Act on Add-Element actions - $this->assignableElementsList->save_object(); - $action = $this->assignableElementsList->getAction(); - if($action['action'] == 'edit'){ - $this->usedElements[] = $this->assignableElementsList->getKey($action['targets'][0]); - $this->usedElements = array_unique($this->usedElements); - } - - // Act on Remove-Item actions - $this->usedElementsList->save_object(); - $action = $this->usedElementsList->getAction(); - if($action['action'] == 'delete'){ - $name = $this->usedElementsList->getKey($action['targets'][0]); - $this->usedElements = array_remove_entries_ics(array($name), $this->usedElements); - } - } - } - - - /*! \brief Save changes back to the GOsa-ng server. - */ - function save() - { - // If no items are assinged we've to remove the extension. - if(!count($this->usedElements)) { - $this->remove_from_parent(); - return; - } - - // Load assignable elements. - $rpc = $this->config->getRpcHandle(); - $release = $this->parent->by_object['InstallRecipe']->installRelease; - $release = preg_replace("/^[^\/]+\//","", $release); - $assignableElements = $rpc->listAssignableElements($release); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), msgPool::rpcError($rpc->get_error()), ERROR_DIALOG); - return(NULL); - }else{ - $this->assignableElements = $assignableElements; - } - - // Collect paramter list. - $params = array(); - foreach($this->usedElements as $name){ - if(isset($this->assignableElements[$name]['parameter'])){ - $params = array_merge($params, $this->assignableElements[$name]['parameter']); - } - } - - // Decide whoch parameter has to be saved and which has to be removed. - $save = array(); - foreach($this->parameterValues as $name => $value){ - if(isset($params[$name])){ - $save[$name] = $value; - } - } - - // Save changes back to server. - $rpc = $this->config->getRpcHandle(); - $installConfigManagement = $this->parent->by_object['InstallRecipe']->installConfigManagement; - $rpc->systemSetConfigParameters($this->deviceUUID, array('method' => $installConfigManagement, - 'var' => $save, 'item' => array_values($this->usedElements))); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), msgPool::rpcError($rpc->get_error()), ERROR_DIALOG); - return(NULL); - } - } - - - /*! \brief Removes the account from the device. - */ - function remove_from_parent() - { - // Save changes back to server. - $rpc = $this->config->getRpcHandle(); - $rpc->removeConfigParameters($this->deviceUUID); - if(!$rpc->success()){ - msg_dialog::display(_("Error"), msgPool::rpcError($rpc->get_error()), ERROR_DIALOG); - return(NULL); - } - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Device config"), - "plDescription" => _("Device config"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("Device"), - "plProvidedAcls" => array( - ))); - } -} -?> diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc deleted file mode 100644 index 5f1a4ed0b..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_DevicePartition.inc +++ /dev/null @@ -1,402 +0,0 @@ -config = &$config; - $this->partitionString = $partitionString; - - #$this->partitionString = "disk sda --initlabel --none; - # part /boot --size 1000 --format --fstype ext3 --ondisk sda; - # part /test --size 1000 --fstype ext3 --ondisk sda; - # part pv.00 --size 10 --bootable --ondisk sda; - # part raid.00 --size 5000 --bootable --ondisk sda; - # part pv.01 --size 10009 --ondisk sda; - # part raid.01 --size 1000 --bootable --ondisk sda; - # part pv.03 --size 1000 --bootable --ondisk sda; - # part raid.02 --size 981 --bootable --ondisk sda; - # raid pv.02 --level 0 --name md0 --format raid.01 raid.00; - # volgroup garnele --format pv.01 pv.00 pv.02; - # logvol /homejj --size 8978 --format --fstype ext3 --name garnele_home --vgname garnele; - # logvol /opt --size 7041 --format --fstype ext3 --name garnele_opt --vgname garnele;"; - - // Prepare lists - $this->entryList = new sortableListing(); - $this->entryList->setDeleteable(false); - $this->entryList->setEditable(false); - $this->entryList->setWidth("100%"); - $this->entryList->setHeight("400px"); - $this->entryList->setHeader(array(_("Type"),_("Target"),_("Size"),_("Uses device")." / "._("Used by"), - _("Filesystem"), _("Options"), _("Details"), "-")); - $this->entryList->setColspecs(array('*','*','*', '*')); - $this->entryList->setAcl('rwcdm'); - $this->entryList->setReorderable(FALSE); - $this->entryList->sortingEnabled(FALSE); - } - - function execute() - { - /***** - * Handle add-partition dialog - *****/ - - // Create button was pressed, show dialog to add new partitions - if(isset($_POST['create_partition'])){ - $this->addDialog = new AddPartitionDialog($this->config, $this->object); - } - - // Abort partition add - if(isset($_POST['cancel_partition_add'])){ - $this->addDialog = NULL; - } - - // Save created partitions - if(isset($_POST['save_partition_add'])){ - $this->addDialog->save_object(); - if($this->addDialog->save()){ - $this->addDialog = NULL; - } - } - - // Show partition dialog - if($this->addDialog){ - $this->addDialog->save_object(); - return($this->addDialog->execute()); - } - - - /***** - * Open partition object on demand - *****/ - - // Open remote parition object - if(!$this->initialized){ - $rpc = $this->config->getRpcHandle(); - $this->object = $rpc->openObject('libinst.preseed.diskdefinition', $this->partitionString); - if(!$rpc->success()){ - $message = _("An error occured while loading partition information."); - $message = sprintf(_("An error occured while loading partition information, error was: '%s'."), $rpc->get_error()); - $smarty = get_smarty(); - $smarty->assign('error', TRUE); - $smarty->assign('errorMsg', $message); - return($smarty->fetch(get_template_path('goto/Device/DevicePartition.tpl', TRUE))); - }else{ - $this->initialized = TRUE; - } - } - - - /***** - * Fill listing - *****/ - - // Receive list informations - $map = array(); - $map['disks'] = 'getDisks'; - $map['partitions'] = 'getPartitions'; - $map['raids'] = 'getRaidDevices'; - $map['volumeGroups'] = 'getVolumeGroups'; - $map['volumes'] = 'getVolumes'; - $map['deviceUsage'] = 'getDeviceUsage'; - foreach($map as $target => $func){ - $$target = @$this->object->$func(); - if(!$this->object->success()){ - $message = sprintf(_("An error occured while loading partition information, error was: '%s'."), $this->object->getError()); - $smarty = get_smarty(); - $smarty->assign('error', TRUE); - $smarty->assign('errorMsg', $message); - return($smarty->fetch(get_template_path('goto/Device/DevicePartition.tpl', TRUE))); - } - } - - // Create a mapping that show which partitions was used for which raid. - $map_partToRaid = array(); - $raidTargets = array(); - foreach($raids as $raid){ - $raidTargets[] = $raid['target']; - foreach($raid['devices'] as $devName){ - $map_partToRaid[$devName] = $raid['name']; - } - } - - // Create a mapping that shows which partition was used in which volumeGroup. - $map_partToVolumeGroup = array(); - foreach($volumeGroups as $vol){ - foreach($vol['partitions'] as $part){ - $map_partToVolumeGroup[$part] = $vol['name']; - } - } - - // Create partition name map - $partNames = array(); - - // Create separators to create a visible indentation - $seps = array(); - $seps[0] = ""; - $seps[1] = str_pad("", 18, " "); - $seps[2] = str_pad("", 36, " "); - - // Prepare images - $partitionImg = image('plugins/goto/images/partition.png','',_("Partition")); - $diskImg = image('plugins/goto/images/disk.png','',_("Disk")); - $raidImg = image('plugins/goto/images/raid.png', '', _('Raid')); - $volumeGroupImg = image('plugins/goto/images/volumeGroups.png', '', _('Volume group')); - $volumeImg = image('plugins/goto/images/volume.png','',_('Volume')); - - // Add raid devices - $lData = array(); - if(count($raids)){ - - // Add raid header - $lData[] = array("data" => array(""._("Raid devices")."")); - - // Add raids - foreach($raids as $id => $raid){ - $str = "{$seps[1]}{$raidImg} {$raid['name']} ("._("Raid")."{$raid['level']})"; - $delImg = image('images/lists/trash.png', "delete_raid_{$id}", _("Remove raid device")); - - $devsStr = ""; - foreach($raid['devices'] as $devName){ - $devsStr .= $partitionImg." ".$devName.", "; - } - $devsStr = rtrim($devsStr, ', '); - - $target = $raid['target']; - if(isset($map_partToVolumeGroup[$target])){ - $target = $volumeGroupImg." ".$target; - } - - $fsType = (isset($raid['fsType'])) ? $raid['fsType'] :""; - $fsOptions = (isset($raid['fsOptions'])) ? $raid['fsOptions'] :""; - - $size = ""; - if(isset($deviceUsage['raid'][$raid['target']])){ - $size = "".$this->__convertPartSize($deviceUsage['raid'][$raid['target']]['size']).""; - } - - $lData[] = array("data" => array($str, - $target, - $size, - $devsStr, - $fsType, - $fsOptions, - '', - $delImg - )); - } - } - - // Add volume groups - if(count($volumeGroups)){ - - // Add LVM volume groups header - $lData[] = array("data" => array(""._("LVM Volume Groups")."")); - - // Add volume groups - foreach($volumeGroups as $id => $vg){ - $str = "{$seps[1]}{$volumeGroupImg} {$vg['name']}"; - $delImg = image('images/lists/trash.png', "delete_vg_{$id}", _("Remove volume group")); - - // Build up a list of all used partitions - $partStr = ""; - foreach($vg['partitions'] as $partName){ - if(in_array_strict($partName, $raidTargets)){ - $img = $raidImg; - }else{ - $img = $partitionImg; - } - $partStr .= "{$img} {$partName}, "; - } - $partStr = rtrim($partStr, ", "); - - $size = ""; - if(isset($deviceUsage['vg'][$vg['name']])){ - $size = "".$this->__convertPartSize($deviceUsage['vg'][$vg['name']]['size']).""; - } - - // Add entry to the list. - $lData[] = array("data" => array($str, '', $size, $partStr, '', '','',$delImg)); - - // Add volumes - foreach($volumes as $vid => $volume){ - $delImg = image('images/lists/trash.png', "delete_v_{$vid}", _("Remove volume")); - if($volume['volGroup'] == $vg['name']){ - $str = "{$seps[2]}{$volumeImg} {$volume['name']}"; - $lData[] = array("data" => array( - $str, - $volume['target'], - $this->__convertPartSize($volume['size']), - '', - $volume['fsType'], - $volume['fsOptions'], - '', - $delImg - )); - - - - } - } - } - } - - // Collect all disk devices names - $diskNames = array(); - foreach($disks as $disk){ - $diskNames[] = $disk['device']; - } - - // Add physical disks to the listing. - if(count($disks)){ - - // Add disks - $lData[] = array("data" => array(""._("Disks")."")); - foreach($disks as $id => $disk){ - $str = "{$seps[1]}{$diskImg} {$disk['device']}"; - - $size = ""; - if(isset($deviceUsage['disk'][$disk['device']])){ - $size = "".$this->__convertPartSize($deviceUsage['disk'][$disk['device']]['size']).""; - } - - // Create remove icon - $delImg = image('images/lists/trash.png', "delete_disk_{$id}", _("Remove disk")); - $lData[] = array("data" => array($str,"",$size,"","","","", $delImg)); - - // Add partitions - foreach($partitions as $pid => $part){ - - if(!in_array_strict($part['onDisk'], $diskNames)){ - - echo "Cannot display '{$part['target']}' the given disk '{$part['onDisk']}' does not exists!
"; - continue; - } - - if($part['onDisk'] == $disk['device']){ - - // Prepare columns - $str = "{$seps[2]}{$partitionImg} {$part['target']}"; - $device = ""; - $fsType = $part['fsType']; - $target = ""; - if(preg_match("/^(swap|\/)/", $part['target'])){ - $target = $part['target']; - } - - // Do we have a raid here? Then update the device column - // to point to the raid name - if(isset($map_partToRaid[$part['target']])){ - $device = sprintf(_("Used by: %s"), $raidImg." ".$map_partToRaid[$part['target']]); - $fsType.= " "._("Software raid"); - $fsType = trim($fsType); - }elseif(isset($map_partToVolumeGroup[$part['target']])){ - $device = sprintf(_("Used by: %s"), $volumeGroupImg." ".$map_partToVolumeGroup[$part['target']]); - $fsType.= " "._("Physical volume LVM"); - $fsType = trim($fsType); - } - - // Create property icons - $emptyImage = image("images/empty.png"); - $formatImg = ($part['format']) ? image('plugins/goto/images/formatDisk.png','',_("Format partition")) : $emptyImage; - $primaryImg = ($part['primary']) ? image('plugins/goto/images/primary.png','',_("Primary partition")) : $emptyImage; - $bootImg = ($part['bootable']) ? image('images/true.png','',_("Bootable")) : $emptyImage; - $encryptImg = ($part['encrypted']) ? image('images/lists/locked.png','',_("Encrypted")) : $emptyImage; - - // Create remove icon - $delImg = image('images/lists/trash.png', "delete_part_{$pid}", _("Remove partition")); - - // Add entry to the listing - $lData[] = array("data" => array( - $str, - $target, - $this->__convertPartSize($part['size'], $part['grow'], $part['maxSize']), - $device, - $fsType, - $part['fsOptions'], - "{$primaryImg} {$formatImg} {$bootImg} {$encryptImg}", - $delImg)); - } - } - } - } - - // Updated columns length for all entries to avoid render errors. - $length = 8; - foreach($lData as $id => $entry){ - while(count($lData[$id]['data']) < $length){ - $lData[$id]['data'][] = ''; - } - } - $this->entryList->setListData($lData, $lData); - $this->entryList->update(); - - $smarty = get_smarty(); - $smarty->assign('error', FALSE); - $smarty->assign('list', $this->entryList->render()); - return($smarty->fetch(get_template_path('goto/Device/DevicePartition.tpl', TRUE))); - } - - - /*! \brief Keep posted HTML values and acts on remove requests. - */ - function save_object() - { - // Create a map whcih points to the correct remove method for each device. - $map = array(); - $map['part'] = array('func' => 'delPartition', 'name' => _("Partition")); - $map['raid'] = array('func' => 'delRaidDevice', 'name' => _("Raid device")); - $map['disk'] = array('func' => 'delDisk', 'name' => _("Disk")); - $map['vg'] = array('func' => 'delVolumeGroup', 'name' => _("Volume group")); - $map['v'] = array('func' => 'delVolume', 'name' => _("Volume")); - - // Walk through posts and search for remove requests. - foreach($_POST as $name => $value){ - foreach($map as $type => $data){ - - // Remove paritions - if(preg_match("/^delete_{$type}_[0-9]*$/", $name)){ - $id = preg_replace("/^delete_{$type}_/i", "", $name) + 0; - $func = $data['func']; - @$this->object->$func($id); - if(!$this->object->success()){ - $msg = sprintf(_("Failed to remove '%s': %s"), $data['name'], $this->object->getError()); - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - } - } - } - } - - - /*! \brief Returns to created partition table string, which can then be - * saved back to the server. - */ - function save() - { - return($this->object->dump()); - } - - - /*! \brief Convert a given size value to a human readable format. - */ - function __convertPartSize($size, $grow = False, $maxSize = NULL) - { - $str = $size." "._("MB"); - - if($maxSize != NULL){ - $str .= " - ".$this->__convertPartSize($maxSize); - }elseif($grow){ - $str .= " - ... ("._("growing").")"; - } - return($str); - } -} - -?> diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc deleted file mode 100644 index 2bd6811cc..000000000 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_InstallRecipe.inc +++ /dev/null @@ -1,753 +0,0 @@ -is_account = $this->initially_was_account = FALSE; - - $this->_device = &$parent; - $this->deviceUUID = $parent->deviceUUID; - - // Set default password hash - $this->hash = $this->config->get_cfg_value("core","passwordDefaultHash"); - - // Get list of password hashes - $tmp = passwordMethod::get_available_methods(); - $this->hashes = array(); - foreach($tmp['name'] as $name){ - $this->hashes[$name] = $name; - } - - // Initialize plugin - $this->init_static_info(); - $this->init($initially = TRUE); - } - - function init($initially = FALSE) - { - // Init the object values. - $this->init_client_info(); - - // Prepare NTP servers list - $this->installNTPServerList= new sortableListing($this->installNTPServer); - $this->installNTPServerList->setDeleteable(true); - $this->installNTPServerList->setEditable(false); - $this->installNTPServerList->setColspecs(array('*')); - $this->installNTPServerList->setWidth("100%"); - $this->installNTPServerList->setHeight("70px"); - - // Preset values for new devices - if(!$this->is_account){ - $this->installTemplate = key($this->installationTemplates); - $this->installRelease = key($this->templateToRelease[$this->installTemplate]); - }else{ - - if(!isset($this->installationTemplates[$this->installTemplate])){ - - // The selected template is no longer available, select the next selectable template. - $new = key($this->installationTemplates); - - if($initially){ - $message = sprintf(_("The selected template '%s' is no longer available. Selecting '%s' as replacement!"), - $this->installTemplate, $new); - msg_dialog::display(_("Warning"), $message, WARNING_DIALOG); - } - $this->installTemplate = $new; - $installRelease = key($this->templateToRelease[$this->installTemplate]); - - }elseif(!isset($this->installationTemplates[$this->installTemplate]['method'])){ - - // Not necessary to warn the user here, the input fields will be empty and thus - // avoid saving. - - }elseif(!in_array_strict($this->installRelease, $this->templateToRelease[$this->installTemplate])){ - - // The selected release is no longer available for the current template - // Warn the user and select the next selectable release. - $new = key($this->templateToRelease[$this->installTemplate]); - if($initially){ - $message = sprintf(_("The selected release '%s' is no longer available. Selecting '%s' as replacement!"), - $this->installRelease, $new); - } - $this->installRelease = $new; - msg_dialog::display(_("Warning"), $message, WARNING_DIALOG); - } - } - - // Update selectable items like kernels and mirrors depending on the current setup (relase) - $this->installBaseMethod = $this->installationTemplates[$this->installTemplate]['method']; - $this->reloadInstallationKernelPackages($initially); - $this->reloadInstallationMirrors($initially); - - // Preset the config management method. - if(!isset($this->installConfigManagementList[$this->installBaseMethod][$this->installConfigManagement])){ - if(isset($this->installConfigManagementList[$this->installBaseMethod]) && - count($this->installConfigManagementList[$this->installBaseMethod])){ - $this->installConfigManagement = key($this->installConfigManagementList[$this->installBaseMethod]); - } - } - } - - - /*! \brief Loads client-information values from the GOsa-backend using jsonRPC - */ - function init_client_info() - { - if(empty($this->deviceUUID)){ - return; - } - - // Load base install Method - $rpc = $this->config->getRpcHandle(); - $bMethod = $rpc->systemGetBaseInstallMethod($this->deviceUUID); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - return(NULL); - } - - // Do nothing while no install method is defined. - if(!$bMethod){ - return; - } - - // Set the bootstrap method. - $this->installBaseMethod = $bMethod; - - $res = $rpc->systemGetBaseInstallParameters($this->deviceUUID); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - return(NULL); - } - - // Apply received options - $this->is_account = $res == True; - if($this->is_account){ - - $map = array( - 'ntp-servers' => "installNTPServer", - 'template' => "installTemplate", - 'keyboard-layout' => "installKeyboardlayout"); - - // We receive an array for these attributes, but require a string instead - // we just use the first element of the array. - $mapArray = array( - 'release' => "installRelease", - 'timezone' => "installTimezone", - 'utc' => "installTimeUTC", - 'kernel' => "installKernelPackage", - 'system-locale' => "installSystemLocale", - 'root-user' => "installRootEnabled", - 'root-hash' => "installRootPasswordHash", - 'disk-setup' => "installPartitionTable"); - - foreach($res as $name => $data){ - if(isset($map[$name])){ - $target = $map[$name]; - $value = $res[$name]; - }elseif(isset($mapArray[$name])){ - $target = $mapArray[$name]; - $value = $res[$name][0]; - } - $this->$target = $value; - } - - // Convert Bool values to Bool. - $boolean = array("installRootEnabled", "installTimeUTC"); - foreach($boolean as $attr){ - $this->$attr = ($this->$attr != FALSE && !preg_match("/false/i", $this->$attr)); - } - } - - return; - } - - - function init_static_info() - { - // Load static values. - foreach(array( - "timeozones" => "getTimezones", - "distributions" => "loadDistributions", - "keyboardLayouts" => "loadInstallationKeyboardLayouts", - "installationTemplates" => "loadInstallationTemplates", - "installationMethods" => "loadInstallationMethods", - "locales" => "getSystemLocales" ) as $target => $func){ - - if(!session::is_set("InstallRecipe::{$func}")){ - $tmp = $this->$func(); - if($tmp == NULL){ - $this->initFailed = TRUE; - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - return; - }else{ - session::set("InstallRecipe::{$func}", $tmp); - } - } - $$target = session::get("InstallRecipe::{$func}"); - } - - // Assign fetchted values - $this->timezones = $timeozones; - $this->installBaseMethodList = $installationMethods['installBaseMethodList']; - $this->installConfigManagementList = $installationMethods['installConfigManagementList']; - $this->installSystemLocaleList = $locales; - $this->installKeyboardlayoutList = $keyboardLayouts; - $this->distributions = $distributions; - - # Create template to relase map - $this->templateToRelease = array(); - - // Walk through installation templates and use the 'repositories' attribute - // to supported releases. - foreach($installationTemplates as $name => $tdata){ - - $mName = isset($this->installBaseMethodList[$tdata['method']]) ? - $this->installBaseMethodList[$tdata['method']]: $tdata['method']; - - $this->installationTemplateNames[$name] = $tdata['description']." (".$mName.")"; - $this->installationTemplates[$name] = $tdata; - $this->templateToRelease[$name] = array(); - - // Check if the 'repository'-category of the template can be found in any - // received release list. - if(isset($installationMethods[$tdata['method']]['repositories'])){ - $repos = $installationMethods[$tdata['method']]['repositories']; - foreach($distributions as $dist){ - if(in_array_strict($dist['type']['name'],$repos) && isset($dist['releases'])){ - foreach($dist['releases'] as $release){ - $rname = $dist['name'].'/'.$release['name']; - $this->templateToRelease[$name][$rname] = $rname; - } - } - } - } - } - } - - - function check() - { - // Check if the parents deviceUUID has changed - if($this->deviceUUID != $this->_device->deviceUUID){ - $this->deviceUUID = $this->_device->deviceUUID; - print "The device uuid has changed."; - } - } - - - function execute() - { - // Log account access - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","Device/".get_class($this),$this->dn); - } - - /*************** - Handle account state - ***************/ - - // Allow to add or remove the distribution list extension - if(isset($_POST['modify_state'])){ - if($this->is_account && $this->acl_is_removeable()){ - $this->is_account= FALSE; - }elseif(!$this->is_account && $this->acl_is_createable()){ - $this->is_account= TRUE; - } - } - - // Show account status-changer - $display = ""; - if ($this->parent !== NULL){ - if ($this->is_account){ - $display= $this->show_disable_header(_("Remove base installation"), - msgPool::featuresEnabled(_("Base installation"))); - } else { - $display= $this->show_enable_header(_("Add base installation"), - msgPool::featuresDisabled(_("Base installation"))); - return ($display); - } - } - - /*************** - Root password hash dialog - ***************/ - - $this->dialog = FALSE; - if($this->setPasswordHash){ - $this->dialog = TRUE; - $smarty = get_smarty(); - $smarty->assign('hashes', set_post($this->hashes)); - $smarty->assign('hash', set_post($this->hash)); - return($smarty->fetch(get_template_path('goto/Device/SetPassword.tpl', TRUE))); - } - - /*************** - Partition dialog - ***************/ - - if(isset($_POST['partition_finish']) && $this->partitionEdit){ - $this->installPartitionTable = $this->partitionEdit->save(); - $this->partitionEdit = NULL; - } - if(isset($_POST['partition_cancel']) && $this->partitionEdit){ - $this->partitionEdit = NULL; - } - if(isset($_POST['edit_installPartitionTable'])){ - $this->partitionEdit = new DevicePartition($this->config, $this->installPartitionTable); - } - if($this->partitionEdit){ - $this->partitionEdit->save_object(); - $this->dialog = TRUE; - return($this->partitionEdit->execute()); - } - - - - /*************** - Generate HTML content - ***************/ - - $this->installNTPServerList->setAcl($this->getacl('installNTPServer')); - $this->installNTPServerList->update(); - - plugin::execute(); - $smarty = get_smarty(); - - // Assign ACLs - foreach($this->attributes as $attr){ - $smarty->assign("{$attr}ACL", $this->getacl($attr)); - } - - $smarty->assign('installTemplateList', $this->installationTemplateNames); - $smarty->assign('installReleaseList', $this->templateToRelease[$this->installTemplate]); - $smarty->assign('timezones', $this->timezones); - $smarty->assign('installKeyboardlayoutList', $this->installKeyboardlayoutList); - $smarty->assign('installKernelPackageList', $this->installKernelPackageList); - $smarty->assign('installMirrorList', $this->installMirrorList); - $smarty->assign('installSystemLocaleList', $this->installSystemLocaleList); - $smarty->assign('installNTPServerList', $this->installNTPServerList->render()); - - $smarty->assign('installBaseMethod', $this->installBaseMethod); - $smarty->assign('installBaseMethodList', $this->installBaseMethodList); - $smarty->assign('installConfigManagement', $this->installConfigManagement); - - // Assign list of available config-management types. - if(isset($this->installConfigManagementList[$this->installBaseMethod])){ - $smarty->assign('installConfigManagementList', $this->installConfigManagementList[$this->installBaseMethod]); - }else{ - $smarty->assign('installConfigManagementList', array()); - } - - foreach($this->attributes as $attr){ - $smarty->assign($attr, $this->$attr); - } - $this->dialog = false; - return($display.$smarty->fetch(get_template_path('goto/Device/InstallRecipe.tpl', TRUE))); - } - - - function save_object() - { - if(isset($_POST['InstallRecipePosted'])){ - - $currentInstallMethod = $this->installConfigManagement; - - $oldRelease = $this->installRelease; - plugin::save_object(); - $this->installRootEnabled = isset($_POST['installRootEnabled']); - $this->installTimeUTC = isset($_POST['installTimeUTC']); - - - if(isset($_POST['setPasswordHash'])){ - $this->setPasswordHash = true; - } - - $this->installNTPServerList->save_object(); - $this->installNTPServer = $this->installNTPServerList->getMaintainedData(); - if(isset($_POST['installNTPServer_Input']) && isset($_POST['installNTPServer_Add'])){ - $add = get_post('installNTPServer_Input'); - if(!in_array_strict($add, $this->installNTPServer) && !empty($add)){ - $this->installNTPServer[] = $add; - } - } - $this->installNTPServerList->setListData($this->installNTPServer); - $this->installBaseMethod = $this->installationTemplates[$this->installTemplate]['method']; - - // The selected release is no longer available for the current template - if(!in_array_strict($this->installRelease, $this->templateToRelease[$this->installTemplate])){ - $this->installRelease = key($this->templateToRelease[$this->installTemplate]); - } - - // Reload list of kernel packages and mirrors - if($oldRelease != $this->installRelease){ - $this->reloadInstallationKernelPackages(); - $this->reloadInstallationMirrors(); - } - } - - if(isset($_POST['cancelPassword'])) $this->setPasswordHash =false; - if(isset($_POST['setPassword'])) { - $this->setPasswordHash =false; - $hash = get_post('passwordHash'); - - // Not sure, why this is here, but maybe some encryption methods require it. - mt_srand((double) microtime()*1000000); - - // Generate the requested hash - $methods = new passwordMethod($this->config, $this->dn); - $available = $methods->get_available_methods(); - $test = new $available[$hash]($this->config,$this->dn); - $this->installRootPasswordHash = @$test->generate_hash(get_post('rootPassword')); - } - } - - - function save() - { - if(!$this->installRootEnabled) $this->installRootPasswordHash = ""; - - $map = array( - "installTemplate"=>'template', - "installRelease"=>'release', - "installTimezone"=>'timezone', - "installTimeUTC"=>'utc', - "installKernelPackage"=>'kernel', - "installSystemLocale"=>'system-locale', - "installRootEnabled"=>'root-user', - "installRootPasswordHash"=>'root-hash', - "installPartitionTable"=>'disk-setup', - "installKeyboardlayout"=>'keyboard-layout', - "installBaseMethod"=>'method', - ); - - // Collect values to be saved. - $data = array(); - foreach($map as $source => $dest){ - if(!empty($this->$source)){ - $data[$dest] = $this->$source; - } - } - - // Enforce an array for ntp-servers - if(!empty($this->installNTPServer)){ - $data['ntp-servers'] = array_values($this->installNTPServer); - } - - // Save Boolean like a String - $boolean = array("root-user" => "installRootEnabled", "utc" => "installTimeUTC"); - foreach($boolean as $attr => $source){ - $data[$attr] = ($this->$source) ? $data[$attr] = "TRUE" : $data[$attr] = "FALSE"; - } - - // Set the base installation parameters - $rpc = $this->config->getRpcHandle(); - $res = $rpc->systemSetBaseInstallParameters($this->deviceUUID, $data); - - // Handle errors - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - return(NULL); - } - } - - - function remove_from_parent() - { - // Try to remove the base install extension. - $rpc = $this->config->getRpcHandle(); - $bMethod = $rpc->removeBaseInstallParameters($this->deviceUUID); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - return(NULL); - } - } - - - /*! \brief Refreshes the list of selectable kernel packages. - */ - function reloadInstallationKernelPackages($initially = FALSE) - { - // Do nothing if no release is given. - if(empty($this->installRelease)){ - $this->installKernelPackageList = array(); - return; - } - - $release = preg_replace("/^[^\/]*\//","", $this->installRelease); - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getKernelPackages($release); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - }else{ - $this->installKernelPackageList = array(); - foreach($res as $data){ - $name = $data['name']; - $this->installKernelPackageList[$name] = $name; - } - - if(!isset($this->installKernelPackageList[$this->installKernelPackage])){ - $new = key($this->installKernelPackageList); - if($initially && $this->is_account){ - msg_dialog::display(_("Warning"), sprintf(_("The selected kernel package '%s' is no longer available! The kernel package '%s' was selected as replacement!"), $this->installKernelPackage, $new), WARNING_DIALOG); - } - $this->installKernelPackage = $new; - } - } - } - - - /*! \brief Returns a list of distributions on success. - * In case of an error, it returns NULL. - */ - function loadDistributions() - { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getDistributions(); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - return(NULL); - } - return($res); - } - - - /*! \brief Returns a list of timezones on success. - * In case of an error, it returns NULL. - */ - function getTimezones() - { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getTimezones(); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - return(NULL); - } - return($res); - } - - - /*! \brief Returns a list of installation mirrors on success. - * In case of an error, it returns NULL. - */ - function reloadInstallationMirrors($initially = FALSE) - { - $res = array( - 'dc=intranet,dc=gonicus,dc=de' => 'Intranet', - 'ou=systems,dc=intranet,dc=gonicus,dc=de' => 'System'); - $this->installMirrorList =$res; - } - - - /*! \brief Returns a list of installation templates on success. - * In case of an error, it returns NULL. - */ - function loadInstallationTemplates() - { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->installListTemplates(); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - return(NULL); - } - return($res); - } - - - /*! \brief Returns a list of keyboard layouts on success. - * In case of an error, it returns NULL. - */ - function loadInstallationKeyboardLayouts() - { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getKeyboardModels(); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - return(NULL); - } - $lay = array(); - foreach($res as $key => $data){ - $lay[$key] = "{$data[0]} - {$data[2]}"; - } - asort($lay); - return($lay); - } - - - /*! \brief Returns a list of system locales on success. - * In case of an error, it returns NULL. - */ - function getSystemLocales() - { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getSystemLocales(); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG); - return(NULL); - } - - return($res); - } - - - /*! \brief Try to load install and bootstrap methods from the GOsa-backend - * This is done via jsonRPC, if calling the backend method fails, - * this method returns FALSE, in case of success it return TRUE; - */ - function loadInstallationMethods() - { - $rpc = $this->config->getRpcHandle(); - $res = $rpc->getSupportedBaseInstallMethods(); - - // Failed to load backend values, keep reported error and return with FALSE; - $this->rpcError = !$rpc->success(); - if(!$rpc->success()){ - $this->rpcErrorMessage = $rpc->get_error(); - return(NULL); - } - - // Walk through result and set bootstrap methods. - foreach($res as $name => $method){ - $res['installBaseMethodList'][$name] = $method['name']; - foreach($method['methods'] as $m){ - $res['installConfigManagementList'][$name][$m] = $m; - } - } - return($res); - } - - - static function plInfo() - { - return (array( - "plShortName" => _("Device"), - "plDescription" => _("Registered device"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("Device"), - "plProvidedAcls" => array( - - "installRelease" => _("Release"), - "installTemplate" => _("Template"), - "installKeyboardlayout" => _("Keyboard layout"), - "installSystemLocale" => _("Locale"), - "installTimezone" => _("Timezone"), - "installTimeUTC" => _("Utc"), - "installNTPServer" => _("Ntp server"), - "installMirror" => _("Mirror"), - "installRootEnabled" => _("Root login enabled"), - "installRootPasswordHash" => _("Root password hash"), - "installKernelPackage" => _("Kernel package"), - "installConfigManagement" => _("Config mangement"), - "installBaseMethod" => _("Bootstrap method"), - "installPartitionTable" => _("Partition table") - ) - ) - ); - } -} -?>