File: thread.php

package info (click to toggle)
imp4 4.0.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 10,424 kB
  • ctags: 3,255
  • sloc: xml: 14,746; php: 14,411; makefile: 63
file content (83 lines) | stat: -rw-r--r-- 3,085 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
 * $Horde: imp/thread.php,v 2.10.2.1 2005/01/03 12:25:32 jan Exp $
 *
 * Copyright 2004-2005 Michael M Slusarz <slusarz@mail.curecati.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('IMP_BASE', dirname(__FILE__));
require_once IMP_BASE . '/lib/base.php';
require_once IMP_BASE . '/lib/MIME/Contents.php';
require_once IMP_BASE . '/lib/MIME/Headers.php';
require_once IMP_BASE . '/lib/Mailbox.php';
require_once 'Horde/Template.php';

/* Make sure we have a valid index. */
$imp_mailbox = &new IMP_Mailbox(Util::getFormData('index'));
if (!$imp_mailbox->isValidIndex()) {
    $actionID = 'message_missing';
    $from_message_page = true;
    $start = null;
    require IMP_BASE . '/mailbox.php';
    exit;
}

/* Set the current time zone. */
NLS::setTimeZone();

$title = _("Thread View");
require IMP_TEMPLATES . '/common-header.inc';
$msgs = array();

require IMP_TEMPLATES . '/menu.inc';
IMP::status();

$threadob = $imp_mailbox->getThreadOb();
$thread = $threadob->getThread($imp_mailbox->getIndex());
$subject = '';
$page_label = IMP::getLabel();
$message_url = Horde::applicationUrl('message.php');
$mailbox_url = Horde::applicationUrl('mailbox.php');
foreach ($thread as $idx) {
    /* Set mailbox object to the message index. */
    $imp_mailbox->setNewIndex($idx);

    /* Get the body of the message. */
    $curr_msg = array();
    $contents = &IMP_Contents::singleton($idx);
    $mime_id = $contents->findBody();
    $mime_part = $contents->getDecodedMIMEPart($mime_id);
    $curr_msg['body'] = $contents->renderMIMEPart($mime_part);

    /* Get headers for the message. */
    $headers = &new IMP_Headers($idx);
    $headers->buildHeaders();
    $headers->buildFlags();
    $headers->setValueByFunction('date', array('nl2br', array($headers, 'addLocalTime'), 'htmlspecialchars'));
    $headers->buildAddressLinks('from', Horde::selfUrl(), true, true);
    $curr_msg['date'] = $headers->getValue('date');
    $curr_msg['from'] = $headers->getValue('from');
    if (empty($subject)) {
        $subject = preg_replace('/^re:\s*/i', '', $headers->getValue('subject'));
    }

    /* Create links to current message and mailbox. */
    $curr_msg['link'] = Horde::widget(Util::addParameter($message_url, array('index' => $idx)), _("Go to Message"), 'widget', '', '', _("Go to Message"), true);
    $curr_msg['link'] .= ' | ' . Horde::widget(Util::addParameter($mailbox_url, array('start' => $imp_mailbox->getMessageIndex())), sprintf(_("Back to %s"), $page_label), 'widget', '', '', sprintf(_("Back to %s"), $page_label), true);

    $msgs[] = $curr_msg;
}

$template = &new Horde_Template();
$template->set('date_string', _("Date"), true);
$template->set('from_string', _("From"), true);
$template->set('messages', $msgs, true);

require IMP_TEMPLATES . '/thread/top.inc';
echo $template->fetch(IMP_TEMPLATES . '/thread/thread.html');
require IMP_TEMPLATES . '/thread/bottom.inc';

require $registry->get('templates', 'horde') . '/common-footer.inc';