From 5e02fcb3213ba79f05405d9bc471ee6b31fab439 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 23 Nov 2006 06:30:31 +0000 Subject: [PATCH] Readded template functionality for workstations and terminals git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5202 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_divListSystem.inc | 2 +- plugins/admin/systems/class_printGeneric.inc | 2 +- .../admin/systems/class_systemManagement.inc | 10 +++++++-- .../admin/systems/class_terminalGeneric.inc | 20 ++++++++++++++++-- .../systems/class_workstationGeneric.inc | 21 ++++++++++++++++--- plugins/admin/systems/terminal.tpl | 4 +++- plugins/admin/systems/workstation.tpl | 3 ++- 7 files changed, 51 insertions(+), 11 deletions(-) diff --git a/plugins/admin/systems/class_divListSystem.inc b/plugins/admin/systems/class_divListSystem.inc index 5350eb746..7544aceae 100644 --- a/plugins/admin/systems/class_divListSystem.inc +++ b/plugins/admin/systems/class_divListSystem.inc @@ -231,7 +231,7 @@ class divListSystem extends MultiSelectWindow } if(isset($val['message'])){ - $display.= " (".$val['message']." '".$this->config->idepartments[$_SESSION['CurrentMainBase']]."' )"; + $display.= " (".$val['message'].")"; } $img = $this->parent->convert_list($val); diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index 7076727f3..4a475c6de 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -66,7 +66,7 @@ class printgeneric extends plugin } /* Update dn, to ensure storing as printer instead of WS / terminal */ - if($this->BelongsTo == "Terminal"){ + if($this->BelongsTo == "Terminal" || $this->BelongsTo == "TerminalTemplate"){ $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); } diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc index 5a2b8d834..5d655f75e 100644 --- a/plugins/admin/systems/class_systemManagement.inc +++ b/plugins/admin/systems/class_systemManagement.inc @@ -646,6 +646,12 @@ class systems extends plugin } } + /* Create a string containing the last part of the department. */ + $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp))); + if(empty($dn_name)){ + $dn_name = "/"; + } + /* check if current object is a new one */ if (preg_match ("/,ou=incoming,/i", $tmp)){ if (in_array_ics('gotoTerminal', $value['objectClass'])){ @@ -672,7 +678,7 @@ class systems extends plugin } else { $terminal = $value; $terminal['type'] = "D"; - $terminal['message'] = _("Terminal template for"); + $terminal['message'] = _("Terminal template for")." '".$dn_name."' "; $terminal['location'] = array_search($tmp, $this->config->departments); } } @@ -688,7 +694,7 @@ class systems extends plugin $terminal = $value; $terminal['type'] = "D"; $terminal['location'] = array_search($tmp, $this->config->departments); - $terminal['message'] = _("Workstation template for"); + $terminal['message'] = _("Workstation template for")." '".$dn_name."' "; } if (isset($value["FAIstate"][0])){ $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]); diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index 8d9c539e9..ba256af50 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -373,7 +373,11 @@ class termgeneric extends plugin { /* Call common method to give check the hook */ $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); + + /* Skip IP & Mac checks if this is a template */ + if($this->cn != "default"){ + $message= array_merge($message, $this->netConfigDNS->check()); + } /* Permissions for that base? */ $this->dn= "cn=".$this->cn."ou=terminals,ou=systems,".$this->base; @@ -395,7 +399,13 @@ class termgeneric extends plugin if ($this->orig_dn == 'new'){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->base); - $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn")); + + /* It is possible to have a 'default' terminal on every base */ + if($this->cn == "default"){ + $ldap->cat($this->dn); + }else{ + $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn")); + } if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ if (preg_match ("/,ou=incoming,/", $ldap->getDN())){ @@ -488,6 +498,12 @@ class termgeneric extends plugin $this->handle_post_events("modify"); } + + /* cn=default and macAddress=- indicates that this is a template */ + if($this->cn == "default"){ + $this->netConfigDNS->macAddress = "-"; + } + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn)); diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index e096867f7..8b34d8278 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -375,7 +375,11 @@ class workgeneric extends plugin { /* Call common method to give check the hook */ $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); + + /* Skip IP & Mac checks if this is a template */ + if($this->cn != "wdefault"){ + $message= array_merge($message, $this->netConfigDNS->check()); + } $this->dn= "cn=".$this->cn.",ou=workstations,ou=systems,".$this->base; @@ -396,7 +400,12 @@ class workgeneric extends plugin if ($this->orig_dn != $this->dn){ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->base); - $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn")); + + if($this->cn == "wdefault"){ + $ldap->cat($this->dn); + }else{ + $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn")); + } if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ if (preg_match ("/,ou=incoming,/", $ldap->getDN())){ @@ -410,7 +419,7 @@ class workgeneric extends plugin } } } - + /* Check for valid ntpServer selection */ if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ $message[]= _("There must be at least one NTP server selected, or the inherit mode activated."); @@ -496,6 +505,12 @@ class workgeneric extends plugin $this->handle_post_events("modify"); } } + + /* cn=default and macAddress=- indicates that this is a template */ + if($this->cn == "wdefault"){ + $this->netConfigDNS->macAddress = "-"; + } + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn)); diff --git a/plugins/admin/systems/terminal.tpl b/plugins/admin/systems/terminal.tpl index fde61c6bb..cbbb965a5 100644 --- a/plugins/admin/systems/terminal.tpl +++ b/plugins/admin/systems/terminal.tpl @@ -128,10 +128,12 @@ + +{if $cn neq 'default'}

 

{$netconfig} - +{/if}

 

{t}Action{/t}

diff --git a/plugins/admin/systems/workstation.tpl b/plugins/admin/systems/workstation.tpl index 378c7c126..df95ee5b9 100644 --- a/plugins/admin/systems/workstation.tpl +++ b/plugins/admin/systems/workstation.tpl @@ -104,10 +104,11 @@
+{if $cn neq 'wdefault'}

 

{$netconfig} - +{/if}

 

{t}Action{/t}

-- 2.30.2