Changeset 5759 in subversion


Ignore:
Timestamp:
Jan 12, 2012 8:57:08 AM (17 months ago)
Author:
alec
Message:
  • Added storage (IMAP) auto-connection feature = improved performance with caching enabled
  • Fixed imap configuration handling, broken in last commit
  • Some CS fixes
Location:
branches/devel-framework/roundcubemail
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-framework/roundcubemail/index.php

    r5758 r5759  
    131131    $error_code = is_object($RCMAIL->storage) ? $RCMAIL->storage->get_error_code() : 1; 
    132132 
    133     $OUTPUT->show_message($error_code < -1 ? 'imaperror' : (!$auth['valid'] ? 'invalidrequest' : 'loginfailed'), 'warning'); 
     133    $OUTPUT->show_message($error_code < -1 ? 'storageerror' : (!$auth['valid'] ? 'invalidrequest' : 'loginfailed'), 'warning'); 
    134134    $RCMAIL->plugins->exec_hook('login_failed', array( 
    135135      'code' => $error_code, 'host' => $auth['host'], 'user' => $auth['user'])); 
  • branches/devel-framework/roundcubemail/program/include/main.inc

    r5758 r5759  
    15951595    $res_code = $RCMAIL->storage->get_response_code(); 
    15961596 
    1597     if ($res_code == rcube_storage::NOPERM) { 
     1597    if ($err_code < 0) { 
     1598        $RCMAIL->output->show_message('storageerror', 'error'); 
     1599    } 
     1600    else if ($res_code == rcube_storage::NOPERM) { 
    15981601        $RCMAIL->output->show_message('errornoperm', 'error'); 
    15991602    } 
  • branches/devel-framework/roundcubemail/program/include/rcmail.php

    r5758 r5759  
    605605 
    606606    $driver = $this->config->get('storage_driver', 'imap'); 
    607     $driver_class = "rcube_$driver"; 
     607    $driver_class = "rcube_{$driver}"; 
    608608 
    609609    if (!class_exists($driver_class)) { 
     
    619619 
    620620    // enable caching of mail data 
    621     $storage_cache  = $this->config->get("$driver_cache"); 
     621    $storage_cache  = $this->config->get("{$driver}_cache"); 
    622622    $messages_cache = $this->config->get('messages_cache'); 
    623623    // for backward compatybility 
     
    641641    // set class options 
    642642    $options = array( 
    643       'auth_type'   => $this->config->get("$driver_auth_type", 'check'), 
    644       'auth_cid'    => $this->config->get("$driver_auth_cid"), 
    645       'auth_pw'     => $this->config->get("$driver_auth_pw"), 
    646       'debug'       => (bool) $this->config->get("$driver_debug", 0), 
    647       'force_caps'  => (bool) $this->config->get("$driver_force_caps"), 
    648       'timeout'     => (int) $this->config->get("$driver_timeout", 0), 
     643      'auth_type'   => $this->config->get("{$driver}_auth_type", 'check'), 
     644      'auth_cid'    => $this->config->get("{$driver}_auth_cid"), 
     645      'auth_pw'     => $this->config->get("{$driver}_auth_pw"), 
     646      'debug'       => (bool) $this->config->get("{$driver}_debug"), 
     647      'force_caps'  => (bool) $this->config->get("{$driver}_force_caps"), 
     648      'timeout'     => (int) $this->config->get("{$driver}_timeout"), 
    649649      'skip_deleted' => (bool) $this->config->get('skip_deleted'), 
    650650    ); 
    651651 
    652     $hook = $this->plugins->exec_hook("$driver_init", $options); 
     652    if (!empty($_SESSION['storage_host'])) { 
     653      $options['host']     = $_SESSION['storage_host']; 
     654      $options['user']     = $_SESSION['username']; 
     655      $options['port']     = $_SESSION['storage_port']; 
     656      $options['ssl']      = $_SESSION['storage_ssl']; 
     657      $options['password'] = $this->decrypt($_SESSION['password']); 
     658    } 
     659 
     660    $hook = $this->plugins->exec_hook("{$driver}_init", $options); 
    653661 
    654662    $this->storage->set_options($options); 
     
    675683      if (!$storage->connect($host, $user, $pass, $port, $ssl)) { 
    676684        if ($this->output) 
    677           $this->output->show_message($storage->get_error_code() == -1 ? 'imaperror' : 'sessionerror', 'error'); 
     685          $this->output->show_message($storage->get_error_code() == -1 ? 'storageerror' : 'sessionerror', 'error'); 
    678686      } 
    679687      else { 
  • branches/devel-framework/roundcubemail/program/include/rcube_imap.php

    r5758 r5759  
    7676    protected $search_sorted = false; 
    7777    protected $options = array('auth_method' => 'check'); 
    78     protected $host, $user, $pass, $port, $ssl; 
    7978    protected $caching = false; 
    8079    protected $messages_caching = false; 
     
    124123 
    125124        if ($this->options['debug']) { 
    126             $this->conn->setDebug(true, array($this, 'debug_handler')); 
     125            $this->set_debug(true); 
    127126 
    128127            $this->options['ident'] = array( 
     
    147146        } while(!$this->conn->connected() && $data['retry']); 
    148147 
    149         $this->host = $data['host']; 
    150         $this->user = $data['user']; 
    151         $this->pass = $pass; 
    152         $this->port = $port; 
    153         $this->ssl  = $use_ssl; 
     148        $config = array( 
     149            'host'     => $data['host'], 
     150            'user'     => $data['user'], 
     151            'password' => $pass, 
     152            'port'     => $port, 
     153            'ssl'      => $use_ssl, 
     154        ); 
     155 
     156        $this->options      = array_merge($this->options, $config); 
     157        $this->connect_done = true; 
    154158 
    155159        if ($this->conn->connected()) { 
     
    181185    { 
    182186        $this->conn->closeConnection(); 
    183         if ($this->mcache) 
     187        if ($this->mcache) { 
    184188            $this->mcache->close(); 
     189        } 
     190    } 
     191 
     192 
     193    /** 
     194     * Check connection state, connect if not connected. 
     195     */ 
     196    public function check_connection() 
     197    { 
     198        // Establish connection if it wasn't done yet 
     199        if (!$this->connect_done && !empty($this->options['user'])) { 
     200            return $this->connect( 
     201                $this->options['host'], 
     202                $this->options['user'], 
     203                $this->options['password'], 
     204                $this->options['port'], 
     205                $this->options['ssl'] 
     206            ); 
     207        } 
     208 
     209        return $this->is_connected(); 
    185210    } 
    186211 
     
    193218    public function is_connected() 
    194219    { 
    195         return $this->conn && $this->conn->connected(); 
     220        return $this->conn->connected(); 
    196221    } 
    197222 
     
    332357    public function get_capability($cap) 
    333358    { 
     359        if (!$this->check_connection()) { 
     360            return false; 
     361        } 
     362 
     363        // @TODO: cache capabilities or store in session (?) 
    334364        return $this->conn->getCapability(strtoupper($cap)); 
    335365    } 
     
    348378        $flag = strtoupper($flag); 
    349379        $imap_flag = $this->conn->flags[$flag]; 
     380 
     381        if ($this->folder !== null) { 
     382            $this->check_connection(); 
     383        } 
     384        // @TODO: cache permanent flags (?) 
     385 
    350386        return (in_array_nocase($imap_flag, $this->conn->data['PERMANENTFLAGS'])); 
    351387    } 
     
    399435        $imap_delimiter = $config->get('imap_delimiter'); 
    400436 
    401         if (!$this->conn->connected()) 
     437        if (!$this->check_connection()) { 
    402438            return; 
     439        } 
    403440 
    404441        $ns = $this->conn->getNamespace(); 
     
    527564                $this->set_folder_stats($folder, 'maxuid', $msg_count ? $this->id2uid($msg_count, $folder) : 0); 
    528565            } 
     566        } 
     567        // Need connection here 
     568        else if (!$this->check_connection()) { 
     569            return 0; 
    529570        } 
    530571        // RECENT count is fetched a bit different 
     
    631672        // use saved message set 
    632673        if ($this->search_string && $folder == $this->folder) { 
    633             return $this->list_header_set($folder, $page, $slice); 
     674            return $this->list_search_messages($folder, $page, $slice); 
    634675        } 
    635676 
    636677        if ($this->threading) { 
    637             return $this->list_thread_headers($folder, $page, $slice); 
     678            return $this->list_thread_messages($folder, $page, $slice); 
    638679        } 
    639680 
     
    669710     * 
    670711     * @return  array    Indexed array with message header objects 
    671      * @see     rcube_imap::list_headers 
    672      */ 
    673     protected function list_thread_headers($folder, $page, $slice=0) 
     712     * @see     rcube_imap::list_messages 
     713     */ 
     714    protected function list_thread_messages($folder, $page, $slice=0) 
    674715    { 
    675716        // get all threads (not sorted) 
     
    698739 
    699740        if (empty($this->icache['threads'])) { 
     741            if (!$this->check_connection()) { 
     742                return new rcube_result_thread(); 
     743            } 
     744 
    700745            // get all threads 
    701746            $result = $this->conn->thread($folder, $this->threading, 
     
    789834     * @return  array    Indexed array with message header objects 
    790835     */ 
    791     protected function list_header_set($folder, $page, $slice=0) 
     836    protected function list_search_messages($folder, $page, $slice=0) 
    792837    { 
    793838        if (!strlen($folder) || empty($this->search_set) || $this->search_set->isEmpty()) { 
     
    797842        // use saved messages from searching 
    798843        if ($this->threading) { 
    799             return $this->list_thread_header_set($folder, $page, $slice); 
     844            return $this->list_search_thread_messages($folder, $page, $slice); 
    800845        } 
    801846 
     
    827872 
    828873                // return empty array if no messages found 
    829                 if ($index->isEmpty()) 
     874                if ($index->isEmpty()) { 
    830875                    return array(); 
     876                } 
    831877            } 
    832878        } 
     
    840886            $index->slice($from, $to-$from); 
    841887 
    842             if ($slice) 
     888            if ($slice) { 
    843889                $index->slice(-$slice, $slice); 
     890            } 
    844891 
    845892            // fetch headers 
     
    860907            $index->slice($start_msg, min($cnt-$from, $this->page_size)); 
    861908 
    862             if ($slice) 
     909            if ($slice) { 
    863910                $index->slice(-$slice, $slice); 
     911            } 
    864912 
    865913            // ...and fetch headers 
     
    875923 
    876924            // return empty array if no messages found 
    877             if (!is_array($a_msg_headers) || empty($a_msg_headers)) 
     925            if (!is_array($a_msg_headers) || empty($a_msg_headers)) { 
    878926                return array(); 
     927            } 
     928 
     929            if (!$this->check_connection()) { 
     930                return array(); 
     931            } 
    879932 
    880933            // if not already sorted 
     
    902955     * 
    903956     * @return  array    Indexed array with message header objects 
    904      * @see rcube_imap::list_header_set() 
    905      */ 
    906     protected function list_thread_header_set($folder, $page, $slice=0) 
     957     * @see rcube_imap::list_search_messages() 
     958     */ 
     959    protected function list_search_thread_messages($folder, $page, $slice=0) 
    907960    { 
    908961        // update search_set if previous data was fetched with disabled threading 
     
    934987        if (!$force && ($mcache = $this->get_mcache_engine())) { 
    935988            $headers = $mcache->get_messages($folder, $msgs); 
     989        } 
     990        else if (!$this->check_connection()) { 
     991            return array(); 
    936992        } 
    937993        else { 
     
    10421098    public function index($folder = '', $sort_field = NULL, $sort_order = NULL) 
    10431099    { 
    1044         if ($this->threading) 
     1100        if ($this->threading) { 
    10451101            return $this->thread_index($folder, $sort_field, $sort_order); 
     1102        } 
    10461103 
    10471104        $this->set_sort_order($sort_field, $sort_order); 
     
    10641121                $index = $this->search_set; 
    10651122            } 
     1123            else if (!$this->check_connection()) { 
     1124                return new rcube_result_index(); 
     1125            } 
    10661126            else { 
    10671127                $index = $this->conn->index($folder, $this->search_set->get(), 
     
    11131173                $index = $this->icache['undeleted_idx']; 
    11141174            } 
     1175            else if (!$this->check_connection()) { 
     1176                return new rcube_result_index(); 
     1177            } 
    11151178            else { 
    11161179                $index = $this->conn->search($folder, 
    11171180                    'ALL' .($this->options['skip_deleted'] ? ' UNDELETED' : ''), true); 
    11181181            } 
     1182        } 
     1183        else if (!$this->check_connection()) { 
     1184            return new rcube_result_index(); 
    11191185        } 
    11201186        // fetch complete message index 
     
    12451311        } 
    12461312 
     1313        if (!$this->check_connection()) { 
     1314            return new rcube_result_index(); 
     1315        } 
     1316 
    12471317        $index = $this->conn->search($mailbox, $str, true); 
    12481318 
     
    12661336        $orig_criteria = $criteria; 
    12671337 
    1268         if ($this->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) 
     1338        if (!$this->check_connection()) { 
     1339            if ($this->threading) { 
     1340                return new rcube_result_thread(); 
     1341            } 
     1342            else { 
     1343                return new rcube_result_index(); 
     1344            } 
     1345        } 
     1346 
     1347        if ($this->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) { 
    12691348            $criteria = 'UNDELETED '.$criteria; 
     1349        } 
    12701350 
    12711351        if ($this->threading) { 
     
    13781458            $headers = $mcache->get_message($folder, $uid); 
    13791459        } 
     1460        else if (!$this->check_connection()) { 
     1461            $headers = false; 
     1462        } 
    13801463        else { 
    13811464            $headers = $this->conn->fetchHeader( 
     
    14161499 
    14171500        // structure might be cached 
    1418         if (!empty($headers->structure)) 
     1501        if (!empty($headers->structure)) { 
    14191502            return $headers; 
     1503        } 
    14201504 
    14211505        $this->msg_uid = $uid; 
     1506 
     1507        if (!$this->check_connection()) { 
     1508            return $headers; 
     1509        } 
    14221510 
    14231511        if (empty($headers->bodystructure)) { 
     
    14271515        $structure = $headers->bodystructure; 
    14281516 
    1429         if (empty($structure)) 
     1517        if (empty($structure)) { 
    14301518            return $headers; 
     1519        } 
    14311520 
    14321521        // set message charset from message headers 
     
    18231912    public function get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false) 
    18241913    { 
     1914        if (!$this->check_connection()) { 
     1915            return null; 
     1916        } 
     1917 
    18251918        // get part data if not provided 
    18261919        if (!is_object($o_part)) { 
     
    18771970    public function get_raw_body($uid, $fp=null) 
    18781971    { 
     1972        if (!$this->check_connection()) { 
     1973            return null; 
     1974        } 
     1975 
    18791976        return $this->conn->handlePartBody($this->folder, $uid, 
    18801977            true, null, null, false, $fp); 
     
    18911988    public function get_raw_headers($uid) 
    18921989    { 
     1990        if (!$this->check_connection()) { 
     1991            return null; 
     1992        } 
     1993 
    18931994        return $this->conn->fetchPartHeader($this->folder, $uid, true); 
    18941995    } 
     
    18971998    /** 
    18981999     * Sends the whole message source to stdout 
    1899      * 
    1900      * @param int $uid Message UID 
    19012000     */ 
    19022001    public function print_raw_body($uid) 
    19032002    { 
     2003        if (!$this->check_connection()) { 
     2004            return; 
     2005        } 
     2006 
    19042007        $this->conn->handlePartBody($this->folder, $uid, true, NULL, NULL, true); 
    19052008    } 
     
    19202023        if (!strlen($folder)) { 
    19212024            $folder = $this->folder; 
     2025        } 
     2026 
     2027        if (!$this->check_connection()) { 
     2028            return false; 
    19222029        } 
    19232030 
     
    20092116 
    20102117        // exit if no message uids are specified 
    2011         if (empty($uids)) 
     2118        if (empty($uids)) { 
    20122119            return false; 
     2120        } 
     2121 
     2122        if (!$this->check_connection()) { 
     2123            return false; 
     2124        } 
    20132125 
    20142126        // make sure folder exists 
     
    20922204        } 
    20932205 
     2206        if (!$this->check_connection()) { 
     2207            return false; 
     2208        } 
     2209 
    20942210        // make sure folder exists 
    20952211        if ($to_mbox != 'INBOX' && !$this->folder_exists($to_mbox)) { 
     
    21322248 
    21332249        // exit if no message uids are specified 
    2134         if (empty($uids)) 
     2250        if (empty($uids)) { 
    21352251            return false; 
     2252        } 
     2253 
     2254        if (!$this->check_connection()) { 
     2255            return false; 
     2256        } 
    21362257 
    21372258        $deleted = $this->conn->flag($folder, $uids, 'DELETED'); 
     
    21842305        } 
    21852306 
     2307        if (!$this->check_connection()) { 
     2308            return false; 
     2309        } 
     2310 
    21862311        // force folder selection and check if folder is writeable 
    21872312        // to prevent a situation when CLOSE is executed on closed 
     
    21912316            return false; 
    21922317        } 
     2318 
    21932319        if (!$this->conn->data['READ-WRITE']) { 
    21942320            $this->conn->setError(rcube_imap_generic::ERROR_READONLY, "Folder is read-only"); 
     
    22912417            $a_folders = $data['folders']; 
    22922418        } 
    2293         else if (!$this->conn->connected()) { 
     2419        else if (!$this->check_connection()) { 
    22942420           return null; 
    22952421        } 
     
    23922518 
    23932519        // cache folder attributes 
    2394         if ($root == '' && $name == '*' && empty($filter)) { 
     2520        if ($root == '' && $name == '*' && empty($filter) && !empty($this->conn->data)) { 
    23952521            $this->update_cache('mailboxes.attributes', $this->conn->data['LIST']); 
    23962522        } 
     
    24242550    protected function _list_folders($root='', $name='*') 
    24252551    { 
     2552        if (!$this->check_connection()) { 
     2553            return null; 
     2554        } 
     2555 
    24262556        $result = $this->conn->listMailboxes($root, $name); 
    24272557 
     
    25182648    public function folder_size($folder) 
    25192649    { 
     2650        if (!$this->check_connection()) { 
     2651            return 0; 
     2652        } 
     2653 
    25202654        // @TODO: could we try to use QUOTA here? 
    25212655        $result = $this->conn->fetchHeaderIndex($folder, '1:*', 'SIZE', false); 
     
    25662700    public function create_folder($folder, $subscribe=false) 
    25672701    { 
     2702        if (!$this->check_connection()) { 
     2703            return false; 
     2704        } 
     2705 
    25682706        $result = $this->conn->createFolder($folder); 
    25692707 
     
    25922730    { 
    25932731        if (!strlen($new_name)) { 
     2732            return false; 
     2733        } 
     2734 
     2735        if (!$this->check_connection()) { 
    25942736            return false; 
    25952737        } 
     
    26472789    { 
    26482790        $delm = $this->get_hierarchy_delimiter(); 
     2791 
     2792        if (!$this->check_connection()) { 
     2793            return false; 
     2794        } 
    26492795 
    26502796        // get list of folders 
     
    27122858        if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) 
    27132859            return true; 
     2860 
     2861        if (!$this->check_connection()) { 
     2862            return false; 
     2863        } 
    27142864 
    27152865        if ($subscription) { 
     
    28202970 
    28212971        if (!is_array($opts)) { 
     2972            if (!$this->check_connection()) { 
     2973                return array(); 
     2974            } 
     2975 
    28222976            $this->conn->listMailboxes('', $folder); 
    28232977            $opts = $this->conn->data['LIST'][$folder]; 
     
    28422996 
    28432997        if ($this->conn->selected != $folder) { 
     2998            if (!$this->check_connection()) { 
     2999                return array(); 
     3000            } 
    28443001            if ($this->conn->select($folder)) 
    28453002                $this->folder = $folder; 
     
    29943151    public function set_acl($folder, $user, $acl) 
    29953152    { 
    2996         if ($this->get_capability('ACL')) 
    2997             return $this->conn->setACL($folder, $user, $acl); 
    2998  
    2999         return false; 
     3153        if (!$this->get_capability('ACL')) { 
     3154            return false; 
     3155        } 
     3156 
     3157        if (!$this->check_connection()) { 
     3158            return false; 
     3159        } 
     3160 
     3161        return $this->conn->setACL($folder, $user, $acl); 
    30003162    } 
    30013163 
     
    30143176    public function delete_acl($folder, $user) 
    30153177    { 
    3016         if ($this->get_capability('ACL')) 
    3017             return $this->conn->deleteACL($folder, $user); 
    3018  
    3019         return false; 
     3178        if (!$this->get_capability('ACL')) { 
     3179            return false; 
     3180        } 
     3181 
     3182        if (!$this->check_connection()) { 
     3183            return false; 
     3184        } 
     3185 
     3186        return $this->conn->deleteACL($folder, $user); 
    30203187    } 
    30213188 
     
    30313198    public function get_acl($folder) 
    30323199    { 
    3033         if ($this->get_capability('ACL')) 
    3034             return $this->conn->getACL($folder); 
    3035  
    3036         return NULL; 
     3200        if (!$this->get_capability('ACL')) { 
     3201            return null; 
     3202        } 
     3203 
     3204        if (!$this->check_connection()) { 
     3205            return null; 
     3206        } 
     3207 
     3208        return $this->conn->getACL($folder); 
    30373209    } 
    30383210 
     
    30503222    public function list_rights($folder, $user) 
    30513223    { 
    3052         if ($this->get_capability('ACL')) 
    3053             return $this->conn->listRights($folder, $user); 
    3054  
    3055         return NULL; 
     3224        if (!$this->get_capability('ACL')) { 
     3225            return null; 
     3226        } 
     3227 
     3228        if (!$this->check_connection()) { 
     3229            return null; 
     3230        } 
     3231 
     3232        return $this->conn->listRights($folder, $user); 
    30563233    } 
    30573234 
     
    30683245    public function my_rights($folder) 
    30693246    { 
    3070         if ($this->get_capability('ACL')) 
    3071             return $this->conn->myRights($folder); 
    3072  
    3073         return NULL; 
     3247        if (!$this->get_capability('ACL')) { 
     3248            return null; 
     3249        } 
     3250 
     3251        if (!$this->check_connection()) { 
     3252            return null; 
     3253        } 
     3254 
     3255        return $this->conn->myRights($folder); 
    30743256    } 
    30753257 
     
    30863268    public function set_metadata($folder, $entries) 
    30873269    { 
     3270        if (!$this->check_connection()) { 
     3271            return false; 
     3272        } 
     3273 
    30883274        if ($this->get_capability('METADATA') || 
    30893275            (!strlen($folder) && $this->get_capability('METADATA-SERVER')) 
     
    31143300    public function delete_metadata($folder, $entries) 
    31153301    { 
     3302        if (!$this->check_connection()) { 
     3303            return false; 
     3304        } 
     3305 
    31163306        if ($this->get_capability('METADATA') ||  
    31173307            (!strlen($folder) && $this->get_capability('METADATA-SERVER')) 
     
    31433333    public function get_metadata($folder, $entries, $options=array()) 
    31443334    { 
    3145         if ($this->get_capability('METADATA') ||  
     3335        if (!$this->check_connection()) { 
     3336            return null; 
     3337        } 
     3338 
     3339        if ($this->get_capability('METADATA') || 
    31463340            (!strlen($folder) && $this->get_capability('METADATA-SERVER')) 
    31473341        ) { 
     
    31663360        } 
    31673361 
    3168         return NULL; 
     3362        return null; 
    31693363    } 
    31703364 
     
    31883382 
    31893383        // @TODO: log error 
    3190         return NULL; 
     3384        return null; 
    31913385    } 
    31923386 
     
    34193613        } 
    34203614 
     3615        if (!$this->check_connection()) { 
     3616            return null; 
     3617        } 
     3618 
    34213619        $uid = $this->conn->ID2UID($folder, $id); 
    34223620 
     
    34353633 
    34363634        if (!empty($folders)) { 
     3635            if (!$this->check_connection()) { 
     3636                return false; 
     3637            } 
     3638 
    34373639            foreach ((array)$folders as $i => $folder) { 
    34383640                $folders[$i] = $folder; 
  • branches/devel-framework/roundcubemail/program/include/rcube_imap_cache.php

    r5758 r5759  
    889889        } 
    890890 
     891        if (!$this->imap->check_connection()) { 
     892            return; 
     893        } 
     894 
    891895        // NOTE: make sure the mailbox isn't selected, before 
    892896        // enabling QRESYNC and invoking SELECT 
  • branches/devel-framework/roundcubemail/program/include/rcube_storage.php

    r5758 r5759  
    466466    public function get_body($uid, $part = 1) 
    467467    { 
    468         $headers = $this->get_headers($uid); 
     468        $headers = $this->get_message_headers($uid); 
    469469        return rcube_charset_convert($this->get_message_part($uid, $part, null), 
    470470            $headers->charset ? $headers->charset : $this->default_charset); 
     
    487487     * 
    488488     * @param int $uid  Message UID 
     489     * 
    489490     * @return string Message headers string 
    490491     */ 
     
    494495    /** 
    495496     * Sends the whole message source to stdout 
    496      * 
    497      * @param int $uid Message UID 
    498497     */ 
    499498    abstract function print_raw_body($uid); 
  • branches/devel-framework/roundcubemail/program/localization/en_US/messages.inc

    r5686 r5759  
    2222$messages['cookiesdisabled'] = 'Your browser does not accept cookies.'; 
    2323$messages['sessionerror'] = 'Your session is invalid or expired.'; 
    24 $messages['imaperror'] = 'Connection to IMAP server failed.'; 
     24$messages['storageerror'] = 'Connection to storage server failed.'; 
    2525$messages['servererror'] = 'Server Error!'; 
    2626$messages['servererrormsg'] = 'Server Error: $msg'; 
  • branches/devel-framework/roundcubemail/program/steps/mail/func.inc

    r5758 r5759  
    2929); 
    3030 
    31 // actions that do not require imap connection here 
    32 $NOSTORAGE_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment', 'get'); 
    33  
    34 // always instantiate imap object (but not yet connect to server) 
     31// always instantiate storage object (but not connect to server yet) 
    3532$RCMAIL->storage_init(); 
    36  
    37 // log in to imap server 
    38 if (!in_array($RCMAIL->action, $NOSTORAGE_ACTIONS) && !$RCMAIL->storage_connect()) { 
    39   $RCMAIL->kill_session(); 
    40  
    41   if ($OUTPUT->ajax_call) 
    42     $OUTPUT->redirect(array(), 2000); 
    43  
    44   $OUTPUT->set_env('task', 'login'); 
    45   $OUTPUT->send('login'); 
    46 } 
    4733 
    4834// set imap properties and session vars 
  • branches/devel-framework/roundcubemail/program/steps/settings/edit_folder.inc

    r5758 r5759  
    2222// WARNING: folder names in UI are encoded with RCMAIL_CHARSET 
    2323 
    24 // init IMAP connection 
    25 $RCMAIL->storage_connect(); 
    26  
    2724function rcmail_folder_form($attrib) 
    2825{ 
    2926    global $RCMAIL; 
    3027 
     28    $storage = $RCMAIL->get_storage(); 
     29 
    3130    // edited folder name (empty in create-folder mode) 
    3231    $mbox      = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true)); 
     
    3736    $parent_imap = rcube_charset_convert($parent, RCMAIL_CHARSET, 'UTF7-IMAP'); 
    3837 
    39     $threading_supported = $RCMAIL->storage->get_capability('THREAD'); 
    40     $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 
     38    $threading_supported = $storage->get_capability('THREAD'); 
     39    $delimiter = $storage->get_hierarchy_delimiter(); 
    4140 
    4241    // Get mailbox parameters 
    4342    if (strlen($mbox)) { 
    4443        $options   = rcmail_folder_options($mbox_imap); 
    45         $namespace = $RCMAIL->storage->get_namespace(); 
     44        $namespace = $storage->get_namespace(); 
    4645 
    4746        $path   = explode($delimiter, $mbox_imap); 
     
    5857        // allow creating subfolders of INBOX folder 
    5958        if ($path == 'INBOX') { 
    60             $path = $RCMAIL->storage->mod_folder($path, 'in'); 
     59            $path = $storage->mod_folder($path, 'in'); 
    6160        } 
    6261    } 
     
    6564    if (strlen($path)) { 
    6665        $path_id = $path; 
    67         $path    = $RCMAIL->storage->mod_folder($path.$delimiter); 
     66        $path    = $storage->mod_folder($path.$delimiter); 
    6867        if ($path[strlen($path)-1] == $delimiter) { 
    6968            $path = substr($path, 0, -1); 
     
    194193 
    195194        if ((!$options['noselect'] && !$options['is_root']) || $mbox_imap == 'INBOX') { 
    196             $msgcount = $RCMAIL->storage->count($mbox_imap, 'ALL', true, false); 
     195            $msgcount = $storage->count($mbox_imap, 'ALL', true, false); 
    197196 
    198197            // Size 
  • branches/devel-framework/roundcubemail/program/steps/settings/folders.inc

    r5758 r5759  
    2424 
    2525// init IMAP connection 
    26 $RCMAIL->storage_connect(); 
     26$STORAGE = $RCMAIL->get_storage(); 
    2727 
    2828// subscribe mailbox 
     
    3131    $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true, 'UTF7-IMAP'); 
    3232    if (strlen($mbox)) { 
    33         $result = $RCMAIL->storage->subscribe(array($mbox)); 
     33        $result = $STORAGE->subscribe(array($mbox)); 
    3434 
    3535        // Handle virtual (non-existing) folders 
    36         if (!$result && $RCMAIL->storage->get_error_code() == -1 && 
    37             $RCMAIL->storage->get_response_code() == rcube_storage::TRYCREATE 
     36        if (!$result && $STORAGE->get_error_code() == -1 && 
     37            $STORAGE->get_response_code() == rcube_storage::TRYCREATE 
    3838        ) { 
    39             $result = $RCMAIL->storage->create_folder($mbox, true); 
     39            $result = $STORAGE->create_folder($mbox, true); 
    4040            if ($result) { 
    4141                // @TODO: remove 'virtual' class of folder's row 
     
    6363    $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true, 'UTF7-IMAP'); 
    6464    if (strlen($mbox)) { 
    65         $result = $RCMAIL->storage->unsubscribe(array($mbox)); 
     65        $result = $STORAGE->unsubscribe(array($mbox)); 
    6666        if ($result) 
    6767            $OUTPUT->show_message('folderunsubscribed', 'confirmation'); 
     
    8181 
    8282        if (!$plugin['abort']) { 
    83             $deleted = $RCMAIL->storage->delete_folder($plugin['name']); 
     83            $deleted = $STORAGE->delete_folder($plugin['name']); 
    8484        } 
    8585        else { 
     
    127127    $mbox_utf8 = get_input_value('_mbox', RCUBE_INPUT_POST, true); 
    128128    $mbox      = rcube_charset_convert($mbox_utf8, RCMAIL_CHARSET, 'UTF7-IMAP'); 
    129     $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 
     129    $delimiter = $STORAGE->get_hierarchy_delimiter(); 
    130130    $trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/'; 
    131131 
     
    134134        || preg_match($trash_regexp, $mbox) 
    135135    ) { 
    136         $success = $RCMAIL->storage->delete_message('*', $mbox); 
     136        $success = $STORAGE->delete_message('*', $mbox); 
    137137        $delete = true; 
    138138    } 
    139139    // copy to Trash 
    140140    else { 
    141         $success = $RCMAIL->storage->move_message('1:*', $CONFIG['trash_mbox'], $mbox); 
     141        $success = $STORAGE->move_message('1:*', $CONFIG['trash_mbox'], $mbox); 
    142142        $delete = false; 
    143143    } 
     
    165165    $name = trim(get_input_value('_mbox', RCUBE_INPUT_POST, true)); 
    166166 
    167     $size = $RCMAIL->storage->folder_size($name); 
     167    $size = $STORAGE->folder_size($name); 
    168168 
    169169    // @TODO: check quota and show percentage usage of specified mailbox? 
     
    200200    } 
    201201 
     202    $STORAGE = $RCMAIL->get_storage(); 
     203 
    202204    // get folders from server 
    203     $RCMAIL->storage->clear_cache('mailboxes', true); 
    204  
    205     $a_unsubscribed = $RCMAIL->storage->list_folders(); 
    206     $a_subscribed   = $RCMAIL->storage->list_folders_subscribed('', '*', null, null, true); // unsorted 
    207     $delimiter      = $RCMAIL->storage->get_hierarchy_delimiter(); 
    208     $namespace      = $RCMAIL->storage->get_namespace(); 
     205    $STORAGE->clear_cache('mailboxes', true); 
     206 
     207    $a_unsubscribed = $STORAGE->list_folders(); 
     208    $a_subscribed   = $STORAGE->list_folders_subscribed('', '*', null, null, true); // unsorted 
     209    $delimiter      = $STORAGE->get_hierarchy_delimiter(); 
     210    $namespace      = $STORAGE->get_namespace(); 
    209211    $a_js_folders   = array(); 
    210212    $seen           = array(); 
     
    214216    foreach ($a_unsubscribed as $i => $folder) { 
    215217        $folder_id     = $folder; 
    216         $folder        = $RCMAIL->storage->mod_folder($folder); 
     218        $folder        = $STORAGE->mod_folder($folder); 
    217219        $foldersplit   = explode($delimiter, $folder); 
    218220        $name          = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP'); 
     
    284286 
    285287        if (!$protected) { 
    286             $attrs = $RCMAIL->storage->folder_attributes($folder['id']); 
     288            $attrs = $STORAGE->folder_attributes($folder['id']); 
    287289            $noselect = in_array('\\Noselect', $attrs); 
    288290        } 
     
    368370    global $RCMAIL; 
    369371 
    370     $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 
     372    $storage   = $RCMAIL->get_storage(); 
     373    $delimiter = $storage->get_hierarchy_delimiter(); 
    371374 
    372375    $plugin = $RCMAIL->plugins->exec_hook('folder_rename', array( 
     
    374377 
    375378    if (!$plugin['abort']) { 
    376         $renamed =  $RCMAIL->storage->rename_folder($oldname, $newname); 
     379        $renamed =  $storage->rename_folder($oldname, $newname); 
    377380    } 
    378381    else { 
     
    406409$OUTPUT->set_pagetitle(rcube_label('folders')); 
    407410$OUTPUT->include_script('list.js'); 
    408 $OUTPUT->set_env('quota', $RCMAIL->storage->get_capability('QUOTA')); 
     411$OUTPUT->set_env('quota', $STORAGE->get_capability('QUOTA')); 
    409412 
    410413// add some labels to client 
  • branches/devel-framework/roundcubemail/program/steps/settings/func.inc

    r5758 r5759  
    318318    } 
    319319 
    320     $RCMAIL->storage_connect(); 
    321     $threading_supported = $RCMAIL->storage->get_capability('THREAD'); 
     320    $storage             = $RCMAIL->get_storage(); 
     321    $threading_supported = $storage->get_capability('THREAD'); 
    322322 
    323323    if (!isset($no_override['autoexpand_threads']) && $threading_supported) { 
     
    683683    // Configure special folders 
    684684    if (!isset($no_override['default_folders'])) { 
    685  
    686       $RCMAIL->storage_connect(); 
    687  
    688685      // load folders list only when needed 
    689686      if ($current) { 
     
    850847    global $RCMAIL; 
    851848 
    852     $options = $RCMAIL->storage->folder_info($mailbox); 
     849    $options = $RCMAIL->get_storage()->folder_info($mailbox); 
    853850    $options['protected'] = $options['is_root'] || ($options['special'] && $RCMAIL->config->get('protect_default_folders')); 
    854851 
     
    868865    global $RCMAIL, $CONFIG, $OUTPUT; 
    869866 
    870     $delimiter    = $RCMAIL->storage->get_hierarchy_delimiter(); 
     867    $storage      = $RCMAIL->get_storage(); 
     868    $delimiter    = $storage->get_hierarchy_delimiter(); 
    871869    $name_utf8    = rcube_charset_convert($name, 'UTF7-IMAP'); 
    872870    $protected    = ($CONFIG['protect_default_folders'] == true && in_array($name, $CONFIG['default_folders'])); 
    873871 
    874     $foldersplit  = explode($delimiter, $RCMAIL->storage->mod_folder($name)); 
     872    $foldersplit  = explode($delimiter, $storage->mod_folder($name)); 
    875873    $level        = count($foldersplit) - 1; 
    876874    $display_name = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level) 
  • branches/devel-framework/roundcubemail/program/steps/settings/save_folder.inc

    r5758 r5759  
    2323 
    2424// init IMAP connection 
    25 $RCMAIL->storage_connect(); 
     25$STORAGE = $RCMAIL->get_storage(); 
    2626 
    2727 
     
    3434// $path is in UTF7-IMAP already 
    3535 
    36 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 
     36$delimiter = $STORAGE->get_hierarchy_delimiter(); 
    3737$options = strlen($old_imap) ? rcmail_folder_options($old_imap) : array(); 
    3838 
     
    6767    } 
    6868    else { 
    69         $name_imap = $RCMAIL->storage->mod_folder($name_imap, 'in'); 
     69        $name_imap = $STORAGE->mod_folder($name_imap, 'in'); 
    7070    } 
    7171} 
     
    7373// Check access rights to the parent folder 
    7474if (!$error && strlen($path) && (!strlen($old_imap) || $old_imap != $name_imap)) { 
    75     $parent_opts = $RCMAIL->storage->folder_info($path); 
     75    $parent_opts = $STORAGE->folder_info($path); 
    7676    if ($parent_opts['namespace'] != 'personal' 
    7777        && (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts))) 
     
    104104 
    105105    if (!$plugin['abort']) { 
    106         $created = $RCMAIL->storage->create_folder($folder['name'], $folder['subscribe']); 
     106        $created = $STORAGE->create_folder($folder['name'], $folder['subscribe']); 
    107107    } 
    108108    else { 
     
    144144    if (!$plugin['abort']) { 
    145145        if ($rename) { 
    146             $updated = $RCMAIL->storage->rename_folder($folder['oldname'], $folder['name']); 
     146            $updated = $STORAGE->rename_folder($folder['oldname'], $folder['name']); 
    147147        } 
    148148        else { 
Note: See TracChangeset for help on using the changeset viewer.