Code

- Added ssh plugin
[gosa.git] / plugins / admin / systems / class_terminalGeneric.inc
index 353ee0d324e67eeeaaaecd467bb0f957faf3256e..66500df3464b8721d69cf4b2b7e56a95d7551b39 100644 (file)
@@ -52,6 +52,8 @@ class termgeneric extends plugin
 
   var $fai_activated = FALSE;
 
+  var $member_of_ogroup = FALSE;
+
   function termgeneric ($config, $dn= NULL, $parent= NULL)
   {
     /* Check if FAI is activated */
@@ -61,6 +63,14 @@ class termgeneric extends plugin
     }
 
     plugin::plugin ($config, $dn, $parent);
+
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn"));
+      $this->member_of_ogroup = $ldap->count() >= 1;
+    }
+
     $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses);
     /* Read arrays */
     foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
@@ -88,6 +98,11 @@ class termgeneric extends plugin
       $this->gotoNtpServer=array();
     }
 
+    /* You can't inherit the NTP service, if we are not member in an object group */
+    if(!$this->member_of_ogroup){
+      $this->inheritTimeServer = FALSE;
+    }
+
     /* Create available ntp options */
     $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
     foreach($this->gotoNtpServers as $key => $server){
@@ -112,7 +127,7 @@ class termgeneric extends plugin
     $tmp = $this->config->data['SERVERS']['SYSLOG'];
     foreach($tmp as $server){
       $visible = $server;
-      if($server == "default") {
+      if($server == "default" && $this->member_of_ogroup) {
         $visible = "["._("inherited")."]";
       }
       $this->gotoSyslogServers[$server] = $visible;
@@ -284,7 +299,9 @@ class termgeneric extends plugin
       if($server != "default"){
         $tmp2[$server]= $server;
       }else{
-        $tmp2[$server]="["._("inherited")."]";
+        if($this->member_of_ogroup){
+          $tmp2[$server]="["._("inherited")."]";
+        }
       }
     }
   
@@ -308,6 +325,9 @@ class termgeneric extends plugin
     $smarty->assign("netconfig", $this->netConfigDNS->execute());
     $smarty->assign("fai_activated",$this->fai_activated);
     $smarty->assign("actionACL", chkacl($this->acl, 'action'));
+
+    $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
+
     return($smarty->fetch (get_template_path('terminal.tpl', TRUE)));
   }
 
@@ -343,6 +363,7 @@ class termgeneric extends plugin
   {
     plugin::save_object();
     $this->netConfigDNS->save_object();
+
     /* Save base, since this is no LDAP attribute */
     if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
       $this->base= $_POST['base'];
@@ -355,12 +376,17 @@ class termgeneric extends plugin
     }
   
     if(isset($_POST['termgeneric_posted']) && chkacl($this->acl,"gotoNtpServer") == ""){
-      if(isset($_POST["inheritTimeServer"])){
+      if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
         $this->inheritTimeServer = true;
       }else{
         $this->inheritTimeServer = false;
       }
     }  
+
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
+
   }
 
 
@@ -503,6 +529,29 @@ class termgeneric extends plugin
     show_ldap_error($ldap->get_error(), _("Saving terminal failed"));
   }
 
+
+  function set_everything_to_inherited()
+  {
+    $this->gotoTerminalPath  = "default";
+    $this->gotoSwapServer    = "default" ;
+    $this->gotoSyslogServer  = "default";
+    $this->inheritTimeServer = TRUE;
+
+    /* Set workstation service attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['termservice'])){
+      foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant",
+            "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
+        $this->parent->by_object['termservice']->$name = "default";
+      }
+    }
+
+    /* Set workstation startup attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['termstartup'])){
+      $this->parent->by_object['termstartup']->gotoBootKernel = "default-inherited";
+      $this->parent->by_object['termstartup']->gotoLdapServer = "default-inherited";
+    }
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: