From 0dab6567d5fe7636da2abd5d1f39f643f9b5c7c0 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 7 Dec 2006 12:11:52 +0000 Subject: [PATCH] Hide FAIstate button if FAI is not active. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5341 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_servGeneric.inc | 57 +++++++++++-------- .../admin/systems/class_terminalGeneric.inc | 54 +++++++++++------- plugins/admin/systems/server.tpl | 3 +- plugins/admin/systems/terminal.tpl | 3 + 4 files changed, 71 insertions(+), 46 deletions(-) diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index 527f56bd8..274d3ded3 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -36,8 +36,16 @@ class servgeneric extends plugin "memcheck" => "memcheck", "sysinfo" => "sysinfo"); + var $fai_activated =FALSE; + function servgeneric ($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->ui = get_userinfo(); @@ -73,7 +81,7 @@ class servgeneric extends plugin } /* Check for action */ - if (isset($_POST['action']) && $this->acvl_is_writeable("FAIstate")){ + if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD"); if ($cmd == ""){ print_red(_("No ACTIONCMD definition found in your gosa.conf")); @@ -86,32 +94,34 @@ 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']]; - } + if($this->fai_activated){ + $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]; - } + 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); } - - $ldap->cd($this->dn); - $ldap->modify($attrs); show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic (FAIstate) with dn '%s' failed."),$this->dn)); } } @@ -188,6 +198,7 @@ class servgeneric extends plugin } /* Show main page */ + $smarty->assign("fai_activated",$this->fai_activated); $smarty->assign("netconfig", $this->netConfigDNS->execute()); $smarty->assign("modes", $this->modes); diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index ca138cc72..aea4d11fc 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 */ @@ -144,34 +151,36 @@ class termgeneric extends plugin if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){ /* 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){ + $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(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn)); } - $ldap->cd($this->dn); - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/generic (FAIstate) with dn '%s' failed."),$this->dn)); - switch($_POST['saction']){ case 'wake': $cmd= search_config($this->config->data['TABS'], "termgeneric", "WAKECMD"); @@ -315,6 +324,7 @@ class termgeneric extends plugin } $smarty->assign("ntpservers", $tmp); + $smarty->assign("fai_activated",$this->fai_activated); /* Variables */ foreach(array("base", "gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){ diff --git a/plugins/admin/systems/server.tpl b/plugins/admin/systems/server.tpl index 3bd985a83..ef53bab8a 100644 --- a/plugins/admin/systems/server.tpl +++ b/plugins/admin/systems/server.tpl @@ -56,6 +56,7 @@ {$netconfig} +{if $fai_activated}

 

{t}Action{/t}

@@ -74,7 +75,7 @@ - +{/if}