Code

Fixed mail server detection
[gosa.git] / include / class_config.inc
index a60ae8e243ce2ccc5f85fdd7334e7ccf0a810c9f..d19adba6f2855806083654d8fdd9176affa177fd 100644 (file)
@@ -327,33 +327,19 @@ class config  {
     $ldap= $this->get_ldap_link();
     $ldap->cd ($this->current['BASE']);
     if (!isset($this->current['MAILMETHOD'])){
-       $this->current['MAILMETHOD']= "";
-    }
-    if ($this->current['MAILMETHOD'] == ""){
-           $ldap->search ("(objectClass=goMailServer)", array('cn'));
-           $this->data['SERVERS']['IMAP']= array();
-           error_reporting(0);
-           while ($attrs= $ldap->fetch()){
-             $name= $attrs['cn'][0];
-             $this->data['SERVERS']['IMAP'][$name]= $name;
-           }
-           error_reporting(E_ALL);
-    } else {
-           $ldap->search ("(objectClass=goImapServer)", array('goImapName', 'goImapConnect', 'goImapAdmin', 'goImapPassword',
-                                                              'goImapSieveServer', 'goImapSievePort'));
-
-           $this->data['SERVERS']['IMAP']= array();
-           error_reporting(0);
-           while ($attrs= $ldap->fetch()){
-             $name= $attrs['goImapName'][0];
-             $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0],
-                 "admin" => $attrs['goImapAdmin'][0],
-                 "password" => $attrs['goImapPassword'][0],
-                 "sieve_server" => $attrs['goImapSieveServer'][0],
-                 "sieve_port" => $attrs['goImapSievePort'][0]);
-           }
-           error_reporting(E_ALL);
+       $this->current['MAILMETHOD']= "";
     }
+    $this->data['SERVERS']['IMAP']= array();
+    $old_err = error_reporting(0);
+    while ($attrs= $ldap->fetch()){
+      $name= $attrs['goImapName'][0];
+      $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0],
+          "admin" => $attrs['goImapAdmin'][0],
+          "password" => $attrs['goImapPassword'][0],
+          "sieve_server" => $attrs['goImapSieveServer'][0],
+          "sieve_port" => $attrs['goImapSievePort'][0]);
+    }
+    error_reporting($old_err);
 
     /* Get kerberos server. FIXME: only one is supported currently */
     $ldap->cd ($this->current['BASE']);