summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7fe1e4f)
raw | patch | inline | side by side (parent: 7fe1e4f)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 5 Sep 2008 13:34:24 +0000 (13:34 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 5 Sep 2008 13:34:24 +0000 (13:34 +0000) |
- Added netboot properties.
- Fixed problem with initialization timeout.
If we have a timeout, we don not load everything new, just whats missing.
- Only save changes, do not save every property settings, even if there are no changes.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12369 594d385d-05f5-0310-b6e9-bd551577e9d8
- Fixed problem with initialization timeout.
If we have a timeout, we don not load everything new, just whats missing.
- Only save changes, do not save every property settings, even if there are no changes.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12369 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc | patch | blob | history | |
gosa-plugins/opsi/admin/opsi/generic.tpl | patch | blob | history |
diff --git a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc
index ab2fcebc4b3e915662d3a0200a37c230777d1b90..a4e5907640a7d7c68b3965ddb706e08e2c08055b 100644 (file)
/* Contains a list of all available netboot products
*/
private $a_availableNetbootProducts = array();
+ private $a_initial_availableNetbootProducts = array();
private $s_selectedNetbootProduct = "";
private $s_initial_selectedNetbootProduct = "";
/* Try to load client infos from the gosa support daemon
*/
- if($this->hostId != "new"){
+ if(! ($this->hostId == "new" || !empty($this->mac) )){
$list = $this->opsi->list_clients($this->hostId);
$err |= $this->opsi->is_error();
}
}
- /* Fetch all product infos from support daemon
- */
- if(!$err){
+ /* Read informations about available netboot products.
+ If not already done, before.
+ */
+ if(!$err && !count($this->a_availableNetbootProducts)){
$this->a_availableNetbootProducts = $this->opsi->get_netboot_products();
+ ksort($this->a_availableNetbootProducts);
$err |= $this->opsi->is_error();
}
- if(!$err) {
+
+ /* Read informations about available netboot products.
+ If not already done, before.
+ */
+ if(!$err && !count($this->a_availableLocalProducts)) {
$this->a_availableLocalProducts = $this->opsi->get_local_products();
+ ksort($this->a_availableLocalProducts);
$err |= $this->opsi->is_error();
}
*/
if(!$err && !empty($this->hostId)) {
$tmp = array_keys($this->opsi->get_netboot_products($this->hostId));
- if(count($tmp)){
+ $err |= $this->opsi->is_error();
+ if(count($tmp) && !$err && !isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
$this->s_selectedNetbootProduct = $tmp[0];
+
+ /* Read configuration for "Netboot Products" */
+ if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct])){
+ $CFG = $this->opsi->get_product_properties($this->s_selectedNetbootProduct,$this->hostId);
+ $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'] = $CFG;
+ }
}
$err |= $this->opsi->is_error();
}
- if(!$err && !empty($this->hostId)) {
+
+ /* Get all selected local products
+ */
+ if(!$err && !empty($this->hostId) && !count($this->a_selectedLocalProducts)) {
$tmp = $this->opsi->get_local_products($this->hostId);
$err |= $this->opsi->is_error();
$this->a_selectedLocalProducts = $tmp;
*/
if(!$err && !empty($this->hostId)) {
foreach($this->a_selectedLocalProducts as $name => $data){
- $CFG = $this->opsi->get_product_properties($name,$this->hostId);
- $err |= $this->opsi->is_error();
- $this->a_selectedLocalProducts[$name]['CFG'] = $CFG;
+ if(!$err && !isset($this->a_selectedLocalProducts[$name]['CFG'])){
+ $CFG = $this->opsi->get_product_properties($name,$this->hostId);
+ $err |= $this->opsi->is_error();
+ $this->a_selectedLocalProducts[$name]['CFG'] = $CFG;
+ }
}
}
/* Check if everything went fine else reset everything and display a retry button
*/
if($err){
- $this->a_availableNetbootProducts = array();
- $this->s_selectedNetbootProduct = "";
- $this->s_initial_selectedNetbootProduct = "";
- $this->a_availableLocalProducts = array();
- $this->a_selectedLocalProducts = array();
- $this->a_initial_selectedLocalProducts = array();
$this->init_failed = TRUE;
+
}else{
/* Remember initial settings */
$this->is_account = $this->initially_was_account;
$this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
$this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
+ $this->a_initial_availableNetbootProducts = $this->a_availableNetbootProducts;
+
+ /* Ensure that a valid netboot is selected product is.
+ */
+ if(empty($this->s_selectedNetbootProduct)){
+ $this->s_selectedNetbootProduct = key($this->a_availableNetbootProducts);
+ echo $this->s_selectedNetbootProduct;
+ }
+
}
}
/* Create list of available local products
*/
- ksort($this->a_availableLocalProducts);
foreach($this->a_availableLocalProducts as $name => $data){
if(isset($this->a_selectedLocalProducts[$name])) continue;
$divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab));
}
- ksort($this->a_availableNetbootProducts);
+ /* Check if netboot product is configurable
+ */
+ $cfg_able =FALSE;
+ if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
+ $cfg_able = count($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG']);
+ }
+
+ $smarty->assign("netboot_configurable",$cfg_able);
$smarty->assign("hostId", $this->hostId);
$smarty->assign("divSLP", $divSLP->DrawList());
$smarty->assign("divALP", $divALP->DrawList());
}
}
+
+ /***********
+ Detect local netboot product changes
+ - Check which products were removed.
+ - Check which products were added.
+ ***********/
+
+
/* Detect which products were removed an which added.
*/
- $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
$del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts);
+ $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
/* Remove products from client
*/
}
/* Add products to client
+ And set the product properties.
*/
foreach($add as $name => $data){
$this->opsi->add_product_to_client($name,$this->hostId);
/* Update product properties if there are changes
*/
- #if(serialize($data['CFG']) != serialize($this->a_initial_selectedLocalProducts[$name]['CFG'])){
- if($data['CFG'] != $this->a_initial_selectedLocalProducts[$name]['CFG']){
- $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
+ $diffs = $this->get_config_changes($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
+ if(count($diffs)){
+ $this->opsi->set_product_properties($name,$diffs,$this->hostId);
if($this->opsi->is_error()){
msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
return;
}
}
+ /*********
+ Detect Netboot product changes
+ - Check if another netboot product was selected.
+ - Check if the product properties were changes.
+ *********/
+
/* Update used netboot product.
*/
if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
return;
}
}
+
+ /* Check if we have to update the netboot product properties
+ This is the case, if this product is newly selected.
+ Or if there was at least one configuration attribute modified.
+ */
+ $cfg_1 = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
+ $cfg_2 = $this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
+ $diffs = $this->get_config_changes($cfg_1,$cfg_2);
+ $to_update = array();
+ if( !$this->initially_was_account ||
+ $this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
+ $to_update = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct];
+ }elseif(count($diffs)){
+ $to_update = $diffs;
+ }
+
+ if(count($to_update)){
+ $name = $this->s_selectedNetbootProduct;
+ $this->opsi->set_product_properties($name,$to_update,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
+ }
+
+
+ public function get_config_changes($c1,$c2)
+ {
+ /* Get key which are not present in both entries
+ */
+ $res = array();
+ foreach($c2 as $name => $value){
+ if(!isset($c1[$name]) || $c1[$name]['DEFAULT'] != $c2[$name]['DEFAULT']){
+ $res[$name] = $c2[$name];
+ }
+ }
+ foreach($c1 as $name => $value){
+ if(!isset($c2[$name]) || $c2[$name]['DEFAULT'] != $c1[$name]['DEFAULT']){
+ $res[$name] = $c1[$name];
+ }
+ }
+ return($res);
}
$CFG = $this->dialog->get_cfg();
if(isset($this->a_selectedLocalProducts[$pro])){
$this->a_selectedLocalProducts[$pro]['CFG'] = $CFG;
+ $this->dialog = NULL;
+ }elseif($this->s_selectedNetbootProduct == $pro){
+ $this->a_availableNetbootProducts[$pro]['CFG'] = $CFG;
+ $this->dialog = NULL;
+ }else{
+ trigger_error("Fatal, unknown product was configured.");
}
- $this->dialog = NULL;
}
/* Save html post
if(isset($_POST['opsi_netboot_product'])){
$SNP = trim($_POST['opsi_netboot_product']);
if(isset($this->a_availableNetbootProducts[$SNP])){
+
+ if(!isset($this->a_availableNetbootProducts[$SNP]['CFG'])){
+ $CFG = $this->opsi->get_product_properties($SNP);
+ $this->a_availableNetbootProducts[$SNP]['CFG'] = $CFG;
+ if($this->opsi->is_error()){
+ $this->init_failed = TRUE;
+ return;
+ }
+ }
$this->s_selectedNetbootProduct = $SNP;
}
}
/* Add/remove/edit local products
*/
foreach($_POST as $name => $value){
+
+ /* Check if netboot product configuration is requested
+ */
+ if(preg_match("/^configure_netboot/",$name)){
+ $pro = $this->s_selectedNetbootProduct;
+ $cfg = $this->a_availableNetbootProducts[$pro]['CFG'];
+ $this->dialog = new opsiProperties($this->config,$pro,$cfg,$this->hostId);
+ break;
+ }
/* Add product
*/
if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){
$this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product];
$CFG = $this->opsi->get_product_properties($product);
+ if($this->opsi->is_error()){
+ $this->init_failed = TRUE;
+ return;
+ }
$this->a_selectedLocalProducts[$product]['CFG'] = $CFG;
}
break;
index 0dcfa462dd13b2e46927c498cb611e295a61eaf7..79ef9b7d1553adaff7dbc88a8289685db06aea34 100644 (file)
<tr>
<td>{t}Boot product{/t}</td>
<td>
- <select name="opsi_netboot_product">
+ <select name="opsi_netboot_product" onChange="document.mainform.submit();">
{foreach from=$ANP item=item key=key}
<option {if $key == $SNP} selected {/if} value="{$key}">{$key}</option>
{/foreach}
</select>
+
+ {if $netboot_configurable}
+ <input type='image' name='configure_netboot' src='images/lists/edit.png'
+ title='{t}Configure package{/t}' class='center'>
+ {else}
+<!-- <input type='image' name='dummy_10' src='images/lists/edit_gray.png'
+ title='{t}Configure package{/t}' class='center'>-->
+ {/if}
</td>
</tr>
</table>