Пример #1
0
 /**
  * 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->imap->skip_deleted = $this->config->get('skip_deleted');
     // enable caching of imap data
     $imap_cache = $this->config->get('imap_cache');
     $messages_cache = $this->config->get('messages_cache');
     // for backward compatybility
     if ($imap_cache === null && $messages_cache === null && $this->config->get('enable_caching')) {
         $imap_cache = 'db';
         $messages_cache = true;
     }
     if ($imap_cache) {
         $this->imap->set_caching($imap_cache);
     }
     if ($messages_cache) {
         $this->imap->set_messages_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_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), '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);
     }
 }