/** * Create global IMAP object and connect to server * * @param boolean True if connection should be established * @todo Remove global $IMAP */ public function imap_init($connect = false) { // already initialized if (is_object($this->imap)) { return; } $this->imap = new rcube_imap($this->db); $this->imap->debug_level = $this->config->get('debug_level'); $this->imap->skip_deleted = $this->config->get('skip_deleted'); // enable caching of imap data if ($this->config->get('enable_caching')) { $this->imap->set_caching(true); } // set pagesize from config $this->imap->set_pagesize($this->config->get('pagesize', 50)); // 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_cid' => $this->config->get('imap_auth_cid'), 'auth_pw' => $this->config->get('imap_auth_pw'), 'debug' => (bool) $this->config->get('imap_debug', 0), 'force_caps' => (bool) $this->config->get('imap_force_caps'), 'timeout' => (int) $this->config->get('imap_timeout', 0)); $this->imap->set_options($options); // set global object for backward compatibility $GLOBALS['IMAP'] = $this->imap; $hook = $this->plugins->exec_hook('imap_init', array('fetch_headers' => $this->imap->fetch_add_headers)); if ($hook['fetch_headers']) { $this->imap->fetch_add_headers = $hook['fetch_headers']; } // support this parameter for backward compatibility but log warning if ($connect) { $this->imap_connect(); raise_error(array('code' => 800, 'type' => 'imap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "rcube::imap_init(true) is deprecated, use rcube::imap_connect() instead"), true, false); } }