From 0f14691cc0baea56f77ba88fda750e4306a32cb7 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 7 Jul 2009 13:36:42 +0000 Subject: [PATCH] Added ARP-Goto functionality. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13905 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../goto/admin/systems/goto/ArpNewDevice.tpl | 44 +++++++++++- .../admin/systems/goto/class_ArpNewDevice.inc | 68 +++++++++++++++++-- .../admin/systems/class_systemManagement.inc | 22 +++++- 3 files changed, 126 insertions(+), 8 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl b/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl index 6ad765324..2bc7b3e78 100644 --- a/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl +++ b/gosa-plugins/goto/admin/systems/goto/ArpNewDevice.tpl @@ -1,4 +1,4 @@ -

{t}Integrating unknown devices{/t}

+

{t}Integrating unknown devices{/t}

{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}

@@ -26,6 +26,48 @@

{$netconfig} +

+ + +

+ {t}GOto integration{/t} +

+ + + + + +
+ + + + +
+ {t}System type{/t}  + +
+
+ + + + +
+ {t}Choose an object group as template{/t}  + +
+

diff --git a/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc b/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc index fb9a41b58..4901c2fdd 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc @@ -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())); + } } } } diff --git a/gosa-plugins/systems/admin/systems/class_systemManagement.inc b/gosa-plugins/systems/admin/systems/class_systemManagement.inc index 7bd00a727..f177d3ae3 100644 --- a/gosa-plugins/systems/admin/systems/class_systemManagement.inc +++ b/gosa-plugins/systems/admin/systems/class_systemManagement.inc @@ -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"){ -- 2.30.2