summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/mail/check_recent.inc32
-rw-r--r--program/steps/mail/compose.inc22
-rw-r--r--program/steps/mail/copy.inc2
-rw-r--r--program/steps/mail/folders.inc6
-rw-r--r--program/steps/mail/func.inc90
-rw-r--r--program/steps/mail/get.inc8
-rw-r--r--program/steps/mail/getunread.inc6
-rw-r--r--program/steps/mail/headers.inc2
-rw-r--r--program/steps/mail/list.inc23
-rw-r--r--program/steps/mail/mark.inc45
-rw-r--r--program/steps/mail/move_del.inc43
-rw-r--r--program/steps/mail/pagenav.inc12
-rw-r--r--program/steps/mail/search.inc20
-rw-r--r--program/steps/mail/sendmail.inc20
-rw-r--r--program/steps/mail/show.inc14
-rw-r--r--program/steps/mail/viewsource.inc4
-rw-r--r--program/steps/settings/edit_folder.inc17
-rw-r--r--program/steps/settings/folders.inc51
-rw-r--r--program/steps/settings/func.inc18
-rw-r--r--program/steps/settings/save_folder.inc12
-rw-r--r--program/steps/settings/save_prefs.inc8
21 files changed, 231 insertions, 224 deletions
diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index 498bf0ce1..6673d0c17 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -19,12 +19,12 @@
*/
-$current = $RCMAIL->imap->get_mailbox_name();
+$current = $RCMAIL->storage->get_folder();
$check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders');
// list of folders to check
if ($check_all) {
- $a_mailboxes = $RCMAIL->imap->list_mailboxes('', '*', 'mail');
+ $a_mailboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
}
else {
$a_mailboxes = (array) $current;
@@ -37,11 +37,11 @@ foreach ($a_mailboxes as $mbox_name) {
$is_current = $mbox_name == $current;
if ($is_current) {
// Synchronize mailbox cache, handle flag changes
- $RCMAIL->imap->mailbox_sync($mbox_name);
+ $RCMAIL->storage->folder_sync($mbox_name);
}
// Get mailbox status
- $status = $RCMAIL->imap->mailbox_status($mbox_name);
+ $status = $RCMAIL->storage->folder_status($mbox_name);
if ($status & 1) {
// trigger plugin hook
@@ -58,7 +58,7 @@ foreach ($a_mailboxes as $mbox_name) {
if ($search_request && isset($_SESSION['search'])
&& $_SESSION['search_request'] == $search_request
) {
- $_SESSION['search'] = $RCMAIL->imap->refresh_search();
+ $_SESSION['search'] = $RCMAIL->storage->refresh_search();
}
if (!empty($_GET['_quota']))
@@ -68,28 +68,32 @@ foreach ($a_mailboxes as $mbox_name) {
if (empty($_GET['_list']))
continue;
- // get overall message count; allow caching because rcube_imap::mailbox_status() did a refresh
- $all_count = $RCMAIL->imap->messagecount(null, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
+ // get overall message count; allow caching because rcube_storage::folder_status() did a refresh
+ $all_count = $RCMAIL->storage->count(null, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
+
+ $page = $RCMAIL->storage->get_page();
+ $page_size = $RCMAIL->storage->get_pagesize();
// check current page if we're not on the first page
- if ($all_count && $RCMAIL->imap->list_page > 1) {
- $remaining = $all_count - $RCMAIL->imap->page_size * ($RCMAIL->imap->list_page - 1);
+ if ($all_count && $page > 1) {
+ $remaining = $all_count - $page_size * ($page - 1);
if ($remaining <= 0) {
- $RCMAIL->imap->set_page($RCMAIL->imap->list_page-1);
- $_SESSION['page'] = $RCMAIL->imap->list_page;
+ $page -= 1;
+ $RCMAIL->storage->set_page($page);
+ $_SESSION['page'] = $page;
}
}
$OUTPUT->set_env('messagecount', $all_count);
- $OUTPUT->set_env('pagecount', ceil($all_count/$RCMAIL->imap->page_size));
+ $OUTPUT->set_env('pagecount', ceil($all_count/$page_size));
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count), $mbox_name);
- $OUTPUT->set_env('current_page', $all_count ? $RCMAIL->imap->list_page : 1);
+ $OUTPUT->set_env('current_page', $all_count ? $page : 1);
// remove old rows (and clear selection if new list is empty)
$OUTPUT->command('message_list.clear', $all_count ? false : true);
if ($all_count) {
- $a_headers = $RCMAIL->imap->list_headers($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']);
+ $a_headers = $RCMAIL->storage->list_messages($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']);
// add message rows
rcmail_js_message_list($a_headers, false);
// remove messages that don't exists from list selection array
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 274983a18..687849863 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -56,7 +56,7 @@ if (!is_array($COMPOSE))
$_SESSION['compose_data_'.$COMPOSE_ID] = array(
'id' => $COMPOSE_ID,
'param' => request2param(RCUBE_INPUT_GET),
- 'mailbox' => $RCMAIL->imap->get_mailbox_name(),
+ 'mailbox' => $RCMAIL->storage->get_folder(),
);
$COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID];
@@ -134,7 +134,7 @@ if (!empty($CONFIG['drafts_mbox'])) {
$OUTPUT->set_env('draft_autosave', $CONFIG['draft_autosave']);
}
// set current mailbox in client environment
-$OUTPUT->set_env('mailbox', $RCMAIL->imap->get_mailbox_name());
+$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false));
$OUTPUT->set_env('top_posting', $RCMAIL->config->get('top_posting', false));
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
@@ -147,7 +147,7 @@ if ($font && !is_array($font)) {
// get reference message and set compose mode
if ($msg_uid = $COMPOSE['param']['draft_uid']) {
- $RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']);
+ $RCMAIL->storage->set_folder($CONFIG['drafts_mbox']);
$compose_mode = RCUBE_COMPOSE_DRAFT;
}
else if ($msg_uid = $COMPOSE['param']['reply_uid'])
@@ -179,10 +179,10 @@ if (!empty($msg_uid))
// make sure message is marked as read
if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']))
- $RCMAIL->imap->set_flag($msg_uid, 'SEEN');
+ $RCMAIL->storage->set_flag($msg_uid, 'SEEN');
if (!empty($MESSAGE->headers->charset))
- $RCMAIL->imap->set_charset($MESSAGE->headers->charset);
+ $RCMAIL->storage->set_charset($MESSAGE->headers->charset);
if ($compose_mode == RCUBE_COMPOSE_REPLY)
{
@@ -1051,12 +1051,12 @@ function rcmail_write_forward_attachment(&$message)
$temp_dir = unslashify($RCMAIL->config->get('temp_dir'));
$path = tempnam($temp_dir, 'rcmAttmnt');
if ($fp = fopen($path, 'w')) {
- $RCMAIL->imap->get_raw_body($message->uid, $fp);
+ $RCMAIL->storage->get_raw_body($message->uid, $fp);
fclose($fp);
} else
return false;
} else {
- $data = $RCMAIL->imap->get_raw_body($message->uid);
+ $data = $RCMAIL->storage->get_raw_body($message->uid);
}
$attachment = array(
@@ -1428,16 +1428,16 @@ function rcmail_check_sent_folder($folder, $create=false)
{
global $RCMAIL;
- if ($RCMAIL->imap->mailbox_exists($folder, true)) {
+ if ($RCMAIL->storage->folder_exists($folder, true)) {
return true;
}
// folder may exist but isn't subscribed (#1485241)
if ($create) {
- if (!$RCMAIL->imap->mailbox_exists($folder))
- return $RCMAIL->imap->create_mailbox($folder, true);
+ if (!$RCMAIL->storage->folder_exists($folder))
+ return $RCMAIL->storage->create_folder($folder, true);
else
- return $RCMAIL->imap->subscribe($folder);
+ return $RCMAIL->storage->subscribe($folder);
}
return false;
diff --git a/program/steps/mail/copy.inc b/program/steps/mail/copy.inc
index edb6af3d5..e553adc14 100644
--- a/program/steps/mail/copy.inc
+++ b/program/steps/mail/copy.inc
@@ -29,7 +29,7 @@ if (!empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) {
$target = get_input_value('_target_mbox', RCUBE_INPUT_POST, true);
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
- $copied = $RCMAIL->imap->copy_message($uids, $target, $mbox);
+ $copied = $RCMAIL->storage->copy_message($uids, $target, $mbox);
if (!$copied) {
// send error message
diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc
index 6e687b06a..2aa83ee0d 100644
--- a/program/steps/mail/folders.inc
+++ b/program/steps/mail/folders.inc
@@ -27,7 +27,7 @@ $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
// send EXPUNGE command
if ($RCMAIL->action == 'expunge') {
- $success = $RCMAIL->imap->expunge($mbox);
+ $success = $RCMAIL->storage->expunge_folder($mbox);
// reload message list if current mailbox
if ($success) {
@@ -48,7 +48,7 @@ if ($RCMAIL->action == 'expunge') {
// clear mailbox
else if ($RCMAIL->action == 'purge')
{
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
+ $delimiter = $RCMAIL->storage->get_hierarchy_delimiter();
$trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/';
$junk_regexp = '/^' . preg_quote($CONFIG['junk_mbox'] . $delimiter, '/') . '/';
@@ -56,7 +56,7 @@ else if ($RCMAIL->action == 'purge')
if ($mbox == $CONFIG['trash_mbox'] || $mbox == $CONFIG['junk_mbox']
|| preg_match($trash_regexp, $mbox) || preg_match($junk_regexp, $mbox)
) {
- $success = $RCMAIL->imap->clear_mailbox($mbox);
+ $success = $RCMAIL->storage->clear_folder($mbox);
if ($success) {
$OUTPUT->show_message('folderpurged', 'confirmation');
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 5d0b30a0e..0ffffc5fc 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -28,31 +28,17 @@ $SEARCH_MODS_DEFAULT = array(
$DRAFTS_MBOX => array('subject'=>1, 'to'=>1)
);
-// actions that do not require imap connection here
-$NOIMAP_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment', 'get');
-
-// always instantiate imap object (but not yet connect to server)
-$RCMAIL->imap_init();
-
-// log in to imap server
-if (!in_array($RCMAIL->action, $NOIMAP_ACTIONS) && !$RCMAIL->imap_connect()) {
- $RCMAIL->kill_session();
-
- if ($OUTPUT->ajax_call)
- $OUTPUT->redirect(array(), 2000);
-
- $OUTPUT->set_env('task', 'login');
- $OUTPUT->send('login');
-}
+// always instantiate storage object (but not connect to server yet)
+$RCMAIL->storage_init();
// set imap properties and session vars
if (strlen(trim($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC, true))))
- $RCMAIL->imap->set_mailbox(($_SESSION['mbox'] = $mbox));
-else if ($RCMAIL->imap)
- $_SESSION['mbox'] = $RCMAIL->imap->get_mailbox_name();
+ $RCMAIL->storage->set_folder(($_SESSION['mbox'] = $mbox));
+else if ($RCMAIL->storage)
+ $_SESSION['mbox'] = $RCMAIL->storage->get_folder();
if (!empty($_GET['_page']))
- $RCMAIL->imap->set_page(($_SESSION['page'] = intval($_GET['_page'])));
+ $RCMAIL->storage->set_page(($_SESSION['page'] = intval($_GET['_page'])));
// set default sort col/order to session
if (!isset($_SESSION['sort_col']))
@@ -69,28 +55,28 @@ if (isset($_GET['_threads'])) {
unset($a_threading[$_SESSION['mbox']]);
$RCMAIL->user->save_prefs(array('message_threading' => $a_threading));
}
-$RCMAIL->imap->set_threading($a_threading[$_SESSION['mbox']]);
+$RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]);
// set message set for search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'])
&& $_SESSION['search_request'] == $_REQUEST['_search']
) {
- $RCMAIL->imap->set_search_set($_SESSION['search']);
+ $RCMAIL->storage->set_search_set($_SESSION['search']);
$OUTPUT->set_env('search_request', $_REQUEST['_search']);
$OUTPUT->set_env('search_text', $_SESSION['last_text_search']);
}
// set main env variables, labels and page title
if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
- $mbox_name = $RCMAIL->imap->get_mailbox_name();
+ $mbox_name = $RCMAIL->storage->get_folder();
if (empty($RCMAIL->action)) {
// initialize searching result if search_filter is used
if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') {
$search_request = md5($mbox_name.$_SESSION['search_filter']);
- $RCMAIL->imap->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $_SESSION['sort_col']);
- $_SESSION['search'] = $RCMAIL->imap->get_search_set();
+ $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $_SESSION['sort_col']);
+ $_SESSION['search'] = $RCMAIL->storage->get_search_set();
$_SESSION['search_request'] = $search_request;
$OUTPUT->set_env('search_request', $search_request);
}
@@ -99,13 +85,15 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
$OUTPUT->set_env('search_mods', $search_mods);
}
+ $threading = (bool) $RCMAIL->storage->get_threading();
+
// set current mailbox and some other vars in client environment
$OUTPUT->set_env('mailbox', $mbox_name);
- $OUTPUT->set_env('pagesize', $RCMAIL->imap->page_size);
- $OUTPUT->set_env('quota', $RCMAIL->imap->get_capability('QUOTA'));
- $OUTPUT->set_env('delimiter', $RCMAIL->imap->get_hierarchy_delimiter());
- $OUTPUT->set_env('threading', (bool) $RCMAIL->imap->threading);
- $OUTPUT->set_env('threads', $RCMAIL->imap->threading || $RCMAIL->imap->get_capability('THREAD'));
+ $OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize());
+ $OUTPUT->set_env('quota', $RCMAIL->storage->get_capability('QUOTA'));
+ $OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter());
+ $OUTPUT->set_env('threading', $threading);
+ $OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD'));
$OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0));
if ($CONFIG['flag_for_deletion'])
@@ -130,7 +118,7 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage',
'copy', 'move', 'quota');
- $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL->imap->mod_mailbox($mbox_name)));
+ $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL->storage->mod_folder($mbox_name)));
}
@@ -161,8 +149,8 @@ function rcmail_message_list($attrib)
// save some variables for use in ajax list
$_SESSION['list_attrib'] = $attrib;
- $mbox = $RCMAIL->imap->get_mailbox_name();
- $delim = $RCMAIL->imap->get_hierarchy_delimiter();
+ $mbox = $RCMAIL->storage->get_folder();
+ $delim = $RCMAIL->storage->get_hierarchy_delimiter();
// show 'to' instead of 'from' in sent/draft messages
if ((strpos($mbox.$delim, $CONFIG['sent_mbox'].$delim)===0 || strpos($mbox.$delim, $CONFIG['drafts_mbox'].$delim)===0)
@@ -218,8 +206,8 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$head_replace = true;
}
- $mbox = $RCMAIL->imap->get_mailbox_name();
- $delim = $RCMAIL->imap->get_hierarchy_delimiter();
+ $mbox = $RCMAIL->storage->get_folder();
+ $delim = $RCMAIL->storage->get_hierarchy_delimiter();
// make sure 'threads' and 'subject' columns are present
if (!in_array('subject', $a_show_cols))
@@ -317,7 +305,7 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$insert_top);
}
- if ($RCMAIL->imap->threading) {
+ if ($RCMAIL->storage->get_threading()) {
$OUTPUT->command('init_threads', (array) $roots, $mbox);
}
}
@@ -430,22 +418,24 @@ function rcmail_get_messagecount_text($count=NULL, $page=NULL)
{
global $RCMAIL;
- if ($page===NULL)
- $page = $RCMAIL->imap->list_page;
+ if ($page === NULL) {
+ $page = $RCMAIL->storage->get_page();
+ }
- $start_msg = ($page-1) * $RCMAIL->imap->page_size + 1;
+ $page_size = $RCMAIL->storage->get_pagesize();
+ $start_msg = ($page-1) * $page_size + 1;
if ($count!==NULL)
$max = $count;
else if ($RCMAIL->action)
- $max = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
+ $max = $RCMAIL->storage->count(NULL, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
if ($max==0)
$out = rcube_label('mailboxempty');
else
- $out = rcube_label(array('name' => $RCMAIL->imap->threading ? 'threadsfromto' : 'messagesfromto',
+ $out = rcube_label(array('name' => $RCMAIL->storage->get_threading() ? 'threadsfromto' : 'messagesfromto',
'vars' => array('from' => $start_msg,
- 'to' => min($max, $start_msg + $RCMAIL->imap->page_size - 1),
+ 'to' => min($max, $start_msg + $page_size - 1),
'count' => $max)));
return Q($out);
@@ -468,7 +458,7 @@ function rcmail_mailbox_name_display($attrib)
function rcmail_get_mailbox_name_text()
{
global $RCMAIL;
- return rcmail_localize_foldername($RCMAIL->imap->get_mailbox_name());
+ return rcmail_localize_foldername($RCMAIL->storage->get_folder());
}
@@ -479,7 +469,7 @@ function rcmail_send_unread_count($mbox_name, $force=false, $count=null, $mark='
$old_unseen = rcmail_get_unseen_count($mbox_name);
if ($count === null)
- $unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', $force);
+ $unseen = $RCMAIL->storage->count($mbox_name, 'UNSEEN', $force);
else
$unseen = $count;
@@ -590,7 +580,7 @@ function rcmail_wash_html($html, $p, $cid_replaces)
// fix (unknown/malformed) HTML tags before "wash"
$html = preg_replace_callback('/(<[\/]*)([^\s>]+)/', 'rcmail_html_tag_callback', $html);
- // charset was converted to UTF-8 in rcube_imap::get_message_part(),
+ // charset was converted to UTF-8 in rcube_storage::get_message_part(),
// change/add charset specification in HTML accordingly,
// washtml cannot work without that
$meta = '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />';
@@ -1010,7 +1000,7 @@ function rcmail_message_body($attrib)
if (!rcmail_mem_check($part->size * 10)) {
$out .= html::span('part-notice', rcube_label('messagetoobig'). ' '
. html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part='.$part->mime_id
- .'&_mbox='. urlencode($RCMAIL->imap->get_mailbox_name()), rcube_label('download')));
+ .'&_mbox='. urlencode($RCMAIL->storage->get_folder()), rcube_label('download')));
continue;
}
@@ -1056,7 +1046,7 @@ function rcmail_message_body($attrib)
if (!rcmail_mem_check(strlen($MESSAGE->body) * 10)) {
$out .= html::span('part-notice', rcube_label('messagetoobig'). ' '
. html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part=0'
- .'&_mbox='. urlencode($RCMAIL->imap->get_mailbox_name()), rcube_label('download')));
+ .'&_mbox='. urlencode($RCMAIL->storage->get_folder()), rcube_label('download')));
}
else {
$plugin = $RCMAIL->plugins->exec_hook('message_body_prefix', array(
@@ -1477,7 +1467,7 @@ function rcmail_send_mdn($message, &$smtp_error)
$message = new rcube_message($message);
if ($message->headers->mdn_to && empty($message->headers->flags['MDNSENT']) &&
- ($RCMAIL->imap->check_permflag('MDNSENT') || $RCMAIL->imap->check_permflag('*')))
+ ($RCMAIL->storage->check_permflag('MDNSENT') || $RCMAIL->storage->check_permflag('*')))
{
$identity = $RCMAIL->user->get_identity();
$sender = format_email_recipient($identity['email'], $identity['name']);
@@ -1533,7 +1523,7 @@ function rcmail_send_mdn($message, &$smtp_error)
if ($sent)
{
- $RCMAIL->imap->set_flag($message->uid, 'MDNSENT');
+ $RCMAIL->storage->set_flag($message->uid, 'MDNSENT');
return true;
}
}
@@ -1596,7 +1586,7 @@ function rcmail_message_error($uid=null)
// Set env variables for messageerror.html template
if ($RCMAIL->action == 'show') {
- $mbox_name = $RCMAIL->imap->get_mailbox_name();
+ $mbox_name = $RCMAIL->storage->get_folder();
$RCMAIL->output->set_env('mailbox', $mbox_name);
$RCMAIL->output->set_env('uid', null);
}
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index d114e7c61..7da8f13fa 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -36,7 +36,7 @@ if (!empty($_GET['_preload'])) {
ob_end_clean();
// Now we need IMAP connection
-if (!$RCMAIL->imap_connect()) {
+if (!$RCMAIL->storage_connect()) {
// Get action is often executed simultanously.
// Some servers have MAXPERIP or other limits.
// To workaround this we'll wait for some time
@@ -117,7 +117,7 @@ else if (strlen($pid = get_input_value('_part', RCUBE_INPUT_GET))) {
if (!rcmail_mem_check($part->size * 10)) {
$out = '<body>' . rcube_label('messagetoobig'). ' '
. html::a('?_task=mail&_action=get&_download=1&_uid='.$MESSAGE->uid.'&_part='.$part->mime_id
- .'&_mbox='. urlencode($RCMAIL->imap->get_mailbox_name()), rcube_label('download')) . '</body></html>';
+ .'&_mbox='. urlencode($RCMAIL->storage->get_folder()), rcube_label('download')) . '</body></html>';
}
else {
// get part body if not available
@@ -157,7 +157,7 @@ else if (strlen($pid = get_input_value('_part', RCUBE_INPUT_GET))) {
$stdout = fopen('php://output', 'w');
stream_filter_register('rcube_content', 'rcube_content_filter') or die('Failed to register content filter');
stream_filter_append($stdout, 'rcube_content');
- $RCMAIL->imap->get_message_part($MESSAGE->uid, $part->mime_id, $part, false, $stdout);
+ $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, false, $stdout);
}
}
else {
@@ -165,7 +165,7 @@ else if (strlen($pid = get_input_value('_part', RCUBE_INPUT_GET))) {
if ($part->body)
echo $part->body;
else if ($part->size)
- $RCMAIL->imap->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
+ $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
}
}
diff --git a/program/steps/mail/getunread.inc b/program/steps/mail/getunread.inc
index 39880b99b..64e7a6aee 100644
--- a/program/steps/mail/getunread.inc
+++ b/program/steps/mail/getunread.inc
@@ -19,11 +19,11 @@
*/
-$a_folders = $RCMAIL->imap->list_mailboxes('', '*', 'mail');
+$a_folders = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
if (!empty($a_folders))
{
- $current = $RCMAIL->imap->get_mailbox_name();
+ $current = $RCMAIL->storage->get_folder();
$inbox = ($current == 'INBOX');
$check_all = (bool)$RCMAIL->config->get('check_all_folders');
@@ -33,7 +33,7 @@ if (!empty($a_folders))
if (!$check_all && $unseen_old !== null && $mbox_row != $current)
$unseen = $unseen_old;
else
- $unseen = $RCMAIL->imap->messagecount($mbox_row, 'UNSEEN', $unseen_old === null);
+ $unseen = $RCMAIL->storage->count($mbox_row, 'UNSEEN', $unseen_old === null);
if ($unseen || $unseen_old === null) {
$OUTPUT->command('set_unread_count', $mbox_row, $unseen, $inbox && $mbox_row == 'INBOX');
diff --git a/program/steps/mail/headers.inc b/program/steps/mail/headers.inc
index 5eee4bdef..0cce5a503 100644
--- a/program/steps/mail/headers.inc
+++ b/program/steps/mail/headers.inc
@@ -20,7 +20,7 @@
if ($uid = get_input_value('_uid', RCUBE_INPUT_POST))
{
- $source = $RCMAIL->imap->get_raw_headers($uid);
+ $source = $RCMAIL->storage->get_raw_headers($uid);
if ($source !== false) {
$source = htmlspecialchars(trim($source));
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index c2a47488f..8bfb4c8f1 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -51,30 +51,31 @@ if ($cols = get_input_value('_cols', RCUBE_INPUT_GET))
if ($save_arr)
$RCMAIL->user->save_prefs($save_arr);
-$mbox_name = $RCMAIL->imap->get_mailbox_name();
+$mbox_name = $RCMAIL->storage->get_folder();
+$threading = (bool) $RCMAIL->storage->get_threading();
// Synchronize mailbox cache, handle flag changes
-$RCMAIL->imap->mailbox_sync($mbox_name);
+$RCMAIL->storage->folder_sync($mbox_name);
// initialize searching result if search_filter is used
if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL')
{
$search_request = md5($mbox_name.$_SESSION['search_filter']);
- $RCMAIL->imap->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col);
- $_SESSION['search'] = $RCMAIL->imap->get_search_set();
+ $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col);
+ $_SESSION['search'] = $RCMAIL->storage->get_search_set();
$_SESSION['search_request'] = $search_request;
$OUTPUT->set_env('search_request', $search_request);
}
// fetch message headers
-if ($count = $RCMAIL->imap->messagecount($mbox_name, $RCMAIL->imap->threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh'])))
- $a_headers = $RCMAIL->imap->list_headers($mbox_name, NULL, $sort_col, $sort_order);
+if ($count = $RCMAIL->storage->count($mbox_name, $threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh'])))
+ $a_headers = $RCMAIL->storage->list_messages($mbox_name, NULL, $sort_col, $sort_order);
// update search set (possible change of threading mode)
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'])
&& $_SESSION['search_request'] == $_REQUEST['_search']
) {
- $_SESSION['search'] = $RCMAIL->imap->get_search_set();
+ $_SESSION['search'] = $RCMAIL->storage->get_search_set();
}
// remove old search data
else if (empty($_REQUEST['_search']) && isset($_SESSION['search'])) {
@@ -91,11 +92,11 @@ if (empty($search_request) && empty($a_headers)) {
rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), $unseen);
// update message count display
-$pages = ceil($count/$RCMAIL->imap->page_size);
+$pages = ceil($count/$RCMAIL->storage->get_pagesize());
$OUTPUT->set_env('messagecount', $count);
$OUTPUT->set_env('pagecount', $pages);
-$OUTPUT->set_env('threading', (bool) $RCMAIL->imap->threading);
-$OUTPUT->set_env('current_page', $count ? $RCMAIL->imap->list_page : 1);
+$OUTPUT->set_env('threading', $threading);
+$OUTPUT->set_env('current_page', $count ? $RCMAIL->storage->get_page() : 1);
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name);
$OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
@@ -108,7 +109,7 @@ if (isset($a_headers) && count($a_headers))
}
else {
// handle IMAP errors (e.g. #1486905)
- if ($err_code = $RCMAIL->imap->get_error_code()) {
+ if ($err_code = $RCMAIL->storage->get_error_code()) {
rcmail_display_server_error();
}
else if ($search_request)
diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc
index 3b52dfe4f..ab64debb7 100644
--- a/program/steps/mail/mark.inc
+++ b/program/steps/mail/mark.inc
@@ -30,18 +30,20 @@ $a_flags_map = array(
'flagged' => 'FLAGGED',
'unflagged' => 'UNFLAGGED');
+$threading = (bool) $RCMAIL->storage->get_threading();
+
if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_value('_flag', RCUBE_INPUT_POST)))
{
$flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
if ($flag == 'DELETED' && $CONFIG['skip_deleted'] && $_POST['_from'] != 'show') {
// count messages before changing anything
- $old_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
- $old_pages = ceil($old_count / $RCMAIL->imap->page_size);
+ $old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
+ $old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
$count = sizeof(explode(',', $uids));
}
- $marked = $RCMAIL->imap->set_flag($uids, $flag);
+ $marked = $RCMAIL->storage->set_flag($uids, $flag);
if (!$marked) {
// send error message
@@ -57,14 +59,14 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va
if ($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
$ruids = get_input_value('_ruid', RCUBE_INPUT_POST);
- $read = $RCMAIL->imap->set_flag($ruids, 'SEEN');
+ $read = $RCMAIL->storage->set_flag($ruids, 'SEEN');
if ($read && !$CONFIG['skip_deleted'])
$OUTPUT->command('flag_deleted_as_read', $ruids);
}
if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
- rcmail_send_unread_count($RCMAIL->imap->get_mailbox_name());
+ rcmail_send_unread_count($RCMAIL->storage->get_folder());
}
else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) {
if ($_POST['_from'] == 'show') {
@@ -73,31 +75,35 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va
else
$OUTPUT->command('command', 'list');
} else {
+ $search_request = get_input_value('_search', RCUBE_INPUT_GPC);
// refresh saved search set after moving some messages
- if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $RCMAIL->imap->search_set) {
- $_SESSION['search'] = $RCMAIL->imap->refresh_search();
+ if ($search_request && $RCMAIL->storage->get_search_set()) {
+ $_SESSION['search'] = $RCMAIL->storage->refresh_search();
}
- $msg_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
- $pages = ceil($msg_count / $RCMAIL->imap->page_size);
- $nextpage_count = $old_count - $RCMAIL->imap->page_size * $RCMAIL->imap->list_page;
- $remaining = $msg_count - $RCMAIL->imap->page_size * ($RCMAIL->imap->list_page - 1);
+ $msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
+ $page_size = $RCMAIL->storage->get_pagesize();
+ $page = $RCMAIL->storage->get_page();
+ $pages = ceil($msg_count / $page_size);
+ $nextpage_count = $old_count - $page_size * $page;
+ $remaining = $msg_count - $page_size * ($page - 1);
// jump back one page (user removed the whole last page)
- if ($RCMAIL->imap->list_page > 1 && $remaining == 0) {
- $RCMAIL->imap->set_page($RCMAIL->imap->list_page-1);
- $_SESSION['page'] = $RCMAIL->imap->list_page;
+ if ($page > 1 && $remaining == 0) {
+ $page -= 1;
+ $RCMAIL->storage->set_page($page);
+ $_SESSION['page'] = $page;
$jump_back = true;
}
// update message count display
$OUTPUT->set_env('messagecount', $msg_count);
- $OUTPUT->set_env('current_page', $RCMAIL->imap->list_page);
+ $OUTPUT->set_env('current_page', $page);
$OUTPUT->set_env('pagecount', $pages);
// update mailboxlist
- $mbox = $RCMAIL->imap->get_mailbox_name();
- $unseen_count = $msg_count ? $RCMAIL->imap->messagecount($mbox, 'UNSEEN') : 0;
+ $mbox = $RCMAIL->storage->get_folder();
+ $unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0;
$old_unseen = rcmail_get_unseen_count($mbox);
if ($old_unseen != $unseen_count) {
@@ -106,15 +112,16 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va
}
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox);
- if ($RCMAIL->imap->threading)
+ if ($threading) {
$count = get_input_value('_count', RCUBE_INPUT_POST);
+ }
// add new rows from next page (if any)
if ($count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
- $a_headers = $RCMAIL->imap->list_headers($mbox, NULL, $sort_col, $sort_order,
+ $a_headers = $RCMAIL->storage->list_messages($mbox, NULL, $sort_col, $sort_order,
$jump_back ? NULL : $count);
rcmail_js_message_list($a_headers, false);
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 95a456ed5..63f27440f 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -24,8 +24,9 @@ if (!$OUTPUT->ajax_call)
return;
// count messages before changing anything
-$old_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
-$old_pages = ceil($old_count / $RCMAIL->imap->page_size);
+$threading = (bool) $RCMAIL->storage->get_threading();
+$old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
+$old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
// move messages
if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && strlen($_POST['_target_mbox'])) {
@@ -33,7 +34,7 @@ if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && strlen($_POST['_targe
$target = get_input_value('_target_mbox', RCUBE_INPUT_POST, true);
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
- $moved = $RCMAIL->imap->move_message($uids, $target, $mbox);
+ $moved = $RCMAIL->storage->move_message($uids, $target, $mbox);
if (!$moved) {
// send error message
@@ -54,7 +55,7 @@ else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {
$count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
- $del = $RCMAIL->imap->delete_message($uids, $mbox);
+ $del = $RCMAIL->storage->delete_message($uids, $mbox);
if (!$del) {
// send error message
@@ -75,9 +76,11 @@ else {
exit;
}
+$search_request = get_input_value('_search', RCUBE_INPUT_GPC);
+
// refresh saved search set after moving some messages
-if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $RCMAIL->imap->search_set) {
- $_SESSION['search'] = $RCMAIL->imap->refresh_search();
+if ($search_request && $RCMAIL->storage->get_search_set()) {
+ $_SESSION['search'] = $RCMAIL->storage->refresh_search();
}
if ($_POST['_from'] == 'show')
@@ -89,26 +92,29 @@ if ($_POST['_from'] == 'show')
}
else
{
- $msg_count = $RCMAIL->imap->messagecount(NULL, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
- $pages = ceil($msg_count / $RCMAIL->imap->page_size);
- $nextpage_count = $old_count - $RCMAIL->imap->page_size * $RCMAIL->imap->list_page;
- $remaining = $msg_count - $RCMAIL->imap->page_size * ($RCMAIL->imap->list_page - 1);
+ $msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
+ $page_size = $RCMAIL->storage->get_pagesize();
+ $page = $RCMAIL->storage->get_page();
+ $pages = ceil($msg_count / $page_size);
+ $nextpage_count = $old_count - $page_size * $page;
+ $remaining = $msg_count - $page_size * ($page - 1);
// jump back one page (user removed the whole last page)
- if ($RCMAIL->imap->list_page > 1 && $remaining == 0) {
- $RCMAIL->imap->set_page($RCMAIL->imap->list_page-1);
- $_SESSION['page'] = $RCMAIL->imap->list_page;
+ if ($page > 1 && $remaining == 0) {
+ $page -= 1;
+ $RCMAIL->storage->set_page($page);
+ $_SESSION['page'] = $page;
$jump_back = true;
}
// update message count display
$OUTPUT->set_env('messagecount', $msg_count);
- $OUTPUT->set_env('current_page', $RCMAIL->imap->list_page);
+ $OUTPUT->set_env('current_page', $page);
$OUTPUT->set_env('pagecount', $pages);
// update mailboxlist
- $mbox = $RCMAIL->imap->get_mailbox_name();
- $unseen_count = $msg_count ? $RCMAIL->imap->messagecount($mbox, 'UNSEEN') : 0;
+ $mbox = $RCMAIL->storage->get_folder();
+ $unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0;
$old_unseen = rcmail_get_unseen_count($mbox);
if ($old_unseen != $unseen_count) {
@@ -123,15 +129,16 @@ else
$OUTPUT->command('set_quota', rcmail_quota_content());
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox);
- if ($RCMAIL->imap->threading)
+ if ($threading) {
$count = get_input_value('_count', RCUBE_INPUT_POST);
+ }
// add new rows from next page (if any)
if ($addrows && $count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
- $a_headers = $RCMAIL->imap->list_headers($mbox, NULL, $sort_col, $sort_order,
+ $a_headers = $RCMAIL->storage->list_messages($mbox, NULL, $sort_col, $sort_order,
$jump_back ? NULL : $count);
rcmail_js_message_list($a_headers, false);
diff --git a/program/steps/mail/pagenav.inc b/program/steps/mail/pagenav.inc
index f15ac38de..e74298b88 100644
--- a/program/steps/mail/pagenav.inc
+++ b/program/steps/mail/pagenav.inc
@@ -20,14 +20,14 @@
*/
$uid = get_input_value('_uid', RCUBE_INPUT_GET);
-$index = $RCMAIL->imap->message_index(null, $_SESSION['sort_col'], $_SESSION['sort_order']);
-$cnt = $index->countMessages();
+$index = $RCMAIL->storage->index(null, $_SESSION['sort_col'], $_SESSION['sort_order']);
+$cnt = $index->count_messages();
if ($cnt && ($pos = $index->exists($uid, true)) !== false) {
- $prev = $pos ? $index->getElement($pos-1) : 0;
- $first = $pos ? $index->getElement('FIRST') : 0;
- $next = $pos < $cnt-1 ? $index->getElement($pos+1) : 0;
- $last = $pos < $cnt-1 ? $index->getElement('LAST') : 0;
+ $prev = $pos ? $index->get_element($pos-1) : 0;
+ $first = $pos ? $index->get_element('FIRST') : 0;
+ $next = $pos < $cnt-1 ? $index->get_element($pos+1) : 0;
+ $last = $pos < $cnt-1 ? $index->get_element('LAST') : 0;
}
// Set UIDs and activate navigation buttons
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index 42bdf9776..8835730e4 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -18,8 +18,8 @@
$REMOTE_REQUEST = TRUE;
// reset list_page and old search results
-$RCMAIL->imap->set_page(1);
-$RCMAIL->imap->set_search_set(NULL);
+$RCMAIL->storage->set_page(1);
+$RCMAIL->storage->set_search_set(NULL);
$_SESSION['page'] = 1;
// using encodeURI with javascript "should" give us
@@ -107,32 +107,32 @@ $search_str = trim($search_str);
// execute IMAP search
if ($search_str)
- $RCMAIL->imap->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']);
+ $RCMAIL->storage->search($mbox, $search_str, $imap_charset, $_SESSION['sort_col']);
// save search results in session
if (!is_array($_SESSION['search']))
$_SESSION['search'] = array();
if ($search_str) {
- $_SESSION['search'] = $RCMAIL->imap->get_search_set();
+ $_SESSION['search'] = $RCMAIL->storage->get_search_set();
$_SESSION['last_text_search'] = $str;
}
$_SESSION['search_request'] = $search_request;
// Get the headers
-$result_h = $RCMAIL->imap->list_headers($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);
-$count = $RCMAIL->imap->messagecount($mbox, $RCMAIL->imap->threading ? 'THREADS' : 'ALL');
+$result_h = $RCMAIL->storage->list_messages($mbox, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);
+$count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
// Make sure we got the headers
if (!empty($result_h)) {
rcmail_js_message_list($result_h);
if ($search_str)
- $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->imap->messagecount(NULL, 'ALL')));
+ $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL')));
}
// handle IMAP errors (e.g. #1486905)
-else if ($err_code = $RCMAIL->imap->get_error_code()) {
+else if ($err_code = $RCMAIL->storage->get_error_code()) {
rcmail_display_server_error();
}
else {
@@ -142,8 +142,6 @@ else {
// update message count display
$OUTPUT->set_env('search_request', $search_str ? $search_request : '');
$OUTPUT->set_env('messagecount', $count);
-$OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->imap->page_size));
+$OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize()));
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1), $mbox);
$OUTPUT->send();
-
-
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 953c7521a..ea673fdcf 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -634,9 +634,9 @@ if (!$savedraft)
// set replied/forwarded flag
if ($COMPOSE['reply_uid'])
- $RCMAIL->imap->set_flag($COMPOSE['reply_uid'], 'ANSWERED', $COMPOSE['mailbox']);
+ $RCMAIL->storage->set_flag($COMPOSE['reply_uid'], 'ANSWERED', $COMPOSE['mailbox']);
else if ($COMPOSE['forward_uid'])
- $RCMAIL->imap->set_flag($COMPOSE['forward_uid'], 'FORWARDED', $COMPOSE['mailbox']);
+ $RCMAIL->storage->set_flag($COMPOSE['forward_uid'], 'FORWARDED', $COMPOSE['mailbox']);
} // End of SMTP Delivery Block
@@ -649,12 +649,12 @@ else
if ($store_target) {
// check if folder is subscribed
- if ($RCMAIL->imap->mailbox_exists($store_target, true))
+ if ($RCMAIL->storage->folder_exists($store_target, true))
$store_folder = true;
// folder may be existing but not subscribed (#1485241)
- else if (!$RCMAIL->imap->mailbox_exists($store_target))
- $store_folder = $RCMAIL->imap->create_mailbox($store_target, true);
- else if ($RCMAIL->imap->subscribe($store_target))
+ else if (!$RCMAIL->storage->folder_exists($store_target))
+ $store_folder = $RCMAIL->storage->create_folder($store_target, true);
+ else if ($RCMAIL->storage->subscribe($store_target))
$store_folder = true;
// append message to sent box
@@ -684,7 +684,7 @@ if ($store_target) {
'message' => "Could not create message: ".$msg->getMessage()),
TRUE, FALSE);
else {
- $saved = $RCMAIL->imap->save_message($store_target, $msg, $headers, $mailbody_file ? true : false);
+ $saved = $RCMAIL->storage->save_message($store_target, $msg, $headers, $mailbody_file ? true : false);
}
if ($mailbody_file) {
@@ -708,11 +708,11 @@ if ($store_target) {
if ($olddraftmessageid) {
// delete previous saved draft
// @TODO: use message UID (remember to check UIDVALIDITY) to skip this SEARCH
- $delete_idx = $RCMAIL->imap->search_once($CONFIG['drafts_mbox'],
+ $delete_idx = $RCMAIL->storage->search_once($CONFIG['drafts_mbox'],
'HEADER Message-ID '.$olddraftmessageid);
if ($del_uid = $delete_idx->getElement('FIRST')) {
- $deleted = $RCMAIL->imap->delete_message($del_uid, $CONFIG['drafts_mbox']);
+ $deleted = $RCMAIL->storage->delete_message($del_uid, $CONFIG['drafts_mbox']);
// raise error if deletion of old draft failed
if (!$deleted)
@@ -733,7 +733,7 @@ if ($savedraft) {
// remember new draft-uid ($saved could be an UID or TRUE here)
if (is_bool($saved)) {
- $draft_idx = $RCMAIL->imap->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid);
+ $draft_idx = $RCMAIL->storage->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid);
$saved = $draft_idx->getElement('FIRST');
}
$COMPOSE['param']['draft_uid'] = $saved;
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index aee563d52..7a3d3cd7f 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -30,14 +30,14 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
rcmail_message_error($uid);
}
- $mbox_name = $RCMAIL->imap->get_mailbox_name();
+ $mbox_name = $RCMAIL->storage->get_folder();
// show images?
rcmail_check_safe($MESSAGE);
// set message charset as default
if (!empty($MESSAGE->headers->charset))
- $RCMAIL->imap->set_charset($MESSAGE->headers->charset);
+ $RCMAIL->storage->set_charset($MESSAGE->headers->charset);
$OUTPUT->set_pagetitle(abbreviate_string($MESSAGE->subject, 128, '...', true));
@@ -47,7 +47,7 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
$OUTPUT->set_env('safemode', $MESSAGE->is_safe);
$OUTPUT->set_env('sender', $MESSAGE->sender['string']);
$OUTPUT->set_env('permaurl', rcmail_url('show', array('_uid' => $MESSAGE->uid, '_mbox' => $mbox_name)));
- $OUTPUT->set_env('delimiter', $RCMAIL->imap->get_hierarchy_delimiter());
+ $OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter());
$OUTPUT->set_env('mailbox', $mbox_name);
// mimetypes supported by the browser (default settings)
@@ -77,7 +77,7 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
if ($MESSAGE->headers->mdn_to
&& empty($MESSAGE->headers->flags['MDNSENT'])
&& empty($MESSAGE->headers->flags['SEEN'])
- && ($RCMAIL->imap->check_permflag('MDNSENT') || $RCMAIL->imap->check_permflag('*'))
+ && ($RCMAIL->storage->check_permflag('MDNSENT') || $RCMAIL->storage->check_permflag('*'))
&& $mbox_name != $CONFIG['drafts_mbox']
&& $mbox_name != $CONFIG['sent_mbox']
) {
@@ -175,8 +175,8 @@ function rcmail_message_buttons()
{
global $MESSAGE, $RCMAIL, $CONFIG;
- $mbox = $RCMAIL->imap->get_mailbox_name();
- $delim = $RCMAIL->imap->get_hierarchy_delimiter();
+ $mbox = $RCMAIL->storage->get_folder();
+ $delim = $RCMAIL->storage->get_hierarchy_delimiter();
$dbox = $CONFIG['drafts_mbox'];
// the message is not a draft
@@ -248,7 +248,7 @@ else
if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']) &&
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0)))
{
- if ($RCMAIL->imap->set_flag($MESSAGE->uid, 'SEEN')) {
+ if ($RCMAIL->storage->set_flag($MESSAGE->uid, 'SEEN')) {
if ($count = rcmail_get_unseen_count($mbox_name)) {
rcmail_set_unseen_count($mbox_name, $count - 1);
}
diff --git a/program/steps/mail/viewsource.inc b/program/steps/mail/viewsource.inc
index e2b4e1b61..c9aeac4c1 100644
--- a/program/steps/mail/viewsource.inc
+++ b/program/steps/mail/viewsource.inc
@@ -24,7 +24,7 @@ ob_end_clean();
// similar code as in program/steps/mail/get.inc
if ($uid = get_input_value('_uid', RCUBE_INPUT_GET))
{
- $headers = $RCMAIL->imap->get_headers($uid);
+ $headers = $RCMAIL->storage->get_message_headers($uid);
$charset = $headers->charset ? $headers->charset : $CONFIG['default_charset'];
header("Content-Type: text/plain; charset={$charset}");
@@ -44,7 +44,7 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET))
header("Content-Disposition: attachment; filename=\"$filename\"");
}
- $RCMAIL->imap->print_raw_body($uid);
+ $RCMAIL->storage->print_raw_body($uid);
}
else
{
diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc
index 9860c2fdd..b99764c60 100644
--- a/program/steps/settings/edit_folder.inc
+++ b/program/steps/settings/edit_folder.inc
@@ -21,13 +21,12 @@
// WARNING: folder names in UI are encoded with RCMAIL_CHARSET
-// init IMAP connection
-$RCMAIL->imap_connect();
-
function rcmail_folder_form($attrib)
{
global $RCMAIL;
+ $storage = $RCMAIL->get_storage();
+
// edited folder name (empty in create-folder mode)
$mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true));
$mbox_imap = rcube_charset_convert($mbox, RCMAIL_CHARSET, 'UTF7-IMAP');
@@ -36,13 +35,13 @@ function rcmail_folder_form($attrib)
$parent = trim(get_input_value('_path', RCUBE_INPUT_GPC, true));
$parent_imap = rcube_charset_convert($parent, RCMAIL_CHARSET, 'UTF7-IMAP');
- $threading_supported = $RCMAIL->imap->get_capability('THREAD');
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
+ $threading_supported = $storage->get_capability('THREAD');
+ $delimiter = $storage->get_hierarchy_delimiter();
// Get mailbox parameters
if (strlen($mbox)) {
$options = rcmail_folder_options($mbox_imap);
- $namespace = $RCMAIL->imap->get_namespace();
+ $namespace = $storage->get_namespace();
$path = explode($delimiter, $mbox_imap);
$folder = array_pop($path);
@@ -57,14 +56,14 @@ function rcmail_folder_form($attrib)
// allow creating subfolders of INBOX folder
if ($path == 'INBOX') {
- $path = $RCMAIL->imap->mod_mailbox($path, 'in');
+ $path = $storage->mod_folder($path, 'in');
}
}
// remove personal namespace prefix
if (strlen($path)) {
$path_id = $path;
- $path = $RCMAIL->imap->mod_mailbox($path.$delimiter);
+ $path = $storage->mod_folder($path.$delimiter);
if ($path[strlen($path)-1] == $delimiter) {
$path = substr($path, 0, -1);
}
@@ -193,7 +192,7 @@ function rcmail_folder_form($attrib)
);
if ((!$options['noselect'] && !$options['is_root']) || $mbox_imap == 'INBOX') {
- $msgcount = $RCMAIL->imap->messagecount($mbox_imap, 'ALL', true, false);
+ $msgcount = $storage->count($mbox_imap, 'ALL', true, false);
// Size
if ($msgcount) {
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index 7364c6eec..94f446265 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -23,20 +23,20 @@
// WARNING: folder names in UI are encoded with RCMAIL_CHARSET
// init IMAP connection
-$RCMAIL->imap_connect();
+$STORAGE = $RCMAIL->get_storage();
// subscribe mailbox
if ($RCMAIL->action == 'subscribe')
{
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true, 'UTF7-IMAP');
if (strlen($mbox)) {
- $result = $RCMAIL->imap->subscribe(array($mbox));
+ $result = $STORAGE->subscribe(array($mbox));
// Handle virtual (non-existing) folders
- if (!$result && $RCMAIL->imap->get_error_code() == -1 &&
- $RCMAIL->imap->get_response_code() == rcube_imap::TRYCREATE
+ if (!$result && $STORAGE->get_error_code() == -1 &&
+ $STORAGE->get_response_code() == rcube_storage::TRYCREATE
) {
- $result = $RCMAIL->imap->create_mailbox($mbox, true);
+ $result = $STORAGE->create_folder($mbox, true);
if ($result) {
// @TODO: remove 'virtual' class of folder's row
}
@@ -45,7 +45,7 @@ if ($RCMAIL->action == 'subscribe')
if ($result) {
// Handle subscription of protected folder (#1487656)
if ($CONFIG['protect_default_folders'] == true
- && in_array($mbox, $CONFIG['default_imap_folders'])
+ && in_array($mbox, $CONFIG['default_folders'])
) {
$OUTPUT->command('disable_subscription', $mbox);
}
@@ -62,7 +62,7 @@ else if ($RCMAIL->action == 'unsubscribe')
{
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true, 'UTF7-IMAP');
if (strlen($mbox)) {
- $result = $RCMAIL->imap->unsubscribe(array($mbox));
+ $result = $STORAGE->unsubscribe(array($mbox));
if ($result)
$OUTPUT->show_message('folderunsubscribed', 'confirmation');
else
@@ -80,7 +80,7 @@ else if ($RCMAIL->action == 'delete-folder')
$plugin = $RCMAIL->plugins->exec_hook('folder_delete', array('name' => $mbox));
if (!$plugin['abort']) {
- $deleted = $RCMAIL->imap->delete_mailbox($plugin['name']);
+ $deleted = $STORAGE->delete_folder($plugin['name']);
}
else {
$deleted = $plugin['result'];
@@ -126,19 +126,19 @@ else if ($RCMAIL->action == 'purge')
{
$mbox_utf8 = get_input_value('_mbox', RCUBE_INPUT_POST, true);
$mbox = rcube_charset_convert($mbox_utf8, RCMAIL_CHARSET, 'UTF7-IMAP');
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
+ $delimiter = $STORAGE->get_hierarchy_delimiter();
$trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/';
// we should only be purging trash (or their subfolders)
if (!strlen($CONFIG['trash_mbox']) || $mbox == $CONFIG['trash_mbox']
|| preg_match($trash_regexp, $mbox)
) {
- $success = $RCMAIL->imap->clear_mailbox($mbox);
+ $success = $STORAGE->delete_message('*', $mbox);
$delete = true;
}
// copy to Trash
else {
- $success = $RCMAIL->imap->move_message('1:*', $CONFIG['trash_mbox'], $mbox);
+ $success = $STORAGE->move_message('1:*', $CONFIG['trash_mbox'], $mbox);
$delete = false;
}
@@ -164,7 +164,7 @@ else if ($RCMAIL->action == 'folder-size')
{
$name = trim(get_input_value('_mbox', RCUBE_INPUT_POST, true));
- $size = $RCMAIL->imap->get_mailbox_size($name);
+ $size = $STORAGE->folder_size($name);
// @TODO: check quota and show percentage usage of specified mailbox?
@@ -199,13 +199,15 @@ function rcube_subscription_form($attrib)
$table->add_header('subscribed', '');
}
+ $STORAGE = $RCMAIL->get_storage();
+
// get folders from server
- $RCMAIL->imap->clear_cache('mailboxes', true);
+ $STORAGE->clear_cache('mailboxes', true);
- $a_unsubscribed = $RCMAIL->imap->list_unsubscribed();
- $a_subscribed = $RCMAIL->imap->list_mailboxes('', '*', null, null, true); // unsorted
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
- $namespace = $RCMAIL->imap->get_namespace();
+ $a_unsubscribed = $STORAGE->list_folders();
+ $a_subscribed = $STORAGE->list_folders_subscribed('', '*', null, null, true); // unsorted
+ $delimiter = $STORAGE->get_hierarchy_delimiter();
+ $namespace = $STORAGE->get_namespace();
$a_js_folders = array();
$seen = array();
$list_folders = array();
@@ -213,7 +215,7 @@ function rcube_subscription_form($attrib)
// pre-process folders list
foreach ($a_unsubscribed as $i => $folder) {
$folder_id = $folder;
- $folder = $RCMAIL->imap->mod_mailbox($folder);
+ $folder = $STORAGE->mod_folder($folder);
$foldersplit = explode($delimiter, $folder);
$name = rcube_charset_convert(array_pop($foldersplit), 'UTF7-IMAP');
$parent_folder = join($delimiter, $foldersplit);
@@ -269,7 +271,7 @@ function rcube_subscription_form($attrib)
$idx = $i + 1;
$sub_key = array_search($folder['id'], $a_subscribed);
$subscribed = $sub_key !== false;
- $protected = ($CONFIG['protect_default_folders'] == true && in_array($folder['id'], $CONFIG['default_imap_folders']));
+ $protected = ($CONFIG['protect_default_folders'] == true && in_array($folder['id'], $CONFIG['default_folders']));
$noselect = false;
$classes = array($i%2 ? 'even' : 'odd');
@@ -283,7 +285,7 @@ function rcube_subscription_form($attrib)
}
if (!$protected) {
- $attrs = $RCMAIL->imap->mailbox_attributes($folder['id']);
+ $attrs = $STORAGE->folder_attributes($folder['id']);
$noselect = in_array('\\Noselect', $attrs);
}
@@ -342,7 +344,7 @@ function rcube_subscription_form($attrib)
$OUTPUT->add_gui_object('subscriptionlist', $attrib['id']);
$OUTPUT->set_env('subscriptionrows', $a_js_folders);
- $OUTPUT->set_env('defaultfolders', $CONFIG['default_imap_folders']);
+ $OUTPUT->set_env('defaultfolders', $CONFIG['default_folders']);
$OUTPUT->set_env('delimiter', $delimiter);
return $form_start . $table->show($attrib) . $form_end;
@@ -367,13 +369,14 @@ function rcmail_rename_folder($oldname, $newname)
{
global $RCMAIL;
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
+ $storage = $RCMAIL->get_storage();
+ $delimiter = $storage->get_hierarchy_delimiter();
$plugin = $RCMAIL->plugins->exec_hook('folder_rename', array(
'oldname' => $oldname, 'newname' => $newname));
if (!$plugin['abort']) {
- $renamed = $RCMAIL->imap->rename_mailbox($oldname, $newname);
+ $renamed = $storage->rename_folder($oldname, $newname);
}
else {
$renamed = $plugin['result'];
@@ -405,7 +408,7 @@ function rcmail_rename_folder($oldname, $newname)
$OUTPUT->set_pagetitle(rcube_label('folders'));
$OUTPUT->include_script('list.js');
-$OUTPUT->set_env('quota', $RCMAIL->imap->get_capability('QUOTA'));
+$OUTPUT->set_env('quota', $STORAGE->get_capability('QUOTA'));
// add some labels to client
$OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting',
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 44d3610f9..f91f2cf46 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -317,8 +317,8 @@ function rcmail_user_prefs($current=null)
);
}
- $RCMAIL->imap_connect();
- $threading_supported = $RCMAIL->imap->get_capability('THREAD');
+ $storage = $RCMAIL->get_storage();
+ $threading_supported = $storage->get_capability('THREAD');
if (!isset($no_override['autoexpand_threads']) && $threading_supported) {
$field_id = 'rcmfd_autoexpand_threads';
@@ -681,10 +681,7 @@ function rcmail_user_prefs($current=null)
);
// Configure special folders
- if (!isset($no_override['default_imap_folders'])) {
-
- $RCMAIL->imap_connect();
-
+ if (!isset($no_override['default_folders'])) {
// load folders list only when needed
if ($current) {
$select = rcmail_mailbox_select(array(
@@ -849,7 +846,7 @@ function rcmail_folder_options($mailbox)
{
global $RCMAIL;
- $options = $RCMAIL->imap->mailbox_info($mailbox);
+ $options = $RCMAIL->get_storage()->folder_info($mailbox);
$options['protected'] = $options['is_root'] || ($options['special'] && $RCMAIL->config->get('protect_default_folders'));
return $options;
@@ -867,11 +864,12 @@ function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class
{
global $RCMAIL, $CONFIG, $OUTPUT;
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
+ $storage = $RCMAIL->get_storage();
+ $delimiter = $storage->get_hierarchy_delimiter();
$name_utf8 = rcube_charset_convert($name, 'UTF7-IMAP');
- $protected = ($CONFIG['protect_default_folders'] == true && in_array($name, $CONFIG['default_imap_folders']));
+ $protected = ($CONFIG['protect_default_folders'] == true && in_array($name, $CONFIG['default_folders']));
- $foldersplit = explode($delimiter, $RCMAIL->imap->mod_mailbox($name));
+ $foldersplit = explode($delimiter, $storage->mod_folder($name));
$level = count($foldersplit) - 1;
$display_name = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)
. Q($protected ? rcmail_localize_foldername($name) : rcube_charset_convert($foldersplit[$level], 'UTF7-IMAP'));
diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc
index 0fc090e12..b912c099b 100644
--- a/program/steps/settings/save_folder.inc
+++ b/program/steps/settings/save_folder.inc
@@ -22,7 +22,7 @@
// WARNING: folder names in UI are encoded with RCMAIL_CHARSET
// init IMAP connection
-$RCMAIL->imap_connect();
+$STORAGE = $RCMAIL->get_storage();
$name = trim(get_input_value('_name', RCUBE_INPUT_POST, true));
@@ -33,7 +33,7 @@ $name_imap = rcube_charset_convert($name, RCMAIL_CHARSET, 'UTF7-IMAP');
$old_imap = rcube_charset_convert($old, RCMAIL_CHARSET, 'UTF7-IMAP');
// $path is in UTF7-IMAP already
-$delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
+$delimiter = $STORAGE->get_hierarchy_delimiter();
$options = strlen($old_imap) ? rcmail_folder_options($old_imap) : array();
// Folder name checks
@@ -66,13 +66,13 @@ else {
$name_imap = $path . $delimiter . $name_imap;
}
else {
- $name_imap = $RCMAIL->imap->mod_mailbox($name_imap, 'in');
+ $name_imap = $STORAGE->mod_folder($name_imap, 'in');
}
}
// Check access rights to the parent folder
if (!$error && strlen($path) && (!strlen($old_imap) || $old_imap != $name_imap)) {
- $parent_opts = $RCMAIL->imap->mailbox_info($path);
+ $parent_opts = $STORAGE->folder_info($path);
if ($parent_opts['namespace'] != 'personal'
&& (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts)))
) {
@@ -103,7 +103,7 @@ if (!$error && !strlen($old)) {
$folder = $plugin['record'];
if (!$plugin['abort']) {
- $created = $RCMAIL->imap->create_mailbox($folder['name'], $folder['subscribe']);
+ $created = $STORAGE->create_folder($folder['name'], $folder['subscribe']);
}
else {
$created = $plugin['result'];
@@ -143,7 +143,7 @@ else if (!$error) {
if (!$plugin['abort']) {
if ($rename) {
- $updated = $RCMAIL->imap->rename_mailbox($folder['oldname'], $folder['name']);
+ $updated = $STORAGE->rename_folder($folder['oldname'], $folder['name']);
}
else {
$updated = true;
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 18ef5e7dd..ccb851bdd 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -181,15 +181,15 @@ switch ($CURR_SECTION)
break;
case 'folders':
- // special handling for 'default_imap_folders'
- if (in_array('default_imap_folders', (array)$CONFIG['dont_override'])) {
+ // special handling for 'default_folders'
+ if (in_array('default_folders', (array)$CONFIG['dont_override'])) {
foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p)
$a_user_prefs[$p] = $CONFIG[$p];
} else {
- $a_user_prefs['default_imap_folders'] = array('INBOX');
+ $a_user_prefs['default_folders'] = array('INBOX');
foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) {
if ($a_user_prefs[$p])
- $a_user_prefs['default_imap_folders'][] = $a_user_prefs[$p];
+ $a_user_prefs['default_folders'][] = $a_user_prefs[$p];
}
}