Example #1
0
 /**
  * Sets delimiter and namespaces
  */
 protected function set_env()
 {
     if ($this->delimiter !== null && $this->namespace !== null) {
         return;
     }
     $config = rcube::get_instance()->config;
     $imap_personal = $config->get('imap_ns_personal');
     $imap_other = $config->get('imap_ns_other');
     $imap_shared = $config->get('imap_ns_shared');
     $imap_delimiter = $config->get('imap_delimiter');
     if (!$this->check_connection()) {
         return;
     }
     $ns = $this->conn->getNamespace();
     // Set namespaces (NAMESPACE supported)
     if (is_array($ns)) {
         $this->namespace = $ns;
     } else {
         $this->namespace = array('personal' => NULL, 'other' => NULL, 'shared' => NULL);
     }
     if ($imap_delimiter) {
         $this->delimiter = $imap_delimiter;
     }
     if (empty($this->delimiter)) {
         $this->delimiter = $this->namespace['personal'][0][1];
     }
     if (empty($this->delimiter)) {
         $this->delimiter = $this->conn->getHierarchyDelimiter();
     }
     if (empty($this->delimiter)) {
         $this->delimiter = '/';
     }
     // Overwrite namespaces
     if ($imap_personal !== null) {
         $this->namespace['personal'] = NULL;
         foreach ((array) $imap_personal as $dir) {
             $this->namespace['personal'][] = array($dir, $this->delimiter);
         }
     }
     if ($imap_other !== null) {
         $this->namespace['other'] = NULL;
         foreach ((array) $imap_other as $dir) {
             if ($dir) {
                 $this->namespace['other'][] = array($dir, $this->delimiter);
             }
         }
     }
     if ($imap_shared !== null) {
         $this->namespace['shared'] = NULL;
         foreach ((array) $imap_shared as $dir) {
             if ($dir) {
                 $this->namespace['shared'][] = array($dir, $this->delimiter);
             }
         }
     }
     // Find personal namespace prefix(es) for self::mod_folder()
     if (is_array($this->namespace['personal']) && !empty($this->namespace['personal'])) {
         // There can be more than one namespace root,
         // - for prefix_out get the first one but only
         //   if there is only one root
         // - for prefix_in get the first one but only
         //   if there is no non-prefixed namespace root (#5403)
         $roots = array();
         foreach ($this->namespace['personal'] as $ns) {
             $roots[] = $ns[0];
         }
         if (!in_array('', $roots)) {
             $this->namespace['prefix_in'] = $roots[0];
         }
         if (count($roots) == 1) {
             $this->namespace['prefix_out'] = $roots[0];
         }
     }
     $_SESSION['imap_namespace'] = $this->namespace;
     $_SESSION['imap_delimiter'] = $this->delimiter;
 }
Example #2
0
 /**
  * Sets delimiter and namespaces
  */
 protected function set_env()
 {
     if ($this->delimiter !== null && $this->namespace !== null) {
         return;
     }
     $config = rcube::get_instance()->config;
     $imap_personal = $config->get('imap_ns_personal');
     $imap_other = $config->get('imap_ns_other');
     $imap_shared = $config->get('imap_ns_shared');
     $imap_delimiter = $config->get('imap_delimiter');
     if (!$this->check_connection()) {
         return;
     }
     $ns = $this->conn->getNamespace();
     // Set namespaces (NAMESPACE supported)
     if (is_array($ns)) {
         $this->namespace = $ns;
     } else {
         $this->namespace = array('personal' => NULL, 'other' => NULL, 'shared' => NULL);
     }
     if ($imap_delimiter) {
         $this->delimiter = $imap_delimiter;
     }
     if (empty($this->delimiter)) {
         $this->delimiter = $this->namespace['personal'][0][1];
     }
     if (empty($this->delimiter)) {
         $this->delimiter = $this->conn->getHierarchyDelimiter();
     }
     if (empty($this->delimiter)) {
         $this->delimiter = '/';
     }
     // Overwrite namespaces
     if ($imap_personal !== null) {
         $this->namespace['personal'] = NULL;
         foreach ((array) $imap_personal as $dir) {
             $this->namespace['personal'][] = array($dir, $this->delimiter);
         }
     }
     if ($imap_other !== null) {
         $this->namespace['other'] = NULL;
         foreach ((array) $imap_other as $dir) {
             if ($dir) {
                 $this->namespace['other'][] = array($dir, $this->delimiter);
             }
         }
     }
     if ($imap_shared !== null) {
         $this->namespace['shared'] = NULL;
         foreach ((array) $imap_shared as $dir) {
             if ($dir) {
                 $this->namespace['shared'][] = array($dir, $this->delimiter);
             }
         }
     }
     // Find personal namespace prefix for mod_folder()
     // Prefix can be removed when there is only one personal namespace
     if (is_array($this->namespace['personal']) && count($this->namespace['personal']) == 1) {
         $this->namespace['prefix'] = $this->namespace['personal'][0][0];
     }
     $_SESSION['imap_namespace'] = $this->namespace;
     $_SESSION['imap_delimiter'] = $this->delimiter;
 }
Example #3
0
 /**
  * Sets delimiter and namespaces
  *
  * @access private
  */
 private function set_env()
 {
     if ($this->delimiter !== null && $this->namespace !== null) {
         return;
     }
     if (isset($_SESSION['imap_namespace']) && isset($_SESSION['imap_delimiter'])) {
         $this->namespace = $_SESSION['imap_namespace'];
         $this->delimiter = $_SESSION['imap_delimiter'];
         return;
     }
     $config = rcmail::get_instance()->config;
     $imap_personal = $config->get('imap_ns_personal');
     $imap_other = $config->get('imap_ns_other');
     $imap_shared = $config->get('imap_ns_shared');
     $imap_delimiter = $config->get('imap_delimiter');
     if (!$this->conn->connected()) {
         return;
     }
     $ns = $this->conn->getNamespace();
     // Set namespaces (NAMESPACE supported)
     if (is_array($ns)) {
         $this->namespace = $ns;
     } else {
         $this->namespace = array('personal' => NULL, 'other' => NULL, 'shared' => NULL);
     }
     if ($imap_delimiter) {
         $this->delimiter = $imap_delimiter;
     }
     if (empty($this->delimiter)) {
         $this->delimiter = $this->namespace['personal'][0][1];
     }
     if (empty($this->delimiter)) {
         $this->delimiter = $this->conn->getHierarchyDelimiter();
     }
     if (empty($this->delimiter)) {
         $this->delimiter = '/';
     }
     // Overwrite namespaces
     if ($imap_personal !== null) {
         $this->namespace['personal'] = NULL;
         foreach ((array) $imap_personal as $dir) {
             $this->namespace['personal'][] = array($dir, $this->delimiter);
         }
     }
     if ($imap_other !== null) {
         $this->namespace['other'] = NULL;
         foreach ((array) $imap_other as $dir) {
             if ($dir) {
                 $this->namespace['other'][] = array($dir, $this->delimiter);
             }
         }
     }
     if ($imap_shared !== null) {
         $this->namespace['shared'] = NULL;
         foreach ((array) $imap_shared as $dir) {
             if ($dir) {
                 $this->namespace['shared'][] = array($dir, $this->delimiter);
             }
         }
     }
     $_SESSION['imap_namespace'] = $this->namespace;
     $_SESSION['imap_delimiter'] = $this->delimiter;
 }