Code

Added ARP-Goto functionality.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Jul 2009 13:36:42 +0000 (13:36 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 7 Jul 2009 13:36:42 +0000 (13:36 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13905 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl
gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc
gosa-plugins/systems/admin/systems/class_systemManagement.inc

index 6ad765324f60130ffae67ba7b49761417219fd41..2bc7b3e7885e60b2ea8691aa3164f51427a98826 100644 (file)
@@ -1,4 +1,4 @@
-<h2><img class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Integrating unknown devices{/t}</h2>
+<h2><img class="center" alt="" src="images/rightarrow.png"> {t}Integrating unknown devices{/t}</h2>
 <p>
  {t}The current device has been detected by the ARP monitor used by GOsa. You can integrate this device into your running DHCP/DNS infrastructure by submitting this form. The device entry will disappear from the list of the systems and move to the DNS/DHCP configuration.{/t}
 </p>
 <p class="seperator"></p>
 {$netconfig}
 
+<p class="seperator"></p>
+
+<!--<h2><img class="center" alt="" src="images/rightarrow.png"> {t}GOto{/t}</h2>-->
+<p>
+<input type='checkbox' value='1' name='gotoIntegration'
+    onChange="changeState('SystemType');changeState('ObjectGroup');"
+    {if $gotoIntegration} checked {/if}>&nbsp;{t}GOto integration{/t}
+</p>
+<table summary="" style='width:100%'>
+ <tr>
+  <td style='width:49%'>
+   <table summary="">
+    <tr>
+     <td> 
+      {t}System type{/t}&nbsp;
+         <select {if !$gotoIntegration} disabled {/if}
+      id="SystemType"
+      name="SystemType" title="{t}System type{/t}" style="width:120px;"
+                       onChange="document.mainform.submit();">
+       {html_options values=$SystemTypeKeys output=$SystemTypes selected=$SystemType}
+      </select>
+     </td>
+    </tr>
+   </table>
+  </td>
+  <td>
+   <table summary="">
+    <tr>
+     <td> 
+      {t}Choose an object group as template{/t}&nbsp;
+           <select {if !$gotoIntegration} disabled {/if}
+        id="ObjectGroup"
+        name="ObjectGroup" title="{t}Object group{/t}" style="width:120px;">
+                 <option value='none'>{t}none{/t}</option>     
+       {html_options options=$ogroups selected=$ObjectGroup}
+      </select>
+     </td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
 <input type='hidden' name='ArpNewDevice_posted' value='1'>
 
 <p class="seperator"></p>
index fb9a41b58f807669c0d72c52ed884a408a424eac..4901c2fddd75d48dd7dee0d26db90d8d03b44698 100644 (file)
@@ -8,6 +8,14 @@ class ArpNewDevice extends plugin
   var $objectclasses = array("gotoHard");
   var $ignore_account = TRUE;
 
+  var $ObjectGroups   = array();
+  var $SystemTypes       = array();
+
+  var $ObjectGroup    = "none";
+  var $SystemType     = "workstation";
+
+  var $gotoIntegration = FALSE;
+
   function ArpNewDevice ($config, $dn= NULL, $parent= NULL)
   {
     plugin :: plugin($config,$dn);
@@ -15,16 +23,50 @@ class ArpNewDevice extends plugin
     $this->acl = "#all#";
     $this->netConfigDNS->acl = $this->acl;
     $this->netConfigDNS->force_dns();
+
+    /* Get object groups */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
+    $tmp= array();
+    while($attrs = $ldap->fetch()){
+      $tmp[$attrs['dn']]= $attrs['cn'][0];
+    }
+    asort($tmp, SORT_LOCALE_STRING);
+    $this->ObjectGroups= $tmp;
+
+    $this->SystemTypes =array("workstation"=>_("Workstation"), "terminal"=>_("Terminal"), "server"=>_("Server"));
+    if(class_available("opsi")){
+      $this->SystemTypes["opsi_client"]= _("Windows workstation");
+    }
   }
 
   function execute()
   {
+    /* Get object groups */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd ($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("gosaGroupObjects","cn"));
+    $tmp= array("W" => array(),"T" => array(), "S" => array(),"O" => array());
+    while($attrs = $ldap->fetch()){
+      $tmp[preg_replace("/[\[\] ]/","",$attrs['gosaGroupObjects'][0])][$attrs['dn']] = $attrs['cn'][0];
+    }
+
     $smarty = get_smarty();
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
     }
     $this->netConfigDNS->cn= $this->cn;
+
+    $map = array("workstation" => "W","terminal" => "T","server" => "S", "opsi_client" => "O");
     $smarty->assign("netconfig", $this->netConfigDNS->execute());
+    $smarty->assign("ogroups", $tmp[$map[$this->SystemType]]);
+    $smarty->assign("SystemTypes"     ,$this->SystemTypes);
+    $smarty->assign("SystemTypeKeys"  ,array_flip($this->SystemTypes)); 
+    $smarty->assign("ObjectGroup",$this->ObjectGroup);
+    $smarty->assign("SystemType",$this->SystemType);
+
+    $smarty->assign("gotoIntegration",$this->gotoIntegration);
 
     /* Display sub dialog from network settings */
     $this->netConfigDNS->acl = $this->acl;
@@ -53,20 +95,36 @@ class ArpNewDevice extends plugin
     if(isset($_POST['ArpNewDevice_posted'])){
       plugin::save_object();
       $this->netConfigDNS->save_object();
+    
+      $this->gotoIntegration = isset($_POST['gotoIntegration']);
+      if($this->gotoIntegration){
+        if(isset($_POST['SystemType'])){
+          $this->SystemType = get_post('SystemType');
+        }
+        if(isset($_POST['ObjectGroup'])){
+          $this->ObjectGroup = get_post('ObjectGroup');
+        }
+      }
     }
   }
 
   function save()
   {
+  
     $this->netConfigDNS->acl = $this->acl;
     plugin::save();
     $this->netConfigDNS->cn = $this->cn;    
     $this->netConfigDNS->save($this->dn);
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->rmdir_recursive($this->dn);
-    if (!$ldap->success()){
-      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $key->dn, LDAP_DEL, get_class()));
+
+    // Do not remove this Arp-Device if gotoIntegration was selected.
+    if(!$this->gotoIntegration){ 
+
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->rmdir_recursive($this->dn);
+      if (!$ldap->success()){
+        msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $key->dn, LDAP_DEL, get_class()));
+      }
     }
   }
 }
index 7bd00a727f58505bacf48d41e0884efdaea3f6bb..f177d3ae3f8589307c8756e28fd10a48eb9d5ab1 100644 (file)
@@ -316,7 +316,20 @@ class systems extends plugin
         If no object group was selected, then we keep the "edit" dialog of 
          the target system opened to allow to edit the objects attributes.
      */
-  
+    
+    if($this->systab instanceOf ArpNewDeviceTabs && isset($_POST['edit_finish'])){
+
+      /* Check tabs, will feed message array */
+      $message = $this->systab->check();
+      if(count($message)){
+        msg_dialog::displayChecks($message);
+      }else{
+        $s_action = "SelectedSystemType";
+        $this->systab = null;
+        unset($_POST['edit_finish']);
+      }
+    }
     if($s_action == "SelectedSystemType"){
 
       /* Possible destination system types 
@@ -325,7 +338,11 @@ class systems extends plugin
 
       /* Remember dialog selection.
        */
-      $selected_group = $_POST['ObjectGroup'];
+      
+      $selected_group = "none";
+      if(isset($_POST['ObjectGroup'])){
+        $selected_group = $_POST['ObjectGroup'];
+      }
       $selected_system = $_POST['SystemType'];
 
       $this->systab = NULL;
@@ -554,6 +571,7 @@ class systems extends plugin
           msg_dialog::display(_("Error"), msgPool::class_not_found("ArpNewDevice"), ERROR_DIALOG);
         }else{
           add_lock ($this->dn, $this->ui->dn);
+          $this->system_activation_object= array($this->dn);
           $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
         }
       }elseif($type == "NewDevice"){