X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fgoto%2Fadmin%2Fsystems%2Fgoto%2Fclass_ArpNewDevice.inc;h=3baf79da5cf7895aa8b61a9d5273ac4777c304c4;hb=a1b99a991d7fc72451c2fd558a33fead5b97e93d;hp=455406ae8646d986509e1df276f2be6cd8253cc9;hpb=362e2b9a81d3bde32512811ede7525ab017eead5;p=gosa.git diff --git a/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc b/gosa-plugins/goto/admin/systems/goto/class_ArpNewDevice.inc index 455406ae8..3baf79da5 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 = "gotoWorkstation"; + + var $gotoIntegration = FALSE; + function ArpNewDevice ($config, $dn= NULL, $parent= NULL) { plugin :: plugin($config,$dn); @@ -15,16 +23,52 @@ 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("gotoWorkstation"=>_("Workstation"), "gotoTermminal"=>_("Terminal"), "goServer"=>_("Server")); + if(class_available("opsi")){ + $this->SystemTypes["FAKE_OC_OpsiHost"]= _("Windows workstation"); + } } function execute() { + plugin::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("gotoWorkstation" => "W","gotoTerminal" => "T","goServer" => "S", "FAKE_OC_OpsiHost" => "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; @@ -43,7 +87,7 @@ class ArpNewDevice extends plugin $message= plugin::check(); $message= array_merge($message, $this->netConfigDNS->check()); if(empty($this->cn)){ - $message[] = _("Please specify a valid dns name."); + $message[] = msgPool::required(_("Name")); } return($message); } @@ -53,20 +97,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())); + } } } }