Code

Set macAddress to must for opsi hosts.
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsigeneric.inc
index 22476bae9b9ed3890dfc3fe4b79927ff34698126..bc3740b07406f6767ad44c3b9f9a7cb19c4ae165 100644 (file)
@@ -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,61 +125,37 @@ class opsiGeneric extends plugin
       }
     }
 
-    /* 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();
-    }
+    // Get package info
+    $list = array(); 
+    $list = $this->opsi->get_full_product_host_information($this->hostId);
+    $err |= $this->opsi->is_error();
 
     /* Read informations about available netboot products. 
-        If not already done, before.
+       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();
-    }
-
-    /* Get products selected by this host.
-     */
-    if(!$err && !empty($this->hostId)) {
-      $tmp = array_keys($this->opsi->get_netboot_products($this->hostId));
-      $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){
+      foreach($list as $key => $entry){
 
-    /* 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;
-    }
+        $tmp = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key);
+        if($entry['configurable']){
+          $tmp['CFG'] = $entry['data']['PROPERTIES'];
+        } 
 
-    /* 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;
+        if($entry['data']['TYPE'] == "localboot"){
+          if(!$entry['installed']){
+            $this->a_availableLocalProducts[$key] = $tmp;
+          }else{
+            $this->a_selectedLocalProducts[$key] = $tmp;
+          }
+        }else{
+          $this->a_availableNetbootProducts[$key] = $tmp;
+          if($entry['installed']){
+            $this->s_selectedNetbootProduct= $key;
+          }
         }
       }
     }
-  
+
     /* Check if everything went fine else reset everything and display a retry button 
      */
     if($err){
@@ -224,7 +200,7 @@ class opsiGeneric extends plugin
       $this->netConfigDNS->set_acl_category("opsi");
       $this->netConfigDNS->set_acl_base($this->config->current['BASE']);
       $this->netConfigDNS->IPisMust = FALSE;
-      $this->netConfigDNS->MACisMust = FALSE;
+      $this->netConfigDNS->MACisMust = TRUE;
     }
   }
 
@@ -560,12 +536,12 @@ class opsiGeneric extends plugin
      */
     $res = array();
     foreach($c2 as $name => $value){
-      if(!isset($c1[$name]) || $c1[$name]['DEFAULT'] != $c2[$name]['DEFAULT']){
+      if(!isset($c1[$name]) || $c1[$name]['CURRENT'] != $c2[$name]['CURRENT']){
         $res[$name] = $c2[$name];
       }
     }
     foreach($c1 as $name => $value){
-      if(!isset($c2[$name]) || $c2[$name]['DEFAULT'] != $c1[$name]['DEFAULT']){
+      if(!isset($c2[$name]) || $c2[$name]['CURRENT'] != $c1[$name]['CURRENT']){
         $res[$name] = $c1[$name];
       }
     }