| | |
| | | } |
| | | |
| | | $this->memcache = new Memcache; |
| | | $mc_available = 0; |
| | | $this->mc_available = 0; |
| | | |
| | | // add alll configured hosts to pool |
| | | $pconnect = $this->config->get('memcache_pconnect', true); |
| | | foreach ($this->config->get('memcache_hosts', array()) as $host) { |
| | | list($host, $port) = explode(':', $host); |
| | | if (!$port) $port = 11211; |
| | | // add server and attempt to connect if not already done yet |
| | | if ($this->memcache->addServer($host, $port) && !$mc_available) |
| | | $mc_available += intval($this->memcache->connect($host, $port)); |
| | | $this->mc_available += intval($this->memcache->addServer($host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure'))); |
| | | } |
| | | |
| | | // test connection and failover (will result in $this->mc_available == 0 on complete failure) |
| | | $this->memcache->increment('__CONNECTIONTEST__', 1); // NOP if key doesn't exist |
| | | |
| | | if (!$mc_available) |
| | | if (!$this->mc_available) |
| | | $this->memcache = false; |
| | | } |
| | | |
| | | return $this->memcache; |
| | | } |
| | | |
| | | /** |
| | | * Callback for memcache failure |
| | | */ |
| | | public function memcache_failure($host, $port) |
| | | { |
| | | static $seen = array(); |
| | | |
| | | // only report once |
| | | if (!$seen["$host:$port"]++) { |
| | | $this->mc_available--; |
| | | raise_error(array('code' => 604, 'type' => 'db', |
| | | 'line' => __LINE__, 'file' => __FILE__, |
| | | 'message' => "Memcache failure on host $host:$port"), |
| | | true, false); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | 'name' => rcube_label('personaladrbook'), |
| | | 'groups' => $this->address_books['0']->groups, |
| | | 'readonly' => $this->address_books['0']->readonly, |
| | | 'autocomplete' => in_array('sql', $autocomplete) |
| | | 'autocomplete' => in_array('sql', $autocomplete), |
| | | 'undelete' => $this->address_books['0']->undelete && $this->config->get('undo_timeout'), |
| | | ); |
| | | } |
| | | |
| | |
| | | // Setting root and delimiter before establishing the connection |
| | | // can save time detecting them using NAMESPACE and LIST |
| | | $options = array( |
| | | 'auth_method' => $this->config->get('imap_auth_type', 'check'), |
| | | 'auth_type' => $this->config->get('imap_auth_type', 'check'), |
| | | 'auth_cid' => $this->config->get('imap_auth_cid'), |
| | | 'auth_pw' => $this->config->get('imap_auth_pw'), |
| | | 'debug' => (bool) $this->config->get('imap_debug', 0), |
| | |
| | | else if ($config['auto_create_user']) { |
| | | if ($created = rcube_user::create($username, $host)) { |
| | | $user = $created; |
| | | |
| | | // fix default settings according to namespace prefix |
| | | $this->fix_namespace_settings($user); |
| | | |
| | | // create default folders on first login |
| | | if ($config['create_default_folders']) |
| | | $this->imap->create_default_folders(); |
| | |
| | | /** |
| | | * Get localized text in the desired language |
| | | * |
| | | * @param mixed Named parameters array or label name |
| | | * @param mixed $attrib Named parameters array or label name |
| | | * @param string $domain Label domain (plugin) name |
| | | * |
| | | * @return string Localized text |
| | | */ |
| | | public function gettext($attrib, $domain=null) |
| | |
| | | |
| | | $nr = is_numeric($attrib['nr']) ? $attrib['nr'] : 1; |
| | | $name = $attrib['name'] ? $attrib['name'] : ''; |
| | | |
| | | |
| | | // attrib contain text values: use them from now |
| | | if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us'])) |
| | | $this->texts[$name] = $setval; |
| | |
| | | |
| | | |
| | | /** |
| | | * Check if the given text lable exists |
| | | * Check if the given text label exists |
| | | * |
| | | * @param string Label name |
| | | * @param string $name Label name |
| | | * @param string $domain Label domain (plugin) name or '*' for all domains |
| | | * @param string $ref_domain Sets domain name if label is found |
| | | * |
| | | * @return boolean True if text exists (either in the current language or in en_US) |
| | | */ |
| | | public function text_exists($name, $domain=null) |
| | | public function text_exists($name, $domain = null, &$ref_domain = null) |
| | | { |
| | | // load localization files if not done yet |
| | | if (empty($this->texts)) |
| | | $this->load_language(); |
| | | |
| | | // check for text with domain first |
| | | return ($domain && isset($this->texts[$domain.'.'.$name])) || isset($this->texts[$name]); |
| | | if (isset($this->texts[$name])) { |
| | | $ref_domain = ''; |
| | | return true; |
| | | } |
| | | |
| | | // any of loaded domains (plugins) |
| | | if ($domain == '*') { |
| | | foreach ($this->plugins->loaded_plugins() as $domain) |
| | | if (isset($this->texts[$domain.'.'.$name])) { |
| | | $ref_domain = $domain; |
| | | return true; |
| | | } |
| | | } |
| | | // specified domain |
| | | else if ($domain) { |
| | | $ref_domain = $domain; |
| | | return isset($this->texts[$domain.'.'.$name]); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /** |