From cc30a234c20b19edc68803dd27232e2e2c79f9c5 Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 7 Oct 2008 12:34:50 +0000 Subject: [PATCH] Make terminals save-able git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12618 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/goto/class_terminalGeneric.inc | 2 +- .../systems/goto/class_terminalService.inc | 64 +++++++++++++++++-- .../systems/goto/class_terminalStartup.inc | 18 +++++- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc index d2ccc9cbe..97c071765 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalGeneric.inc @@ -74,7 +74,7 @@ class termgeneric extends plugin if(!isset($this->parent->by_object['ogroup'])){ $ldap = $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn")); + $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))",array("cn")); $this->member_of_ogroup = $ldap->count() >= 1; } diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc index b6c736d6d..2a580e10f 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalService.inc @@ -76,7 +76,7 @@ class termservice extends plugin */ $ldap= $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))"); + $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))"); if($ldap->count()){ $this->is_ogroup_member = TRUE; } @@ -233,7 +233,7 @@ class termservice extends plugin "gotoXMouseType", "gotoXMethod", "gotoXMouseport"); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",$map); + $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))",$map); if ($ldap->count() == 1){ $attrs= $ldap->fetch(); foreach ($map as $name){ @@ -536,10 +536,9 @@ class termservice extends plugin /* Convert to string */ $this->gotoLpdEnable= $this->gotoLpdEnable?"Yes":"No"; - if($this->is_ogroup){ - $this->objectclasses = array("gotoWorkstationTemplate"); - }else{ - $this->objectclasses = array("GOhard"); + /* remove objectclass GOhard if this is an ogroup tab */ + if(isset($this->parent->by_object['ogroup'])){ + $this->objectclasses = array(); } plugin::save(); @@ -578,6 +577,11 @@ class termservice extends plugin msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class())); } $this->handle_post_events("modify"); + + /* Send goto reload event to gosaSupportDaemon */ + if(count($this->attrs)){ + $this->send_goto_reload(); + } } @@ -605,6 +609,54 @@ class termservice extends plugin return($drivers); } + function send_goto_reload() + { + if(count($this->attrs) && class_available("DaemonEvent")){ + $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT); + $o_queue = new gosaSupportDaemon(); + if(isset($events['TRIGGERED']['DaemonEvent_goto_reload'])){ + $evt = $events['TRIGGERED']['DaemonEvent_goto_reload']; + $macs = array(); + + /* Get list of macAddresses + */ + if(isset($this->parent->by_object['ogroup'])){ + + /* If we are an object group, add all member macs + */ + $p = $this->parent->by_object['ogroup']; + foreach($p->memberList as $dn => $obj){ + if(preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$dn)) continue; + if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){ + $macs[] = $p->objcache[$dn]['macAddress']; + } + } + }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){ + + /* We are a workstation. Add current mac. + */ + $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress; + if(!empty($mac) && !preg_match("/".normalizePreg(get_ou("systemIncomingRDN"))."/",$this->orig_dn)){ + $macs[] = $mac; + } + } + + /* Trigger event for all member objects + */ + if(count($macs)){ + $tmp = new $evt['CLASS_NAME']($this->config); + $tmp->set_type(TRIGGERED_EVENT); + $target = $o_queue->get_host().":".$o_queue->get_port(); + $tmp->add_targets(array($target)); + $tmp->set_macs($macs); + if(!$o_queue->append($tmp,TRUE)){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG); + } + } + } + } + } + /* Return plugin informations for acl handling */ static function plInfo() diff --git a/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc b/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc index 665acb09b..8bac77b75 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_terminalStartup.inc @@ -116,7 +116,7 @@ class termstartup extends plugin /* Load hardware list */ $ldap= $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))"); + $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))"); if ($ldap->count() == 1){ $map= array("gotoLdapServer","gotoBootKernel"); $attrs= $ldap->fetch(); @@ -341,6 +341,22 @@ class termstartup extends plugin /* Save to LDAP */ function save() { + /* Depending on the baseobject (Ogroup / WS) we + * use another set of objectClasses + * In case of TS itself, we use "array("GOhard");" + * if we are currently editing from ogroup menu we use (array("goTerminalTemplate")) + */ + if(isset($this->parent->by_object['ogroup'])){ + $this->objectclasses = array("gotoTerminalTemplate"); + }elseif(isset($this->parent->by_object['termgeneric'])){ + $this->objectclasses = array("GOhard"); + }else{ + msg_dialog::display(_("Fatal error"), + "Object Type Configuration is unknown. Please contact the GOsa developers.", + FATAL_ERROR_DIALOG); + exit(); + } + /* Find proper terminal path for tftp configuration FIXME: This is suboptimal when the default has changed to another location! */ -- 2.30.2