X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=program%2Fsteps%2Fmail%2Ffunc.inc;h=b3c4e63b51ca7c2ee95cc7409726b853dbb8bcda;hb=315a64971ff1249e4d5884f309fab5ddbfe55cc6;hp=3a971bd4052387f6c54f55e686fa68b758ac1509;hpb=0af63e79917234f76cfa7ec74e9d97b24fbf9b55;p=roundcube.git diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 3a971bd..b3c4e63 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, RoundCube Dev. - Switzerland | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2005-2010, Roundcube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -15,1514 +15,1759 @@ | Author: Thomas Bruederli | +-----------------------------------------------------------------------+ - $Id: func.inc 429 2006-12-22 22:26:24Z thomasb $ + $Id: func.inc 4509 2011-02-09 10:51:50Z thomasb $ */ -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)); +// Simplified for IDN in Unicode +//$EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-z]{2,5})'; +$EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[^&@"\'.][^@&"\']*\\.[a-z]{2,5})'; -$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; +// actions that do not require imap connection here +$NOIMAP_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment', 'get'); -if (empty($_SESSION['mbox'])){ - $_SESSION['mbox'] = $IMAP->get_mailbox_name(); -} +// always instantiate imap object (but not yet connect to server) +$RCMAIL->imap_init(); -// set imap properties and session vars -if (strlen($_GET['_mbox'])) - { - $IMAP->set_mailbox($_GET['_mbox']); - $_SESSION['mbox'] = $_GET['_mbox']; - } +// log in to imap server +if (!in_array($RCMAIL->action, $NOIMAP_ACTIONS) && !$RCMAIL->imap_connect()) { + $RCMAIL->kill_session(); -if (strlen($_GET['_page'])) - { - $IMAP->set_page($_GET['_page']); - $_SESSION['page'] = $_GET['_page']; - } + if ($OUTPUT->ajax_call) + $OUTPUT->redirect(array(), 2000); + + $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']; - - -// define url for getting message parts -if (strlen($_GET['_uid'])) - $GET_URL = sprintf('%s&_action=get&_mbox=%s&_uid=%d', $COMM_PATH, $IMAP->get_mailbox_name(), $_GET['_uid']); - - -// set current mailbox in client environment -$OUTPUT->add_script(sprintf("%s.set_env('mailbox', '%s');", $JS_OBJECT_NAME, $IMAP->get_mailbox_name())); - -if ($CONFIG['trash_mbox']) - $OUTPUT->add_script(sprintf("%s.set_env('trash_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['trash_mbox'])); + $_SESSION['sort_order'] = strtoupper($CONFIG['message_sort_order']) == 'ASC' ? 'ASC' : 'DESC'; -if ($CONFIG['drafts_mbox']) - $OUTPUT->add_script(sprintf("%s.set_env('drafts_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['drafts_mbox'])); - -if ($CONFIG['junk_mbox']) - $OUTPUT->add_script(sprintf("%s.set_env('junk_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['junk_mbox'])); - -// return the mailboxlist in HTML -function rcmail_mailbox_list($attrib) - { - global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH; - static $s_added_script = FALSE; - static $a_mailboxes; +// set threads mode +$a_threading = $RCMAIL->config->get('message_threading', array()); +if (isset($_GET['_threads'])) { + if ($_GET['_threads']) + $a_threading[$_SESSION['mbox']] = true; + else + unset($a_threading[$_SESSION['mbox']]); + $RCMAIL->user->save_prefs(array('message_threading' => $a_threading)); +} +$IMAP->set_threading($a_threading[$_SESSION['mbox']]); + +// set message set for search result +if (!empty($_REQUEST['_search']) && isset($_SESSION['search']) + && $_SESSION['search_request'] == $_REQUEST['_search'] +) { + $IMAP->set_search_set($_SESSION['search']); + $OUTPUT->set_env('search_request', $_REQUEST['_search']); + $OUTPUT->set_env('search_text', $_SESSION['last_text_search']); +} - // add some labels to client - rcube_add_label('purgefolderconfirm'); - -// $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