[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> thread.php (source)

   1  <?php
   2  /**
   3   * $Horde: imp/thread.php,v 2.10.2.19 2007/03/09 00:43:51 jan Exp $
   4   *
   5   * Copyright 2004-2007 Michael M Slusarz <slusarz@mail.curecati.org>
   6   *
   7   * See the enclosed file COPYING for license information (GPL).  If you
   8   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
   9   */
  10  
  11  @define('IMP_BASE', dirname(__FILE__));
  12  require_once  IMP_BASE . '/lib/base.php';
  13  require_once  IMP_BASE . '/lib/IMAP.php';
  14  require_once  IMP_BASE . '/lib/MIME/Contents.php';
  15  require_once  IMP_BASE . '/lib/MIME/Headers.php';
  16  require_once  IMP_BASE . '/lib/Mailbox.php';
  17  require_once  IMP_BASE . '/lib/Search.php';
  18  require_once 'Horde/Template.php';
  19  
  20  /* What mode are we in?
  21   * DEFAULT/'thread' - Thread mode
  22   * 'msgview' - Multiple message view
  23   */
  24  $mode = Util::getFormData('mode', 'thread');
  25  
  26  $imp_mailbox = &IMP_Mailbox::singleton(Util::getFormData('index'));
  27  
  28  $error = false;
  29  if ($mode == 'thread') {
  30      /* THREAD MODE: Make sure we have a valid index. */
  31      if (!$imp_mailbox->isValidIndex()) {
  32          $error = true;
  33      }
  34  } else {
  35      /* MSGVIEW MODE: Make sure we have a valid list of messages. */
  36      $cacheID = Util::getFormData('msglist');
  37      if (!$cacheID) {
  38          $error = true;
  39      }
  40      require_once 'Horde/SessionObjects.php';
  41      $cacheSess = &Horde_SessionObjects::singleton();
  42      $msglist = $cacheSess->query($cacheID);
  43      if ($msglist) {
  44          $cacheSess->setPruneFlag($cacheID, true);
  45      } else {
  46          $error = true;
  47      }
  48  }
  49  
  50  if ($error) {
  51      $actionID = 'message_missing';
  52      $from_message_page = true;
  53      $start = null;
  54      require  IMP_BASE . '/mailbox.php';
  55      exit;
  56  }
  57  
  58  /* Set the current time zone. */
  59  NLS::setTimeZone();
  60  
  61  $imp_imap = &IMP_IMAP::singleton();
  62  
  63  /* Run through action handlers. */
  64  $actionID = Util::getFormData('actionID');
  65  switch ($actionID) {
  66  case 'add_address':
  67      $contact_link = IMP::addAddress(Util::getFormData('address'), Util::getFormData('name'));
  68      if (is_a($contact_link, 'PEAR_Error')) {
  69          $notification->push($contact_link);
  70      } else {
  71          $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $contact_link), 'horde.success', array('content.raw'));
  72      }
  73      break;
  74  }
  75  
  76  $msgs = $tree = array();
  77  $rowct = 0;
  78  
  79  $subject = '';
  80  $page_label = IMP::getLabel();
  81  
  82  require_once 'Horde/Identity.php';
  83  $identity = &Identity::singleton(array('imp', 'imp'));
  84  
  85  if ($mode == 'thread') {
  86      $threadob = $imp_mailbox->getThreadOb();
  87      $index_array = $imp_mailbox->getIMAPIndex();
  88      $thread = $threadob->getThread($index_array['index']);
  89      $threadtree = $threadob->getThreadImageTree($thread, false);
  90      $loop_array = array($imp['mailbox'] => $thread);
  91  } else {
  92      $loop_array = IMP::parseIndicesList($msglist);
  93  }
  94  
  95  foreach ($loop_array as $mbox => $idxlist) {
  96      $imp_imap->changeMbox($mbox);
  97  
  98      foreach ($idxlist as $idx) {
  99          /* Get the body of the message. */
 100          $curr_msg = $curr_tree = array();
 101          $imp_mailbox->setNewIndex($idx);
 102          $contents = &IMP_Contents::singleton($idx . IMP_IDX_SEP . $mbox);
 103          $mime_id = $contents->findBody();
 104          $mime_part = $contents->getDecodedMIMEPart($mime_id);
 105          if ($contents->canDisplayInline($mime_part)) {
 106              $curr_msg['body'] = $contents->renderMIMEPart($mime_part);
 107          } else {
 108              $curr_msg['body'] = '<em>' . _("There is no text that can be displayed inline.") . '</em>';
 109          }
 110          $curr_msg['idx'] = $idx;
 111  
 112          /* Get headers for the message. */
 113          $headers = &new IMP_Headers($idx);
 114          $headers->buildHeaders();
 115          $headers->setValueByFunction('date', array('nl2br', array($headers, 'addLocalTime'), 'htmlspecialchars'));
 116          $curr_msg['date'] = $headers->getValue('date');
 117  
 118          $addr_type = (($GLOBALS['imp']['mailbox'] == IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)) || (in_array($GLOBALS['imp']['mailbox'], $identity->getAllSentmailFolders()))) ? 'to' : 'from';
 119          $addr = $headers->getValue($addr_type);
 120          $curr_msg['addr_to'] = ($addr_type == 'to');
 121          if ($curr_msg['addr_to']) {
 122              $addr = _("To:") . ' ' . $addr;
 123          }
 124          $headers->buildAddressLinks($addr_type, Horde::selfUrl(true), true, true);
 125          $curr_msg['addr'] = $headers->getValue($addr_type);;
 126  
 127          $subject_header = @htmlspecialchars($headers->getValue('subject'), ENT_COMPAT, NLS::getCharset());
 128          if ($mode == 'thread') {
 129              if (empty($subject)) {
 130                  $subject = preg_replace('/^re:\s*/i', '', $subject_header);
 131              }
 132          }
 133          $curr_msg['subject'] = $subject_header;
 134  
 135          /* Create links to current message and mailbox. */
 136          if ($mode == 'thread') {
 137              $curr_msg['link'] = Horde::widget('#display', _("Back to Thread Display"), 'widget', '', '', _("Back to Thread Display"), true);
 138          } else {
 139              $curr_msg['link'] = Horde::widget('#display', _("Back to Multiple Message View Index"), 'widget', '', '', _("Back to Multiple Message View Index"), true);
 140          }
 141          $curr_msg['link'] .= ' | ' . Horde::widget(Util::addParameter(IMP::generateSearchUrl('message.php', $mbox), array('index' => $idx)), _("Go to Message"), 'widget', '', '', _("Go to Message"), true);
 142          $curr_msg['link'] .= ' | ' . Horde::widget(Util::addParameter(IMP::generateSearchUrl('mailbox.php', $mbox), array('start' => $imp_mailbox->getMessageIndex())), sprintf(_("Back to %s"), $page_label), 'widget', '', '', sprintf(_("Back to %s"), $page_label), true);
 143  
 144          $curr_tree['class'] = (++$rowct % 2) ? 'text' : 'item0';
 145          $curr_tree['subject'] = (($mode == 'thread') ? $threadtree[$idx] : null) . ' ' . Horde::link('#' . $idx) . $subject_header . '</a> (' . htmlspecialchars($addr) . ')';
 146  
 147          $msgs[] = $curr_msg;
 148          $tree[] = $curr_tree;
 149      }
 150  }
 151  
 152  /* Flag messages as seen. */
 153  require_once  IMP_BASE . '/lib/Message.php';
 154  $imp_message = &IMP_Message::singleton();
 155  $imp_message->flag('\\SEEN', $loop_array);
 156  
 157  $template = &new Horde_Template();
 158  $template->set('subject', ($mode == 'thread') ? @htmlspecialchars($subject, ENT_COMPAT, NLS::getCharset()) : sprintf(_("%d Messages"), count($msgs)));
 159  $template->set('thread', ($mode == 'thread'), true);
 160  $template->set('messages', $msgs, true);
 161  $template->set('tree', $tree, true);
 162  
 163  /* Output page. */
 164  $title = ($mode == 'thread') ? _("Thread View") : _("Multiple Message View");
 165  require IMP_TEMPLATES . '/common-header.inc';
 166  require IMP_TEMPLATES . '/menu.inc';
 167  IMP::status();
 168  echo $template->fetch(IMP_TEMPLATES . '/thread/thread.html');
 169  require $registry->get('templates', 'horde') . '/common-footer.inc';


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics