From 28182a91109772ab05db418afd20b4d301e4fa08 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 4 Sep 2008 12:52:40 +0000 Subject: [PATCH] Updated opsi -Implemented new property settings. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12364 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-plugins/opsi/admin/opsi/class_opsi.inc | 17 ++++++++-- .../opsi/admin/opsi/class_opsiProperties.inc | 2 +- .../opsi/admin/opsi/class_opsigeneric.inc | 31 +++++++++++++------ gosa-plugins/opsi/admin/opsi/properties.tpl | 13 +++++++- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/gosa-plugins/opsi/admin/opsi/class_opsi.inc b/gosa-plugins/opsi/admin/opsi/class_opsi.inc index a60ce9085..3c964b8aa 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsi.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsi.inc @@ -259,7 +259,20 @@ class opsi extends gosaSupportDaemon if(isset($res['XML'][0]['ITEM'])){ foreach($res['XML'][0]['ITEM'] as $entry){ foreach($entry as $name => $val){ - $items[$name] = $val['0']['VALUE']; + + foreach(array("DESCRIPTION","DEFAULT") as $attr){ + $items[$name][$attr] = ""; + if(isset($val[0][$attr])){ + $items[$name][$attr] = $val[0][$attr][0]['VALUE']; + } + } + $items[$name]['VALUE'] = array(); + if(isset($val['0']['VALUE'])){ + foreach($val['0']['VALUE'] as $value){ + $items[$name]['VALUE'][] = $value['VALUE']; + } + } + $items[$name]['VALUE_CNT'] = count($items[$name]['VALUE']); } } } @@ -292,7 +305,7 @@ class opsi extends gosaSupportDaemon /* Add properties */ $data['item'] = array(); foreach($cfg as $name => $value){ - $data['item'][] = "".$name."".$value.""; + $data['item'][] = "".$name."".$value['DEFAULT'].""; } /* Query SI server */ diff --git a/gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc b/gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc index 16d4b2127..91c4d8a15 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc @@ -44,7 +44,7 @@ class opsiProperties extends plugin { foreach($this->cfg as $name => $value){ if(isset($_POST['value_'.$name])){ - $this->cfg[$name] = validate(get_post('value_'.$name)); + $this->cfg[$name]['DEFAULT'] = validate(get_post('value_'.$name)); } } } diff --git a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc index 45309f161..ab2fcebc4 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc @@ -34,6 +34,10 @@ class opsiGeneric extends plugin public $note = ""; // A note public $description = ""; // The client description + public $initial_mac = ""; + public $initial_note = ""; + public $initial_description = ""; + private $init_failed = FALSE; // Is true if the opsi communication failed private $parent_mode = TRUE; // Is true if this is a standlone plugin. (Not samba) private $is_installed= FALSE; // Is true is the hast is already installed. @@ -102,7 +106,8 @@ class opsiGeneric extends plugin "description" => "DESCRIPTION", "mac" => "MAC", "note" => "NOTES") as $des => $src){ - $this->$des = $entry[$src][0]['VALUE']; + $des2 = "initial_".$des; + $this->$des2 = $this->$des = $entry[$src][0]['VALUE']; } break; } @@ -315,12 +320,17 @@ class opsiGeneric extends plugin } }else{ - /* Update client modifcations + /* Update client modifcations. + -Only if necessary */ - $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description); - if($this->opsi->is_error()){ - msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG); - return; + if($this->note != $this->initial_note || + $this->description != $this->initial_description || + $this->mac != $this->initial_mac){ + $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description); + if($this->opsi->is_error()){ + msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG); + return; + } } } @@ -360,9 +370,12 @@ class opsiGeneric extends plugin */ foreach($this->a_selectedLocalProducts as $name => $data){ if(isset($del[$name]) || isset($add[$name])) continue; - $diff = array_diff($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']); - if(count($diff)){ - $this->opsi->set_product_properties($name,$diff,$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); if($this->opsi->is_error()){ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG); return; diff --git a/gosa-plugins/opsi/admin/opsi/properties.tpl b/gosa-plugins/opsi/admin/opsi/properties.tpl index d2f77716d..79d12c642 100644 --- a/gosa-plugins/opsi/admin/opsi/properties.tpl +++ b/gosa-plugins/opsi/admin/opsi/properties.tpl @@ -13,7 +13,18 @@ {foreach from=$cfg item=item key=key} {$key} - + + {if $item.VALUE_CNT} + + {else} + + {/if} + + {/foreach} -- 2.30.2