Code

Updated opsiLicense Mangement
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Oct 2009 13:27:37 +0000 (13:27 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 30 Oct 2009 13:27:37 +0000 (13:27 +0000)
-Fixed problem with pool listing. Don't display error messages if we do not have any pools..

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

gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc
gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenses.inc

index 116681ff8791cc43dad4dcb31155c1e389d3b585..fd8b01f472f7580ace9d88cc517779db0045c6d8 100644 (file)
@@ -19,29 +19,34 @@ class opsiLicenceHandler extends opsi  {
     $data= array();
     $res = $this->send_data("gosa_opsi_getLicensePools_listOfHashes",$this->target,$data,TRUE);
     $items  = array();
-    if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
-      $items = $res['XML'][0]['RESULT'][0]['HIT'];
-      $data =array();
-      foreach($items as $item){
-        $entry = array();
-        foreach(
-          array(
-            "DESCRIPTION"       => "description",
-            "LICENSEPOOLID"     => "cn",
-            "PRODUCTIDS"        => "productId",
-            "WINDOWSSOFTWAREIDS"=> "softwareId") as $source => $dest){
-        
-          if(isset($item[$source])){
-            $entry[$dest] = array('count' => 0);
-            foreach($item[$source] as $obj){
-              $entry[$dest][] = $obj['VALUE'];
-            }
-            $entry[$dest]['count'] = (count($entry[$dest]) -1 );
-          } 
+    if(isset($res['XML'][0]['ANSWER_OPSI_GETLICENSEPOOLS_LISTOFHASHES'])){
+      if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
+        $items = $res['XML'][0]['RESULT'][0]['HIT'];
+        $data =array();
+        foreach($items as $item){
+          $entry = array();
+          foreach(
+              array(
+                "DESCRIPTION"       => "description",
+                "LICENSEPOOLID"     => "cn",
+                "PRODUCTIDS"        => "productId",
+                "WINDOWSSOFTWAREIDS"=> "softwareId") as $source => $dest){
+
+            if(isset($item[$source])){
+              $entry[$dest] = array('count' => 0);
+              foreach($item[$source] as $obj){
+                $entry[$dest][] = $obj['VALUE'];
+              }
+              $entry[$dest]['count'] = (count($entry[$dest]) -1 );
+            } 
+          }
+          $data[] =$entry;
         }
-        $data[] =$entry;
+        return($data);
+      }else{
+        // No entries, but got an answer. We probably do not have any pools yet.
+        return(array());
       }
-      return($data);
     }
     return(FALSE);
   }
@@ -145,6 +150,7 @@ class opsiLicenceHandler extends opsi  {
   {
     $data= array();
     $res = $this->send_data("gosa_opsi_getAllSoftwareLicenses",$this->target,$data,TRUE);
+
     if(isset($res['XML'][0]['ANSWER_OPSI_GETALLSOFTWARELICENSES'])){
 
       $licenses = array();
index 06f3534f83c5d1a12aa02a28380bb99f3624a6ad..27466eb68f4ba2f6c4e01ee767d9f0b4f585b46e 100644 (file)
@@ -294,7 +294,7 @@ class opsiLicenses extends plugin
     $si = new opsiLicenceHandler($this->config);
     $this->licenses = array();
     $res = $si->listPools();
-    if($si->is_error() || !$res){
+    if($si->is_error() || !is_array($res)){
       $this->init_successfull = FALSE;
       msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
       return;