Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_workstationStartup.inc
index c74b3761756fbcaf2b61f97a87b7863152e3aa42..59582f76dc5a0c750d1d06fc90a8dfbc7d3fc564 100644 (file)
@@ -1,11 +1,6 @@
 <?php
 class workstartup extends plugin
 {
-  /* CLI vars */
-  var $cli_summary= "Manage terminal startup options";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* Ldap server list */
   var $gotoLdapServers    = array();
   var $gotoLdapServerList = array();
@@ -853,6 +848,11 @@ 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%")){
       $this->attrs['gotoBootKernel']= array();
     }
@@ -893,8 +893,26 @@ class workstartup extends plugin
     $ldap->modify ($this->attrs); 
     new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/startup with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+    }
     $this->handle_post_events("modify");
+
+    /* Check if LDAP server has changed */
+    if ($ldap_changed && class_available("DaemonEvent")){
+      $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(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+                $o_queue->get_error()),ERROR_DIALOG);
+        }
+      }
+    }
   }
 
 
@@ -1009,9 +1027,10 @@ class workstartup extends plugin
     if($force || !isset($this->cache['SERVERS'])){
       $ldap = $this->config->get_ldap_link();
       $ldap->cd($this->config->current['BASE']);
-      $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("FAIrepository"));
-      $this->cache['SERVERS'] = array();
 
+      $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){
@@ -1023,7 +1042,7 @@ class workstartup extends plugin
       $this->cache['SERVERS']['auto'] = array();
       $sort_by = array("auto");
       $server_tmp = array("auto"=>array());
-      while($attr = $ldap->fetch()){
+      foreach($server_list as $attr){
         if(isset($attr['FAIrepository'])){
           for($i = 0 ; $i < $attr['FAIrepository']['count'] ; $i ++ ){
             $rep = $attr['FAIrepository'][$i];
@@ -1082,10 +1101,11 @@ class workstartup extends plugin
       if($force || !isset($this->cache['RELEASE_DNS'])){
         $this->cache['RELEASE_DNS'] = array();
         $fai_ou_parts = preg_replace("/\/.*$/","",$this->FAIrelease);
-        $ldap = $this->config->get_ldap_link();
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->search("(objectClass=FAIbranch)",array("ou"));
-        while($attrs = $ldap->fetch()){
+
+        $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']);
           }