Code

Moved ldap->error
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index 33e23c53e51704cc8295a737b5a65cc7a2051e43..f33fcae8f012307850614a0158dbb820a67efdbd 100644 (file)
@@ -8,16 +8,16 @@ class workstartup extends plugin
 
   /* Generic terminal attributes */
   var $bootmode             = "G";
-  var $goLdapServerList     = array("default");
+  var $goLdapServerList     = array();
   var $gotoBootKernel       = "default";
   var $gotoKernelParameters = "";
-  var $gotoLdapServer       = "";
+  var $gotoLdapServer       = "default";
   var $gotoModules          = array();
   var $gotoAutoFs           = array();
   var $gotoFilesystem       = array();
   var $gotoTerminalPath     = "";
   var $FAIstatus            = "";
-
+  var $gotoBootKernels      = array();
 
   /* attribute list for save action */
   var $attributes     = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "FAIclass", "FAIstatus", "gotoShare","FAIdebianMirror", "FAIrelease");
@@ -53,7 +53,9 @@ class workstartup extends plugin
      */
     $ldap   = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    
+   
+    $this->goLdapServerList = array("default" =>"["._("inherited")."]");
+   
     $_SESSION['getAvailableClassesForThisRelease_CACHE'] = array();
     $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'] = array();
 
@@ -220,6 +222,32 @@ class workstartup extends plugin
     }
 
     $this->orig_dn= $this->dn;
+
+    /* Handle inheritance value "default" */
+    $this->gotoBootKernels= array("%default%" => '['._("inherited").']');
+
+    /* Get list of boot kernels */
+    if (isset($this->config->data['TABS'])){
+      $command= search_config($this->config->data['TABS'], get_class($this), "KERNELS");
+
+      if (!check_command($command)){
+        $message[]= sprintf(_("Command '%s', specified as KERNELS hook for plugin '%s' doesn't seem to exist."), $command,
+            get_class($this));
+      } else {
+        $fh= popen($command, "r");
+        while (!feof($fh)) {
+          $buffer= trim(fgets($fh, 256));
+          
+          if ($buffer != ""){
+            $this->gotoBootKernels[preg_replace('/:.*$/', '', $buffer)]= $buffer;
+          }
+        }
+        pclose($fh);
+        ksort($this->gotoBootKernels);
+      }
+      
+    }
+
   }
 
   
@@ -346,15 +374,21 @@ class workstartup extends plugin
   function check()
   {
     $messages = array();
+    
+    /* Call common method to give check the hook */
+    $messages= plugin::check();
+
     /* If there are packages selected, but no mirror show error */   
     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
     }
+
     return($messages);
   }
 
   function execute()
   {
+
        /* Call parent execute */
        plugin::execute();
 
@@ -517,33 +551,44 @@ class workstartup extends plugin
 
     $smarty->assign("gotoShares",$this->printOutAssignedShares());
     $smarty->assign("gotoShareKeys",array_flip($this->printOutAssignedShares()));
+    $smarty->assign("gotoBootKernels",$this->gotoBootKernels);
 
     /* Arrays */
-
     $tmp = $this->config->data['SERVERS']['LDAP'];
-    $smarty->assign("ldapserverKeys", $tmp);
-
-//    foreach($tmp as $key => $server){
-//      if(strlen($server)> 51){
-//        $tmp[$key] = substr($server,0,48)."...";
-//      }
-//    }
-    $smarty->assign("ldapservers", $tmp);
-    $smarty->assign("gotoLdapServer_select", $this->gotoLdapServer);
-
 
+    /* Create divSelectBox for ldap server selection
+     */
     $SelectBoxLdapServer = new divSelectBox("LdapServer");
-    $SelectBoxLdapServer->SetHeight(80);
+    $SelectBoxLdapServer->SetHeight(130);
+
+    /* Set first entry as selected, if $this->gotoLdapServer is empty
+     *  or given entry is no longer available ... 
+     */
+    $found = false;
     foreach($tmp as $server){
+      if($this->gotoLdapServer==$server){
+        $found = true;
+      }
+    }
 
+    /* Add Entries 
+     */
+    foreach($tmp as $server){
       $use ="";
-      if($this->gotoLdapServer == $server) {
+      if(($this->gotoLdapServer == $server) || ($found == false)) {
+        $found = true;
         $use = " checked ";
       };
 
+      if($server == "default"){
+        $display = "["._("inherited")."]";
+      }else{
+        $display = $server;
+      }
+
       $SelectBoxLdapServer->AddEntry(
           array(
-            array("string"=>$server),
+            array("string"=>$display),
             array("string"=>"<input type='radio' name='gotoLdapServer' value='".$server."' ".$use.">",
                   "attach"=>"style='border-right:0px;'")
             ));
@@ -761,9 +806,11 @@ class workstartup extends plugin
      * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
      */
     if(isset($this->parent->by_object['ogroup'])){
-      $this->objectclasses = array("gotoWorkstationTemplate","GOhard", "FAIobject");
+      $this->objectclasses = array("gotoWorkstationTemplate", "FAIobject");
     }elseif(isset($this->parent->by_object['workgeneric'])){
       $this->objectclasses = array("GOhard", "FAIobject");
+    }elseif(isset($this->parent->by_object['servgeneric'])){
+      $this->objectclasses = array("GOhard", "FAIobject");
     }else{
       print "Object Type Configuration : unknown";
       exit();
@@ -785,7 +832,7 @@ class workstartup extends plugin
         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
 
         $ldap->cat("cn=default,ou=terminals,ou=systems,$tmp".
-            $this->config->current['BASE']);
+            $this->config->current['BASE'], array('gotoTerminalPath'));
         $attrs= $ldap->fetch();
         if (isset($attrs['gotoTerminalPath'])){
           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
@@ -801,10 +848,7 @@ class workstartup extends plugin
 
     /* Add semi automatic values */
     // FIXME: LDAP Server may not be set here...
-    $this->gotoKernelParameters= "root=/dev/nfs nfsroot=".
-      $this->gotoTerminalPath.
-      ",ro,hard,nolock,fg,rsize=8192 ".
-      "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer);
+    $this->gotoKernelParameters= "ldap=".base64_encode($this->gotoLdapServer);
 
     switch ($this->bootmode){
       case "D":
@@ -844,15 +888,20 @@ class workstartup extends plugin
     }
     /* Strip out 'default' values */
     if ($this->attrs['gotoLdapServer'] == "default"){
-      unset ($this->attrs['gotoLdapServer']);
+      $this->attrs['gotoLdapServer']= array();
+    }
+
+    if ($this->attrs['gotoBootKernel'] == "%default%" || $this->attrs['gotoBootKernel'] == "default"){
+      $this->attrs['gotoBootKernel']= array();
     }
 
     /* if mirror == none stop saving this attribute */
     if($this->FAIdebianMirror == "none"){
       $this->FAIdebianMirror = "";
     }
-    
-    if((count($this->attrs['FAIclass'])==0)&&(empty($this->FAIdebianMirror))){
+   
+    /* Remove FAI objects if no FAI class is selected */ 
+    if(count($this->FAIclass)==0){
       $tmp = array();
       foreach($this->attrs['objectClass'] as $class){
         if($class != "FAIobject"){
@@ -876,9 +925,9 @@ class workstartup extends plugin
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $this->cleanup();
-$ldap->modify ($this->attrs); 
+    $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving workstation startup settings failed"));
     $this->handle_post_events("modify");
   }