/** * get config for type IMAP/SMTP * * @param string $_configType * @return array */ public static function getConfig($_configType) { if (!isset(self::$_configs[$_configType])) { self::$_configs[$_configType] = Tinebase_Config::getInstance()->get($_configType, new Tinebase_Config_Struct())->toArray(); /* * If LDAP-Url is given (instead of comma separated domains) add secondary domains from LDAP * e.g. ldap://localhost/ou=domains,ou=mailConfig,dc=example,dc=com?dc?sub?objectclass=mailDomain */ if ($_configType == Tinebase_Config::SMTP && array_key_exists('secondarydomains', self::$_configs[Tinebase_Config::SMTP]) && preg_match("~^ldaps?://~i", self::$_configs[Tinebase_Config::SMTP]['secondarydomains'])) { $ldap_url = parse_url(self::$_configs[Tinebase_Config::SMTP]['secondarydomains']); $ldap_url['path'] = substr($ldap_url['path'], 1); $query = explode('?', $ldap_url['query']); count($query) > 0 ? $ldap_url['attributes'] = explode(',', $query[0]) : ($ldap_url['attributes'] = array()); $ldap_url['scope'] = Zend_Ldap::SEARCH_SCOPE_BASE; if (count($query) > 1) { switch ($query[1]) { case 'subtree': case 'sub': $ldap_url['scope'] = Zend_Ldap::SEARCH_SCOPE_SUB; break; case 'one': $ldap_url['scope'] = Zend_Ldap::SEARCH_SCOPE_ONE; break; } } count($query) > 2 ? $ldap_url['filter'] = $query[2] : ($ldap_url['filter'] = 'objectClass=*'); // By now your options are limited to configured server $ldap = new Tinebase_Ldap(Tinebase_User::getBackendConfiguration()); $ldap->connect()->bind(); $secondarydomains = $ldap->searchEntries($ldap_url['filter'], $ldap_url['path'], $ldap_url['scope'], $ldap_url['attributes']); self::$_configs[Tinebase_Config::SMTP]['secondarydomains'] = ''; foreach ($secondarydomains as $dn) { foreach ($ldap_url['attributes'] as $attr) { if (array_key_exists($attr, $dn)) { foreach ($dn[$attr] as $domain) { self::$_configs[Tinebase_Config::SMTP]['secondarydomains'] != '' ? $domain = ',' . $domain : $domain; self::$_configs[Tinebase_Config::SMTP]['secondarydomains'] .= $domain; } } } } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Secondarydomains: ' . print_r(self::$_configs[Tinebase_Config::SMTP]['secondarydomains'], true)); } } } return self::$_configs[$_configType]; }