Code

Updated Opsi stuff
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Aug 2008 13:58:23 +0000 (13:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Aug 2008 13:58:23 +0000 (13:58 +0000)
-Implemented a new xml parse method which is more reliable

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12262 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsi/class_opsi.inc

index 2e42a3abe74c0fd2087ff47ef8ba97983f7ab553..727314ee25faacd7cd0939a448568d1bd50d1bf1 100644 (file)
@@ -44,6 +44,7 @@
 class opsi extends gosaSupportDaemon 
 {
   private $config = NULL;
+  protected $use_alternative_xml_parse_method = TRUE;
 
   /*! \brief           Create opsi object.
     @param
@@ -67,14 +68,14 @@ class opsi extends gosaSupportDaemon
 
     $data = array();
     foreach($res as $entry){
-      if(!isset($entry['MAC'])) $entry['MAC'] = "";;
+      if(!isset($entry['MAC'][0]['VALUE'])) $entry['MAC'][0]['VALUE'] = "";
       $data[] = array(
-        "dn"          => "opsi:=".$entry['NAME'].",".get_ou("winstations").$this->config->current['BASE'],
+        "dn"          => "opsi:=".$entry['NAME'][0]['VALUE'].",".get_ou("winstations").$this->config->current['BASE'],
         "objectClass" => array("gosa_opsi_client"),
-        "cn"          => array(0 => $entry['NAME']),
-        "description" => array(0 => $entry['DESCRIPTION']),
-        "macAddress"  => array(0 => $entry['MAC']),
-        "opsi_notes"  => array(0 => $entry['NOTES']));
+        "cn"          => array(0 => $entry['NAME'][0]['VALUE']),
+        "description" => array(0 => $entry['DESCRIPTION'][0]['VALUE']),
+        "macAddress"  => array(0 => $entry['MAC'][0]['VALUE']),
+        "opsi_notes"  => array(0 => $entry['NOTES'][0]['VALUE']));
         
     }
   
@@ -82,6 +83,12 @@ class opsi extends gosaSupportDaemon
   }
 
 
+  private function xml_to_array($xml,$alternative_method = FALSE)
+  {
+    echo "asd";
+    return(gosaSupportDaemon::xml_to_array($xml,TRUE));
+  }
+
   /******************
     SI Communication functions
    ******************/
@@ -103,14 +110,14 @@ class opsi extends gosaSupportDaemon
 
     $res    = $this->send_data("gosa_opsi_get_netboot_products",$this->target,$data,TRUE);
     $items  = array();
-    if(isset($res['XML']['ITEM']['PRODUCTID'])){
-      if(!is_array($res['XML']['ITEM']['PRODUCTID'])){
-        $items[$res['XML']['ITEM']['PRODUCTID']]['NAME'] = $res['XML']['ITEM']['PRODUCTID'];
-        $items[$res['XML']['ITEM']['PRODUCTID']]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'];
+    if(isset($res['XML'][0]['ITEM']['PRODUCTID'])){
+      if(!is_array($res['XML'][0]['ITEM']['PRODUCTID'])){
+        $items[$res['XML'][0]['ITEM']['PRODUCTID']]['NAME'] = $res['XML'][0]['ITEM']['PRODUCTID'];
+        $items[$res['XML'][0]['ITEM']['PRODUCTID']]['DESC'] = $res['XML'][0]['ITEM']['DESCRIPTION'];
       }else{
-        foreach($res['XML']['ITEM']['PRODUCTID'] as $id => $name){
+        foreach($res['XML'][0]['ITEM']['PRODUCTID'] as $id => $name){
           $items[$name]['NAME'] = $name;
-          $items[$name]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'][$id];
+          $items[$name]['DESC'] = $res['XML'][0]['ITEM']['DESCRIPTION'][$id];
         }
       } 
     }
@@ -134,14 +141,14 @@ class opsi extends gosaSupportDaemon
 
     $res    = $this->send_data("gosa_opsi_get_local_products",$this->target,$data,TRUE);
     $items  = array();
-    if(isset($res['XML']['ITEM']['PRODUCTID'])){
-      if(!is_array($res['XML']['ITEM']['PRODUCTID'])){
-        $items[$res['XML']['ITEM']['PRODUCTID']]['NAME'] = $res['XML']['ITEM']['PRODUCTID'];
-        $items[$res['XML']['ITEM']['PRODUCTID']]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'];
+    if(isset($res['XML'][0]['ITEM']['PRODUCTID'])){
+      if(!is_array($res['XML'][0]['ITEM']['PRODUCTID'])){
+        $items[$res['XML'][0]['ITEM']['PRODUCTID']]['NAME'] = $res['XML'][0]['ITEM']['PRODUCTID'];
+        $items[$res['XML'][0]['ITEM']['PRODUCTID']]['DESC'] = $res['XML'][0]['ITEM']['DESCRIPTION'];
       }else{
-        foreach($res['XML']['ITEM']['PRODUCTID'] as $id => $name){
+        foreach($res['XML'][0]['ITEM']['PRODUCTID'] as $id => $name){
           $items[$name]['NAME'] = $name;
-          $items[$name]['DESC'] = $res['XML']['ITEM']['DESCRIPTION'][$id];
+          $items[$name]['DESC'] = $res['XML'][0]['ITEM']['DESCRIPTION'][$id];
         }
       } 
     }
@@ -173,8 +180,8 @@ class opsi extends gosaSupportDaemon
 
     /* Query SI server */
     $res    = $this->send_data("gosa_opsi_get_product_properties",$this->target,$data,TRUE);
-    if(isset($res['XML']['ITEM'])){   
-      return($res['XML']['ITEM']);
+    if(isset($res['XML'][0]['ITEM'])){   
+      return($res['XML'][0]['ITEM']);
     }
     return(array());
   }
@@ -275,9 +282,7 @@ class opsi extends gosaSupportDaemon
 
     /* Query SI server */
     $res    = $this->send_data("gosa_opsi_get_client_hardware",$this->target,$data,TRUE);
-    if(isset($res['XML']['ITEM'])){
-      #print_a($res['XML']['ITEM']);
-    }
+    print_a($res);
   }
 
 
@@ -308,17 +313,8 @@ class opsi extends gosaSupportDaemon
     $data   = array();
     $res    = $this->send_data("gosa_opsi_list_clients",$this->target,$data,TRUE);
     $items  = array();
-    if(isset($res['XML']['ITEM'])){
-      if(!is_array($res['XML']['ITEM']['NAME'])){
-        $obj = $res['XML']['ITEM'];
-        $items[$obj['NAME']] = $obj;
-      }else{
-        foreach($res['XML']['ITEM'] as $type => $val){
-          foreach($val as $key => $value){
-            $items[$key][$type] = $value;
-          }
-        }
-      }
+    if(isset($res['XML'][0]['ITEM'])){
+      $items = $res['XML'][0]['ITEM'];
     }
     return($items);
   }