From 04780e37492aafbea65c85fe29601481dc56d518 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 25 Nov 2008 12:37:02 -0700 Subject: [PATCH] MIMP has been moved into IMP. Still need to tweak some things, and there is currently no meaningful message display, but navigation through the various pages is working fine. --- imp/compose-mimp.php | 262 +++++++++++++++++++++++++ imp/config/conf.xml | 12 ++ imp/config/prefs.php.dist | 17 ++ imp/docs/CHANGES | 1 + imp/folders-mimp.php | 62 ++++++ imp/lib/IMP.php | 8 +- imp/lib/MIMP.php | 69 +++++++ imp/lib/Mime/Viewer/html.php | 9 + imp/lib/Mime/Viewer/plain.php | 23 ++- imp/lib/Session.php | 16 +- imp/lib/base.php | 51 +++-- imp/login.php | 32 +-- imp/mailbox-mimp.php | 207 ++++++++++++++++++++ imp/message-mimp.php | 335 ++++++++++++++++++++++++++++++++ imp/redirect.php | 29 ++- imp/templates/compose/compose-mimp.inc | 66 +++++++ imp/templates/compose/redirect-mimp.inc | 22 +++ imp/templates/folders/folders-mimp.inc | 37 ++++ imp/templates/mailbox/mailbox-mimp.inc | 37 ++++ 19 files changed, 1234 insertions(+), 61 deletions(-) create mode 100644 imp/compose-mimp.php create mode 100644 imp/folders-mimp.php create mode 100644 imp/lib/MIMP.php create mode 100644 imp/mailbox-mimp.php create mode 100644 imp/message-mimp.php create mode 100644 imp/templates/compose/compose-mimp.inc create mode 100644 imp/templates/compose/redirect-mimp.inc create mode 100644 imp/templates/folders/folders-mimp.inc create mode 100644 imp/templates/mailbox/mailbox-mimp.inc diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php new file mode 100644 index 000000000..78ae6eb41 --- /dev/null +++ b/imp/compose-mimp.php @@ -0,0 +1,262 @@ + + * @author Michael Slusarz + */ + +function &_getIMPContents($index, $mailbox) +{ + if (empty($index)) { + return false; + } + $imp_contents = &IMP_Contents::singleton($index . IMP::IDX_SEP . $mailbox); + if (is_a($imp_contents, 'PEAR_Error')) { + $GLOBALS['notification']->push(_("Could not retrieve the message from the mail server."), 'horde.error'); + return false; + } + return $imp_contents; +} + +require_once dirname(__FILE__) . '/lib/base.php'; +require_once 'Horde/Identity.php'; + +/* The message text. */ +$msg = ''; + +/* The headers of the message. */ +$header = array( + 'bcc' => '', + 'cc' => '', + 'in_reply_to' => Util::getFormData('in_reply_to'), + 'references' => Util::getFormData('references'), + 'subject' => '', + 'to' => '', +); + +/* Set the current identity. */ +$identity = &Identity::singleton(array('imp', 'imp')); +if (!$prefs->isLocked('default_identity')) { + $identity_id = Util::getFormData('identity'); + if ($identity_id !== null) { + $identity->setDefault($identity_id); + } +} + +$save_sent_mail = $prefs->getValue('save_sent_mail'); +$sent_mail_folder = $identity->getValue('sent_mail_folder'); +$index = Util::getFormData('index'); +$thismailbox = Util::getFormData('thismailbox'); +$resume_draft = false; + +/* Determine if mailboxes are readonly. */ +$draft = IMP::folderPref($prefs->getValue('drafts_folder'), true); +$readonly_drafts = (empty($draft)) ? false : $imp_imap->isReadOnly($draft); +if ($imp_imap->isReadOnly($sent_mail_folder)) { + $save_sent_mail = false; +} + +/* Determine if compose mode is disabled. */ +$compose_disable = !empty($conf['hooks']['disable_compose']) && + Horde::callHook('_imp_hook_disable_compose', array(true), 'imp'); + +/* Set the current time zone. */ +NLS::setTimeZone(); + +/* Initialize the IMP_Compose:: object. */ +$oldCacheID = Util::getFormData('composeCache'); +$imp_compose = &IMP_Compose::singleton($oldCacheID); + +/* Run through the action handlers. */ +$actionID = Util::getFormData('a'); +switch ($actionID) { +// 'd' = draft +case 'd': + $result = $imp_compose->resumeDraft($index . IMP::IDX_SEP . $thismailbox); + if (is_a($result, 'PEAR_Error')) { + $notification->push($result, 'horde.error'); + } else { + $msg = $result['msg']; + $header = array_merge($header, $result['header']); + if (!is_null($result['identity']) && + ($result['identity'] != $identity->getDefault()) && + !$prefs->isLocked('default_identity')) { + $identity->setDefault($result['identity']); + $sent_mail_folder = $identity->getValue('sent_mail_folder'); + } + $resume_draft = true; + } + break; + +case _("Expand Names"): + $action = Util::getFormData('action'); + $imp_ui = new IMP_UI_Compose(); + $header['to'] = $imp_ui->expandAddresses(Util::getFormData('to'), $imp_compose); + if ($action !== 'rc') { + if ($prefs->getValue('compose_cc')) { + $header['cc'] = $imp_ui->expandAddresses(Util::getFormData('cc'), $imp_compose); + } + if ($prefs->getValue('compose_bcc')) { + $header['bcc'] = $imp_ui->expandAddresses(Util::getFormData('bcc'), $imp_compose); + } + } + if ($action !== null) { + $actionID = $action; + } + break; + +// 'r' = reply +// 'rl' = reply to list +// 'ra' = reply to all +case 'r': +case 'ra': +case 'rl': + if (!($imp_contents = &_getIMPContents($index, $thismailbox))) { + break; + } + $actions = array('r' => 'reply', 'ra' => 'reply_all', 'rl' => 'reply_list'); + $reply_msg = $imp_compose->replyMessage($actions[$actionID], $imp_contents, Util::getFormData('to')); + $header = $reply_msg['headers']; + break; + +// 'f' = forward +case 'f': + if (!($imp_contents = &_getIMPContents($index, $thismailbox))) { + break; + } + $fwd_msg = $imp_compose->forwardMessage($imp_contents); + $header = $fwd_msg['headers']; + break; + +case _("Redirect"): + if (!($imp_contents = &_getIMPContents($index, $thismailbox))) { + break; + } + + $imp_ui = new IMP_UI_Compose(); + + $f_to = $imp_ui->getAddressList(Util::getFormData('to')); + + $result = $imp_ui->redirectMessage($f_to, $imp_compose, $imp_contents, NLS::getEmailCharset()); + if (!is_a($result, 'PEAR_Error')) { + if ($prefs->getValue('compose_confirm')) { + $notification->push(_("Message redirected successfully."), 'horde.success'); + } + require IMP_BASE . '/mailbox-mimp.php'; + exit; + } + $actionID = 'rc'; + $notification->push($result, 'horde.error'); + break; + +case _("Send"): + if ($compose_disable) { + break; + } + $message = Util::getFormData('message', ''); + $f_to = Util::getFormData('to'); + $f_cc = $f_bcc = null; + $header = array(); + + if ($ctype = Util::getFormData('ctype')) { + if (!($imp_contents = &_getIMPContents($index, $thismailbox))) { + break; + } + + switch ($ctype) { + case 'reply': + $reply_msg = $imp_compose->replyMessage('reply', $imp_contents, $f_to); + $msg = $reply_msg['body']; + $message .= "\n" . $msg; + break; + + case 'forward': + $fwd_msg = $imp_compose->forwardMessage($imp_contents); + $msg = $fwd_msg['body']; + $message .= "\n" . $msg; + $imp_compose->attachIMAPMessage(array($index . IMP::IDX_SEP . $thismailbox), $header); + break; + } + } + + $sig = $identity->getSignature(); + if (!empty($sig)) { + $message .= "\n" . $sig; + } + + $header['from'] = $identity->getFromLine(null, Util::getFormData('from')); + $header['replyto'] = $identity->getValue('replyto_addr'); + $header['subject'] = Util::getFormData('subject'); + + $imp_ui = new IMP_UI_Compose(); + + $header['to'] = $imp_ui->getAddressList(Util::getFormData('to')); + if ($conf['compose']['allow_cc']) { + $header['cc'] = $imp_ui->getAddressList(Util::getFormData('cc')); + } + if ($conf['compose']['allow_bcc']) { + $header['bcc'] = $imp_ui->getAddressList(Util::getFormData('bcc')); + } + + $options = array( + 'save_sent' => $save_sent_mail, + 'sent_folder' => $sent_mail_folder, + 'reply_type' => $ctype, + 'reply_index' => empty($index) ? null : $index . IMP::IDX_SEP . $thismailbox, + 'readreceipt' => Util::getFormData('request_read_receipt') + ); + $sent = $imp_compose->buildAndSendMessage($message, $header, NLS::getEmailCharset(), false, $options); + + if (is_a($sent, 'PEAR_Error')) { + $notification->push($sent, 'horde.error'); + } elseif ($sent) { + if (Util::getFormData('resume_draft') && + $prefs->getValue('auto_delete_drafts')) { + $imp_message = &IMP_Message::singleton(); + $idx_array = array($index . IMP::IDX_SEP . $thismailbox); + $delete_draft = $imp_message->delete($idx_array, true); + } + + $notification->push(_("Message sent successfully."), 'horde.success'); + require IMP_BASE . '/mailbox-mimp.php'; + exit; + } + break; +} + +/* Get the message cache ID. */ +$cacheID = $imp_compose->getCacheId(); + +$title = _("Message Composition"); +$mimp_render->set('title', $title); + +$select_list = $identity->getSelectList(); + +/* Grab any data that we were supplied with. */ +if (empty($msg)) { + $msg = Util::getFormData('message', ''); +} +foreach (array('to', 'cc', 'bcc', 'subject') as $val) { + if (empty($header[$val])) { + $header[$val] = Util::getFormData($val); + } +} + +$menu = &new Horde_Mobile_card('o', _("Menu")); +$mset = &$menu->add(new Horde_Mobile_linkset()); +MIMP::addMIMPMenu($mset, 'compose'); + +if ($actionID == 'rc') { + require IMP_TEMPLATES . '/compose/redirect-mimp.inc'; +} else { + require IMP_TEMPLATES . '/compose/compose-mimp.inc'; +} diff --git a/imp/config/conf.xml b/imp/config/conf.xml index 0c865480f..36cadbbd2 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -445,4 +445,16 @@ prefs.php (set the value of 'tos_agreement' to 1)."/> + + + + Mailbox Settings + 10 + 20 + + diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 8e33284c3..42a4e2f80 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -187,6 +187,14 @@ if (Util::extensionExists('openssl') && isset($GLOBALS['conf']['utils']['openssl ); } +$prefGroups['mimp'] = array( + 'column' => _("Other Options"), + 'label' => _("MIMP Options"), + 'desc' => _("Configure MIMP Options."), + 'members' => array('mimp_preview_msg') +); + + // Personal Information preferences // user preferred email address for Reply-To:, if different from From: @@ -1429,6 +1437,15 @@ $_prefs['smime_additional_cert'] = array( // End S/MIME Options +// display only the first 250 characters of a message on first message view? +$_prefs['mimp_preview_msg'] = array( + 'value' => 0, + 'locked' => true, + 'shared' => false, + 'type' => 'checkbox', + 'desc' => _("Display only the first 250 characters of a message initially?") +); + // Other entries (used internally in IMP) // virtual inbox identifier diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index f5964a7e8..92cf6c42b 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-cvs -------- +[mms] MIMP has been absorbed into IMP. [mms] Allow all parts in a message to be displayed (Bug #1866). [mms] Only support FCKeditor as GUI HTML editor. [mms] Strip extra 'Fwd' and 'Re' cruft from subject line when replying to or diff --git a/imp/folders-mimp.php b/imp/folders-mimp.php new file mode 100644 index 000000000..1b9556c44 --- /dev/null +++ b/imp/folders-mimp.php @@ -0,0 +1,62 @@ + + * @author Anil Madhavapeddy + * @author Michael Slusarz + */ + +require_once dirname(__FILE__) . '/lib/base.php'; + +/* Redirect back to the mailbox if folder use is not allowed. */ +if (empty($conf['user']['allow_folders'])) { + $notification->push(_("Folder use is not enabled."), 'horde.error'); + header('Location: ' . Horde::applicationUrl('mailbox-mimp.php', true)); + exit; +} + +/* Decide whether or not to show all the unsubscribed folders */ +$subscribe = $prefs->getValue('subscribe'); +$showAll = (!$subscribe || $_SESSION['imp']['showunsub']); + +/* Initialize the IMP_IMAP_Tree object. */ +$imptree = &IMP_IMAP_Tree::singleton(); +$mask = IMP_IMAP_TREE::NEXT_SHOWCLOSED; + +/* Toggle subscribed view, if necessary. */ +if ($subscribe && Util::getFormData('ts')) { + $showAll = !$showAll; + $_SESSION['imp']['showunsub'] = $showAll; + $imptree->showUnsubscribed($showAll); + $mask |= IMP_IMAP_TREE::NEXT_SHOWSUB; +} + +/* Start iterating through the list of mailboxes, displaying them. */ +$rows = array(); +$tree_ob = $imptree->build($mask); +foreach ($tree_ob[0] as $val) { + $rows[] = array( + 'level' => str_repeat('..', $val['level']), + 'label' => $val['base_elt']['l'], + 'link' => ((empty($val['container'])) ? IMP::generateIMPUrl('mailbox-mimp.php', $val['value']) : null), + 'msgs' => ((isset($val['msgs'])) ? ($val['unseen'] . '/' . $val['msgs']) : null) + ); +} + +$selfurl = Horde::applicationUrl('folders-mimp.php'); +if ($subscribe) { + $sub_text = $showAll ? _("Show Subscribed Folders") : _("Show All Folders"); + $sub_link = Util::addParameter($selfurl, 'ts', 1); +} + +$title = _("Folders"); +require IMP_TEMPLATES . '/folders/folders-mimp.inc'; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 65bf5d3ed..de29d379b 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -411,9 +411,11 @@ class IMP static public function composeLink($args = array(), $extra = array()) { $args = IMP::composeLinkArgs($args, $extra); + $is_mimp = ($_SESSION['imp']['view'] == 'mimp'); - if ($GLOBALS['prefs']->getValue('compose_popup') - && $GLOBALS['browser']->hasFeature('javascript')) { + if (!$is_mimp && + $GLOBALS['prefs']->getValue('compose_popup') && + $GLOBALS['browser']->hasFeature('javascript')) { Horde::addScriptFile('prototype.js', 'horde', true); Horde::addScriptFile('popup.js', 'imp', true); if (isset($args['to'])) { @@ -421,7 +423,7 @@ class IMP } return "javascript:" . IMP::popupIMPString('compose.php', $args); } else { - return Util::addParameter(Horde::applicationUrl('compose.php'), $args); + return Util::addParameter(Horde::applicationUrl($is_mimp ? 'compose-mimp.php' : 'compose.php'), $args); } } diff --git a/imp/lib/MIMP.php b/imp/lib/MIMP.php new file mode 100644 index 000000000..9f3163415 --- /dev/null +++ b/imp/lib/MIMP.php @@ -0,0 +1,69 @@ + + * @author Michael Slusarz + * @package IMP + */ +class MIMP +{ + /** + * Take a Horde_Mobile_card and add global menu items. + * + * @param Horde_Mobile_linkset &$menu The menu linkset, with page-specific + * options already filled in. + * @param string $page The current page ('compose', + * 'folders', 'mailbox', 'message'). + */ + public function addMIMPMenu(&$menu, $page) + { + $items = array(); + + if (!in_array($page, array('mailbox', 'message')) || + ($GLOBALS['imp_mbox']['mailbox'] != 'INBOX')) { + $items[IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX')] = _("Inbox"); + } + + if (($page != 'compose') && + (empty($GLOBALS['conf']['hooks']['disable_compose']) || + Horde::callHook('_imp_hook_disable_compose', array(true), 'imp'))) { + + $items[Util::addParameter(Horde::applicationUrl('compose-mimp.php'), 'u', base_convert(microtime() . mt_rand(), 10, 36))] = _("New Message"); + } + + if ($page != 'folders') { + $items[Horde::applicationUrl('folders-mimp.php')] = _("Folders"); + } + + // @TODO - Options for mobile browsers + // if ($options_link = Horde::getServiceLink('options', 'mimp')) { + // $items[Util::addParameter($options_link, 'mobile', 1, false)] = _("Options"); + // } + $logout_link = IMP::getLogoutUrl(); + if (!empty($logout_link)) { + $items[Auth::addLogoutParameters($logout_link, AUTH_REASON_LOGOUT)] = _("Log out"); + } + + foreach ($items as $link => $label) { + $menu->add(new Horde_Mobile_link($label, $link)); + } + + if (is_readable(IMP_BASE . '/config/menu.php')) { + include IMP_BASE . '/config/menu.php'; + if (isset($_menu) && is_array($_menu)) { + foreach ($_menu as $menuitem) { + if ($menuitem == 'separator') { + continue; + } + $menu->add(new Horde_Mobile_link($menuitem['text'], $menuitem['url'])); + } + } + } + } +} diff --git a/imp/lib/Mime/Viewer/html.php b/imp/lib/Mime/Viewer/html.php index 7e9055665..0c85fab64 100644 --- a/imp/lib/Mime/Viewer/html.php +++ b/imp/lib/Mime/Viewer/html.php @@ -134,6 +134,15 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html $cleanhtml = $this->_cleanHTML($data, $inline); $data = $cleanhtml['html']; + /* We are done processing if in mimp mode. */ + if ($_SESSION['imp']['view'] == 'mimp') { + require_once 'Horde/Text/Filter.php'; + $data = Text_Filter::filter($data, 'html2text'); + + // Filter bad language. + return IMP::filterText($data); + } + /* Reset absolutely positioned elements. */ if ($inline) { $data = preg_replace('/(style\s*=\s*)(["\'])?([^>"\']*)position\s*:\s*absolute([^>"\']*)\2/i', '$1"$3$4"', $data); diff --git a/imp/lib/Mime/Viewer/plain.php b/imp/lib/Mime/Viewer/plain.php index e07e7e626..e9c26b431 100644 --- a/imp/lib/Mime/Viewer/plain.php +++ b/imp/lib/Mime/Viewer/plain.php @@ -23,14 +23,17 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain { global $conf, $prefs; + $mime_id = $this->_mimepart->getMimeId(); + $type = 'text/html; charset=' . NLS::getCharset(); + // Trim extra whitespace in the text. $text = rtrim($this->_mimepart->getContents()); if ($text == '') { return array( - $this->_mimepart->getMimeId() => array( + $mime_id => array( 'data' => '', 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => $type ) ); } @@ -38,7 +41,6 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain // Convert to the local charset. $text = String::convertCharset($text, $this->_mimepart->getCharset()); - // Check for 'flowed' text data. if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') { $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')); @@ -51,6 +53,17 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain $text = preg_replace('/(\n+)> ?From(\s+)/', "$1From$2", $text); } + /* Done processing if in mimp mode. */ + if ($_SESSION['imp']['view'] == 'mimp') { + return array( + $mime_id => array( + 'data' => IMP::filterText($text), + 'status' => array(), + 'type' => $type + ) + ); + } + // Build filter stack. Starts with HTML markup and tab expansion. require_once 'Horde/Text/Filter.php'; $filters = array( @@ -107,10 +120,10 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain } return array( - $this->_mimepart->getMimeId() => array( + $mime_id => array( 'data' => '
' . "\n" . $text . '
', 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => $type ) ); } diff --git a/imp/lib/Session.php b/imp/lib/Session.php index 225fb2e24..0157ae8d5 100644 --- a/imp/lib/Session.php +++ b/imp/lib/Session.php @@ -32,7 +32,6 @@ class IMP_Session * 'autologin' -- Is autologin available? * 'cache' -- Various IMP libraries can use this variable to cache * data. - * 'default_view' -- The default view (dimp, imp, or mimp). * 'file_upload' -- If file uploads are allowed, the max size. * 'filteravail' -- Can we apply filters manually? * 'imap' -- Config for various IMAP resources (acl, admin, @@ -48,7 +47,7 @@ class IMP_Session * 'showunsub' -- Show unsusubscribed mailboxes on the folders screen. * 'tasklistavail' -- Is listing of tasklists available? * 'uniquser' -- The unique user name. - * 'viewmode' -- The imp view mode (currently dimp, imp, or mimp) + * 'view' -- The imp view mode (currently dimp, imp, or mimp) * * @param string $imapuser The username of the user. * @param string $password The password of the user. @@ -321,7 +320,18 @@ class IMP_Session */ static public function getInitialUrl($actionID = null, $encode = true) { - $init_url = ($_SESSION['imp']['protocol'] == 'pop') ? 'INBOX' : $GLOBALS['prefs']->getValue('initial_page'); + /* TODO: For now, redirect MIMP to mailbox page. */ + if ($_SESSION['imp']['view'] == 'mimp') { + $url = Util::addParameter(Horde::applicationUrl('mailbox-mimp.php', true), array('mailbox' => 'INBOX')); + if (!empty($actionID)) { + $url = Util::addParameter($url, array('actionID' => $actionID), null, false); + } + return $url; + } + + $init_url = ($_SESSION['imp']['protocol'] == 'pop') + ? 'INBOX' + : $GLOBALS['prefs']->getValue('initial_page'); $imp_search = new IMP_Search(); diff --git a/imp/lib/base.php b/imp/lib/base.php index 759141cca..b5632a5f5 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -10,14 +10,16 @@ * 'none' - Do not authenticate * Default - Authenticate to IMAP/POP server * $compose_page - If true, we are on IMP's compose page + * $mimp_debug - If true, output text/plain version of page. * $no_compress - Controls whether the page should be compressed - * $noset_impview - Don't set viewmode variable. * $session_control - Sets special session control limitations * * Global variables defined: - * $imp_imap - An IMP_IMAP object - * $imp_mbox - Current mailbox information - * $imp_search - An IMP_Search object + * $imp_imap - An IMP_IMAP object + * $imp_mbox - Current mailbox information + * $imp_search - An IMP_Search object + * $mimp_notify - (MIMP view only) A Notification_Listener_Mobile object + * $mimp_render - (MIMP view only) A Horde_Mobile object * * Copyright 1999-2008 The Horde Project (http://www.horde.org/) * @@ -60,6 +62,9 @@ if ($session_control == 'none') { $registry = &Registry::singleton(); } +// Need to explicitly load IMP.php +require_once IMP_BASE . '/lib/IMP.php'; + // We explicitly do not check application permissions for the compose // and login pages, since those are handled below and need to fall through // to IMP-specific code. @@ -75,16 +80,6 @@ if (!defined('IMP_TEMPLATES')) { define('IMP_TEMPLATES', $registry->get('templates')); } -// Notification system. -require_once IMP_BASE . '/lib/Notification/Listener/status.php'; -$notification = &Notification::singleton(); -$notification->attach('status', null, 'Notification_Listener_status_imp'); -require_once 'Horde/Notification/Listener/audio.php'; -$notification->attach('audio'); - -// Horde libraries. -require_once 'Horde/Secret.php'; - // Initialize global $imp_imap object. if (!isset($GLOBALS['imp_imap'])) { $GLOBALS['imp_imap'] = new IMP_IMAP(); @@ -137,13 +132,23 @@ if ($authentication !== 'none') { } else { IMP::checkAuthentication(false, ($authentication === 'horde')); } +} - // Set viewmode. - if (!Util::nonInputVar('noset_impview')) { - $_SESSION['imp']['viewmode'] = 'imp'; - } +// Notification system. +$notification = &Notification::singleton(); +if ($_SESSION['imp']['view'] == 'mimp') { + require_once 'Horde/Notification/Listener/mobile.php'; + $GLOBALS['mimp_notify'] = &$notification->attach('status', null, 'Notification_Listener_mobile'); +} else { + require_once IMP_BASE . '/lib/Notification/Listener/status.php'; + require_once 'Horde/Notification/Listener/audio.php'; + $notification->attach('status', null, 'Notification_Listener_status_imp'); + $notification->attach('audio'); } +// Horde libraries. +require_once 'Horde/Secret.php'; + // Initialize global $imp_mbox array. $GLOBALS['imp_mbox'] = IMP::getCurrentMailboxInfo(); @@ -159,3 +164,13 @@ if ((IMP::loginTasksFlag() === 2) && !strstr($_SERVER['PHP_SELF'], 'maintenance.php')) { IMP_Session::loginTasks(); } + +if ($_SESSION['imp']['view'] == 'mimp') { + // Need to explicitly load MIMP.php + require_once IMP_BASE . '/lib/MIMP.php'; + + // Mobile markup renderer. + $debug = Util::nonInputVar('mimp_debug'); + $GLOBALS['mimp_render'] = new Horde_Mobile(null, $debug); + $GLOBALS['mimp_render']->set('debug', !empty($debug)); +} diff --git a/imp/login.php b/imp/login.php index 0cd7cc168..99305fa17 100644 --- a/imp/login.php +++ b/imp/login.php @@ -193,22 +193,26 @@ if ($choose_language) { /* If DIMP/MIMP are available, show selection of alternate views. */ $views = array(); if (!empty($conf['user']['select_view'])) { - $apps = $registry->listApps(null, true); $view_cookie = isset($_COOKIE['default_imp_view']) ? $_COOKIE['default_imp_view'] - : ($browser->isMobile() && isset($apps['mimp']) ? 'mimp' : 'imp'); - if (isset($apps['dimp']) || isset($apps['mimp'])) { - $views[] = array('sel' => $view_cookie == 'imp', - 'val' => 'imp', 'name' => _("Traditional")); - if (isset($apps['dimp'])) { - $views[] = array('sel' => $view_cookie == 'dimp', - 'val' => 'dimp', 'name' => _("Dynamic")); - } - if (isset($apps['mimp'])) { - $views[] = array('sel' => $view_cookie == 'mimp', - 'val' => 'mimp', 'name' => _("Minimalist")); - } - } + : ($browser->isMobile() ? 'mimp' : 'imp'); + $views = array( + array( + 'sel' => $view_cookie == 'imp', + 'val' => 'imp', + 'name' => _("Traditional") + ), + array( + 'sel' => $view_cookie == 'dimp', + 'val' => 'dimp', + 'name' => _("Dynamic") + ), + array( + 'sel' => $view_cookie == 'mimp', + 'val' => 'mimp', + 'name' => _("Minimalist") + ) + ); } /* Mobile login page. */ diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php new file mode 100644 index 000000000..02c736ccd --- /dev/null +++ b/imp/mailbox-mimp.php @@ -0,0 +1,207 @@ + + * @author Michael Slusarz + */ + +require_once dirname(__FILE__) . '/lib/base.php'; + +/* Determine if mailbox is readonly. */ +$readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']); + +/* Set the current time zone. */ +NLS::setTimeZone(); + +/* Run through the action handlers */ +$actionID = Util::getFormData('a'); +switch ($actionID) { +// 'm' = message missing +case 'm': + $notification->push(_("There was an error viewing the requested message."), 'horde.error'); + break; + +// 'e' = expunge mailbox +case 'e': + if (!$readonly) { + $imp_message = &IMP_Message::singleton(); + $imp_message->expungeMailbox(array($imp_mbox['mailbox'] => 1)); + } + break; + +// 'c' = change sort +case 'c': + IMP::setSort(Util::getFormData('sb'), Util::getFormData('sd')); + break; +} + +/* Initialize the user's identities. */ +require_once 'Horde/Identity.php'; +$identity = &Identity::singleton(array('imp', 'imp')); + +/* Get the base URL for this page. */ +$mailbox_url = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']); + +/* Build the list of messages in the mailbox. */ +$imp_mailbox = &IMP_Mailbox::singleton($imp_mbox['mailbox']); +$pageOb = $imp_mailbox->buildMailboxPage(Util::getFormData('p'), Util::getFormData('s')); + +/* Generate page links. */ +$pages_first = $pages_prev = $pages_last = $pages_next = null; +if ($pageOb['page'] != 1) { + $pages_first = new Horde_Mobile_link(_("First Page"), Util::addParameter($mailbox_url, 'p', 1)); + $pages_prev = new Horde_Mobile_link(_("Previous Page"), Util::addParameter($mailbox_url, 'p', $pageOb['page'] - 1)); +} +if ($pageOb['page'] != $pageOb['pagecount']) { + $pages_next = new Horde_Mobile_link(_("Next Page"), Util::addParameter($mailbox_url, 'p', $pageOb['page'] + 1)); + $pages_last = new Horde_Mobile_link(_("Last Page"), Util::addParameter($mailbox_url, 'p', $pageOb['pagecount'])); +} + +/* Generate mailbox summary string. */ +$title = IMP::getLabel($imp_mbox['mailbox']); +$mimp_render->set('title', $title); +if ($pageOb['msgcount']) { + $msgcount = $pageOb['msgcount']; + $unseen = $imp_mailbox->unseenMessages(true); +} + +$charset = NLS::getCharset(); +$curr_time = time(); +$curr_time -= $curr_time % 60; +$msgs = array(); +$sortpref = IMP::getSort($imp_mbox['mailbox']); + +$imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox'], $charset, $identity); + +/* Build the array of message information. */ +$mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end'])); + +/* Get thread information. */ +$threadob = ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) + ? $imp_mailbox->getThreadOb() + : null; + +reset($mbox_info); +while (list(,$ob) = each($mbox_info['overview'])) { + /* Initialize the header fields. */ + $msg = array( + 'number' => $ob['seq'], + 'status' => '' + ); + + /* Format the from header. */ + $getfrom = $imp_ui->getFrom($ob['envelope'], false); + $msg['from'] = $getfrom['from']; + if (String::length($msg['from']) > $conf['mimp']['max_from_chars']) { + $msg['from'] = String::substr($msg['from'], 0, $conf['mimp']['max_from_chars']) . '...'; + } + + $msg['subject'] = $imp_ui->getSubject($ob['envelope']['subject']); + + if (!is_null($threadob) && ($threadob->getThreadIndent($ob['uid']) - 1)) { + $msg['subject'] = '>> ' . ltrim($msg['subject']); + } + + if (String::length($msg['subject']) > $conf['mimp']['max_subj_chars']) { + $msg['subject'] = String::substr($msg['subject'], 0, $conf['mimp']['max_subj_chars']) . '...'; + } + + /* Generate the target link. */ + $target = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $ob['uid'], $ob['mailbox']); + + /* Get flag information. */ + if ($_SESSION['imp']['protocol'] != 'pop') { + $to_ob = Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to']); + if (!empty($to_ob) && $identity->hasAddress($to_ob[0]['inner'])) { + $msg['status'] .= '+'; + } + if (!in_array('\\seen', $ob['flags'])) { + $msg['status'] .= 'N'; + } + if (in_array('\\answered', $ob['flags'])) { + $msg['status'] .= 'r'; + } + if (in_array('\\draft', $ob['flags'])) { + $target = IMP::composeLink(array(), array('a' => 'd', 'thismailbox' => $imp_mbox['mailbox'], 'index' => $ob['uid'], 'bodypart' => 1)); + } + if (in_array('\\flagged', $ob['flags'])) { + $msg['status'] .= 'I'; + } + if (in_array('\\deleted', $ob['flags'])) { + $msg['status'] .= 'D'; + } + } + + $msg['target'] = $target; + $msgs[] = $msg; +} + +$mailbox = Util::addParameter($mailbox_url, 'p', $pageOb['page']); +$items = array($mailbox => _("Refresh")); + +/* Determine if we are going to show the Purge Deleted link. */ +if (!$readonly && + !$prefs->getValue('use_trash') && + !$imp_search->isVINBOXFolder()) { + $items[Util::addParameter($mailbox, array('a' => 'e'))] = _("Purge Deleted"); +} + +/* Create sorting links. */ +$sort = array(); +$sort_list = array( + Horde_Imap_Client::SORT_ARRIVAL => '#', + Horde_Imap_Client::SORT_FROM => _("From"), + Horde_Imap_Client::SORT_SUBJECT => _("Subject") +); +foreach ($sort_list as $key => $val) { + if ($sortpref['limit']) { + $sort[$key] = (($key == Horde_Imap_Client::SORT_ARRIVAL) ? '*' : '') . $val; + } else { + $sortdir = $sortpref['dir']; + $sortkey = $key; + if (($key == Horde_Imap_Client::SORT_SUBJECT) && IMP::threadSortAvailable($mailbox)) { + if (is_null($threadob)) { + $items[Util::addParameter($mailbox, array('a' => 'c', 'sb' => Horde_Imap_Client::SORT_THREAD, 'sd' => $sortdir))] = _("Sort by Thread"); + } else { + $sortkey = Horde_Imap_Client::SORT_THREAD; + $items[Util::addParameter($mailbox, array('a' => 'c', 'sb' => Horde_Imap_Client::SORT_SUBJECT, 'sd' => $sortdir))] = _("Do Not Sort by Thread"); + } + } + if ($sortpref['by'] == $key) { + $val = '*' . $val; + $sortdir = !$sortdir; + } + $sort[$key] = new Horde_Mobile_link($val, Util::addParameter($mailbox, array('a' => 'c', 'sb' => $sortkey, 'sd' => $sortdir))); + } +} + +/* Create mailbox menu. */ +$menu = new Horde_Mobile_card('o', _("Menu")); +$mset = &$menu->add(new Horde_Mobile_linkset()); + +foreach ($items as $link => $label) { + $mset->add(new Horde_Mobile_link($label, $link)); +} + +$nav = array('pages_first', 'pages_prev', 'pages_next', 'pages_last'); +foreach ($nav as $n) { + if (Util::nonInputVar($n)) { + $mset->add($$n); + } +} + +MIMP::addMIMPMenu($mset, 'mailbox'); +require IMP_TEMPLATES . '/mailbox/mailbox-mimp.inc'; diff --git a/imp/message-mimp.php b/imp/message-mimp.php new file mode 100644 index 000000000..625f5a8d2 --- /dev/null +++ b/imp/message-mimp.php @@ -0,0 +1,335 @@ + + * @author Michael Slusarz + */ + +require_once dirname(__FILE__) . '/lib/base.php'; + +/* Make sure we have a valid index. */ +$imp_mailbox = &IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['index']); +if (!$imp_mailbox->isValidIndex()) { + header('Location: ' . Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']), array('a' => 'm'), null, false)); + exit; +} + +/* Update IMP_Mailbox on message actions. */ +$imp_message = &IMP_Message::singleton(); +$imp_message->updateMailboxOb($imp_mailbox); + +/* Determine if mailbox is readonly. */ +$readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']); + +/* Set the current time zone. */ +NLS::setTimeZone(); + +/* Run through action handlers */ +$actionID = Util::getFormData('a'); +switch ($actionID) { +// 'd' = delete message +// 'u' = undelete message +case 'd': +case 'u': + if ($readonly) { + break; + } + + /* Get mailbox/UID of message. */ + $index_array = $imp_mailbox->getIMAPIndex(); + $indices_array = array($index_array['mailbox'] => array($index_array['index'])); + + if ($actionID == 'u') { + $imp_message->undelete($indices_array); + } else { + $result = IMP::checkRequestToken('imp.message-mimp', Util::getFormData('mt')); + if (is_a($result, 'PEAR_Error')) { + $notification->push($result); + } else { + $imp_message->delete($indices_array); + if ($prefs->getValue('mailbox_return')) { + header('Location: ' . Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']), array('s' => $imp_mailbox->getMessageIndex()), null, false)); + exit; + } + if (($_SESSION['imp']['protocol'] != 'pop') && + !IMP::hideDeletedMsgs() && + !$GLOBALS['prefs']->getValue('use_trash')) { + $imp_mailbox->setIndex(1, 'offset'); + } + } + } + break; +} + +/* We may have done processing that has taken us past the end of the + * message array, so we will return to mailbox.php if that is the + * case. */ +if (!$imp_mailbox->isValidIndex()) { + header('Location: ' . Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']), array('s' => $imp_mailbox->getMessageIndex()), null, false)); + exit; +} + +/* Now that we are done processing the messages, get the index and + * array index of the current message. */ +$index_array = $imp_mailbox->getIMAPIndex(); +$index = $index_array['index']; +$mailbox_name = $index_array['mailbox']; + +/* Get envelope/flag/header information. */ +try { + /* Need to fetch flags before HEADERTEXT, because SEEN flag might be set + * before we can grab it. */ + $flags_ret = $imp_imap->ob->fetch($mailbox_name, array( + Horde_Imap_Client::FETCH_FLAGS => true, + ), array('ids' => array($index))); + $fetch_ret = $imp_imap->ob->fetch($mailbox_name, array( + Horde_Imap_Client::FETCH_ENVELOPE => true, + Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $readonly)) + ), array('ids' => array($index))); +} catch (Horde_Imap_Client_Exception $e) { + header('Location: ' . Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $mailbox_name), array('a' => 'm'), null, false)); + exit; +} + +$envelope = $fetch_ret[$index]['envelope']; +$flags = $flags_ret[$index]['flags']; +$mime_headers = $fetch_ret[$index]['headertext'][0]; +$use_pop = ($_SESSION['imp']['protocol'] == 'pop'); + +/* Parse the message. */ +$imp_contents = &IMP_Contents::singleton($index . IMP::IDX_SEP . $mailbox_name); +if (is_a($imp_contents, 'PEAR_Error')) { + header('Location: ' . Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $mailbox_name), array('a' => 'm'), null, false)); + exit; +} + +/* Create the IMP_UI_Message:: object. */ +$imp_ui = new IMP_UI_Message(); + +/* Create the Identity object. */ +require_once 'Horde/Identity.php'; +$user_identity = &Identity::singleton(array('imp', 'imp')); + +/* Get the starting index for the current message and the message count. */ +$msgindex = $imp_mailbox->getMessageIndex(); +$msgcount = $imp_mailbox->getMessageCount(); + +/* Generate the mailbox link. */ +$mailbox_link = Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']), array('s' => $msgindex)); +$self_link = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $index, $mailbox_name); + +/* Develop the list of headers to display. */ +$basic_headers = $imp_ui->basicHeaders(); +$display_headers = $msgAddresses = array(); + +$format_date = $imp_ui->addLocalTime(nl2br($envelope['date'])); +if (!empty($format_date)) { + $display_headers['date'] = $format_date; +} + +/* Build From address links. */ +$display_headers['from'] = $imp_ui->buildAddressLinks($envelope['from']); + +/* Build To/Cc/Bcc links. */ +foreach (array('to', 'cc', 'bcc') as $val) { + $msgAddresses[] = $mime_headers->getValue($val); + $addr_val = $imp_ui->buildAddressLinks($envelope[$val]); + if (!empty($addr_val)) { + $display_headers[$val] = $addr_val; + } +} + +/* Process the subject now. */ +if (($subject = $mime_headers->getValue('subject'))) { + /* Filter the subject text, if requested. */ + $subject = IMP::filterText($subject); + + /* Generate the shortened subject text. */ + if (String::length($subject) > $conf['mimp']['max_subj_chars']) { + $subject = String::substr($subject, 0, $conf['mimp']['max_subj_chars']) . '...'; + } +} else { + $subject = _("[No Subject]"); +} +$display_headers['subject'] = $subject; + +/* Check for the presence of mailing list information. */ +$list_info = $imp_ui->getListInformation($mime_headers); + +/* See if the 'X-Priority' header has been set. */ +switch ($imp_ui->getXpriority($mime_headers)) { +case 'high': +case 'low': + $basic_headers['priority'] = _("Priority"); + $display_headers['priority'] = $mime_headers->getValue('x-priority'); + break; +} + +/* Set the status information of the message. */ +$status = ''; +$identity = null; +$addresses = array(); +if (!$use_pop) { + if (!empty($msgAddresses)) { + $identity = $user_identity->getMatchingIdentity($msgAddresses); + if (!is_null($identity) || + ($user_identity->getMatchingIdentity($msgAddresses, false) !== null)) { + $status .= '+'; + } + if (is_null($identity)) { + $identity = $user_identity->getDefault(); + } + } + + /* Set status flags. */ + if (!in_array('\\seen', $flags)) { + $status .= 'N'; + } + $flag_array = array( + 'answered' => 'r', + 'draft' => 'D', + 'flagged' => '!', + 'deleted' => 'd' + ); + foreach ($flag_array as $flag => $desc) { + if (in_array('\\' . $flag, $flags)) { + $status .= $desc; + } + } +} + +/* Generate previous/next links. */ +$prev_msg = $imp_mailbox->getIMAPIndex(-1); +if ($prev_msg) { + $prev_link = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $prev_msg['index'], $prev_msg['mailbox']); +} +$next_msg = $imp_mailbox->getIMAPIndex(1); +if ($next_msg) { + $next_link = IMP::generateIMPUrl('message.php', $imp_mbox['mailbox'], $next_msg['index'], $next_msg['mailbox']); +} + +/* Create the body of the message. */ +// TODO +//$msgText = $mimp_contents->getMessage(); +$msgText = 'TODO'; + +/* Display the first 250 characters, or display the entire message? */ +if ($prefs->getValue('mimp_preview_msg') && !Util::getFormData('fullmsg')) { + $msgText = String::substr($msgText, 0, 250) . " [...]\n"; + $fullmsg_link = new Horde_Mobile_link(_("View Full Message"), Util::addParameter($self_link, array('fullmsg' => 1))); +} else { + $fullmsg_link = null; +} + +/* Create message menu. */ +$menu = new Horde_Mobile_card('o', _("Menu")); +$mset = &$menu->add(new Horde_Mobile_linkset()); + +if (!$readonly) { + if (in_array('\\deleted', $flags)) { + $mset->add(new Horde_Mobile_link(_("Undelete"), Util::addParameter($self_link, array('a' => 'u')))); + } else { + $mset->add(new Horde_Mobile_link(_("Delete"), Util::addParameter($self_link, array('a' => 'd', 'mt' => IMP::getRequestToken('imp.message-mimp'))))); + } +} + +$compose_params = array( + 'index' => $index, + 'identity' => $identity, + 'thismailbox' => $mailbox_name +); + +/* Add compose actions (Reply, Reply List, Reply All, Forward, Redirect). */ +if (empty($conf['hooks']['disable_compose']) || + !Horde::callHook('_imp_hook_disable_compose', array(true), 'imp')) { + $items = array(IMP::composeLink(array(), array('a' => 'r') + $compose_params) => _("Reply")); + + if ($list_info['reply_list']) { + $items[IMP::composeLink(array(), array('a' => 'rl') + $compose_params)] = _("Reply to List"); + } + + if (Horde_Mime_Address::addrArray2String(array_merge($envelope['to'], $envelope['cc']), array_keys($user_identity->getAllFromAddresses(true)))) { + $items[IMP::composeLink(array(), array('a' => 'ra') + $compose_params)] = _("Reply All"); + } + + $items[IMP::composeLink(array(), array('a' => 'f') + $compose_params)] = _("Forward"); + $items[IMP::composeLink(array(), array('a' => 'rc') + $compose_params)] = _("Redirect"); +} + +foreach ($items as $link => $label) { + $mset->add(new Horde_Mobile_link($label, $link)); +} + +if (isset($next_link)) { + $mset->add(new Horde_Mobile_link(_("Next"), $next_link)); +} +if (isset($prev_link)) { + $mset->add(new Horde_Mobile_link(_("Prev"), $prev_link)); +} + +$mset->add(new Horde_Mobile_link(sprintf(_("To %s"), IMP::getLabel($mailbox_name)), $mailbox_link)); + +MIMP::addMIMPMenu($mset, 'message'); + +$mimp_render->set('title', $display_headers['subject']); + +$c = &$mimp_render->add(new Horde_Mobile_card('m', $status . ' ' . $display_headers['subject'] . ' ' . sprintf(_("(%d of %d)"), $msgindex, $msgcount))); +$c->softkey('#o', _("Menu")); + +$mimp_notify->setMobileObject($c); +$notification->notify(array('listeners' => 'status')); + +$null = null; +$hb = &$c->add(new Horde_Mobile_block($null)); + +$allto_param = Util::getFormData('allto'); + +foreach ($display_headers as $head => $val) { + $all_to = false; + $hb->add(new Horde_Mobile_text($basic_headers[$head] . ': ', array('b'))); + if ((String::lower($head) == 'to') && + !$allto_param && + (($pos = strpos($val, ',')) !== false)) { + $val = String::substr($val, 0, strpos($val, ',')); + $all_to = true; + } + $t = &$hb->add(new Horde_Mobile_text($val . (($all_to) ? ' ' : "\n"))); + if ($all_to) { + $hb->add(new Horde_Mobile_link('[' . _("Show All") . ']', Util::addParameter($self_link, array('allto' => 1)))); + $t = &$hb->add(new Horde_Mobile_text("\n")); + } + $t->set('linebreaks', true); +} + +/* TODO +foreach (array_keys($this->_atc) as $key) { +$part = $this->_message->getPart($key); +if ($part !== false) { +$hb->add(new Horde_Mobile_text(_("Attachment") . ': ', array('b'))); +$t = &$hb->add(new Horde_Mobile_text(sprintf('%s (%s KB)', $part->getName(true, true), $part->getSize()) . "\n")); +$t->set('linebreaks', true); +} +} + */ + +$t = &$c->add(new Horde_Mobile_text($msgText)); +$t->set('linebreaks', true); + +if (!is_null($fullmsg_link)) { + $c->add($fullmsg_link); +} + +$mimp_render->add($menu); +$mimp_render->display(); diff --git a/imp/redirect.php b/imp/redirect.php index ee5b53b75..7219e3a71 100644 --- a/imp/redirect.php +++ b/imp/redirect.php @@ -17,19 +17,13 @@ function _framesetUrl($url) return $url; } -function _newSessionUrl($actionID, $isLogin, $view) +function _newSessionUrl($actionID, $isLogin) { $url = ''; $addActionID = true; - $apps = $GLOBALS['registry']->listApps(null, true); - $default_view = ($GLOBALS['browser']->isMobile() && isset($apps['mimp'])) ? 'mimp' : 'imp'; - if ($GLOBALS['url_in']) { $url = Horde::url(Util::removeParameter($GLOBALS['url_in'], session_name()), true); - } elseif ($view != $default_view || $view != 'imp') { - $GLOBALS['noframeset'] = true; - return Horde::url($GLOBALS['registry']->get('webroot', $view) . '/', true); } elseif (Auth::getProvider() == 'imp') { $url = Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/', true); /* Force the initial page to IMP if we're logging in to compose a @@ -111,7 +105,7 @@ if (Util::getFormData(MAINTENANCE_DONE_PARAM)) { /* Finish up any login tasks we haven't completed yet. */ IMP_Session::loginTasks(); - _redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin, isset($_SESSION['imp']['default_view']) ? $_SESSION['imp']['default_view'] : 'imp'))); + _redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin))); } /* If we already have a session: */ @@ -162,23 +156,22 @@ if (!is_null($imapuser) && !is_null($pass)) { $_SESSION['horde_language'] = $horde_language; } - if (!empty($conf['hooks']['postlogin'])) { - Horde::callHook('_imp_hook_postlogin', array($actionID, $isLogin), 'imp'); - } + $view = empty($conf['user']['select_view']) + ? (empty($conf['user']['force_view']) ? 'imp' : $conf['user']['force_view']) + : Util::getFormData('select_view', 'imp'); - if (empty($conf['user']['select_view'])) { - $view = empty($conf['user']['force_view']) ? 'imp' : $conf['user']['force_view']; - } else { - $view = Util::getFormData('select_view', 'imp'); - } setcookie('default_imp_view', $view, time() + 30 * 86400, $conf['cookie']['path'], $conf['cookie']['domain']); - $_SESSION['imp']['default_view'] = $view; + $_SESSION['imp']['view'] = $view; + + if (!empty($conf['hooks']['postlogin'])) { + Horde::callHook('_imp_hook_postlogin', array($actionID, $isLogin), 'imp'); + } IMP_Session::loginTasks(); - _redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin, $view))); + _redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin))); } _redirect(Auth::addLogoutParameters(IMP::logoutUrl())); diff --git a/imp/templates/compose/compose-mimp.inc b/imp/templates/compose/compose-mimp.inc new file mode 100644 index 000000000..fdef42cc2 --- /dev/null +++ b/imp/templates/compose/compose-mimp.inc @@ -0,0 +1,66 @@ +add(new Horde_Mobile_card('m', $title)); +$c->softkey('#o', _("Menu")); + +$mimp_notify->setMobileObject($c); +$notification->notify(array('listeners' => 'status')); + +$f = &$c->add(new Horde_Mobile_form('compose-mimp.php')); + +// Hidden Variables. +$f->add(new Horde_Mobile_hidden('composeCache', $cacheID)); +$f->add(new Horde_Mobile_hidden('thismailbox', Util::getFormData('thismailbox'))); +$f->add(new Horde_Mobile_hidden('index', Util::getFormData('index'))); +$f->add(new Horde_Mobile_hidden('resume_draft', Util::getFormData('resume_draft', $resume_draft))); + +if (Util::getFormData('ctype')) { + $f->add(new Horde_Mobile_hidden('ctype', Util::getFormData('ctype'))); +} else { + switch ($actionID) { + case 'r': + case 'ra': + case 'rl': + $f->add(new Horde_Mobile_hidden('ctype', 'reply')); + break; + + case 'f': + $f->add(new Horde_Mobile_hidden('ctype', 'forward')); + break; + } +} + +if ((Util::getFormData('is_reply') == 1) || + (strpos($actionID, 'reply') === 0)) { + $f->add(new Horde_Mobile_hidden('is_reply', 1)); + $f->add(new Horde_Mobile_hidden('in_reply_to', $header['in_reply_to'])); + $f->add(new Horde_Mobile_hidden('references', $header['references'])); +} + +if (!$prefs->isLocked('default_identity')) { + $ib = &$f->add(new Horde_Mobile_block(new Horde_Mobile_text(_("Identity")))); + $ident_sel = &$ib->add(new Horde_Mobile_select('identity')); + $default = Util::getFormData('identity', $identity->getDefault()); + foreach ($select_list as $key => $select) { + $ident_sel->add($select, $key, ($key == $default)); + } +} + +$f->add(new Horde_Mobile_input('to', $header['to'], _("To: "))); +if ($prefs->getValue('compose_cc')) { + $f->add(new Horde_Mobile_input('cc', $header['cc'], _("Cc: "))); +} +if ($prefs->getValue('compose_bcc')) { + $f->add(new Horde_Mobile_input('bcc', $header['bcc'], _("Bcc: "))); +} +$f->add(new Horde_Mobile_input('subject', $header['subject'], _("Subject: "))); + +$f->add(new Horde_Mobile_textarea('message', $msg, _("Message: "), 10, 80)); + +if (!$compose_disable) { + $f->add(new Horde_Mobile_submit(_("Send"), 'a')); +} +$f->add(new Horde_Mobile_submit(_("Expand Names"), 'a')); + +$mimp_render->add($menu); +$mimp_render->display(); diff --git a/imp/templates/compose/redirect-mimp.inc b/imp/templates/compose/redirect-mimp.inc new file mode 100644 index 000000000..c4fda9232 --- /dev/null +++ b/imp/templates/compose/redirect-mimp.inc @@ -0,0 +1,22 @@ +add(new Horde_Mobile_card('m', $title)); +$c->softkey('#o', _("Menu")); + +$mimp_notify->setMobileObject($c); +$notification->notify(array('listeners' => 'status')); + +$f = &$c->add(new Horde_Mobile_form('compose.php')); + +$f->add(new Horde_Mobile_hidden('thismailbox', $thismailbox)); +$f->add(new Horde_Mobile_hidden('index', $index)); +$f->add(new Horde_Mobile_hidden('action', 'rc')); +$f->add(new Horde_Mobile_hidden('array_index', Util::getFormData('array_index'))); + +$f->add(new Horde_Mobile_input('to', $header['to'], _("To: "))); + +$f->add(new Horde_Mobile_submit(_("Redirect"), 'a')); +$f->add(new Horde_Mobile_submit(_("Expand Names"), 'a')); + +$mimp_render->add($menu); +$mimp_render->display(); diff --git a/imp/templates/folders/folders-mimp.inc b/imp/templates/folders/folders-mimp.inc new file mode 100644 index 000000000..426dc5c64 --- /dev/null +++ b/imp/templates/folders/folders-mimp.inc @@ -0,0 +1,37 @@ +set('title', $title); +$c = &$mimp_render->add(new Horde_Mobile_card('m', $title)); +$c->softkey('#o', _("Menu")); + +$mimp_notify->setMobileObject($c); +$notification->notify(array('listeners' => 'status')); + +$null = null; +$fb = &$c->add(new Horde_Mobile_block($null)); + +foreach ($rows as $val) { + $fb->add(new Horde_Mobile_text($val['level'])); + if (empty($val['link'])) { + $fb->add(new Horde_Mobile_text($val['label'])); + } else { + $fb->add(new Horde_Mobile_link($val['label'], $val['link'])); + } + if (!is_null($val['msgs'])) { + $fb->add(new Horde_Mobile_text(' (' . $val['msgs'] . ')')); + } + + $t = &$fb->add(new Horde_Mobile_text("\n")); + $t->set('linebreaks', true); +} + +$menu = &new Horde_Mobile_card('o', _("Menu")); +$mset = &$menu->add(new Horde_Mobile_linkset()); +$mset->add(new Horde_Mobile_link(_("Refresh"), $selfurl)); +if ($subscribe) { + $mset->add(new Horde_Mobile_link($sub_text, $sub_link)); +} +MIMP::addMIMPMenu($mset, 'folders'); + +$mimp_render->add($menu); +$mimp_render->display(); diff --git a/imp/templates/mailbox/mailbox-mimp.inc b/imp/templates/mailbox/mailbox-mimp.inc new file mode 100644 index 000000000..5e47abea7 --- /dev/null +++ b/imp/templates/mailbox/mailbox-mimp.inc @@ -0,0 +1,37 @@ + 1) { + $title .= ' - ' . $pageOb['page'] . ' ' . _("of") . ' ' . $pageOb['pagecount']; +} +$c = &$mimp_render->add(new Horde_Mobile_card('m', $title)); +$c->softkey('#o', _("Menu")); + +$mimp_notify->setMobileObject($c); +$notification->notify(array('listeners' => 'status')); + +if (!empty($pageOb['end'])) { + $t = &$c->add(new Horde_Mobile_table()); + $t->set('border', 0); + $t->set('padding', 1); + $t->set('spacing', 1); + + $r = &$t->add(new Horde_Mobile_row()); + $r->add($sort[Horde_Imap_Client::SORT_ARRIVAL]); + $r->add($sort[Horde_Imap_Client::SORT_FROM]); + $r->add($sort[Horde_Imap_Client::SORT_SUBJECT]); + + $i = 1; + foreach ($msgs as $msg) { + $r = &$t->add(new Horde_Mobile_row()); + $r->add($msg['status']); + $r->add($msg['from']); + $l = &$r->add(new Horde_Mobile_link($msg['subject'], $msg['target'])); + $l->set('accesskey', $i++); + } +} + +$mimp_render->add($menu); +$mimp_render->display(); -- 2.11.0