From 3c88e19dd94a575e5a78de17985d44dfa21763bb Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 8 Dec 2006 06:12:54 +0000 Subject: [PATCH] Terminal/Server/Workstation. Only set action (FAIstate) if fai is enabled, and the edited entry already exists in ldap git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5344 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_servGeneric.inc | 58 +++++++++++------- .../admin/systems/class_terminalGeneric.inc | 57 +++++++++++------- .../systems/class_workstationGeneric.inc | 60 +++++++++++-------- plugins/admin/systems/server.tpl | 3 +- plugins/admin/systems/terminal.tpl | 2 + plugins/admin/systems/workstation.tpl | 3 + 6 files changed, 111 insertions(+), 72 deletions(-) diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index af9812c9e..30ee0acac 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -36,10 +36,18 @@ class servgeneric extends plugin "memcheck" => "memcheck", "sysinfo" => "sysinfo"); + var $fai_activated = FALSE; + function servgeneric ($config, $dn= NULL, $parent= NULL) { plugin::plugin ($config, $dn, $parent); + /* Check if FAI is activated */ + $tmp = search_config($config->data,"faiManagement","CLASS"); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + } + $this->modes["active"]= _("Activated"); $this->modes["locked"]= _("Locked"); @@ -82,33 +90,36 @@ class servgeneric extends plugin $this->didAction= TRUE; /* Set FAIstate */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); - - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } + if($this->fai_activated && $this->dn != "new"){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn,array("objectClass")); + $res = $ldap->fetch(); - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } + $attrs = array(); + $attrs['FAIstate'] = ""; + if(isset($this->mapActions[$_POST['saction']])){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } + + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } + + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + + if($attrs['FAIstate'] == ""){ +#FIXME we should check if FAIobject is used anymore + $attrs['FAIstate'] = array(); + } - if($attrs['FAIstate'] == ""){ - #FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error()); } - - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error()); } } } @@ -176,6 +187,7 @@ class servgeneric extends plugin /* Show main page */ $this->netConfigDNS->cn= $this->cn; $smarty->assign("netconfig", $this->netConfigDNS->execute()); + $smarty->assign("fai_activated",$this->fai_activated); $smarty->assign("modes", $this->modes); return($smarty->fetch (get_template_path('server.tpl', TRUE))); diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index 88bbce350..7a12d4ef9 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -55,9 +55,16 @@ class termgeneric extends plugin "memcheck" => "memcheck", "sysinfo" => "sysinfo"); + var $fai_activated = FALSE; function termgeneric ($config, $dn= NULL, $parent= NULL) { + /* Check if FAI is activated */ + $tmp = search_config($config->data,"faiManagement","CLASS"); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + } + plugin::plugin ($config, $dn, $parent); $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Read arrays */ @@ -131,34 +138,37 @@ class termgeneric extends plugin if (isset($_POST['action'])){ - /* Set FAIstate */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } + if($this->fai_activated && $this->dn != "new"){ + /* Set FAIstate */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn,array("objectClass")); + $res = $ldap->fetch(); - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } + $attrs = array(); + $attrs['FAIstate'] = ""; + if(isset($this->mapActions[$_POST['saction']])){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } - if($attrs['FAIstate'] == ""){ - #FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); - } + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error()); + if($attrs['FAIstate'] == ""){ +#FIXME we should check if FAIobject is used anymore + $attrs['FAIstate'] = array(); + } + + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error()); + } switch($_POST['saction']){ case 'wake': @@ -299,6 +309,7 @@ class termgeneric extends plugin /* Show main page */ $this->netConfigDNS->cn= $this->cn; $smarty->assign("netconfig", $this->netConfigDNS->execute()); + $smarty->assign("fai_activated",$this->fai_activated); $smarty->assign("actionACL", chkacl($this->acl, 'action')); return($smarty->fetch (get_template_path('terminal.tpl', TRUE))); } diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 3ba74d927..577ed196c 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -59,9 +59,16 @@ class workgeneric extends plugin "sysinfo" => "sysinfo"); + var $fai_activated = FALSE; function workgeneric ($config, $dn= NULL, $parent= NULL) { + /* Check if FAI is activated */ + $tmp = search_config($config->data,"faiManagement","CLASS"); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + } + plugin::plugin ($config, $dn, $parent); $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); @@ -144,36 +151,38 @@ class workgeneric extends plugin print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); } elseif ($_POST['saction'] != "wake") { - /* Set FAIstate */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->cat($this->dn,array("objectClass")); - $res = $ldap->fetch(); + if($this->fai_activated && $this->dn != "new"){ + /* Set FAIstate */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn,array("objectClass")); + $res = $ldap->fetch(); + + $attrs = array(); + $attrs['FAIstate'] = ""; + if(isset($this->mapActions[$_POST['saction']])){ + $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; + } - $attrs = array(); - $attrs['FAIstate'] = ""; - if(isset($this->mapActions[$_POST['saction']])){ - $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']]; - } + for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $res['objectClass'][$i]; + } - for($i = 0; $i < $res['objectClass']['count'] ; $i ++){ - $attrs['objectClass'][] = $res['objectClass'][$i]; - } + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } - if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ - $attrs['objectClass'][] = "FAIobject"; - } + if($attrs['FAIstate'] == ""){ +#FIXME we should check if FAIobject is used anymore + $attrs['FAIstate'] = array(); + } - if($attrs['FAIstate'] == ""){ - #FIXME we should check if FAIobject is used anymore - $attrs['FAIstate'] = array(); - } + $ldap->cd($this->dn); + $ldap->modify($attrs); + show_ldap_error($ldap->get_error()); - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error()); - - $this->didAction= TRUE; + $this->didAction= TRUE; + } } } } @@ -269,6 +278,7 @@ class workgeneric extends plugin /* Show main page */ $this->netConfigDNS->cn= $this->cn; $smarty->assign("netconfig", $this->netConfigDNS->execute()); + $smarty->assign("fai_activated",$this->fai_activated); return($smarty->fetch (get_template_path('workstation.tpl', TRUE))); } diff --git a/plugins/admin/systems/server.tpl b/plugins/admin/systems/server.tpl index f33a589da..4c9067d4d 100644 --- a/plugins/admin/systems/server.tpl +++ b/plugins/admin/systems/server.tpl @@ -45,6 +45,7 @@ {$netconfig} +{if $fai_activated}

 

{t}Action{/t}

@@ -61,7 +62,7 @@ - +{/if}