diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index 3ea62e115..bb036d6b3 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -236,6 +236,8 @@ $rcmail_config['address_book_type'] = 'sql'; // In order to enable public ldap search, configure an array like the Verisign // example further below. if you would like to test, simply uncomment the example. +$rcmail_config['ldap_public'] = array(); + // // If you are going to use LDAP for individual address books, you will need to // set 'user_specific' to true and use the variables to generate the appropriate DNs to access it. diff --git a/installer/rcube_install.php b/installer/rcube_install.php index 4bef17eb2..96134d2b9 100644 --- a/installer/rcube_install.php +++ b/installer/rcube_install.php @@ -43,11 +43,12 @@ class rcube_install // these config options are optional or can be set to null var $optional_config = array( 'log_driver', 'syslog_id', 'syslog_facility', 'imap_auth_type', - 'smtp_helo_host', 'sendmail_delay', 'double_auth', 'language', - 'mail_header_delimiter', 'create_default_folders', + 'smtp_helo_host', 'smtp_auth_type', 'sendmail_delay', 'double_auth', + 'language', 'mail_header_delimiter', 'create_default_folders', 'quota_zero_as_unlimited', 'spellcheck_uri', 'spellcheck_languages', 'http_received_header', 'session_domain', 'mime_magic', 'log_logins', - 'enable_installer', 'skin_include_php'); + 'enable_installer', 'skin_include_php', 'imap_root', 'imap_delimiter', + 'virtuser_file', 'virtuser_query', 'dont_override'); /** * Constructor @@ -192,7 +193,7 @@ class rcube_install // replace the matching line in config file $out = preg_replace( '/(\$rcmail_config\[\''.preg_quote($prop).'\'\])\s+=\s+(.+);/Uie', - "'\\1 = ' . var_export(\$value, true) . ';'", + "'\\1 = ' . rcube_install::_dump_var(\$value) . ';'", $out); } @@ -258,7 +259,16 @@ class rcube_install $out['dependencies'][] = array('prop' => 'syslog_id', 'explain' => 'Using syslog for logging requires a syslog ID to be configured'); } - + } + + // check ldap_public sources having global_search enabled + if (is_array($this->config['ldap_public']) && !is_array($this->config['autocomplete_addressbooks'])) { + foreach ($this->config['ldap_public'] as $ldap_public) { + if ($ldap_public['global_search']) { + $out['replaced'][] = array('prop' => 'ldap_public::global_search', 'replacement' => 'autocomplete_addressbooks'); + break; + } + } } return $out; @@ -291,7 +301,21 @@ class rcube_install unset($current[$prop]); } - $this->config = array_merge($current, $this->config); + // add all ldap_public sources having global_search enabled to autocomplete_addressbooks + if (is_array($current['ldap_public'])) { + foreach ($current['ldap_public'] as $key => $ldap_public) { + if ($ldap_public['global_search']) { + $this->config['autocomplete_addressbooks'][] = $key; + unset($current['ldap_public'][$key]['global_search']); + } + } + } + + $this->config = array_merge($this->config, $current); + + foreach ((array)$current['ldap_public'] as $key => $values) { + $this->config['ldap_public'][$key] = $current['ldap_public'][$key]; + } } @@ -457,18 +481,46 @@ class rcube_install } - function _clean_array($arr) + static function _clean_array($arr) { $out = array(); - foreach (array_unique($arr) as $i => $val) - if (!empty($val)) - $out[] = $val; + foreach (array_unique($arr) as $k => $val) { + if (!empty($val)) { + if (is_numeric($k)) + $out[] = $val; + else + $out[$k] = $val; + } + } return $out; } + static function _dump_var($var) { + if (is_array($var)) { + if (empty($var)) { + return 'array()'; + } + else { // check if all keys are numeric + $isnum = true; + foreach ($var as $key => $value) { + if (!is_numeric($key)) { + $isnum = false; + break; + } + } + + if ($isnum) + return 'array(' . join(', ', array_map(array('rcube_install', '_dump_var'), $var)) . ')'; + } + } + + return var_export($var, true); + } + + /** * Initialize the database with the according schema *