Code

Updated opsi
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Sep 2008 12:52:40 +0000 (12:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Sep 2008 12:52:40 +0000 (12:52 +0000)
-Implemented new property settings.

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

gosa-plugins/opsi/admin/opsi/class_opsi.inc
gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc
gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc
gosa-plugins/opsi/admin/opsi/properties.tpl

index a60ce9085464a6a735a91787dbcceec0a2f2e345..3c964b8aaa5961c58b4e56fc2eb6a068aa5dc023 100644 (file)
@@ -259,7 +259,20 @@ class opsi extends gosaSupportDaemon
     if(isset($res['XML'][0]['ITEM'])){   
       foreach($res['XML'][0]['ITEM'] as $entry){
         foreach($entry as $name => $val){
-          $items[$name] = $val['0']['VALUE'];
+
+          foreach(array("DESCRIPTION","DEFAULT") as $attr){
+            $items[$name][$attr] = "";
+            if(isset($val[0][$attr])){
+              $items[$name][$attr] = $val[0][$attr][0]['VALUE'];
+            }
+          }
+          $items[$name]['VALUE'] = array();
+          if(isset($val['0']['VALUE'])){
+            foreach($val['0']['VALUE'] as $value){
+              $items[$name]['VALUE'][] = $value['VALUE'];
+            }
+          }
+          $items[$name]['VALUE_CNT'] = count($items[$name]['VALUE']);
         }
       }
     }
@@ -292,7 +305,7 @@ class opsi extends gosaSupportDaemon
     /* Add properties */
     $data['item'] = array();
     foreach($cfg as $name => $value){
-      $data['item'][] = "<name>".$name."</name><value>".$value."</value>";
+      $data['item'][] = "<name>".$name."</name><value>".$value['DEFAULT']."</value>";
     }  
 
     /* Query SI server */
index 16d4b21279e09da1a6ea56365f8153477e39b7da..91c4d8a153e5129cae9bd6b31982613e359a29a8 100644 (file)
@@ -44,7 +44,7 @@ class opsiProperties extends plugin
   {
     foreach($this->cfg as $name => $value){
       if(isset($_POST['value_'.$name])){
-        $this->cfg[$name] = validate(get_post('value_'.$name));
+        $this->cfg[$name]['DEFAULT'] = validate(get_post('value_'.$name));
       }
     }
   }
index 45309f16164429e3636e8606edd62705035114a1..ab2fcebc4b3e915662d3a0200a37c230777d1b90 100644 (file)
@@ -34,6 +34,10 @@ class opsiGeneric extends plugin
   public  $note         = ""; // A note
   public  $description  = ""; // The client description
 
+  public  $initial_mac          = ""; 
+  public  $initial_note         = ""; 
+  public  $initial_description  = ""; 
+
   private $init_failed = FALSE; // Is true if the opsi communication failed
   private $parent_mode = TRUE;  // Is true if this is a standlone plugin. (Not samba)
   private $is_installed= FALSE; // Is true is the hast is already installed.
@@ -102,7 +106,8 @@ class opsiGeneric extends plugin
                 "description"  => "DESCRIPTION",
                 "mac"          => "MAC", 
                 "note"         => "NOTES") as $des => $src){
-            $this->$des = $entry[$src][0]['VALUE'];
+            $des2 = "initial_".$des;
+            $this->$des2 = $this->$des = $entry[$src][0]['VALUE'];
           } 
           break;
         }
@@ -315,12 +320,17 @@ class opsiGeneric extends plugin
       }
     }else{
 
-      /* Update client modifcations 
+      /* Update client modifcations.
+          -Only if necessary  
        */
-      $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
-      if($this->opsi->is_error()){
-        msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
-        return;
+      if($this->note != $this->initial_note || 
+          $this->description != $this->initial_description ||
+          $this->mac != $this->initial_mac){
+        $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
+        if($this->opsi->is_error()){
+          msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+          return;
+        }
       }
     }
 
@@ -360,9 +370,12 @@ class opsiGeneric extends plugin
      */
     foreach($this->a_selectedLocalProducts as $name => $data){
       if(isset($del[$name]) || isset($add[$name])) continue;
-      $diff = array_diff($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
-      if(count($diff)){
-        $this->opsi->set_product_properties($name,$diff,$this->hostId);
+
+      /* Update product properties if there are changes 
+       */
+      #if(serialize($data['CFG']) != serialize($this->a_initial_selectedLocalProducts[$name]['CFG'])){
+      if($data['CFG'] != $this->a_initial_selectedLocalProducts[$name]['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;
index d2f77716da5d9d854d36f90d8fed2f0eac4f9534..79d12c6425d4bae0e6fbedc0a40e914dbca70c96 100644 (file)
 {foreach from=$cfg item=item key=key}
        <tr>
                <td>{$key}</td>
-               <td><input type='input' name='value_{$key}' value="{$item}"></td>
+               <td>
+                       {if $item.VALUE_CNT}
+                               <select name="value_{$key}" style='width:180px;'>
+                               {foreach from=$item.VALUE key=k item=i}
+                                       <option {if $item.DEFAULT == $i} selected {/if} value="{$i}">{$i}</option>
+                               {/foreach}
+                               </select>
+                       {else}
+                               <input type='input' name='value_{$key}' value="{$item.DEFAULT}" style='width:280px;'>
+                       {/if}
+
+               </td>
        </tr>
 {/foreach}
 </table>