Code

Renamed opsi class.
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsigeneric.inc
index e963399626454d40da3960168859ff76acffe465..acc0789f2bd4ad856d26d7166d891ab141aa30a6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-class opsigeneric extends plugin
+class opsiGeneric extends plugin
 {
   private $opsi;
   private $hostId;  
@@ -43,14 +43,14 @@ class opsigeneric extends plugin
 
     /* Get hostId */
     if($hostId != "new"){
-      if(preg_match("/^opsi=/",$hostId)){
+      if(preg_match("/^opsi:/",$hostId)){
         $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
-      }else{
-        $this->hostId = &$this->parent->cn;
-//        $this->mac =    &$this->parent->netConfigDNS->macAddress;
+      }elseif($this->parent instanceof wingeneric){
+        $this->hostId = $this->parent->cn;
+        $this->hostId = preg_replace('/\$$/',"",$this->hostId);
       }
     }
+  
     /* Try to plugin */
     $this->init();
   }
@@ -65,7 +65,7 @@ class opsigeneric extends plugin
       $list = $this->opsi->list_clients($this->hostId);
       $err |= $this->opsi->is_error();
       foreach($list as $entry){
-        if(preg_match("/^".normalizePreg($this->hostId).".$/i",$entry['NAME'][0]['VALUE'])){
+        if(preg_match("/^".normalizePreg($this->hostId)."$/i",$entry['NAME'][0]['VALUE'])){
           $this->initially_was_account = TRUE; 
           foreach(array("description" => "DESCRIPTION","mac" => "MAC", "note" => "NOTES") as $des => $src){
             $this->$des = $entry[$src][0]['VALUE'];
@@ -244,9 +244,6 @@ class opsigeneric extends plugin
 
   public function save()
   {
-    /* Check if this a new opsi client 
-        -Do we have to create this client first?
-     */
     if(!$this->initially_was_account && $this->is_account){
       $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description);
       if($this->opsi->is_error()){
@@ -271,15 +268,18 @@ class opsigeneric extends plugin
       }
     }
     foreach($add as $name => $data){
+      echo "Adding '$name' to ".$this->hostId."<br>";
       $this->opsi->add_product_to_client($name,$this->hostId);
       if($this->opsi->is_error()){
         msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
         return;
       }
-      $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
-      if($this->opsi->is_error()){
-        msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
-        return;
+      if(!empty($data['CFG'])){
+        $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
+        if($this->opsi->is_error()){
+          msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
+          return;
+        }
       }
     }
 
@@ -330,7 +330,7 @@ class opsigeneric extends plugin
     if(isset($_POST['cancel_properties']) && is_object($this->dialog)){
       $this->dialog = NULL;
     }
-    if(isset($_POST['save_properties']) && ($this->dialog instanceof opsi_product_config)){
+    if(isset($_POST['save_properties']) && ($this->dialog instanceof opsiProperties)){
       $this->dialog->save_object();
       $pro = $this->dialog->get_product();
       $CFG = $this->dialog->get_cfg();
@@ -340,7 +340,7 @@ class opsigeneric extends plugin
       $this->dialog = NULL;
     }
 
-    if(isset($_POST['opsigeneric_posted'])){
+    if(isset($_POST['opsiGeneric_posted'])){
 
       plugin::save_object();
 
@@ -386,7 +386,7 @@ class opsigeneric extends plugin
         }
         if(preg_match("/^edit_lp_/",$name)){
           $product = preg_replace("/^edit_lp_(.*)_.$/","\\1",$name);
-          $this->dialog = new opsi_product_config($this->config,
+          $this->dialog = new opsiProperties($this->config,
               $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId);
           break;
         }