Code

Hide FAIstate button if FAI is not active.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Dec 2006 12:11:52 +0000 (12:11 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 7 Dec 2006 12:11:52 +0000 (12:11 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5341 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servGeneric.inc
plugins/admin/systems/class_terminalGeneric.inc
plugins/admin/systems/server.tpl
plugins/admin/systems/terminal.tpl

index 527f56bd8b9cc078e7e63bbd33630f83314f55e1..274d3ded3736da1a26183f23f4041f0f2bba7bee 100644 (file)
@@ -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);
 
index ca138cc72272400157fac43ec1929d7e0e2f9eba..aea4d11fca748eefc08f06573055c7960dd5cdd4 100644 (file)
@@ -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){
index 3bd985a830c4767974ccfd9bea27eb367c2b210d..ef53bab8ad2b356e49f4e5a53a75f84d8fbec010 100644 (file)
@@ -56,6 +56,7 @@
 
 {$netconfig}
 
+{if $fai_activated}
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 
 <h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
@@ -74,7 +75,7 @@
   </td>
  </tr>
 </table>
-
+{/if}
 
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
index cbbb965a55d2206f56fb0d05555a621e526cddf5..48eb310e7ac330dde404bc1aee684627af95a9ba 100644 (file)
 
 {$netconfig}
 {/if}
+
+{if $fai_activated}
 <p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
 <h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
 <table summary="">
   </td>
  </tr>
 </table>
+{/if}
 
 <input type="hidden" name="termgeneric_posted" value="1">
 <!-- Place cursor -->