Code

replaced plugbottom by pluin-actions
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsi.inc
index 1ddd6959f576bba2f54a8d1c2ba36c456c9c8411..2aee03ea2156b5a40ef68269cd60c66a61f26c49 100644 (file)
@@ -110,11 +110,13 @@ class opsi extends gosaSupportDaemon
       $opsi_acl = $ui->get_permissions($obj['dn'],"opsi/opsiGeneric");
       if(preg_match("/r/",$opsi_acl)){
         if(!empty($entry['DESCRIPTION'][0]['VALUE'])){ 
-          $obj["description"] =$entry['DESCRIPTION'][0]['VALUE'];
+          $obj["description"]= array();
+          $obj["description"][0]= $entry['DESCRIPTION'][0]['VALUE'];
         }
         $data[] = $obj;
       }
     }
+
     return($data);
   }
 
@@ -139,6 +141,23 @@ class opsi extends gosaSupportDaemon
     }
   }
 
+  
+  public function job_opsi_activate_client($id,$mac)
+  {
+    $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+    $o_queue = new gosaSupportDaemon();
+    if(isset($events['TRIGGERED']['DaemonEvent_activate'])){
+      $evt = $events['TRIGGERED']['DaemonEvent_activate'];
+      $tmp = new $evt['CLASS_NAME']($this->config);
+      $tmp->set_type(TRIGGERED_EVENT);
+      $tmp->add_targets(array($mac));
+      if(!$o_queue->append($tmp)){
+        msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+      }
+    }
+  }
+
+
 
   /******************
     SI Communication functions
@@ -263,6 +282,86 @@ class opsi extends gosaSupportDaemon
   }
 
 
+  /*! \brief           Returns a list of netboot products.
+    @param
+    @return            
+   */
+  public function get_full_product_host_information($host = "")
+  {
+    /* Append host attribute to query data 
+     */
+    $data = array();
+    if(!empty($host)){
+      $data['hostId'] = trim($host);
+    }
+
+    $res    = $this->send_data("gosa_opsi_get_full_product_host_information",$this->target,$data,TRUE);
+    $items = array();
+    $attrs = array("TYPE","PRIORITY","ONCESCRIPT","LICENSEREQUIRED","PACKAGEVERSION","PRODUCTVERSION",
+        "ADVICE","SETUPSCRIPT","WINDOWSSOFTWAREIDS","PXECONFIGTEMPLATE","NAME","CREATIONTIMESTAMP", "TYPE",
+        "ALWAYSSCRIPT","PRODUCTID","DESCRIPTION","UNINSTALLSCRIPT","UPDATESCRIPT","PRODUCTCLASSNAMES");
+
+    if(isset($res['XML'][0]['ITEM'])){
+      foreach($res['XML'][0]['ITEM'] as $entry){
+        $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;
+      }
+    }
+    return($items);
+  }
+
+
   /*! \brief           Returns a list of all product properties. \ 
     .           Additionally you can specify the host parameter to \
     .           get host specific product properties
@@ -292,7 +391,7 @@ class opsi extends gosaSupportDaemon
       foreach($res['XML'][0]['ITEM'] as $entry){
         foreach($entry as $name => $val){
 
-          foreach(array("DESCRIPTION","DEFAULT") as $attr){
+          foreach(array("DESCRIPTION","CURRENT") as $attr){
             $items[$name][$attr] = "";
             if(isset($val[0][$attr])){
               $items[$name][$attr] = $val[0][$attr][0]['VALUE'];
@@ -337,7 +436,7 @@ class opsi extends gosaSupportDaemon
     /* Add properties */
     $data['item'] = array();
     foreach($cfg as $name => $value){
-      $data['item'][] = "<name>".$name."</name><value>".$value['DEFAULT']."</value>";
+      $data['item'][] = "<name>".$name."</name><value>".$value['CURRENT']."</value>";
     }  
 
     /* Query SI server */