Code

Column name changed.
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_workstationStartup.inc
index 5064c9603acb6d6cc8a2f03bf6078ed6aab15ad2..ea4db08a490e13d67b80f8cc1c65ac5ff10d370c 100644 (file)
@@ -35,8 +35,10 @@ class workstartup extends plugin
  
   /* FAI class selection */ 
   var $FAIclass           = array();  // The currently selected classes 
-  var $FAIrelease         = "";
-  var $FAIdebianMirror    = "auto";
+  var $FAIrelease           = "";
+  var $FAIdebianMirror      = "auto";
+  var $si_active            = FALSE;
+  var $si_fai_action_failed = FALSE;
 
   var $cache              = array(); // Used as cache in fai mehtods
 
@@ -59,7 +61,7 @@ class workstartup extends plugin
   {
     /* Check if FAI is active */
     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
-    if(!empty($tmp)){
+    if(!empty($tmp) && class_available("faiManagement")){
       $this->fai_activated = TRUE;
     }else{
       $this->attributes = array("gotoLdapServer", "gotoBootKernel", "gotoKernelParameters", "gotoShare");
@@ -68,6 +70,9 @@ class workstartup extends plugin
 
     plugin::plugin ($config, $dn, $parent);
 
+    /* Check for si daemon */
+    $this->si_active = $this->config->get_cfg_value("gosaSupportURI") != "";
+
     /* Check object group membership */
     if(!isset($this->parent->by_object['ogroup'])){
       $ldap = $this->config->get_ldap_link();
@@ -97,7 +102,9 @@ class workstartup extends plugin
       foreach($this->attrs['gotoLdapServer'] as $value){
         $this->gotoLdapServers[] = preg_replace("/^[0-9]*:/","",$value);
       }
-    }
+    } 
+    natcasesort($this->gotoLdapServerList);
+
     if(!count($this->gotoLdapServers) && $this->member_of_ogroup){ 
       $this->gotoLdap_inherit = TRUE;
     }
@@ -228,19 +235,18 @@ class workstartup extends plugin
     }
 
 
-    if($this->fai_activated){
+    if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
 
       /* Check if the current mirror is available 
        */
       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
         if(count($this->FAIclass)){
-          msg_dialog(_("Error"), sprintf(_("FAI mirror '%s' is not available - setting to mirror 'auto'!"), $this->FAIdebianMirror), ERROR_DIALOG);
+          msg_dialog::display(_("Error"), sprintf(_("FAI mirror '%s' is not available - setting to mirror 'auto'!"), $this->FAIdebianMirror), ERROR_DIALOG);
         }
         $this->FAIdebianMirror = "auto";
         $this->FAIrelease = key($this->cache['SERVERS'][$this->FAIdebianMirror]);
-        $this->cache =array();
+        $this->cache['CLASSES'] = array();
         $this->update_fai_cache();
-        
       }
   
       /* Check if the current mirror is available 
@@ -248,43 +254,13 @@ class workstartup extends plugin
       if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror][$this->FAIrelease])){
         $new_release = key($this->cache['SERVERS'][$this->FAIdebianMirror]); 
         if(count($this->FAIclass)){
-          msg_dialog(_("Error"), sprintf(_("FAI release '%s' is not available on mirror '%s' - setting to release '%s'!"), $this->FAIrelease, $this->FAIdebianmirror), ERROR_DIALOG);
+          msg_dialog::display(_("Error"), sprintf(_("FAI release '%s' is not available on mirror '%s' - setting to release '%s'!"), $this->FAIrelease, $this->FAIdebianMirror,$new_release), ERROR_DIALOG);
         }
         $this->FAIrelease = $new_release;
-        $this->cache =array();
+        $this->cache['CLASSES'] = array();
         $this->update_fai_cache();
       }
     }
-
-    /* Get list of boot kernels */
-    if (isset($this->config->data['TABS'])){
-      $command= $this->config->search(get_class($this), "KERNELS",array('tabs'));
-      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(!empty($buffer)){
-            $name=$value = $buffer;
-            if(preg_match("/:/",$buffer)){
-              $name = preg_replace("/:.*$/","",$buffer);
-              $value= preg_replace("/^.*:/","",$buffer);
-              $this->gotoBootKernels[$name]= $name.":".$value;
-            }else{
-              $this->gotoBootKernels[$name]= $value;
-            }
-          }
-        }
-        pclose($fh);
-      }
-    }
-
-    /* Turn to default, if we've nothing to inherit */
-    if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
-      $this->gotoBootKernel= "default";
-    }
   }
 
   
@@ -313,32 +289,23 @@ class workstartup extends plugin
       new log("view","workstation/".get_class($this),$this->dn);
     }
 
-    /* Do we need to flip is_account state? */
-    if(isset($_POST['modify_state'])){
-      if($this->is_account && $this->acl_is_removeable()){
-        $this->is_account= FALSE;
-      }elseif(!$this->is_account && $this->acl_is_createable()){
-        $this->is_account= TRUE;
-      }
-    }
-
     /* Do we represent a valid terminal? */
     if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+      $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
         msgPool::noValidExtension(_("workstation"))."</b>";
       return ($display);
     }
 
     /* Add module */
     if (isset ($_POST['add_module'])){
-      if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModule")){
+      if ($_POST['module'] != "" && $this->acl_is_writeable("gotoModules")){
         $this->add_list ($this->gotoModules, $_POST['module']);
       }
     }
 
     /* Delete module */
     if (isset ($_POST['delete_module'])){
-      if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModule")){
+      if (count($_POST['modules_list']) && $this->acl_is_writeable("gotoModules")){
         $this->del_list ($this->gotoModules, $_POST['modules_list']);
       }
     }
@@ -364,7 +331,7 @@ class workstartup extends plugin
         }
 
         if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
-          msg_dialog(_("Error"), _("There is already a profile containing a partition table in your configuration!") , ERROR_DIALOG);
+          msg_dialog::display(_("Error"), _("There is already a profile containing a partition table in your configuration!") , ERROR_DIALOG);
         }else{
           $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
         }
@@ -469,12 +436,13 @@ class workstartup extends plugin
     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
      * This entry will be, a combination of mountPoint and sharedefinitions
      */
-    if((isset($_POST['gotoShareAdd'])) && ($this->acl_is_writeable("gotoShare"))) {
+    if((isset($_POST['gotoShareAdd'])) && isset($_POST['gotoShareSelection']) && ($this->acl_is_writeable("gotoShare"))) {
       /* We assign a share to this user, if we don't know where to mount the share */
       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
-        msg_dialog(_("Error"), msgPool::required(_("Mount point"), ERROR_DIALOG);
+        msg_dialog::display(_("Error"), msgPool::required(_("Mount point")), ERROR_DIALOG);
       }else{
-        if(count($this->gotoAvailableShares)){
+    
+        if(isset($this->gotoAvailableShares[$_POST['gotoShareSelection']])){
           $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
           $s_mount = $_POST['gotoShareMountPoint'];
           /* Preparing the new assignment */
@@ -502,7 +470,10 @@ class workstartup extends plugin
     $SelectBoxLdapServer->SetHeight(130);
 
     /* Add new ldap server to the list */
-    if(!$this->gotoLdap_inherit && isset($_POST['add_ldap_server']) && isset($_POST['ldap_server_to_add'])){
+    if($this->acl_is_writeable("gotoLdapServer") && 
+        !$this->gotoLdap_inherit && 
+        isset($_POST['add_ldap_server']) && 
+        isset($_POST['ldap_server_to_add'])){
       if(isset($this->gotoLdapServerList[$_POST['ldap_server_to_add']])){
         $to_add = $this->gotoLdapServerList[$_POST['ldap_server_to_add']];
         if(!in_array($to_add,$this->gotoLdapServers)){
@@ -512,7 +483,7 @@ class workstartup extends plugin
     }
     
     /* Move ldap servers up and down */
-    if(!$this->gotoLdap_inherit){
+    if(!$this->gotoLdap_inherit && $this->acl_is_writeable("gotoLdapServer")){
       foreach($_POST as $name => $value){
         if(preg_match("/sort_ldap_up_/",$name)){
           $id = preg_replace("/^sort_ldap_up_([0-9]*)_(x|y)$/","\\1",$name);
@@ -543,20 +514,33 @@ class workstartup extends plugin
       } 
     }
   
-    /* Add Entries 
-     */
-    foreach($this->gotoLdapServers as $key => $server){
-      if(!in_array($server,$this->gotoLdapServerList)){
-        $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
+    /* Add Entries */
+    if($this->acl_is_readable("gotoLdapServer")){
+
+      foreach($this->gotoLdapServers as $key => $server){
+
+        /* Announce missing entries */
+        if(!in_array($server,$this->gotoLdapServerList)){
+          $server = $server."&nbsp;<font style='color:red'>(missing)</font>";
+        }
+
+        /* Convert old style entry */
+        if (!preg_match('%:ldaps?://%', $server)){
+          $server= "ldap://".preg_replace('/^([^:]+):/', '\1/', $server);
+
+        /* Beautify new style entries */
+      } else {
+        $server= preg_replace("/^[^:]+:/", "", $server);
       }
 
       $SelectBoxLdapServer->AddEntry(
           array(array("string" => $server),
             array("string" => 
-              "<input class='center' type='image' src='images/sort_up.png' name='sort_ldap_up_".$key."'>&nbsp;".
-              "<input class='center' type='image' src='images/sort_down.png' name='sort_ldap_down_".$key."'>&nbsp;".
-              "<input class='center' type='image' src='images/edittrash.png' name='gotoLdapRemove_".$key."'>",
+              "<input class='center' type='image' src='images/lists/sort-up.png' name='sort_ldap_up_".$key."'>&nbsp;".
+              "<input class='center' type='image' src='images/lists/sort-down.png' name='sort_ldap_down_".$key."'>&nbsp;".
+              "<input class='center' type='image' src='images/lists/trash.png' name='gotoLdapRemove_".$key."'>",
               "attach" => "style='text-align:right;width:40px;border-right:0px;'")));
+      }    
     }    
 
     if($this->gotoLdap_inherit){
@@ -568,6 +552,16 @@ class workstartup extends plugin
     $list = array();
     foreach($this->gotoLdapServerList as $key => $entry){
       if(!in_array($entry,$this->gotoLdapServers)){
+
+        /* Convert old style entry */
+        if (!preg_match('%:ldap[s]*://%', $entry)){
+          $entry= "ldap://".preg_replace('/^([^:]+):/', '\1/', $entry);
+
+        /* Beautify new style entries */
+        } else {
+          $entry= preg_replace("/^[^:]+:/", "", $entry);
+        }
+
         $list[$key] = $entry;
       }
     }
@@ -588,22 +582,34 @@ class workstartup extends plugin
     $smarty->assign("fai_activated",$this->fai_activated);
 
     /* Create FAI output */
-    if($this->fai_activated){
-
-      $this->update_fai_cache();
+    $this->update_fai_cache();
+    $smarty->assign("si_fai_action_failed",$this->si_fai_action_failed);
+    $smarty->assign("si_active",$this->si_active);
+  
+    if(!$this->si_fai_action_failed && $this->si_active && $this->fai_activated){
 
       $smarty->assign("FAIservers"  , $this->cache['SERVERS']);
       $smarty->assign("FAIdebianMirror",$this->FAIdebianMirror);
       $smarty->assign("FAIrelease"  , $this->FAIrelease);
       $smarty->assign("FAIclasses"  , $this->selectable_classes());
 
+      /* Get classes for release from cache.
+       * Or build cache
+       */
+      if($this->FAIdebianMirror == "inherited"){
+        $release = $this->InheritedFAIrelease;
+      }else{
+        $release = $this->FAIrelease;
+      }
+
+      $smarty->assign("gotoBootKernels",$this->cache['KERNELS'][$release]);
       $smarty->assign("InheritedFAIrelease",$this->InheritedFAIrelease);
 
       $div = new divSelectBox("WSFAIscriptClasses");
       $div -> SetHeight("110");
-      $str_up     = " &nbsp;<input type='image' src='images/sort_up.png'    name='sort_up_%s'    value='%s'>";
-      $str_down   = " &nbsp;<input type='image' src='images/sort_down.png'  name='sort_down_%s'  value='%s'>";
-      $str_remove = " &nbsp;<input type='image' src='images/edittrash.png'  name='fai_remove_%s' value='%s'>";
+      $str_up     = " &nbsp;<input type='image' src='images/lists/sort-up.png'    name='sort_up_%s'    value='%s'>";
+      $str_down   = " &nbsp;<input type='image' src='images/lists/sort-down.png'  name='sort_down_%s'  value='%s'>";
+      $str_remove = " &nbsp;<input type='image' src='images/lists/trash.png'  name='fai_remove_%s' value='%s'>";
       $str_empty  = " &nbsp;<img src='images/empty.png' alt=\"\" width='7'>"; 
 
       /* Get classes */
@@ -748,7 +754,9 @@ class workstartup extends plugin
     }elseif(isset($this->parent->by_object['servgeneric'])){
       $this->objectclasses = array("GOhard","gotoWorkstationTemplate");
     }else{
-      print "Object Type Configuration : unknown";
+      msg_dialog::display(_("Fatal error"),
+          "Object Type Configuration is unknown. Please contact the GOsa developers.",
+          FATAL_ERROR_DIALOG);
       exit();
     }
 
@@ -764,7 +772,7 @@ class workstartup extends plugin
       $ldap= $this->config->get_ldap_link();
 
       /* Strip relevant part from dn, keep trailing ',' */
-      $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalou')."/i", "", $this->dn);
+      $tmp= preg_replace("/^cn=[^,]+,".get_ou('terminalRDN')."/i", "", $this->dn);
       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
 
       /* Walk from top to base and try to load default values for
@@ -772,7 +780,7 @@ class workstartup extends plugin
       while (TRUE){
         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
 
-        $ldap->cat("cn=default,".get_ou('terminalou').$tmp.
+        $ldap->cat("cn=default,".get_ou('terminalRDN').$tmp.
             $this->config->current['BASE'], array('gotoTerminalPath'));
         $attrs= $ldap->fetch();
         if (isset($attrs['gotoTerminalPath'])){
@@ -806,27 +814,25 @@ class workstartup extends plugin
     plugin::save();
 
     unset( $this->attrs['FAIrelease'] );
-    
     $str = "";
 
     /* Skip FAI attribute handling if not necessary */
-    if($this->fai_activated){
+    if($this->fai_activated && !$this->si_fai_action_failed){
       if($this->FAIdebianMirror == "inherited"){
-        $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array(); 
+        $this->attrs['FAIclass'] = $this->attrs['FAIrelease'] =  $this->attrs['FAIdebianMirror'] = array();
       }else{
         foreach($this->FAIclass as $class){
           $str .= $class." ";
         }
-        $str .= ":" . $this->FAIrelease;
-        $this->attrs['FAIclass']= "";
-        $this->attrs['FAIclass']= trim($str);
-
+        $str = trim($str);
         if(empty($this->attrs['FAIclass'])){
           $this->attrs['FAIclass'] = array();
+        }else{
+          $this->attrs['FAIclass']= $str." :".$this->FAIrelease;
         }
       }
     }
-  
+
     /* Add missing arrays */
     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
       if (isset ($this->$val) && count ($this->$val) != 0){
@@ -846,12 +852,7 @@ class workstartup extends plugin
       }
     }
 
-    /* Check if LDAP server has changed */
-    $ldap_changed= (isset($this->attrs['gotoLdapServer'])) && 
-                   (isset($this->saved_attributes['gotoLdapServer'])) &&
-                   ($this->attrs['gotoLdapServer'] != $this->saved_attributes['gotoLdapServer']);
-
-    if (($this->attrs['gotoBootKernel'] == "default-inherited") || ($this->attrs['gotoBootKernel'] == "%default%")){
+    if ($this->attrs['gotoBootKernel'] == "default-inherited"){
       $this->attrs['gotoBootKernel']= array();
     }
 
@@ -866,7 +867,7 @@ class workstartup extends plugin
 
 
     /* Skip FAI attribute handling if not necessary */
-    if($this->fai_activated){
+    if($this->fai_activated && !$this->si_fai_action_failed && $this->si_active){
       $ldap->cat($this->dn,array("FAIstate"));
       $checkFAIstate = $ldap->fetch();
 
@@ -875,8 +876,13 @@ class workstartup extends plugin
         $this->attrs['FAIclass']        = array();
         $this->attrs['FAIdebianMirror'] = array();
       }
-    }
+    }else{
 
+      /* Don't touch FAI objects if something went wrong with the si daemon.
+       */
+      if(isset($this->attrs['FAIclass'])) unset($this->attrs['FAIclass']);
+      if(isset($this->attrs['FAIdebianMirror'])) unset($this->attrs['FAIdebianMirror']);
+    }
 
     /* prepare share settings */
     $tmp = array();
@@ -886,7 +892,6 @@ class workstartup extends plugin
       $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
     }
     $this->attrs['gotoShare']=$tmp;
-
     $this->cleanup();
     $ldap->modify ($this->attrs); 
     new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
@@ -897,16 +902,52 @@ class workstartup extends plugin
     $this->handle_post_events("modify");
 
     /* Check if LDAP server has changed */
-    if ($ldap_changed && class_available("DaemonEvent")){
+    if ((isset($this->attrs['gotoLdapServer']) && class_available("DaemonEvent")) || $this->gotoLdap_inherit){
       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
       $o_queue = new gosaSupportDaemon();
       if(isset($events['TRIGGERED']['DaemonEvent_reload_ldap_config'])){
         $evt = $events['TRIGGERED']['DaemonEvent_reload_ldap_config'];
-        $tmp = new $evt['CLASS_NAME']($this->config);
-        $tmp->set_type(TRIGGERED_EVENT);
-        $tmp->add_targets(array($this->parent->by_object['workgeneric']->netConfigDNS->macAddress));
-        if(!$o_queue->append($tmp)){
-          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+        $macs = array();
+    
+        /* Get list of macAddresses 
+         */
+        if(isset($this->parent->by_object['ogroup'])){
+        
+          /* If we are an object group, add all member macs 
+           */
+          $p = $this->parent->by_object['ogroup'];
+          foreach($p->memberList as $dn => $obj){
+            if(isset($p->objcache[$dn]['macAddress']) && !empty($p->objcache[$dn]['macAddress'])){
+              $macs[] = $p->objcache[$dn]['macAddress'];
+            }
+          }
+        }elseif(isset($this->parent->by_object['workgeneric']->netConfigDNS->macAddress)){
+
+          /* We are a workstation. Add current mac.
+           */
+          $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
+          if(!empty($mac)){
+            $macs[] = $mac;
+          }          
+        }elseif(isset($this->parent->by_object['servgeneric']->netConfigDNS->macAddress)){
+
+          /* We are a server. Add current mac.
+           */
+          $mac = $this->parent->by_object['servgeneric']->netConfigDNS->macAddress;
+          if(!empty($mac)){
+            $macs[] = $mac;
+          }          
+        }
+
+        /* Trigger event for all member objects 
+         */
+        foreach($macs as $mac){
+          $tmp = new $evt['CLASS_NAME']($this->config);
+          $tmp->set_type(TRIGGERED_EVENT);
+          $tmp->add_targets(array($mac));
+          if(!$o_queue->append($tmp)){
+            msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+          }
         }
       }
     }
@@ -1018,50 +1059,40 @@ class workstartup extends plugin
   function update_fai_cache($first_call = FALSE)
   {
     $force = FALSE;
+    if(!$this->si_active) return; 
+    $start = microtime(TRUE);  
+
+    if($this->si_fai_action_failed && !isset($_POST['fai_si_retry'])) return;
+
+    $this->si_fai_action_failed = FALSE;
 
     /* Get the list of available servers and their releases. 
      */
     if($force || !isset($this->cache['SERVERS'])){
-      $ldap = $this->config->get_ldap_link();
-      $ldap->cd($this->config->current['BASE']);
 
-      $server_list = get_sub_list("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",
-                      "",get_ou("serverou"),$this->config->current['BASE'],array("FAIrepository"),GL_NO_ACL_CHECK);
-     
-      /* Only add inherit option, if we are part in an object group
-       */
-      if($this->member_of_ogroup){
-        $this->cache['SERVERS']['inherited']=array();
-      }
-
-      /* Add auto value  
-       */
-      $this->cache['SERVERS']['auto'] = array();
-      $sort_by = array("auto");
-      $server_tmp = array("auto"=>array());
-      foreach($server_list as $attr){
-        if(isset($attr['FAIrepository'])){
-          for($i = 0 ; $i < $attr['FAIrepository']['count'] ; $i ++ ){
-            $rep = $attr['FAIrepository'][$i];
-            $tmp = split("\|",$rep);
-            if(count($tmp)==4){
-              $sections = split(",",$tmp[3]);
-              $release  = $tmp[2];
-              $server   = $tmp[1];
-              $url      = $tmp[0];
-              $server_tmp[$url][$release]=$release;
-              $server_tmp['auto'][$release]=$release;
-              $sort_by[$url] = $url;
-            }
-          }
+      $o_queue = new gosaSupportDaemon();
+      $tmp = $o_queue->FAI_get_server();
+      if($o_queue->is_error()){
+        msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+        $this->si_fai_action_failed = TRUE;
+        $this->cache = array();
+        return;
+      }else{
+        foreach($tmp as $entry){
+          $rel = $entry['FAI_RELEASE'];
+          $this->cache['SERVERS']['auto'][$rel] = $rel;
+          $this->cache['SERVERS'][$entry['SERVER']][$rel] = $rel;
+          uksort($this->cache['SERVERS']['auto'], 'strnatcasecmp');
+          uksort($this->cache['SERVERS'][$entry['SERVER']], 'strnatcasecmp');
         }
       }
-      natcasesort($sort_by);
-      foreach($sort_by as $name){
-        $releases = $server_tmp[$name];
-        natcasesort($releases);
-        $this->cache['SERVERS'][$name] = $releases; 
-      }
+    }
+
+    /* Ensure that our selection is valid, else we get several PHP warnings 
+        if there is no FAI configuration at all.
+     */
+    if(!isset($this->cache['SERVERS'][$this->FAIdebianMirror])){
+      $this->cache['SERVERS'][$this->FAIdebianMirror][''] ='';
     }
 
     /* Build up arrays, without checks */
@@ -1089,46 +1120,24 @@ class workstartup extends plugin
     }else{
       $release = $this->FAIrelease;
     }
-    if($force || !isset($this->cache['CLASSES'][$release])){
-
-      /*  Create a list of available releases.
-       *  $this->cache['RELEASE_DNS'][ou=siga...,c=de]         = "siga";
-       *  $this->cache['RELEASE_DNS'][ou=siga,ou=rc1,...,c=de] = "siga/rc1";
-       */
-      if($force || !isset($this->cache['RELEASE_DNS'])){
-        $this->cache['RELEASE_DNS'] = array();
-        $fai_ou_parts = preg_replace("/\/.*$/","",$this->FAIrelease);
-
-        $tmp = get_sub_list("(objectClass=FAIbranch)","",get_ou("faiou"),
-                $this->config->current['BASE'],array("ou"),GL_NO_ACL_CHECK | GL_SUBSEARCH);
 
-        foreach($tmp as $attrs){
-          if(preg_match("/".normalizePreg(get_ou("faiou"))."/",$attrs['dn'])){
-            $this->cache['RELEASE_DNS'][$attrs['dn']] = $this->dn_to_release_name($attrs['dn']);
-          }
-        }
-      }
+    if($force || !isset($this->cache['CLASSES'][$release]) && $release != ""){
 
-      /* Create list of available classes for the currenlty selected release.
+      /* Get the list of available servers and their releases.
        */
-      $base = array_search($release,$this->cache['RELEASE_DNS']);
+      $o_queue = new gosaSupportDaemon();
+      $tmp = $o_queue->FAI_get_classes($release);
       $this->cache['CLASSES'][$release] = array();
-
-      if(class_exists("FAI")){
-        if(!empty($base)){
-          $filter = "(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)".
-            "(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)".
-            "(objectClass=FAIpartitionTable))";
-          $list = FAI::get_all_objects_for_given_base($base,$filter,TRUE);
-          foreach($list as $attrs){
-            $info = $this->analyse_fai_object($attrs);
-            if(count($info)){
-              $this->cache['CLASSES'][$release][$attrs['cn'][0]][] = $info;
-            }
-          }
-        }
+      if($o_queue->is_error()){
+        msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+        $this->si_fai_action_failed = TRUE;
+        $this->cache=array();
+        return;
       }else{
-        msg_dialog(_("Configuration error"), _("Missing FAI plugin extension!"), ERROR_DIALOG);
+        foreach($tmp as $entry){
+          $class = $entry['CLASS'];
+          $this->cache['CLASSES'][$release][$class] = $this->analyse_fai_object($entry); 
+        }
       }
 
       /* Add object caught from external hook
@@ -1139,26 +1148,54 @@ class workstartup extends plugin
         $server = $entries['0'];
         $url    = $entries['1'];
         if (!empty($url)){
-          
+
           /* Split releases */
           if (isset($entries[2])){
             $releases= split(",", $entries[2]);
 
             foreach ($releases as $release_data){
-              $release= preg_replace('/:.*$/', '', $release_data);
-              $sections = split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
-              $classes  = split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
-              $this->cache['SERVERS'][$url][$release]=$release;
-              $this->cache['SERVERS']['auto'][$release]=$release; 
-              foreach ($classes as $class){
-                if ($class != ""){
-                  $this->cache['CLASSES'][$release][$class]= array();
+              $release_c  = preg_replace('/:.*$/', '', $release_data);
+              $sections_c = split(':', preg_replace('/^[^:]+:([^|]+)|.*$/', '\1', $release_data));
+              $classes_c  = split('\|', preg_replace('/^[^|]+\|(.*)$/', '\1', $release_data));
+
+              if($release_c == $release){
+                $this->cache['SERVERS'][$url][$release_c]=$release_c;
+                $this->cache['SERVERS']['auto'][$release_c]=$release_c; 
+                foreach ($classes_c as $class){
+                  if ($class != ""){
+                    $this->cache['CLASSES'][$release_c][$class]= array();
+                  }
                 }
               }
             }
           }
         }
       }
+      uksort($this->cache['SERVERS'], 'strnatcasecmp');
+
+      /* Only add inherit option, if we are part in an object group
+       */
+      if($this->member_of_ogroup){
+        $this->cache['SERVERS'] = array_merge(array('inherited' => array()),$this->cache['SERVERS']);
+      }
+    }
+
+    /* Get list of available kernel for this release 
+     */
+    if(!isset($this->cache['KERNELS'])) $this->cache['KERNELS'] = array();
+
+    if($force || !isset($this->cache['KERNELS'][$release])){
+      $o_queue = new gosaSupportDaemon();
+      $tmp = $o_queue->FAI_get_kernels($release);
+      $this->cache['KERNELS'][$release] = array();
+      foreach($this->gotoBootKernels as $name => $default){
+        $this->cache['KERNELS'][$release][$name] = $default;
+      }
+      foreach($tmp as $kernel){
+        if(empty($kernel)) continue;
+        $this->cache['KERNELS'][$release][$kernel]=$kernel;
+      }
+      ksort($this->cache['KERNELS'][$release]);
     }
   }
 
@@ -1169,10 +1206,12 @@ class workstartup extends plugin
   function get_invalid_classes($classes)
   {
     $this->update_fai_cache();
-    if($this->FAIdebianMirror == "inherited"){
+    if($this->FAIdebianMirror == "inherited" && isset($this->cache['CLASSES'][$this->InheritedFAIrelease])){
       $release_classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
-    }else{
+    }elseif(isset($this->cache['CLASSES'][$this->FAIrelease])){
       $release_classes = $this->cache['CLASSES'][$this->FAIrelease];
+    }else{
+      $release_classes = array();
     }
 
 
@@ -1195,10 +1234,12 @@ class workstartup extends plugin
   {
     $this->update_fai_cache();
 
-    if($this->FAIdebianMirror == "inherited"){
+    if($this->FAIdebianMirror == "inherited" && isset($this->cache['CLASSES'][$this->InheritedFAIrelease])){
       $classes = $this->cache['CLASSES'][$this->InheritedFAIrelease];
-    }else{
+    }elseif(isset($this->cache['CLASSES'][$this->FAIrelease])){
       $classes = $this->cache['CLASSES'][$this->FAIrelease];
+    }else{
+      $classes = array();
     }
 
     $Abbr ="";
@@ -1223,46 +1264,40 @@ class workstartup extends plugin
    */
   function analyse_fai_object($attr)
   {
-    $tmp2 = array();
-    if(!isset($attr['description'])){
-      $attr['description'][0] ="";
-    }
-    if(in_array('FAIpackageList',$attr['objectClass'])){
-      $tmp2["Type"]   = 'FAIpackageList'; 
-      $tmp2["Abbr"]   = 'Pl';
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    if(in_array('FAItemplate',$attr['objectClass'])){
-      $tmp2["Type"]      = 'FAItemplate'; 
-      $tmp2["Abbr"]      = 'T'; 
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    if(in_array('FAIvariable',$attr['objectClass'])){
-      $tmp2["Type"]      = 'FAIvariable'; 
-      $tmp2["Abbr"]      = 'V'; 
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    if(in_array('FAIscript',$attr['objectClass'])){
-      $tmp2["Type"]        = 'FAIscript'; 
-      $tmp2["Abbr"]        = 'S'; 
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    if(in_array('FAIhook',$attr['objectClass'])){
-      $tmp2["Type"]          = 'FAIhook'; 
-      $tmp2["Abbr"]          = 'H'; 
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    if(in_array('FAIpartitionTable',$attr['objectClass'])){
-      $tmp2["Type"]= 'FAIpartitionTable'; 
-      $tmp2["Abbr"]= 'Pt'; 
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    if(in_array('FAIprofile',$attr['objectClass'])){
-      $tmp2["Type"]= 'FAIprofile'; 
-      $tmp2["Abbr"]= 'P'; 
-      $tmp2["Desc"]  = $attr['description'][0];
-    }
-    return($tmp2);
+    $tmp = array();
+    switch($attr['TYPE']){
+
+      case 'FAIpackageList':
+        $tmp["Type"]= 'FAIpackageList';
+        $tmp["Abbr"]= 'Pl';
+        break;
+      case 'FAItemplate': 
+        $tmp["Type"]= 'FAItemplate'; 
+        $tmp["Abbr"]= 'T'; 
+        break;
+      case 'FAIvariable':
+        $tmp["Type"]= 'FAIvariable'; 
+        $tmp["Abbr"]= 'V'; 
+        break;
+      case 'FAIscript':
+        $tmp["Type"]= 'FAIscript'; 
+        $tmp["Abbr"]= 'S'; 
+        break;
+      case 'FAIhook':
+        $tmp["Type"]= 'FAIhook'; 
+        $tmp["Abbr"]= 'H'; 
+        break;
+      case 'FAIpartitionTable':
+        $tmp["Type"]= 'FAIpartitionTable'; 
+        $tmp["Abbr"]= 'Pt'; 
+        break;
+      case 'FAIprofile':
+        $tmp["Type"]= 'FAIprofile'; 
+        $tmp["Abbr"]= 'P'; 
+        break;
+      default: trigger_error("Unknown FAI object type!");;
+    }
+    return($tmp);
   }
 
 
@@ -1271,14 +1306,14 @@ class workstartup extends plugin
   function GetHookElements()
   {
     $ret = array();
-    $cmd= $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs'));
+    $cmd= $this->config->search("servrepository", "repositoryBranchHook",array('tabs'));
     if(!empty($cmd)){
       $res = shell_exec($cmd);
       $res2 = trim($res);
       if((!$res)){
-        msg_dialog(_("Configuration error"), msgPool::cmdexecfailed("REPOSITORY_HOOK", $cmd), ERROR_DIALOG);
+        msg_dialog::display(_("Configuration error"), msgPool::cmdexecfailed("repositoryBranchHook", $cmd), ERROR_DIALOG);
       }elseif(empty($res2)){
-        msg_dialog(_("Configuration error"), _("REPOSITORY_HOOK returned empty result!"), ERROR_DIALOG);
+        msg_dialog::display(_("Configuration error"), _("repositoryBranchHook returned no result!"), ERROR_DIALOG);
       }else{
         $tmp = split("\n",$res);
         foreach($tmp as $line){