summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a62bd24)
raw | patch | inline | side by side (parent: a62bd24)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 17 May 2011 09:28:34 +0000 (09:28 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 17 May 2011 09:28:34 +0000 (09:28 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20842 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/goto/admin/systems/goto/Device/DeviceConfig.tpl | patch | blob | history | |
gosa-plugins/goto/admin/systems/goto/Device/class_DeviceConfig.inc | patch | blob | history |
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/DeviceConfig.tpl b/gosa-plugins/goto/admin/systems/goto/Device/DeviceConfig.tpl
index 21e889b220af641be2a2d9d00d58d7c99ff65746..f5439f66e267ec402403f7cea0deb1209185589b 100644 (file)
-<table width='100%'>
- <tr>
- <td style='width:50%; vertical-align: top;padding-right:5px;'>
- <h3>{t}Assignable items{/t}</h3>
- {$assignableElementsList}
- </td>
- <td style='width:50%; vertical-align: top;padding-left:5px;' class='left-border'>
- <h3>{t}Assigned items{/t}</h3>
- {$usedElementsList}
- </td>
- </tr>
- <tr>
- <td colspan=2>
- <hr>
- </td>
- </tr>
- <tr>
- <td colspan=2>
- <h3>{t}Parameters{/t}</h3>
- {$parameterList}
- </td>
- </tr>
-</table>
+{if $error}
+
+ <p>
+ {$errorMsg}
+ </p>
+ <button type='submit' name='retry'>{t}Retry{/t}</button>
+
+{else}
+
+ <table width='100%'>
+ <tr>
+ <td style='width:50%; vertical-align: top;padding-right:5px;'>
+ <h3>{t}Assignable items{/t}</h3>
+ {$assignableElementsList}
+ </td>
+ <td style='width:50%; vertical-align: top;padding-left:5px;' class='left-border'>
+ <h3>{t}Assigned items{/t}</h3>
+ {$usedElementsList}
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <hr>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=2>
+ <h3>{t}Parameters{/t}</h3>
+ {$parameterList}
+ </td>
+ </tr>
+ </table>
+
+{/if}
diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_DeviceConfig.inc
index b064c1cfe103766aa646272925b484702b261caf..006a2b91b5ae3eed3b17a91296805051d0eb0caf 100644 (file)
public $usedElements = array();
public $assignableElements = array();
+ public $parameterValues = array();
+ public $parameterWidgets = array();
+
+ public $initialized = FALSE;
/*! \brief Initialize the plugin and its widgets.
* Finally call init() to load values from the backend.
$this->parameterList = new sortableListing();
$this->parameterList->setDeleteable(TRUE);
$this->parameterList->setInstantDelete(FALSE);
- $this->parameterList->setEditable(TRUE);
+ $this->parameterList->setEditable(FALSE);
$this->parameterList->setWidth("100%");
$this->parameterList->setHeight("200px");
$this->parameterList->setHeader(array(_("Type")));
function execute()
{
+ // Initialize to plugin
+ if(!$this->initialized){
+ $rpc = $this->config->getRpcHandle();
+ $res = $rpc->systemGetConfigParameters($this->deviceUUID);
+ if(!$rpc->success()){
+ $smarty = get_smarty();
+ $smarty->assign("error", TRUE);
+ $smarty->assign("errorMsg", msgPool::rpcError($this->rpcErrorMessage));
+ return($display.$smarty->fetch(get_template_path('goto/Device/DeviceConfig.tpl', TRUE)));
+ }else{
+ $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'];
+ }
+ }
+
+
// Log account access
if($this->is_account && !$this->view_logged){
$this->view_logged = TRUE;
foreach($parameter as $param => $desc){
$data[$param] = NULL;
}
- $value = (isset($this->parameterValues[$param])) ? $this->parameterValues[$param] : "<i>"._('unset')."</i>";
- $lData[$param] = array('data' => array($name, $param, $value));
+ $value = (isset($this->parameterValues[$param])) ? $this->parameterValues[$param] : "";
+
+ if(!isset($this->parameterWidgets[$param])){
+ $this->parameterWidgets[$param] = new TemplateWidget_string($this->config, $param, $value,
+ $desc, '', FALSE, 'string', $param);
+ }
+ $w = $this->parameterWidgets[$param];
+ $lData[$param] = array('data' => array($w->getDisplayName(), $w->render()));
}
$this->parameterList->setListData($data, $lData);
-
-
$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());
function save_object()
{
+ // Get posted parameter values
+ foreach($this->parameterWidgets as $name => $w){
+ $w->save_object();
+ $this->parameterValues[$name] = $w->getValue();
+ }
+
// Act on Add-Element actions
$this->assignableElementsList->save_object();
$action = $this->assignableElementsList->getAction();
function save()
{
+
+ // Collect paramter list.
+ $params = array();
+ foreach($this->usedElements as $name){
+ $params = array_merge($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();
+ $rpc->systemSetConfigParameters($this->deviceUUID, array('method' => 'puppet', 'var' => $save, 'item' => $this->usedElements));
+ if(!$rpc->success()){
+ $this->rpcErrorMessage = $rpc->get_error();
+ msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
+ return(NULL);
+ }
}
function remove_from_parent()
{
+ // Save changes back to server.
+ $rpc = $this->config->getRpcHandle();
+ $rpc->removeConfigParameters($this->deviceUUID);
+ if(!$rpc->success()){
+ $this->rpcErrorMessage = $rpc->get_error();
+ msg_dialog::display(_("Error"), msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
+ return(NULL);
+ }
}