X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=program%2Fsteps%2Fmail%2Ffunc.inc;h=3c93cda1d993acdf1e6c2a9e88726b8223281e98;hb=76507f7c63a660742e76889ad6e3919f3dde3bb0;hp=5628ad7ff31615bff83d261cb19898db2f470214;hpb=8bb10dbda276f4c5f1050a05786ba5a5a6cc787d;p=roundcube.git diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 5628ad7..3c93cda 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -4,8 +4,8 @@ +-----------------------------------------------------------------------+ | program/steps/mail/func.inc | | | - | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2005-2010, The Roundcube Dev Team | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -15,1468 +15,1570 @@ | Author: Thomas Bruederli | +-----------------------------------------------------------------------+ - $Id: func.inc 575 2007-05-18 12:35:28Z thomasb $ + $Id: func.inc 5601 2011-12-14 09:08:54Z alec $ */ -require_once('lib/html2text.inc'); -require_once('lib/enriched.inc'); +// setup some global vars used by mail steps +$SENT_MBOX = $RCMAIL->config->get('sent_mbox'); +$DRAFTS_MBOX = $RCMAIL->config->get('drafts_mbox'); +$SEARCH_MODS_DEFAULT = array( + '*' => array('subject'=>1, 'from'=>1), + $SENT_MBOX => array('subject'=>1, 'to'=>1), + $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'); -$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; +// always instantiate imap object (but not yet connect to server) +$RCMAIL->imap_init(); -if (empty($_SESSION['mbox'])) - $_SESSION['mbox'] = $IMAP->get_mailbox_name(); +// log in to imap server +if (!in_array($RCMAIL->action, $NOIMAP_ACTIONS) && !$RCMAIL->imap_connect()) { + $RCMAIL->kill_session(); -// set imap properties and session vars -if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC)) - { - $IMAP->set_mailbox($mbox); - $_SESSION['mbox'] = $mbox; - } + if ($OUTPUT->ajax_call) + $OUTPUT->redirect(array(), 2000); -if (!empty($_GET['_page'])) - { - $IMAP->set_page((int)$_GET['_page']); - $_SESSION['page'] = (int)$_GET['_page']; - } + $OUTPUT->set_env('task', 'login'); + $OUTPUT->send('login'); +} -// set mailbox to INBOX if not set -if (empty($_SESSION['mbox'])) +// set imap properties and session vars +if (strlen(trim($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC, true)))) + $IMAP->set_mailbox(($_SESSION['mbox'] = $mbox)); +else if ($IMAP) $_SESSION['mbox'] = $IMAP->get_mailbox_name(); +if (!empty($_GET['_page'])) + $IMAP->set_page(($_SESSION['page'] = intval($_GET['_page']))); + // set default sort col/order to session if (!isset($_SESSION['sort_col'])) - $_SESSION['sort_col'] = $CONFIG['message_sort_col']; + $_SESSION['sort_col'] = !empty($CONFIG['message_sort_col']) ? $CONFIG['message_sort_col'] : ''; if (!isset($_SESSION['sort_order'])) - $_SESSION['sort_order'] = $CONFIG['message_sort_order']; - -// set message set for search result -if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) - $IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]); - - -// define url for getting message parts -if (strlen($_GET['_uid'])) - $GET_URL = rcmail_url('get', array('_mbox'=>$IMAP->get_mailbox_name(), '_uid'=>get_input_value('_uid', RCUBE_INPUT_GET))); - - -// set current mailbox in client environment -$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name()); -$OUTPUT->set_env('quota', $IMAP->get_capability('quota')); - -if ($CONFIG['trash_mbox']) - $OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']); -if ($CONFIG['drafts_mbox']) - $OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']); -if ($CONFIG['junk_mbox']) - $OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']); - -if (!$OUTPUT->ajax_call) - rcube_add_label('checkingmail'); - - -// return the mailboxlist in HTML -function rcmail_mailbox_list($attrib) - { - global $IMAP, $CONFIG, $OUTPUT, $COMM_PATH; - static $s_added_script = FALSE; - static $a_mailboxes; - - // add some labels to client - rcube_add_label('purgefolderconfirm'); - rcube_add_label('deletemessagesconfirm'); - -// $mboxlist_start = rcube_timer(); - - $type = $attrib['type'] ? $attrib['type'] : 'ul'; - $add_attrib = $type=='select' ? array('style', 'class', 'id', 'name', 'onchange') : - array('style', 'class', 'id'); - - if ($type=='ul' && !$attrib['id']) - $attrib['id'] = 'rcmboxlist'; - - // allow the following attributes to be added to the