From: hickert Date: Tue, 22 Dec 2009 08:40:30 +0000 (+0000) Subject: Replaced some opsi loading mechanisms with newer and faster methods X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9965e44e286c3628f44754a1c7e247e1915e6bbe;p=gosa.git Replaced some opsi loading mechanisms with newer and faster methods git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14922 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/opsi/admin/opsi/class_opsi.inc b/gosa-plugins/opsi/admin/opsi/class_opsi.inc index ebbf46c21..3277b2c7a 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsi.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsi.inc @@ -296,12 +296,66 @@ class opsi extends gosaSupportDaemon } $res = $this->send_data("gosa_opsi_get_full_product_host_information",$this->target,$data,TRUE); - print_a($res); $items = array(); + + $attrs = array("PRIORITY","ONCESCRIPT","LICENSEREQUIRED","PACKAGEVERSION","PRODUCTVERSION", + "ADVICE","SETUPSCRIPT","WINDOWSSOFTWAREIDS","PXECONFIGTEMPLATE","NAME","CREATIONTIMESTAMP", + "ALWAYSSCRIPT","PRODUCTID","DESCRIPTION","UNINSTALLSCRIPT","UPDATESCRIPT","PRODUCTCLASSNAMES"); + if(isset($res['XML'][0]['ITEM'])){ foreach($res['XML'][0]['ITEM'] as $entry){ - $e = array("DESC" => $entry['DESCRIPTION'][0]['VALUE'], - "NAME" => $entry['PRODUCTID'][0]['VALUE']); + $e = array(); + foreach($attrs as $attr){ + if(isset($entry[$attr])){ + foreach($entry[$attr] as $key => $value){ + if(isset($value['VALUE'])){ + $e['data'][$attr] = $value['VALUE']; + }elseif($value['ELEMENT']){ + foreach($value['ELEMENT'] as $element){ + $e['data'][$attr][] = $element['VALUE']; + } + } + } + } + } + + $e["configurable"] = FALSE; + if(isset($entry['PROPERTIES']) && count($entry['PROPERTIES'])){ + $e["configurable"] = TRUE; + $p_data = array(); + + foreach($entry['PROPERTIES'][0] as $p_name => $p_values){ + if(empty($p_values)) continue; + $p_data[$p_name]= array(); + foreach(array('CURRENT','DEFAULT','DESCRIPTION') as $p_tmp){ + if(isset($p_values[0][$p_tmp])){ + if(isset($p_values[0][$p_tmp][0]['VALUE'])){ + $p_data[$p_name][$p_tmp] = $p_values[0][$p_tmp][0]['VALUE']; + } + } + } + + if(isset($p_values[0]['VALUES'][0]['ELEMENT'])){ + foreach($p_values[0]['VALUES'][0]['ELEMENT'] as $val){ + $p_data[$p_name]['VALUE'][] = $val['VALUE']; + } + $p_data[$p_name]['VALUE_CNT'] = count($p_data[$p_name]['VALUE']); + } + } + + $e["data"]['PROPERTIES'] = $p_data; + } + + + $e["installed"] = FALSE; + if(isset($entry['ACTIONREQUEST'])){ + $e["installed"] = TRUE; + } + + $e["requires_licence"] = FALSE; + if(isset($e['data']['LICENSEREQUIRED']) && preg_match("/true/i",$e['data']['LICENSEREQUIRED'])){ + $e["requires_licence"] = TRUE; + } $items[$entry['PRODUCTID'][0]['VALUE']] = $e; } } diff --git a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc index 22476bae9..174764002 100644 --- a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc +++ b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc @@ -97,10 +97,10 @@ class opsiGeneric extends plugin $this->is_account = TRUE; } + /* Try to load client infos from the gosa support daemon */ if(!empty($this->hostId)){ - $list = $this->opsi->list_clients($this->hostId); $err |= $this->opsi->is_error(); @@ -125,6 +125,12 @@ class opsiGeneric extends plugin } } + // Get package info + if(!empty($this->hostId)){ + $list = $this->opsi->get_full_product_host_information($this->hostId); + } + + /* Read informations about available netboot products. If not already done, before. */ @@ -137,11 +143,21 @@ class opsiGeneric extends plugin /* 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(); + foreach($list as $key => $entry){ + if(!$entry['installed']){ + $this->a_availableLocalProducts[$key] = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key); + }else{ + $this->a_selectedLocalProducts[$key] = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key); + if($entry['configurable']){ + $this->a_selectedLocalProducts[$key]['CFG'] = $entry['data']['PROPERTIES']; + } + } } +# if(!$err && !count($this->a_availableLocalProducts)) { +# $this->a_availableLocalProducts = $this->opsi->get_local_products(); +# ksort($this->a_availableLocalProducts); +# $err |= $this->opsi->is_error(); +# } /* Get products selected by this host. */ @@ -160,26 +176,26 @@ class opsiGeneric extends plugin $err |= $this->opsi->is_error(); } - /* 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; - } +# /* 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; +# } +# +# /* Load product configuration for all already selected products. +# */ +# if(!$err && !empty($this->hostId)) { +# foreach($this->a_selectedLocalProducts as $name => $data){ +# 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; +# } +# } +# } - /* Load product configuration for all already selected products. - */ - if(!$err && !empty($this->hostId)) { - foreach($this->a_selectedLocalProducts as $name => $data){ - 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){