Code

Some changes for opsi
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Aug 2008 09:15:23 +0000 (09:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Aug 2008 09:15:23 +0000 (09:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12291 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc
gosa-plugins/opsi/admin/opsi/generic.tpl

index d3c2743bf6c21cfb49053c03ac78f014c7ad8974..e963399626454d40da3960168859ff76acffe465 100644 (file)
@@ -25,20 +25,32 @@ class opsigeneric extends plugin
   public $mac          = "";
   public $note         = "";
   public $description  = "";
-
   public $attributes = array("mac","note","description");
 
-  public function __construct($config,$hostId)
+  public $parent = NULL;
+
+  public function __construct($config,$hostId,&$parent = NULL)
   {
     $this->opsi = new opsi($config); 
     $this->is_account =TRUE;
-  
+    
+    /* Check if we are are part of a windows workstation 
+     */
+    $this->parent = $parent;
+    if($parent instanceof wingeneric){
+      $this->parent_mode = FALSE;
+    }
+
     /* Get hostId */
     if($hostId != "new"){
-      $this->initially_was_account = TRUE;
-      $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$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;
+      }
     }
-  
     /* Try to plugin */
     $this->init();
   }
@@ -47,12 +59,14 @@ class opsigeneric extends plugin
   {
     $err = FALSE;
     $this->init_failed = FALSE;
+    $this->initially_was_account = FALSE; 
 
     if($this->hostId != "new"){
       $list = $this->opsi->list_clients($this->hostId);
       $err |= $this->opsi->is_error();
       foreach($list as $entry){
-        if($entry['NAME'][0]['VALUE'] == $this->hostId){  
+        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'];
           } 
@@ -107,6 +121,7 @@ class opsigeneric extends plugin
     }else{
 
       /* Remember initial settings */ 
+      $this->is_account = $this->initially_was_account;
       $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
       $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
     }
@@ -114,6 +129,7 @@ class opsigeneric extends plugin
 
   public function check()
   {
+    return(array());
     $messages = plugin::check();
     if(!preg_match("/\./",$this->hostId)){
       $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",_("The client name must contain a domain part (e.g. '.company.de')."));
@@ -126,6 +142,11 @@ class opsigeneric extends plugin
 
   public function execute()
   {
+    $display ="";
+
+    /* The pluign initialization failed due to communication problems with the gosa daemon. 
+       A retry button will be displayed here.
+     */
     if($this->init_failed){
       $smarty = get_smarty();
       $smarty->assign("init_failed",TRUE);
@@ -133,13 +154,38 @@ class opsigeneric extends plugin
       return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
     }  
 
+    /* If we are not a stand alone opsi client, we must be a samba client 
+       which has the opsi tab enabled.
+       Check if the opsi is added or removed and display state buttons.
+     */
+    if(!$this->parent_mode){
+      if(isset($_POST['modify_state'])){
+        if($this->is_account){
+          $this->is_account= FALSE;
+        }elseif(!$this->is_account){
+          $this->is_account= TRUE;
+        }
+      }
+      if($this->is_account){
+        $display = $this->show_disable_header(msgPool::removeFeaturesButton(_("Opsi")), 
+            msgPool::featuresEnabled(_("Opsi")));
+      }else{
+        $display = $this->show_enable_header(msgPool::addFeaturesButton(_("Opsi")), 
+            msgPool::featuresDisabled(_("Opsi")));
+        return($display);
+      } 
+    } 
+
+    /* Check if we have a sub dialog opened
+     */
     if(is_object($this->dialog)){
       $this->dialog->save_object();
       return($this->dialog->execute());
     }
 
+    /* Create HTML output of this plugin
+     */
     $smarty = get_smarty();
-
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
     }
@@ -192,7 +238,7 @@ class opsigeneric extends plugin
     $smarty->assign("divALP", $divALP->DrawList());
     $smarty->assign("SNP", $this->s_selectedNetbootProduct);
     $smarty->assign("ANP", $this->a_availableNetbootProducts);
-    return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
+    return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
   }
 
 
index d34a2a0e121eb1a49854f05ada1e523326a34210..aa8d6ed52fb0c7be499d5faa8938ef31074d8966 100644 (file)
   <td>
    <table>
     {if $parent_mode}
-     <tr>
-      <td>{t}Name{/t}</td>
-      <td><input type='text' name='hostId' value='{$hostId}'></td>
-     </tr>
-    {/if}
     <tr>
-     <td>{t}Description{/t}</td>
-     <td><input type='text' name='description' value='{$description}'></td>
+     <td>{t}Name{/t}</td>
+     <td><input style='width:300px;' type='text' name='hostId' value='{$hostId}'></td>
     </tr>
     <tr>
-     <td>{t}Notes{/t}</td>
-     <td><input type='text' name='note' value='{$note}'></td>
+     <td>{t}MAC address{/t}</td>
+     <td><input type='text' name="mac" value="{$mac}"></td>
+       </tr>
+       {else}
+    <tr>
+     <td>{t}Name{/t}</td>
+     <td><input style='width:300px;' type='text' disabled value="{$hostId}"></td>
     </tr>
-   </table>
-  </td>
-  <td style='vertical-align: top;'>
-   <table>
     <tr>
      <td>{t}MAC address{/t}</td>
-     <td><input type='text' name='mac' value='{$mac}'></td>
+     <td><input type='text' name="mac" value="{$mac}"></td>
     </tr>
+    {/if}
     <tr>
      <td>{t}Boot product{/t}</td>
      <td>
     </tr>
    </table>
   </td>
+  <td style='vertical-align: top;'>
+   <table>
+    <tr>
+     <td>{t}Description{/t}</td>
+     <td><input type='text' name='description' value='{$description}'></td>
+    </tr>
+    <tr>
+     <td>{t}Notes{/t}</td>
+     <td><input type='text' name='note' value='{$note}'></td>
+    </tr>
+   </table>
+  </td>
  </tr>
  <tr>
   <td colspan="2">