/** * Return the rendered information about the Horde_Mime_Part object. * * URL parameters used by this function: * - zip_contents: (integer) If set, show contents of ZIP file. * * @return array See Horde_Mime_Viewer_Driver::render(). */ protected function _renderInfo() { global $injector; $vars = $injector->getInstance('Horde_Variables'); if (!$this->getConfigParam('show_contents') && !$vars->zip_contents) { $status = new IMP_Mime_Status($this->_mimepart, _("This is a compressed file.")); $status->addMimeAction('zipViewContents', _("Click to display the file contents.")); $status->icon('mime/compressed.png'); return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8')); } $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mime')); $view->addHelper('Text'); $view->downloadclass = 'zipdownload'; $view->files = array(); $view->tableclass = 'zipcontents'; $zlib = Horde_Util::extensionExists('zlib'); foreach ($this->_getZipInfo() as $key => $val) { $file = new stdClass(); $file->name = $val['name']; $file->size = IMP::sizeFormat($val['size']); /* TODO: Add ability to render in-browser for filetypes we can * handle. */ if (!empty($val['size']) && strstr($val['attr'], 'D') === false && ($zlib && $val['method'] == 0x8 || $val['method'] == 0x0)) { $file->download = $this->getConfigParam('imp_contents')->linkView($this->_mimepart, 'download_render', '', array('class' => 'iconImg downloadAtc', 'jstext' => _("Download"), 'params' => array('zip_attachment' => $key))); } else { $file->download = ''; } $view->files[] = $file; } return array($this->_mimepart->getMimeId() => array('data' => $view->render('compressed'), 'type' => 'text/html; charset=UTF-8')); }
/** * Return the rendered information about the Horde_Mime_Part object. * * URL parameters used by this function: * - tgz_contents: (integer) If set, show contents of ZIP file. * * @return array See Horde_Mime_Viewer_Driver::render(). */ protected function _renderInfo() { global $injector; $vars = $injector->getInstance('Horde_Variables'); if (!$this->getConfigParam('show_contents') && !isset($vars->tgz_contents)) { $status = new IMP_Mime_Status($this->_mimepart, _("This is a compressed file.")); $status->addMimeAction('tgzViewContents', _("Click to display the file contents.")); $status->icon('mime/compressed.png'); return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8')); } $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mime')); $view->addHelper('Text'); $view->downloadclass = 'tgzdownload'; $view->files = array(); $view->tableclass = 'tgzcontents'; $tgzInfo = $this->_getTgzInfo(); foreach ($tgzInfo as $key => $val) { if (!strlen($val['data'])) { continue; } $file = new stdClass(); $file->download = ''; $file->name = $val['name']; $file->size = IMP::sizeFormat($val['size']); if (!empty($val['size'])) { $file->download = $this->getConfigParam('imp_contents')->linkView($this->_mimepart, 'download_render', '', array('class' => 'iconImg downloadAtc', 'jstext' => _("Download"), 'params' => array('tgz_attachment' => $key))); } $view->files[] = $file; } return array($this->_mimepart->getMimeId() => array('data' => $view->render('compressed'), 'type' => 'text/html; charset=UTF-8')); }
/** * Constructor. * * @param string $from The email address of the original sender. * @param Horde_Mime_Headers $h The headers object for the message. */ public function __construct($from, Horde_Mime_Headers $h) { global $prefs; $addressList = $nameList = array(); /* First we'll get a comma separated list of email addresses * and a comma separated list of personal names out of $from * (there just might be more than one of each). */ $addr_list = IMP::parseAddressList($from); foreach ($addr_list as $addr) { if (!is_null($addr->mailbox)) { $addressList[] = $addr->bare_address; } if (!is_null($addr->personal)) { $nameList[] = $addr->personal; } elseif (!is_null($addr->mailbox)) { $nameList[] = $addr->mailbox; } } /* Define the macros. */ if (is_array($message_id = $h->getValue('message-id'))) { $message_id = reset($message_id); } if (!($subject = $h->getValue('subject'))) { $subject = _("[No Subject]"); } $udate = strtotime($h->getValue('date')); $match = array('/%n/' => "\n", '/%%/' => '%', '/%f/' => $from, '/%a/' => implode(', ', $addressList), '/%p/' => implode(', ', $nameList), '/%r/' => $h->getValue('date'), '/%d/' => strftime("%a, %d %b %Y", $udate), '/%x/' => strftime("%x", $udate), '/%c/' => strftime("%c", $udate), '/%m/' => $message_id, '/%s/' => $subject); $this->_text = preg_replace(array_keys($match), array_values($match), $prefs->getValue('attrib_text')); }
/** * Constructor. * * @param string|Horde_Mail_Rfc822_Object $from The email address of the * original sender. * @param Horde_Mime_Headers $h The headers object for * the message. * @param string $attrib Use this for the * attribution config * instead of the default * prefs version. */ public function __construct($from, Horde_Mime_Headers $h, $attrib = null) { global $prefs; $this->_text = preg_replace_callback('/\\%./', function ($matches) use($from, $h) { switch ($matches[0]) { case '%n': /* New line. */ return "\n"; case '%%': /* Percent character. */ return '%'; case '%f': /* Name and email address of original sender. */ if ($from) { $from = new Horde_Mail_Rfc822_Address($from); return $from->writeAddress(array('noquote' => true)); } return _("Unknown Sender"); case '%a': /* Senders email address(es). */ /* Senders email address(es). */ case '%p': /* Senders name(s). */ $out = array(); foreach (IMP::parseAddressList($from) as $addr) { if ($matches[0] == '%a') { if (!is_null($addr->mailbox)) { $out[] = $addr->bare_address; } } else { $out[] = $addr->label; } } return count($out) ? implode(', ', $out) : _("Unknown Sender"); case '%r': /* RFC 822 date and time. */ return $h['Date']; case '%d': /* Date as ddd, dd mmm yyyy. */ return strftime("%a, %d %b %Y", strtotime($h['Date'])); case '%c': /* Date and time in locale's default. */ /* Date and time in locale's default. */ case '%x': /* Date in locale's default. */ return strftime($matches[0], strtotime($h['Date'])); case '%m': /* Message-ID. */ return strval($h['Message-Id']); case '%s': /* Message subject. */ return strlen($subject = $h['Subject']) ? $subject : _("[No Subject]"); default: return ''; } }, is_null($attrib) ? $prefs->getValue('attrib_text') : $attrib); }
/** * Logs an attempt to send a message. * * @param integer $action Why the message was sent (IMP_Sentmail * constant). * @param string $message_id The Message-ID. * @param string|array $recipients The list of message recipients. * @param boolean $success Whether the attempt was successful. */ public function log($action, $message_id, $recipients, $success = true) { if (!is_array($recipients)) { $recipients = array($recipients); } foreach ($recipients as $addresses) { foreach (IMP::parseAddressList($addresses) as $recipient) { $this->_log($action, $message_id, $recipient->bare_address, $success); } } }
/** */ public function update(Horde_Core_Prefs_Ui $ui) { global $conf, $injector, $notification; $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp'); if (isset($ui->vars->delete_pgp_privkey)) { $imp_pgp->deletePersonalKeys(); $notification->push(_("Personal PGP keys deleted successfully."), 'horde.success'); } elseif (isset($ui->vars->create_pgp_key) && !empty($conf['pgp']['keylength'])) { /* Sanity checking for email address. */ try { $email = IMP::parseAddressList($ui->vars->generate_email, array('validate' => true)); } catch (Horde_Mail_Exception $e) { $notification->push($e); return false; } /* Check that fields are filled out (except for Comment) and that * the passphrases match. */ if (empty($ui->vars->generate_realname) || empty($email)) { $notification->push(_("Name and/or email cannot be empty"), 'horde.error'); } elseif (empty($ui->vars->generate_passphrase1) || empty($ui->vars->generate_passphrase2)) { $notification->push(_("Passphrases cannot be empty"), 'horde.error'); } elseif ($ui->vars->generate_passphrase1 !== $ui->vars->generate_passphrase2) { $notification->push(_("Passphrases do not match"), 'horde.error'); } else { /* Expire date is delivered in UNIX timestamp in * milliseconds, not seconds. */ $expire_date = $ui->vars->generate_expire ? null : $ui->vars->generate_expire_date / 1000; try { $imp_pgp->generatePersonalKeys($ui->vars->generate_realname, $email[0]->bare_address_idn, $ui->vars->generate_passphrase1, $ui->vars->generate_comment, $conf['pgp']['keylength'], $expire_date); $notification->push(_("Personal PGP keypair generated successfully."), 'horde.success'); } catch (Exception $e) { $notification->push($e); } } } elseif (isset($ui->vars->send_pgp_key)) { try { $imp_pgp->sendToPublicKeyserver($imp_pgp->getPersonalPublicKey()); $notification->push(_("Key successfully sent to the public keyserver."), 'horde.success'); } catch (Exception $e) { $notification->push($e); } } elseif (isset($ui->vars->unset_pgp_passphrase)) { $imp_pgp->unsetPassphrase('personal'); $notification->push(_("PGP passphrase successfully unloaded."), 'horde.success'); } return false; }
/** * Format output text with IMP additions. * * @param string $text The HTML text. * * @return string The text with extra IMP formatting applied. */ protected function _IMPformat($text) { // Highlight quoted parts of an email. if ($GLOBALS['prefs']->getValue('highlight_text')) { $text = implode("\n", preg_replace('|^(\\s*>.+)$|', '<span class="quoted1">\\1</span>', explode("\n", $text))); $indent = 1; while (preg_match('|>(\\s?>){' . $indent . '}|', $text)) { $text = implode("\n", preg_replace('|^<span class="quoted' . (($indent - 1) % 5 + 1) . '">(\\s*>(\\s?>){' . $indent . '}.+)$|', '<span class="quoted' . ($indent % 5 + 1) . '">\\1', explode("\n", $text))); ++$indent; } } // Dim signatures. if ($GLOBALS['prefs']->getValue('dim_signature')) { $parts = preg_split('|(\\n--\\s*\\n)|', $text, 2, PREG_SPLIT_DELIM_CAPTURE); $text = array_shift($parts); if (count($parts)) { $text .= '<span class="signature">' . $parts[0] . preg_replace('|class="[^"]+"|', 'class="signature-fixed"', $parts[1]) . '</span>'; } } // Filter bad language. return IMP::filterText($text); }
/** * Get summary info for a MIME ID. * * @param string $id The MIME ID. * @param integer $mask A bitmask indicating what information to return: * <pre> * Always output: * 'type' = MIME type * * IMP_Contents::SUMMARY_BYTES * Output: parts = 'bytes' * * IMP_Contents::SUMMARY_SIZE * Output: parts = 'size' * * IMP_Contents::SUMMARY_ICON * IMP_Contents::SUMMARY_ICON_RAW * Output: parts = 'icon' * * IMP_Contents::SUMMARY_DESCRIP * Output: parts = 'description_raw' * * IMP_Contents::SUMMARY_DESCRIP_LINK * Output: parts = 'description' * * IMP_Contents::SUMMARY_DOWNLOAD * Output: parts = 'download', 'download_url' * * IMP_Contents::SUMMARY_IMAGE_SAVE * Output: parts = 'img_save' * * IMP_Contents::SUMMARY_PRINT * IMP_Contents::SUMMARY_PRINT_STUB * Output: parts = 'print' * * IMP_Contents::SUMMARY_STRIP * Output: parts = 'strip' * </pre> * * @return array An array with the requested information. */ public function getSummary($id, $mask = 0) { $autodetect_link = false; $param_array = array(); $this->_buildMessage(); $part = array('bytes' => null, 'download' => null, 'download_url' => null, 'id' => $id, 'img_save' => null, 'size' => null, 'strip' => null); $mime_part = $this->getMimePart($id, array('nocontents' => true)); if (!$mime_part) { return $part; } $mime_type = $mime_part->getType(); /* If this is an attachment that has no specific MIME type info, see * if we can guess a rendering type. */ if (in_array($mime_type, array('application/octet-stream', 'application/base64'))) { $mime_type = Horde_Mime_Magic::filenameToMIME($mime_part->getName()); if ($mime_type == $mime_part->getType()) { $autodetect_link = true; } else { $mime_part = clone $mime_part; $mime_part->setType($mime_type); $param_array['ctype'] = $mime_type; } } $part['type'] = $mime_type; /* Is this part an attachment? */ $is_atc = $mime_part->isAttachment(); /* Get bytes/size information. */ if ($mask & self::SUMMARY_BYTES || $mask & self::SUMMARY_SIZE) { $part['bytes'] = $size = $mime_part->getBytes(); $part['size'] = $size > 1048576 ? sprintf(_("%s MB"), IMP::numberFormat($size / 1048576, 1)) : sprintf(_("%s KB"), max(round($size / 1024), 1)); } /* Get part's icon. */ if ($mask & self::SUMMARY_ICON || $mask & self::SUMMARY_ICON_RAW) { $part['icon'] = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->getIcon($mime_type); if ($mask & self::SUMMARY_ICON) { $part['icon'] = Horde_Themes_Image::tag($part['icon'], array('attr' => array('title' => $mime_type))); } } else { $part['icon'] = null; } /* Get part's description. */ $description = $this->getPartName($mime_part, true); if ($mask & self::SUMMARY_DESCRIP_LINK) { if (($can_d = $this->canDisplay($mime_part, self::RENDER_FULL)) || $autodetect_link) { $part['description'] = $this->linkViewJS($mime_part, 'view_attach', htmlspecialchars($description), array('jstext' => sprintf(_("View %s"), $description), 'params' => array_filter(array_merge($param_array, array('autodetect' => !$can_d))))); } else { $part['description'] = htmlspecialchars($description); } } if ($mask & self::SUMMARY_DESCRIP) { $part['description_raw'] = $description; } /* Download column. */ if ($is_atc && $mask & self::SUMMARY_DOWNLOAD) { $part['download'] = $this->linkView($mime_part, 'download_attach', '', array('attr' => array('download' => $mime_part->getName(true) ?: $mime_part->getPrimaryType()), 'class' => 'iconImg downloadAtc', 'jstext' => _("Download"))); $part['download_url'] = $this->urlView($mime_part, 'download_attach'); } /* Display the image save link if the required registry calls are * present. */ if ($mask & self::SUMMARY_IMAGE_SAVE && $GLOBALS['registry']->hasMethod('images/selectGalleries') && $mime_part->getPrimaryType() == 'image') { $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'iconImg saveImgAtc', null, Horde::popupJs(IMP_Basic_Saveimage::url(), array('params' => array('muid' => strval($this->getIndicesOb()), 'id' => $id), 'height' => 200, 'width' => 450, 'urlencode' => true)) . 'return false;') . '</a>'; } /* Add print link? */ if (($mask & self::SUMMARY_PRINT || $mask & self::SUMMARY_PRINT_STUB) && $this->canDisplay($id, self::RENDER_FULL)) { $part['print'] = $mask & self::SUMMARY_PRINT ? $this->linkViewJS($mime_part, 'print_attach', '', array('css' => 'iconImg printAtc', 'jstext' => _("Print"), 'onload' => 'IMP_JS.printWindow', 'params' => $param_array)) : Horde::link('#', _("Print"), 'iconImg printAtc', null, null, null, null, array('mimeid' => $id)) . '</a>'; } /* Strip Attachment? Allow stripping of base parts other than the * base multipart and the base text (body) part. */ if ($mask & self::SUMMARY_STRIP && $id != 0 && intval($id) != 1 && strpos($id, '.') === false) { $part['strip'] = Horde::link(Horde::selfUrlParams()->add(array('actionID' => 'strip_attachment', 'imapid' => $id, 'muid' => strval($this->getIndicesOb()), 'token' => $GLOBALS['session']->getToken())), _("Strip Attachment"), 'iconImg deleteImg stripAtc', null, null, null, null, array('mimeid' => $id)) . '</a>'; } return $part; }
/** * Return information about the current attachment(s) for a message. * * @param mixed $ob If an IMP_Compose object, return info on all * attachments. If an IMP_Compose_Attachment object, * only return information on that object. * @param integer $type The compose type. */ public function attachment($ob, $type = IMP_Compose::COMPOSE) { global $injector; $parts = $ob instanceof IMP_Compose ? iterator_to_array($ob) : array($ob); $viewer = $injector->getInstance('IMP_Factory_MimeViewer'); foreach ($parts as $val) { $mime = $val->getPart(); $mtype = $mime->getType(); $tmp = array('icon' => strval(Horde_Url_Data::create('image/png', file_get_contents($viewer->getIcon($mtype)->fs))), 'name' => $mime->getName(true), 'num' => $val->id, 'type' => $mtype, 'size' => IMP::sizeFormat($mime->getBytes())); if ($viewer->create($mime)->canRender('full')) { $tmp['url'] = strval($val->viewUrl()->setRaw(true)); $tmp['view'] = intval(!in_array($type, array(IMP_Compose::FORWARD_ATTACH, IMP_Compose::FORWARD_BOTH)) && $mtype != 'application/octet-stream'); } $this->_atc[] = $tmp; } }
/** * Create the object used to display the message. * * @param array $args Configuration parameters: * - headers: (array) The headers desired in the returned headers array * (only used with non-preview view). * - preview: (boolean) Is this the preview view? * * @return array Array with the following keys: * - atc_download: The download all link * - atc_label: The label to use for Attachments * - atc_list: The list (HTML code) of attachments * - bcc (FULL): The Bcc addresses * - cc: The CC addresses * - fulldate (FULL): The full canonical date. * - from: The From addresses * - headers (FULL): An array of headers (not including basic headers) * - js: Javascript code to run on display * - list_info (FULL): List information. * - localdate (PREVIEW): The date formatted to the user's timezone * - md: Metadata * - msgtext: The text of the message * - onepart: True if message only contains one part. * - replyTo (FULL): The Reply-to addresses * - save_as: The save link * - subject: The subject * - subjectlink: The subject with linked URLs/email addresses (defaults * to 'subject') * - title (FULL): The title of the page * - to: The To addresses * * @throws IMP_Exception */ public function showMessage($args) { global $injector, $page_output, $prefs, $registry, $session; $preview = !empty($args['preview']); $result = array(); $mime_headers = $this->_peek ? $this->_contents->getHeader() : $this->_contents->getHeaderAndMarkAsSeen(); $headers = array(); $imp_ui = $injector->getInstance('IMP_Message_Ui'); /* Develop the list of Headers to display now. Deal with the 'basic' * header information first since there are various manipulations * done to them. */ $basic_headers = $imp_ui->basicHeaders(); if (empty($args['headers'])) { $args['headers'] = array('from', 'date', 'to', 'cc', 'bcc'); } $headers_list = array_intersect_key($basic_headers, array_flip($args['headers'])); /* Build From/To/Cc/Bcc/Reply-To links. */ foreach (array('from', 'to', 'cc', 'bcc', 'reply-to') as $val) { if (isset($headers_list[$val]) && (!$preview || $val != 'reply-to')) { if ($tmp = $this->getAddressHeader($val)) { $result[$val] = $tmp; } if ($preview) { unset($headers_list[$val]); } } } /* Build the rest of the headers. */ foreach ($headers_list as $head => $str) { if ($val = $mime_headers->getValue($head)) { if ($head == 'date') { /* Add local time to date header. */ $date_ob = new IMP_Message_Date($this->_envelope->date); $val = htmlspecialchars($date_ob->format($date_ob::DATE_LOCAL)); if ($preview) { $result['localdate'] = $val; } else { $result['fulldate'] = $date_ob->format($date_ob::DATE_FORCE); } } elseif (!$preview) { $val = htmlspecialchars($val); } if (!$preview) { $headers[$head] = array('id' => Horde_String::ucfirst($head), 'name' => $str, 'value' => $val); } } } if (empty($result['reply-to']) || $result['from']['addr'][0]->b == $result['reply-to']['addr'][0]->b) { unset($result['reply-to'], $headers['reply-to']); } /* JS requires camelized name for reply-to. */ if (!$preview && isset($headers['reply-to'])) { $result['replyTo'] = $result['reply-to']; $headers['reply-to']['id'] = 'ReplyTo'; unset($result['reply-to']); } /* Maillog information. */ $ajax_queue = $injector->getInstance('IMP_Ajax_Queue'); $ajax_queue->maillog($this->_indices); if (!$preview) { /* Display the user-specified headers for the current identity. */ $user_hdrs = $imp_ui->getUserHeaders(); foreach ($user_hdrs as $user_hdr) { $user_val = $mime_headers->getValue($user_hdr); if (!empty($user_val)) { if (!is_array($user_val)) { $user_val = array($user_val); } foreach ($user_val as $val) { $headers[] = array('name' => $user_hdr, 'value' => htmlspecialchars($val)); } } } $result['headers'] = array_values($headers); } /* Process the subject. */ $subject = $mime_headers->getValue('subject'); if ($subject) { $text_filter = $injector->getInstance('Horde_Core_Factory_TextFilter'); $filtered_subject = preg_replace("/\\b\\s+\\b/", ' ', IMP::filterText($subject)); $result['subject'] = $text_filter->filter($filtered_subject, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML)); $subjectlink = $text_filter->filter($filtered_subject, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)); if ($subjectlink != $result['subject']) { $result['subjectlink'] = $subjectlink; } if (!$preview) { $result['title'] = $subject; } } else { $result['subject'] = _("[No Subject]"); if (!$preview) { $result['title'] = _("[No Subject]"); } } // Create message text and attachment list. $result['msgtext'] = ''; $show_parts = $prefs->getValue('parts_display'); switch ($registry->getView()) { case $registry::VIEW_SMARTMOBILE: $contents_mask = 0; break; default: $contents_mask = IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_ICON | IMP_Contents::SUMMARY_DESCRIP_LINK | IMP_Contents::SUMMARY_DOWNLOAD | IMP_Contents::SUMMARY_DOWNLOAD_ZIP | IMP_Contents::SUMMARY_PRINT_STUB; break; } $part_info = $part_info_display = array('icon', 'description', 'size', 'download', 'download_zip'); $part_info_display[] = 'print'; list($mbox, $uid) = $this->_indices->getSingle(); /* Do MDN processing now. */ switch ($registry->getView()) { case $registry::VIEW_DYNAMIC: if ($imp_ui->MDNCheck(new IMP_Indices($mbox, $uid), $mime_headers)) { $status = new IMP_Mime_Status(array(_("The sender of this message is requesting notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link('#', '', '', '', '', '', '', array('id' => 'send_mdn_link')) . _("HERE") . '</a>'))); $status->domid('sendMdnMessage'); $result['msgtext'] .= strval($status); } } /* Build body text. This needs to be done before we build the * attachment list. */ $session->close(); $inlineout = $this->_contents->getInlineOutput(array('mask' => $contents_mask, 'part_info_display' => $part_info_display, 'show_parts' => $show_parts)); $session->start(); $result['md'] = $inlineout['metadata']; $result['msgtext'] .= $inlineout['msgtext']; if ($inlineout['one_part']) { $result['onepart'] = true; } if (count($inlineout['atc_parts']) || $show_parts == 'all' && count($inlineout['display_ids']) > 2) { $result['atc_label'] = $show_parts == 'all' ? _("Parts") : sprintf(ngettext("%d Attachment", "%d Attachments", count($inlineout['atc_parts'])), count($inlineout['atc_parts'])); if (count($inlineout['atc_parts']) > 2) { $result['atc_download'] = Horde::link($this->_contents->urlView($this->_contents->getMIMEMessage(), 'download_all')) . '[' . _("Save All") . ']</a>'; } } /* Show attachment information in headers? */ if (!empty($inlineout['atc_parts'])) { $partlist = array(); if ($show_parts == 'all') { array_unshift($part_info, 'id'); } foreach ($inlineout['atc_parts'] as $id) { $contents_mask |= IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD | IMP_Contents::SUMMARY_ICON | IMP_Contents::SUMMARY_SIZE; $part_info[] = 'description_raw'; $part_info[] = 'download_url'; $summary = $this->_contents->getSummary($id, $contents_mask); $tmp = array(); foreach ($part_info as $val) { if (isset($summary[$val])) { $tmp[$val] = $summary[$val] instanceof Horde_Url ? strval($summary[$val]->setRaw(true)) : $summary[$val]; } } $partlist[] = array_filter($tmp); } $result['atc_list'] = $partlist; } $result['save_as'] = IMP_Contents_View::downloadUrl(htmlspecialchars_decode($result['subject']), array_merge(array('actionID' => 'save_message'), $mbox->urlParams($uid))); if ($preview) { /* Need to grab cached inline scripts. */ Horde::startBuffer(); $page_output->outputInlineScript(true); if ($js_inline = Horde::endBuffer()) { $result['js'] = array($js_inline); } $result['save_as'] = strval($result['save_as']->setRaw(true)); } else { $list_info = $imp_ui->getListInformation($mime_headers); if (!empty($list_info['exists'])) { $result['list_info'] = $list_info; } } /* Add changed flag information. */ if (!$this->_peek && $mbox->is_imap) { $status = $mbox->imp_imap->status($mbox, Horde_Imap_Client::STATUS_PERMFLAGS); if (in_array(Horde_Imap_Client::FLAG_SEEN, $status['permflags'])) { $ajax_queue->flag(array(Horde_Imap_Client::FLAG_SEEN), true, $this->_indices); } } return array_filter($result); }
<?php /** * Base redirection page for IMP. * * Copyright 1999-2015 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.horde.org/licenses/gpl. * * @author Chuck Hagenbuch <*****@*****.**> * @category Horde * @copyright 1999-2015 Horde LLC * @license http://www.horde.org/licenses/gpl GPL * @package IMP */ // Will redirect to login page if not authenticated. require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('imp'); IMP::getInitialPage()->url->redirect();
/** * Formats the subject header. * * @param string $subject The subject header. * @param string $htmlspaces HTML-ize spaces? * * @return string The formatted subject header. */ public function getSubject($subject, $htmlspaces = false) { if (!strlen($subject)) { return _("[No Subject]"); } $new_subject = $subject = IMP::filterText(preg_replace("/\\s+/", ' ', $subject)); if ($htmlspaces) { $new_subject = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($subject, 'space2html', array('encode' => true)); if (empty($new_subject)) { $new_subject = htmlspecialchars($subject); } } return empty($new_subject) ? $subject : $new_subject; }
/** * Expand addresses in a string. Only the last address in the string will * be expanded. * * @param string $input The input string. * * @return mixed If a string, this value should be used as the new * input string. If an array, the first value is the * input string without the search string; the second * value is the search string; and the third value is * the list of matching addresses. */ protected function _expandAddresses($input) { $addr_list = IMP::parseAddressList($input, array('default_domain' => null)); if (!($size = count($addr_list))) { return ''; } $search = $addr_list[$size - 1]; /* Don't search if the search string looks like an e-mail address. */ if (!is_null($search->mailbox) && !is_null($search->host)) { return strval($search); } /* "Search" string will be in mailbox element. */ $imple = new IMP_Ajax_Imple_ContactAutoCompleter(); $res = $imple->getAddressList($search->mailbox); switch (count($res)) { case 0: $GLOBALS['notification']->push(sprintf(_("Search for \"%s\" failed: no address found."), $search->mailbox), 'horde.warning'); return strval($addr_list); case 1: $addr_list[$size] = $res[0]; return strval($addr_list); default: $GLOBALS['notification']->push(_("Ambiguous address found."), 'horde.warning'); unset($addr_list[$size]); return array(strval($addr_list), $search->mailbox, $res); } }
/** * URL parameters: * - bcc: BCC addresses. * - bcc_json: JSON encoded addresses to send to. Overwrites 'bcc'. * - body: Message body text. * - cc: CC addresses. * - cc_json: JSON encoded addresses to send to. Overwrites 'cc'. * - identity: Force message to use this identity by default. * - subject: Subject to use. * - type: redirect, reply, reply_auto, reply_all, reply_list, * forward_attach, forward_auto, forward_body, forward_both, * forward_redirect, resume, new, new_to, editasnew, template, * template_edit, template_new * - to: Addresses to send to. * - to_json: JSON encoded addresses to send to. Overwrites 'to'. */ protected function _init() { global $injector, $notification, $page_output, $prefs, $session; $alist = $injector->getInstance('IMP_Dynamic_AddressList'); $clink = new IMP_Compose_Link($this->vars); $addr = array(); foreach (array('to', 'cc', 'bcc') as $val) { $var_name = $val . '_json'; if (isset($this->vars->{$var_name})) { /* Check for JSON encoded information. */ $addr[$val] = $alist->parseAddressList($this->vars->{$var_name}); } elseif (isset($clink->args[$val])) { /* Non-JSON encoded address information. */ $addr[$val] = IMP::parseAddressList($clink->args[$val]); } } $subject = isset($clink->args['subject']) ? $clink->args['subject'] : null; $identity = $injector->getInstance('IMP_Identity'); if (!$prefs->isLocked('default_identity') && isset($this->vars->identity)) { $identity->setDefault($this->vars->identity); } /* Init objects. */ $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create(); $compose_ajax = new IMP_Ajax_Application_Compose($imp_compose, $this->vars->type); $ajax_queue = $injector->getInstance('IMP_Ajax_Queue'); $ajax_queue->compose($imp_compose); $compose_opts = array('title' => _("New Message")); switch ($this->vars->type) { case 'reply': case 'reply_all': case 'reply_auto': case 'reply_list': try { $result = $imp_compose->replyMessage($compose_ajax->reply_map[$this->vars->type], $this->_getContents(), array('to' => isset($addr['to']) ? $addr['to'] : null)); } catch (IMP_Exception $e) { $notification->push($e, 'horde.error'); break; } $onload = $compose_ajax->getResponse($result); switch ($result['type']) { case IMP_Compose::REPLY_SENDER: $compose_opts['title'] = _("Reply"); break; case IMP_Compose::REPLY_ALL: $compose_opts['title'] = _("Reply to All"); break; case IMP_Compose::REPLY_LIST: $compose_opts['title'] = _("Reply to List"); break; } $compose_opts['title'] .= ': ' . $result['subject']; break; case 'forward_attach': case 'forward_auto': case 'forward_body': case 'forward_both': try { if (count($this->indices) > 1) { if (!in_array($this->vars->type, array('forward_attach', 'forward_auto'))) { $notification->push(_("Multiple messages can only be forwarded as attachments."), 'horde.warning'); } $result = $imp_compose->forwardMultipleMessages($this->indices); } else { $result = $imp_compose->forwardMessage($compose_ajax->forward_map[$this->vars->type], $this->_getContents()); } } catch (IMP_Exception $e) { $notification->push($e, 'horde.error'); break; } $onload = $compose_ajax->getResponse($result); $compose_opts['title'] = $result['title']; $ajax_queue->attachment($imp_compose, IMP_Compose::FORWARD_ATTACH); break; case 'forward_redirect': try { $imp_compose->redirectMessage($this->indices); $compose_opts['title'] = _("Redirect"); } catch (IMP_Compose_Exception $e) { $notification->push($e, 'horde.error'); } $onload = $compose_ajax->getBaseResponse(); break; case 'editasnew': case 'resume': case 'template': case 'template_edit': try { switch ($this->vars->type) { case 'editasnew': $result = $imp_compose->editAsNew($this->indices); break; case 'resume': $result = $imp_compose->resumeDraft($this->indices); $compose_opts['resume'] = true; break; case 'template': $result = $imp_compose->useTemplate($this->indices); break; case 'template_edit': $result = $imp_compose->editTemplate($this->indices); $compose_opts['template'] = true; break; } $onload = $compose_ajax->getResponse($result); $ajax_queue->attachment($imp_compose, $result['type']); $show_editor = $result['format'] == 'html'; } catch (IMP_Compose_Exception $e) { $notification->push($e); } break; case 'new_to': $h = $this->_getContents()->getHeader(); $addr['to'] = $h->getOb('reply-to') ?: $h->getOb('from'); // Fall-through // Fall-through case 'new': case 'template_new': default: $show_editor = $prefs->getValue('compose_html') && $session->get('imp', 'rteavail'); $onload = $compose_ajax->getBaseResponse(); $onload->body = isset($clink->args['body']) ? strval($clink->args['body']) : ''; if ($show_editor) { $onload->format = 'html'; } if ($this->vars->type == 'template_new') { $compose_opts['template'] = true; } break; } $compose_opts['redirect'] = $this->vars->type == 'forward_redirect'; if (isset($onload->addr) || !empty($addr)) { foreach (array('to', 'cc', 'bcc') as $val) { if (!isset($onload->addr[$val])) { $onload->addr[$val] = array(); } if (isset($addr[$val])) { $onload->addr[$val] = array_merge($onload->addr[$val], array_map('strval', $addr[$val]->base_addresses)); } } } if (!is_null($subject)) { $onload->subject = $subject; } $this->title = $compose_opts['title']; $this->view->compose = $injector->getInstance('IMP_Dynamic_Compose_Common')->compose($this, $compose_opts); $page_output->addInlineJsVars(array('DimpCompose.onload_show' => $onload, 'DimpCompose.tasks' => $injector->getInstance('Horde_Core_Factory_Ajax')->create('imp', $this->vars)->getTasks())); Horde::startBuffer(); $notification->notify(array('listeners' => array('status', 'audio'))); $this->view->status = Horde::endBuffer(); $this->_pages[] = 'compose-base'; }
/** * URL Parameters: * a: (string) Action ID. * allto: (boolean) View all To addresses? * buid: (string) Browser UID. * t: (string) Token. */ protected function _init() { global $injector, $notification, $page_output, $prefs, $session; $imp_mailbox = $this->indices->mailbox->list_ob; $imp_mailbox->setIndex($this->indices); $mailbox_url = IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox)); /* Make sure we have a valid index. */ if (!$imp_mailbox->isValidIndex()) { $mailbox_url->add('a', 'm')->redirect(); } $imp_ui = $injector->getInstance('IMP_Message_Ui'); /* Run through action handlers */ $msg_delete = false; switch ($this->vars->a) { // 'd' = delete message case 'd': $old_index = $imp_mailbox->getIndex(); try { $session->checkToken($this->vars->t); $msg_delete = (bool) $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox)); } catch (Horde_Exception $e) { $notification->push($e); } break; // 'u' = undelete message // 'u' = undelete message case 'u': $old_index = $imp_mailbox->getIndex(); $injector->getInstance('IMP_Message')->undelete($this->indices); break; // 'rs' = report spam // 'ri' = report innocent // 'rs' = report spam // 'ri' = report innocent case 'rs': case 'ri': $old_index = $imp_mailbox->getIndex(); $msg_delete = $injector->getInstance('IMP_Factory_Spam')->create($this->vars->a == 'rs' ? IMP_Spam::SPAM : IMP_Spam::INNOCENT)->report($this->indices, array('mailboxob' => $imp_mailbox)) === 1; break; } if ($msg_delete && $imp_ui->moveAfterAction($this->indices->mailbox)) { $imp_mailbox->setIndex(1); } /* We may have done processing that has taken us past the end of the * message array, so we will return to the mailbox. */ if (!$imp_mailbox->isValidIndex() || $msg_delete && $prefs->getValue('mailbox_return')) { $mailbox_url->add('s', $old_index)->redirect(); } /* Now that we are done processing, get the index and array index of * the current message. */ $msg_index = $imp_mailbox[$imp_mailbox->getIndex()]; $mailbox = $msg_index['m']; $uid = $msg_index['u']; $buid = $imp_mailbox->getBuid($mailbox, $uid); /* Get envelope/flag/header information. */ try { $imp_imap = $mailbox->imp_imap; /* Need to fetch flags before HEADERTEXT, because SEEN flag might * be set before we can grab it. */ $query = new Horde_Imap_Client_Fetch_Query(); $query->flags(); $flags_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid))); $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); $fetch_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid))); } catch (IMP_Imap_Exception $e) { $mailbox_url->add('a', 'm')->redirect(); } $envelope = $fetch_ret->first()->getEnvelope(); $flags = $flags_ret->first()->getFlags(); /* Parse the message. */ try { $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox)); $mime_headers = $imp_contents->getHeaderAndMarkAsSeen(); } catch (IMP_Exception $e) { $mailbox_url->add('a', 'm')->redirect(); } /* Get the starting index for the current message and the message * count. */ $msgindex = $imp_mailbox->getIndex(); $msgcount = count($imp_mailbox); /* Generate the mailbox link. */ $mailbox_link = $mailbox_url->add('s', $msgindex); $self_link = self::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox)); /* Create the Identity object. */ $user_identity = $injector->getInstance('IMP_Identity'); /* Develop the list of headers to display. */ $basic_headers = $imp_ui->basicHeaders(); $display_headers = $msgAddresses = array(); if ($subject = $mime_headers->getValue('subject')) { /* Filter the subject text, if requested. */ $subject = Horde_String::truncate(IMP::filterText($subject), 50); } else { $subject = _("[No Subject]"); } $display_headers['subject'] = $subject; $format_date = $imp_ui->getLocalTime($envelope->date); if (!empty($format_date)) { $display_headers['date'] = $format_date; } /* Build From address links. */ $display_headers['from'] = $imp_ui->buildAddressLinks($envelope->from, null, false); /* Build To/Cc/Bcc links. */ foreach (array('to', 'cc', 'bcc') as $val) { $msgAddresses[] = $mime_headers->getValue($val); $addr_val = $imp_ui->buildAddressLinks($envelope->{$val}, null, false); if (!empty($addr_val)) { $display_headers[$val] = $addr_val; } } /* Check for the presence of mailing list information. */ $list_info = $imp_ui->getListInformation($mime_headers); /* See if the priority has been set. */ switch ($priority = $injector->getInstance('IMP_Mime_Headers')->getPriority($mime_headers)) { case 'high': case 'low': $basic_headers['priority'] = _("Priority"); $display_headers['priority'] = Horde_String::ucfirst($priority); break; } /* Set the status information of the message. */ $status = ''; $match_identity = $identity = null; if (!empty($msgAddresses)) { $match_identity = $identity = $user_identity->getMatchingIdentity($msgAddresses); if (is_null($identity)) { $identity = $user_identity->getDefault(); } } $flag_parse = $injector->getInstance('IMP_Flags')->parse(array('flags' => $flags, 'personal' => $match_identity)); foreach ($flag_parse as $val) { if ($abbrev = $val->abbreviation) { $status .= $abbrev; } elseif ($val instanceof IMP_Flag_User) { $status .= ' *' . Horde_String::truncate($val->label, 8) . '*'; } } /* Create the body of the message. */ $inlineout = $imp_contents->getInlineOutput(array('display_mask' => IMP_Contents::RENDER_INLINE, 'no_inline_all' => true)); $msg_text = $inlineout['msgtext']; $this->view->msg = nl2br($injector->getInstance('Horde_Core_Factory_TextFilter')->filter($msg_text, 'space2html')); $menu = array(); if ($this->indices->mailbox->access_deletemsgs) { $menu[] = in_array(Horde_Imap_Client::FLAG_DELETED, $flags) ? array(_("Undelete"), $self_link->copy()->add('a', 'u')) : array(_("Delete"), $self_link->copy()->add(array('a' => 'd', 't' => $session->getToken()))); } /* Add compose actions (Reply, Reply List, Reply All, Forward, * Redirect, Edit as New). */ if (IMP_Compose::canCompose()) { $clink_ob = new IMP_Compose_Link(); $clink_ob->args['buid'] = $buid; $clink_ob->args['mailbox'] = $this->indices->mailbox; $clink = $clink_ob->link()->add(array('identity' => $identity)); $menu[] = array(_("Reply"), $clink->copy()->add(array('a' => 'r'))); if ($list_info['reply_list']) { $menu[] = array(_("Reply to List"), $clink->copy()->add(array('a' => 'rl'))); } $addr_ob = clone $envelope->to; $addr_ob->add($envelope->cc); $addr_ob->setIteratorFilter(0, $user_identity->getAllFromAddresses()); if (count($addr_ob)) { $menu[] = array(_("Reply All"), $clink->copy()->add(array('a' => 'ra'))); } $menu[] = array(_("Forward"), $clink->copy()->add(array('a' => 'f'))); $menu[] = array(_("Redirect"), $clink->copy()->add(array('a' => 'rc'))); $menu[] = array(_("Edit as New"), $clink->copy()->add(array('a' => 'en'))); } /* Generate previous/next links. */ if ($prev_msg = $imp_mailbox[$imp_mailbox->getIndex() - 1]) { $menu[] = array(_("Previous Message"), self::url(array('buid' => $imp_mailbox->getBuid($prev_msg['m'], $prev_msg['u']), 'mailbox' => $this->indices->mailbox))); } if ($next_msg = $imp_mailbox[$imp_mailbox->getIndex() + 1]) { $menu[] = array(_("Next Message"), self::url(array('buid' => $imp_mailbox->getBuid($next_msg['m'], $next_msg['u']), 'mailbox' => $this->indices->mailbox))); } $menu[] = array(sprintf(_("To %s"), $this->indices->mailbox->label), $mailbox_link); if ($mailbox->spam_show) { $menu[] = array(_("Report as Spam"), $self_link->copy()->add(array('a' => 'rs', 't' => $session->getToken()))); } if ($mailbox->innocent_show) { $menu[] = array(_("Report as Innocent"), $self_link->copy()->add(array('a' => 'ri', 't' => $session->getToken()))); } $this->view->menu = $this->getMenu('message', $menu); $hdrs = array(); foreach ($display_headers as $head => $val) { $tmp = array('label' => $basic_headers[$head]); if (Horde_String::lower($head) == 'to' && !isset($this->vars->allto) && ($pos = strpos($val, ',')) !== false) { $val = Horde_String::substr($val, 0, $pos); $tmp['all_to'] = $self_link->copy()->add('allto', 1); } $tmp['val'] = $val; $hdrs[] = $tmp; } $this->view->hdrs = $hdrs; $atc = array(); foreach ($inlineout['atc_parts'] as $key) { $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD); $tmp = array('descrip' => $summary['description_raw'], 'size' => $summary['size'], 'type' => $summary['type']); if (!empty($summary['download'])) { /* Preference: if set, only show download confirmation screen * if attachment over a certain size. */ $tmp['download'] = IMP_Minimal_Messagepart::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox))->add('atc', $key); } if ($imp_contents->canDisplay($key, IMP_Contents::RENDER_INLINE)) { $tmp['view'] = IMP_Minimal_Messagepart::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox))->add('id', $key); } $atc[] = $tmp; } $this->view->atc = $atc; $this->title = $display_headers['subject']; $this->view->title = ($status ? $status . ' ' : '') . sprintf(_("(Message %d of %d)"), $msgindex, $msgcount); $page_output->noDnsPrefetch(); $this->_pages[] = 'message'; $this->_pages[] = 'menu'; }
/** * Obtains IMAP overview data for a given set of message UIDs. * * @param IMP_Mailbox $mbox The current mailbox. * @param array $msglist The list of message sequence numbers to * process. * * @return array TODO * @throws Horde_Exception */ private function _getOverviewData($mbox, $msglist) { global $injector; $msgs = array(); if (empty($msglist)) { return $msgs; } /* Get mailbox information. */ $flags = $mbox->access_flags; $imp_flags = $injector->getInstance('IMP_Flags'); $imp_ui = new IMP_Mailbox_Ui($mbox); $list_ob = $mbox->list_ob; $overview = $list_ob->getMailboxArray($msglist); /* Display message information. */ reset($overview['overview']); while (list(, $ob) = each($overview['overview'])) { /* Get all the flag information. */ $msg = array('flag' => $flags ? array_map('strval', $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'personal' => $ob['envelope']->to, 'runhook' => $ob, 'structure' => $ob['structure']))) : array()); /* Format size information. */ $msg['size'] = IMP::sizeFormat($ob['size']); /* Format the Date: Header. */ $msg['date'] = strval(new IMP_Message_Date(isset($ob['envelope']->date) ? $ob['envelope']->date : null)); /* Format the From: Header. */ $getfrom = $imp_ui->getFrom($ob['envelope']); if (count($getfrom['from_list'])) { $from_ob = new IMP_Ajax_Addresses($getfrom['from_list']); $msg['from'] = $from_ob->toArray()->addr; if (isset($getfrom['from_label'])) { $msg['fromlabel'] = $getfrom['from_label']; } } else { $msg['from'] = array(); $msg['fromlabel'] = $getfrom['from']; } /* Format the Subject: Header. */ $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject); /* Check to see if this is a list message. Namely, we want to * check for 'List-Post' information because that is the header * that gives the e-mail address to reply to, which is all we * care about. */ if (isset($ob['headers']['List-Post'])) { $msg['listmsg'] = 1; } $msgs[$list_ob->getBuid($ob['mailbox'], $ob['uid'])] = $msg; } return $msgs; }
/** * Adds linked attachments to message. * * @param string &$body Plaintext data. * @param mixed $html HTML data (Horde_Domhtml) or null. * * @throws IMP_Compose_Exception */ protected function _linkAttachments(&$body, $html) { global $conf; if (empty($conf['compose']['link_attachments'])) { return; } $link_all = false; $linked = array(); if (!empty($conf['compose']['link_attach_size_hard'])) { $limit = intval($conf['compose']['link_attach_size_hard']); foreach ($this as $val) { if (($limit -= $val->getPart()->getBytes()) < 0) { $link_all = true; break; } } } foreach (iterator_to_array($this) as $key => $val) { if ($link_all && !$val->linked) { $val = new IMP_Compose_Attachment($this, $val->getPart(), $val->storage->getTempFile()); $val->forceLinked = true; unset($this[$key]); $this[$key] = $val; } if ($val->linked && !$val->related) { $linked[] = $val; } } if (empty($linked)) { return; } if ($del_time = IMP_Compose_LinkedAttachment::keepDate(false)) { /* Subtract 1 from time to get the last day of the previous * month. */ $expire = ' (' . sprintf(_("links will expire on %s"), strftime('%x', $del_time - 1)) . ')'; } $body .= "\n-----\n" . _("Attachments") . $expire . ":\n"; if ($html) { $body = $html->getBody(); $dom = $html->dom; $body->appendChild($dom->createElement('HR')); $body->appendChild($div = $dom->createElement('DIV')); $div->appendChild($dom->createElement('H4', _("Attachments") . $expire . ':')); $div->appendChild($ol = $dom->createElement('OL')); } $i = 0; foreach ($linked as $val) { $apart = $val->getPart(); $name = $apart->getName(true); $size = IMP::sizeFormat($apart->getBytes()); $url = strval($val->link_url->setRaw(true)); $body .= "\n" . ++$i . '. ' . $name . ' (' . $size . ') [' . $apart->getType() . "]\n" . sprintf(_("Download link: %s"), $url) . "\n"; if ($html) { $ol->appendChild($li = $dom->createElement('LI')); $li->appendChild($dom->createElement('STRONG', $name)); $li->appendChild($dom->createTextNode(' (' . $size . ') [' . htmlspecialchars($apart->getType()) . ']')); $li->appendChild($dom->createElement('BR')); $li->appendChild($dom->createTextNode(_("Download link") . ': ')); $li->appendChild($a = $dom->createElement('A', htmlspecialchars($url))); $a->setAttribute('href', $url); } } }
/** */ public function getInitialPage() { return strval(IMP::getInitialPage()->url->setRaw(true)); }
<div> <?php echo _("Your signature to use when composing with the HTML editor (if empty, the text signature will be used)") . ($this->img_limit ? ' (' . sprintf(_("maximum total image size is %s"), IMP::sizeFormat($this->img_limit)) . ')' : ''); ?> : </div> <div class="fixed"> <textarea id="signature_html" name="signature_html" rows="4" cols="80" class="fixed"><?php echo $this->h($this->signature); ?> </textarea> </div>
/** * Render the object. * * @param boolean $inline Viewing inline? * * @return array See parent::render(). */ protected function _impRender($inline) { global $injector, $prefs, $registry; $cache = $this->getConfigParam('imp_contents')->getViewCache(); $mime_id = $this->_mimepart->getMimeId(); if (isset($cache->plain[$mime_id])) { return array($mime_id => null); } // Trim extra whitespace in the text. $charset = $this->_mimepart->getCharset(); $text = trim($this->_mimepart->getContents()); if ($text == '') { return array($mime_id => array('data' => '', 'type' => 'text/html; charset=' . $charset)); } // Convert to the local charset. if ($inline) { $text = Horde_String::convertCharset($text, $charset, 'UTF-8'); $charset = $this->getConfigParam('charset'); } $type = 'text/html; charset=' . $charset; // Check for 'flowed' text data. if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') { $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')); } else { /* A "From" located at the beginning of a line in the body text * will be escaped with a '>' by the IMAP server. Remove this * escape character or else the line will display as being * quoted. Flowed conversion would have already taken care of this * for us. */ $text = preg_replace('/(\\n+)> ?From(\\s+)/', "\$1From\$2", $text); } $text = IMP::filterText($text); /* Done processing if in minimal mode. */ if ($registry->getView() == Horde_Registry::VIEW_MINIMAL) { $filters = array('text2html' => array('charset' => $charset, 'parselevel' => Horde_Text_Filter_Text2html::NOHTML_NOBREAK)); $text = $this->_textFilter($text, array_keys($filters), array_values($filters)); return array($mime_id => array('data' => $text, 'type' => $type)); } // Build filter stack. Starts with HTML markup and tab expansion. $filters = array('text2html' => array('charset' => $charset, 'parselevel' => $inline ? Horde_Text_Filter_Text2html::MICRO : Horde_Text_Filter_Text2html::MICRO_LINKURL), 'tabs2spaces' => array()); // Highlight quoted parts of an email. if ($prefs->getValue('highlight_text')) { $hideBlocks = $js_blocks = false; if ($registry->getView() !== $registry::VIEW_SMARTMOBILE) { $js_blocks = $inline; if ($inline) { $show = $prefs->getValue('show_quoteblocks'); $hideBlocks = $show == 'hidden' || $show == 'thread' && $injector->getInstance('Horde_Variables')->page == 'thread'; if (!$hideBlocks && in_array($show, array('list', 'listthread'))) { $header = $this->getConfigParam('imp_contents')->getHeader(); $list_info = $injector->getInstance('IMP_Message_Ui')->getListInformation($header); $hideBlocks = $list_info['exists']; } } } if ($js_blocks) { $filters['highlightquotes'] = array('hideBlocks' => $hideBlocks, 'noJS' => $registry->getView() == Horde_Registry::VIEW_DYNAMIC); } else { $filters['Horde_Text_Filter_Highlightquotes'] = array('hideBlocks' => $hideBlocks); } } // Highlight simple markup of an email. if ($prefs->getValue('highlight_simple_markup')) { $filters['simplemarkup'] = array(); } // Dim signatures. if ($prefs->getValue('dim_signature')) { $filters['dimsignature'] = array(); } if ($prefs->getValue('emoticons')) { $filters['emoticons'] = array('entities' => true); } // Run filters. $status = array(); $text = $this->_textFilter($text, array_keys($filters), array_values($filters)); if (strlen($text)) { // Wordwrap. $text = str_replace(array(' ', "\n "), array(' ', "\n "), $text); if (!strncmp($text, ' ', 1)) { $text = ' ' . substr($text, 1); } } else { $error = new IMP_Mime_Status(array(_("Cannot display message text."), _("The message part may contain incorrect character set information preventing correct display."))); $error->action(IMP_Mime_Status::ERROR); $status[] = $error; } return array($mime_id => array('data' => "<div class=\"fixed leftAlign\">\n" . $text . '</div>', 'status' => $status, 'type' => $type)); }
/** * Obtains IMAP overview data for a given set of message UIDs. * * @param IMP_Mailbox $mbox The current mailbox. * @param array $msglist The list of message sequence numbers to * process. * * @return array TODO * @throws Horde_Exception */ private function _getOverviewData($mbox, $msglist) { global $injector, $prefs; $msgs = array(); if (empty($msglist)) { return $msgs; } /* Get mailbox information. */ $flags = $mbox->access_flags; $imp_flags = $injector->getInstance('IMP_Flags'); $imp_ui = new IMP_Mailbox_Ui($mbox); $list_ob = $mbox->list_ob; $overview = $list_ob->getMailboxArray($msglist, array('headers' => true, 'type' => $prefs->getValue('atc_flag'))); /* Display message information. */ reset($overview['overview']); while (list(, $ob) = each($overview['overview'])) { /* Get all the flag information. */ $msg = array('flag' => $flags ? array_map('strval', $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'runhook' => $ob, 'personal' => $ob['envelope']->to))) : array()); /* Format size information. */ $msg['size'] = IMP::sizeFormat($ob['size']); /* Format the Date: Header. */ $msg['date'] = $imp_ui->getDate(isset($ob['envelope']->date) ? $ob['envelope']->date : null); /* Format the From: Header. */ $getfrom = $imp_ui->getFrom($ob['envelope']); $msg['from'] = $getfrom['from']; if ($getfrom['from'] !== $getfrom['from_addr']) { $msg['fromaddr'] = $getfrom['from_addr']; } /* Format the Subject: Header. */ $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject); /* Check to see if this is a list message. Namely, we want to * check for 'List-Post' information because that is the header * that gives the e-mail address to reply to, which is all we * care about. */ if ($ob['headers']->getValue('list-post')) { $msg['listmsg'] = 1; } $msgs[$list_ob->getBuid($ob['mailbox'], $ob['uid'])] = $msg; } /* Allow user to alter template array. */ try { $msgs = $injector->getInstance('Horde_Core_Hooks')->callHook('mailboxarray', 'imp', array($msgs)); } catch (Horde_Exception_HookNotSet $e) { } return $msgs; }
/** */ protected function _title() { return Horde::link(IMP::getInitialPage()->url) . $GLOBALS['registry']->get('name') . '</a>'; }
/** * Return subject header data. * * @return array Array with these possible keys: * <pre> * - subject: (string) The subject. * - subjectlink: (string) The subject with linked URLs/email addresses * (if not present, is same as 'subject'). * - title: (string) The title of the page derived from the subject. * </pre> */ public function getSubject() { global $injector; if (!isset($this->_cache['subject'])) { $out = array(); if (strlen($subject = $this->_envelope->subject)) { $text_filter = $injector->getInstance('Horde_Core_Factory_TextFilter'); $filtered_subject = preg_replace("/\\b\\s+\\b/", ' ', IMP::filterText($subject)); $out['subject'] = $text_filter->filter($filtered_subject, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML)); $subjectlink = $text_filter->filter($filtered_subject, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)); if ($subjectlink != $out['subject']) { $out['subjectlink'] = $subjectlink; } $out['title'] = $subject; } else { $out['subject'] = $out['title'] = _("[No Subject]"); } $this->_cache['subject'] = $out; } return $this->_cache['subject']; }
/** * Sets a property with a specified value. * * @see setValue() */ public function setValue($key, $val, $identity = null) { switch ($key) { case 'alias_addr': case 'bcc_addr': case 'replyto_addr': case 'tieto_addr': if (is_string($val) && strpbrk($val, "\r\n") !== false) { $val = preg_split("/[\r\n]+/", $val); } /* Validate Reply-To, Alias, Tie-to, and BCC addresses. */ $ob = IMP::parseAddressList($val, array('limit' => $val == 'replyto_addr' ? 1 : 0)); foreach ($ob as $address) { try { IMP::parseAddressList($address, array('validate' => true)); } catch (Horde_Mail_Exception $e) { throw new Horde_Prefs_Exception(sprintf(_("\"%s\" is not a valid email address.", strval($address)))); } } $val = $ob->addresses; break; case IMP_Mailbox::MBOX_SENT: $GLOBALS['injector']->getInstance('IMP_Mailbox_SessionCache')->expire(IMP_Mailbox_SessionCache::CACHE_SPECIALMBOXES); $val = IMP_Mailbox::prefTo($val); break; } return parent::setValue($key, $val, $identity); }
/** * Sets a property with a specified value. * * @see setValue() */ public function setValue($key, $val, $identity = null) { switch ($key) { case 'alias_addr': case 'bcc_addr': case 'replyto_addr': case 'tieto_addr': if (is_string($val) && strpbrk($val, "\r\n") !== false) { $val = preg_split("/[\r\n]+/", $val); } /* Validate Reply-To, Alias, Tie-to, and BCC addresses. */ $val = IMP::parseAddressList($val, array('limit' => $val == 'replyto_addr' ? 1 : 0))->addresses; break; case IMP_Mailbox::MBOX_SENT: $GLOBALS['injector']->getInstance('IMP_Mailbox_SessionCache')->expire(IMP_Mailbox_SessionCache::CACHE_SPECIALMBOXES); $val = IMP_Mailbox::prefTo($val); break; } return parent::setValue($key, $val, $identity); }
/** */ protected function _init() { global $browser, $injector, $notification, $page_output, $prefs, $registry, $session; /* Mailto link handler: redirect based on current view. */ if ($this->vars->actionID == 'mailto_link') { switch ($registry->getView()) { case Horde_Registry::VIEW_DYNAMIC: IMP_Dynamic_Compose::url()->add($_GET)->redirect(); exit; case Horde_Registry::VIEW_MINIMAL: IMP_Minimal_Compose::url()->add($_GET)->redirect(); exit; } } /* The message headers and text. */ $header = array(); $msg = ''; $redirect = $resume = $spellcheck = false; $oldrtemode = $rtemode = null; /* Is this a popup window? */ if ($isPopup = $prefs->getValue('compose_popup') || $this->vars->popup) { $page_output->topbar = $page_output->sidebar = false; } /* Set the current identity. */ $identity = $injector->getInstance('IMP_Identity'); if (!$prefs->isLocked('default_identity') && !is_null($this->vars->identity)) { $identity->setDefault($this->vars->identity); } if ($this->vars->actionID) { switch ($this->vars->actionID) { case 'draft': case 'editasnew': case 'forward_attach': case 'forward_auto': case 'forward_body': case 'forward_both': case 'fwd_digest': case 'mailto': case 'mailto_link': case 'reply': case 'reply_all': case 'reply_auto': case 'reply_list': case 'redirect_compose': case 'template': case 'template_edit': case 'template_new': /* These are all safe actions that might be invoked without a * token. */ break; default: try { $session->checkToken($this->vars->compose_requestToken); } catch (Horde_Exception $e) { $notification->push($e); $this->vars->actionID = null; } } } /* Check for duplicate submits. */ if ($reload = $this->vars->compose_formToken) { try { $session->checkNonce($reload); } catch (Horde_Exception $e) { $notification->push(_("You have already submitted this page."), 'horde.error'); $this->vars->actionID = null; } } /* Determine if compose mode is disabled. */ $compose_disable = !IMP_Compose::canCompose(); /* Determine if mailboxes are readonly. */ $draft = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS); $readonly_drafts = $draft && $draft->readonly; $sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT); if (!$sent_mail) { $readonly_sentmail = $save_sent_mail = false; } elseif ($sent_mail->readonly) { $readonly_sentmail = true; $save_sent_mail = false; } else { $readonly_sentmail = false; $save_sent_mail = $reload ? (bool) $this->vars->save_sent_mail : true; } /* Initialize the IMP_Compose:: object. */ $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($this->vars->composeCache); /* Init objects. */ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create(); $imp_ui = new IMP_Compose_Ui(); /* Determine the composition type - text or HTML. $rtemode is null if browser does not support it. */ if ($session->get('imp', 'rteavail')) { if ($prefs->isLocked('compose_html')) { $rtemode = $prefs->getValue('compose_html'); } else { $rtemode = $this->vars->rtemode; if (is_null($rtemode)) { $rtemode = $prefs->getValue('compose_html'); } else { $rtemode = intval($rtemode); $oldrtemode = intval($this->vars->oldrtemode); } } } /* Update the file attachment information. */ $attach_upload = $imp_compose->canUploadAttachment(); if ($attach_upload) { /* Only notify if we are reloading the compose screen. */ $notify = !in_array($this->vars->actionID, array('send_message', 'save_draft')); $deleteList = Horde_Util::getPost('delattachments', array()); /* Update the attachment information. */ foreach ($imp_compose as $key => $val) { if (!in_array($key, $deleteList)) { $val->getPart()->setDescription($this->vars->filter('file_description_' . $key)); $imp_compose[$key] = $val; } } /* Delete attachments. */ foreach ($deleteList as $val) { if ($notify) { $notification->push(sprintf(_("Deleted attachment \"%s\"."), $imp_compose[$val]->getPart()->getName(true)), 'horde.success'); } unset($imp_compose[$val]); } /* Add attachments. */ for ($i = 1, $fcount = count($_FILES); $i <= $fcount; ++$i) { if (isset($_FILES['upload_' . $i]) && strlen($_FILES['upload_' . $i]['name'])) { try { $atc_ob = $imp_compose->addAttachmentFromUpload('upload_' . $i); if ($atc_ob[0] instanceof IMP_Compose_Exception) { throw $atc_ob[0]; } if ($notify) { $notification->push(sprintf(_("Added \"%s\" as an attachment."), $atc_ob[0]->getPart()->getName()), 'horde.success'); } } catch (IMP_Compose_Exception $e) { /* Any error will cancel the current action. */ $this->vars->actionID = null; $notification->push($e, 'horde.error'); } } } } /* Get message priority. */ $priority = $this->vars->get('priority', 'normal'); /* Request read receipt? */ $request_read_receipt = (bool) $this->vars->request_read_receipt; /* Run through the action handlers. */ $this->title = _("New Message"); switch ($this->vars->actionID) { case 'mailto': try { $contents = $this->_getContents(); } catch (IMP_Exception $e) { $notification->push($e, 'horde.error'); break; } $imp_headers = $contents->getHeader(); $header['to'] = ''; if ($this->vars->mailto) { $header['to'] = $imp_headers->getValue('to'); } if (empty($header['to'])) { ($header['to'] = strval($imp_headers->getOb('from'))) || ($header['to'] = strval($imp_headers->getOb('reply-to'))); } break; case 'mailto_link': $clink = new IMP_Compose_Link($this->vars); if (isset($clink->args['body'])) { $msg = $clink->args['body']; } foreach (array('to', 'cc', 'bcc', 'subject') as $val) { if (isset($clink->args[$val])) { $header[$val] = $clink->args[$val]; } } break; case 'draft': case 'editasnew': case 'template': case 'template_edit': try { switch ($this->vars->actionID) { case 'draft': $result = $imp_compose->resumeDraft($this->indices); $resume = true; break; case 'editasnew': $result = $imp_compose->editAsNew($this->indices); break; case 'template': $result = $imp_compose->useTemplate($this->indices); break; case 'template_edit': $result = $imp_compose->editTemplate($this->indices); $this->vars->template_mode = true; break; } if (!is_null($rtemode)) { $rtemode = $result['format'] == 'html'; } $msg = $result['body']; $header = array_merge($header, $this->_convertToHeader($result)); if (!is_null($result['identity']) && $result['identity'] != $identity->getDefault() && !$prefs->isLocked('default_identity')) { $identity->setDefault($result['identity']); $sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT); } $priority = $result['priority']; $request_read_receipt = $result['readreceipt']; } catch (IMP_Compose_Exception $e) { $notification->push($e); } break; case 'reply': case 'reply_all': case 'reply_auto': case 'reply_list': try { $contents = $this->_getContents(); } catch (IMP_Exception $e) { $notification->push($e, 'horde.error'); break; } $reply_map = array('reply' => IMP_Compose::REPLY_SENDER, 'reply_all' => IMP_Compose::REPLY_ALL, 'reply_auto' => IMP_Compose::REPLY_AUTO, 'reply_list' => IMP_Compose::REPLY_LIST); $reply_msg = $imp_compose->replyMessage($reply_map[$this->vars->actionID], $contents, array('to' => $this->vars->to)); $msg = $reply_msg['body']; $header = $this->_convertToHeader($reply_msg); $format = $reply_msg['format']; switch ($reply_msg['type']) { case IMP_Compose::REPLY_SENDER: $this->vars->actionID = 'reply'; $this->title = _("Reply:"); break; case IMP_Compose::REPLY_ALL: if ($this->vars->actionID == 'reply_auto') { $recip_list = $imp_compose->recipientList($header); if (!empty($recip_list['list'])) { $replyauto_all = count($recip_list['list']); } } $this->vars->actionID = 'reply_all'; $this->title = _("Reply to All:"); break; case IMP_Compose::REPLY_LIST: if ($this->vars->actionID == 'reply_auto') { $replyauto_list = true; if (($parse_list = $injector->getInstance('Horde_ListHeaders')->parse('list-id', $contents->getHeader()->getValue('list-id'))) && !is_null($parse_list->label)) { $replyauto_list_id = $parse_list->label; } } $this->vars->actionID = 'reply_list'; $this->title = _("Reply to List:"); break; } if (!empty($reply_msg['lang'])) { $reply_lang = array_values($reply_msg['lang']); } $this->title .= ' ' . $header['subject']; if (!is_null($rtemode)) { $rtemode = $rtemode || $format == 'html'; } break; case 'replyall_revert': case 'replylist_revert': try { $reply_msg = $imp_compose->replyMessage(IMP_Compose::REPLY_SENDER, $imp_compose->getContentsOb()); $header = $this->_convertToHeader($reply_msg); } catch (IMP_Exception $e) { $notification->push($e, 'horde.error'); } break; case 'forward_attach': case 'forward_auto': case 'forward_body': case 'forward_both': $fwd_map = array('forward_attach' => IMP_Compose::FORWARD_ATTACH, 'forward_auto' => IMP_Compose::FORWARD_AUTO, 'forward_body' => IMP_Compose::FORWARD_BODY, 'forward_both' => IMP_Compose::FORWARD_BOTH); try { $fwd_msg = $imp_compose->forwardMessage($fwd_map[$this->vars->actionID], $this->_getContents()); } catch (IMP_Exception $e) { $notification->push($e, 'horde.error'); break; } $msg = $fwd_msg['body']; $header = $this->_convertToHeader($fwd_msg); $format = $fwd_msg['format']; $rtemode = $rtemode || !is_null($rtemode) && $format == 'html'; $this->title = $fwd_msg['title']; break; case 'redirect_compose': try { $imp_compose->redirectMessage($this->indices); $redirect = true; $this->title = ngettext("Redirect", "Redirect Messages", count($this->indices)); } catch (IMP_Compose_Exception $e) { $notification->push($e, 'horde.error'); } break; case 'redirect_send': try { $num_msgs = $imp_compose->sendRedirectMessage($this->vars->to); $imp_compose->destroy('send'); if ($isPopup) { if ($prefs->getValue('compose_confirm')) { $notification->push(ngettext("Message redirected successfully.", "Messages redirected successfully", count($num_msgs)), 'horde.success'); $this->_popupSuccess(); return; } echo Horde::wrapInlineScript(array('window.close();')); } else { $notification->push(ngettext("Message redirected successfully.", "Messages redirected successfully", count($num_msgs)), 'horde.success'); $this->_mailboxReturnUrl()->redirect(); } exit; } catch (Horde_Exception $e) { $notification->push($e); $this->vars->actionID = 'redirect_compose'; } break; case 'auto_save_draft': case 'save_draft': case 'save_template': case 'send_message': // Drafts readonly is handled below. if ($compose_disable && $this->vars->actionID == 'send_message') { break; } try { $header['from'] = strval($identity->getFromLine(null, $this->vars->from)); } catch (Horde_Exception $e) { $header['from'] = ''; $notification->push($e); break; } $header['to'] = $this->vars->to; $header['cc'] = $this->vars->cc; $header['bcc'] = $this->vars->bcc; $header['subject'] = strval($this->vars->subject); $message = strval($this->vars->message); /* Save the draft. */ switch ($this->vars->actionID) { case 'auto_save_draft': case 'save_draft': case 'save_template': if (!$readonly_drafts || $this->vars->actionID == 'save_template') { $save_opts = array('html' => $rtemode, 'priority' => $priority, 'readreceipt' => $request_read_receipt); try { switch ($this->vars->actionID) { case 'save_template': $result = $imp_compose->saveTemplate($header, $message, $save_opts); break; default: $result = $imp_compose->saveDraft($header, $message, $save_opts); break; } /* Closing draft if requested by preferences. */ switch ($this->vars->actionID) { case 'save_draft': if ($isPopup) { if ($prefs->getValue('close_draft')) { $imp_compose->destroy('save_draft'); echo Horde::wrapInlineScript(array('window.close();')); exit; } $notification->push($result, 'horde.success'); } else { $notification->push($result, 'horde.success'); if ($prefs->getValue('close_draft')) { $imp_compose->destroy('save_draft'); $this->_mailboxReturnUrl()->redirect(); } } break; case 'save_template': if ($isPopup) { echo Horde::wrapInlineScript(array('window.close();')); exit; } $notification->push($result, 'horde.success'); $this->_mailboxReturnUrl()->redirect(); break; } } catch (IMP_Compose_Exception $e) { if ($this->vars->actionID == 'save_draft') { $notification->push($e); } } } if ($this->vars->actionID == 'auto_save_draft') { $r = new stdClass(); $r->requestToken = $session->getToken(); $r->formToken = $session->getNonce(); $response = new Horde_Core_Ajax_Response_HordeCore($r); $response->sendAndExit(); } break; default: $header['replyto'] = $identity->getValue('replyto_addr'); if ($this->vars->sent_mail) { $sent_mail = IMP_Mailbox::formFrom($this->vars->sent_mail); } try { $imp_compose->buildAndSendMessage($message, $header, $identity, array('encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $this->vars->encrypt_options, 'html' => $rtemode, 'pgp_attach_pubkey' => $this->vars->pgp_attach_pubkey, 'priority' => $priority, 'save_sent' => $save_sent_mail, 'sent_mail' => $sent_mail, 'signature' => $this->vars->signature, 'strip_attachments' => !$this->vars->save_attachments_select, 'readreceipt' => $request_read_receipt, 'vcard_attach' => $this->vars->vcard ? $identity->getValue('fullname') : null)); $imp_compose->destroy('send'); if ($isPopup) { if ($prefs->getValue('compose_confirm')) { $notification->push(_("Message sent successfully."), 'horde.success'); $this->_popupSuccess(); return; } echo Horde::wrapInlineScript(array('window.close();')); } else { $notification->push(_("Message sent successfully."), 'horde.success'); $this->_mailboxReturnUrl()->redirect(); } exit; } catch (IMP_Compose_Exception $e) { $code = $e->getCode(); $notification->push($e->getMessage(), strpos($code, 'horde.') === 0 ? $code : 'horde.error'); /* Switch to tied identity. */ if (!is_null($e->tied_identity)) { $identity->setDefault($e->tied_identity); $notification->push(_("Your identity has been switched to the identity associated with the current recipient address. The identity will not be checked again during this compose action.")); } switch ($e->encrypt) { case 'pgp_symmetric_passphrase_dialog': $imp_ui->passphraseDialog('pgp_symm', $imp_compose->getCacheId()); break; case 'pgp_passphrase_dialog': $imp_ui->passphraseDialog('pgp'); break; case 'smime_passphrase_dialog': $imp_ui->passphraseDialog('smime'); break; } } break; } break; case 'fwd_digest': if (count($this->indices)) { try { $res = $imp_compose->forwardMultipleMessages($this->indices); $header['subject'] = $res['subject']; $fwd_msg = array('type' => IMP_Compose::FORWARD_ATTACH); } catch (IMP_Compose_Exception $e) { $notification->push($e, 'horde.error'); } } break; case 'cancel_compose': case 'discard_compose': $imp_compose->destroy($this->vars->actionID == 'cancel_compose' ? 'cancel' : 'discard'); if ($isPopup) { echo Horde::wrapInlineScript(array('window.close();')); } else { $this->_mailboxReturnUrl()->redirect(); } exit; case 'template_new': $this->vars->template_mode = true; break; } /* Get the message cache ID. */ $composeCacheID = filter_var($imp_compose->getCacheId(), FILTER_SANITIZE_STRING); /* Attach autocompleters to the compose form elements. */ if ($redirect) { $imp_ui->attachAutoCompleter(array('to')); } else { $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc')); $spellcheck = $imp_ui->attachSpellChecker(); $page_output->addScriptFile('ieescguard.js', 'horde'); } $max_attach = $imp_compose->additionalAttachmentsAllowed(); /* Get the URL to use for the cancel action. If the attachments cache * is not empty, or this is the resume drafts page, we must reload * this page and delete the attachments and/or the draft message. */ if ($isPopup) { if ($resume || count($imp_compose)) { $cancel_url = self::url()->setRaw(true)->add(array('actionID' => 'cancel_compose', 'compose_requestToken' => $session->getToken(), 'composeCache' => $composeCacheID, 'popup' => 1)); $discard_url = clone $cancel_url; $discard_url->add('actionID', 'discard_compose'); } else { $cancel_url = $discard_url = ''; } } elseif ($resume || count($imp_compose)) { $cancel_url = $this->_mailboxReturnUrl(self::url()->setRaw(true))->setRaw(true)->add(array('actionID' => 'cancel_compose', 'compose_requestToken' => $session->getToken(), 'composeCache' => $composeCacheID)); $discard_url = clone $cancel_url; $discard_url->add('actionID', 'discard_compose'); } else { $cancel_url = $discard_url = $this->_mailboxReturnUrl(false)->setRaw(true); } /* Grab any data that we were supplied with. */ if (!strlen($msg)) { $msg = $this->vars->get('message', strval($this->vars->body)); if ($browser->hasQuirk('double_linebreak_textarea')) { $msg = preg_replace('/(\\r?\\n){3}/', '$1', $msg); } $msg = "\n" . $msg; } if (isset($this->vars->signature)) { $signature = $this->vars->signature; if ($browser->hasQuirk('double_linebreak_textarea')) { $signature = preg_replace('/(\\r?\\n){3}/', '$1', $signature); } $signatureChanged = $signature != $identity->getSignature($oldrtemode ? 'html' : 'text'); } else { $signatureChanged = false; } /* Convert from Text -> HTML or vice versa if RTE mode changed. */ if (!is_null($oldrtemode) && $oldrtemode != $rtemode) { $msg = $imp_ui->convertComposeText($msg, $rtemode ? 'html' : 'text'); if ($signatureChanged) { $signature = $imp_ui->convertComposeText($signature, $rtemode ? 'html' : 'text'); } } /* If this is the first page load for this compose item, add auto BCC * addresses. */ if (!$reload && !$resume) { $header['bcc'] = strval($identity->getBccAddresses()); } foreach (array('to', 'cc', 'bcc') as $val) { if (!isset($header[$val])) { $header[$val] = $this->vars->{$val}; } } if (!isset($header['subject'])) { $header['subject'] = $this->vars->subject; } /* If PGP encryption is set by default, and we have a recipient list * on first load, make sure we have public keys for all recipients. */ $encrypt_options = $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $this->vars->encrypt_options; if ($prefs->getValue('use_pgp') && !$prefs->isLocked('default_encrypt') && $prefs->getValue('pgp_reply_pubkey')) { $default_encrypt = $prefs->getValue('default_encrypt'); if (!$reload && in_array($default_encrypt, array(IMP_Crypt_Pgp::ENCRYPT, IMP_Crypt_Pgp::SIGNENC))) { $addrs = $imp_compose->recipientList($header); if (!empty($addrs['list'])) { $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp'); try { foreach ($addrs['list'] as $val) { $imp_pgp->getPublicKey(strval($val)); } } catch (Horde_Exception $e) { $notification->push(_("PGP encryption cannot be used by default as public keys cannot be found for all recipients."), 'horde.warning'); $encrypt_options = $default_encrypt == IMP_Crypt_Pgp::ENCRYPT ? IMP::ENCRYPT_NONE : IMP_Crypt_Pgp::SIGN; } } } } /* Define some variables used in the javascript code. */ $js_vars = array('ImpComposeBase.editor_on' => $rtemode, 'ImpCompose.auto_save' => intval($prefs->getValue('auto_save_drafts')), 'ImpCompose.cancel_url' => strval($cancel_url), 'ImpCompose.cursor_pos' => $rtemode ? null : $prefs->getValue('compose_cursor'), 'ImpCompose.discard_url' => strval($discard_url), 'ImpCompose.max_attachments' => $max_attach === true ? null : $max_attach, 'ImpCompose.popup' => intval($isPopup), 'ImpCompose.redirect' => intval($redirect), 'ImpCompose.reloaded' => intval($reload), 'ImpCompose.sm_check' => intval(!$prefs->isLocked(IMP_Mailbox::MBOX_SENT)), 'ImpCompose.spellcheck' => intval($spellcheck && $prefs->getValue('compose_spellcheck')), 'ImpCompose.text' => array('cancel' => _("Cancelling this message will permanently discard its contents.") . "\n" . _("Are you sure you want to do this?"), 'change_identity' => _("You have edited your signature. Change the identity and lose your changes?"), 'discard' => _("Doing so will discard this message permanently."), 'file' => _("File"), 'nosubject' => _("The message does not have a Subject entered.") . "\n" . _("Send message without a Subject?"), 'recipient' => _("You must specify a recipient."))); /* Set up the base view now. */ $view = $injector->createInstance('Horde_View'); $view->addHelper('FormTag'); $view->addHelper('Horde_Core_View_Helper_Accesskey'); $view->addHelper('Horde_Core_View_Helper_Help'); $view->addHelper('Horde_Core_View_Helper_Image'); $view->addHelper('Horde_Core_View_Helper_Label'); $view->addHelper('Tag'); $view->allow_compose = !$compose_disable; $view->post_action = self::url(); $blank_url = new Horde_Url('#'); if ($redirect) { /* Prepare the redirect template. */ $view->cacheid = $composeCacheID; $view->title = $this->title; $view->token = $session->getToken(); if ($registry->hasMethod('contacts/search')) { $view->abook = $blank_url->copy()->link(array('class' => 'widget', 'id' => 'redirect_abook', 'title' => _("Address Book"))); $js_vars['ImpCompose.redirect_contacts'] = strval(IMP_Basic_Contacts::url()->add(array('to_only' => 1))->setRaw(true)); } $view->input_value = $header['to']; $this->output = $view->render('basic/compose/redirect'); } else { /* Prepare the compose template. */ $view->file_upload = $attach_upload; $hidden = array('actionID' => '', 'attachmentAction' => '', 'compose_formToken' => $session->getNonce(), 'compose_requestToken' => $session->getToken(), 'composeCache' => $composeCacheID, 'composeHmac' => $imp_compose->getHmac(), 'oldrtemode' => $rtemode, 'rtemode' => $rtemode, 'user' => $registry->getAuth()); if ($attach_upload) { $hidden['MAX_FILE_SIZE'] = $session->get('imp', 'file_upload'); } foreach (array('page', 'start', 'popup', 'template_mode') as $val) { $hidden[$val] = $this->vars->{$val}; } $view->hidden = $hidden; $view->tabindex = 1; $view->title = $this->title; if (!$this->vars->template_mode) { $view->send_msg = true; $view->save_draft = $imp_imap->access(IMP_Imap::ACCESS_DRAFTS) && !$readonly_drafts; } $view->resume = $resume; $view->di_locked = $prefs->isLocked('default_identity'); if ($view->di_locked) { $view->fromaddr_locked = $prefs->isLocked('from_addr'); try { $view->from = $identity->getFromLine(null, $this->vars->from); } catch (Horde_Exception $e) { } } else { $select_list = $identity->getSelectList(); $view->last_identity = $identity->getDefault(); if (count($select_list) > 1) { $view->count_select_list = true; $t_select_list = array(); foreach ($select_list as $key => $select) { $t_select_list[] = array('label' => $select, 'selected' => $key == $identity->getDefault(), 'value' => $key); } $view->select_list = $t_select_list; } else { $view->identity_default = $identity->getDefault(); $view->identity_text = $select_list[0]; } } $view->signature = $identity->hasSignature(true); $addr_array = array('to' => _("_To"), 'cc' => _("_Cc"), 'bcc' => _("_Bcc")); $address_array = array(); foreach ($addr_array as $val => $label) { $address_array[] = array('id' => $val, 'label' => $label, 'val' => $header[$val]); } $view->addr = $address_array; $view->subject = $header['subject']; if ($prefs->getValue('set_priority')) { $view->set_priority = true; $priorities = array('high' => _("High"), 'normal' => _("Normal"), 'low' => _("Low")); $priority_option = array(); foreach ($priorities as $key => $val) { $priority_option[] = array('label' => $val, 'selected' => $priority == $key, 'val' => $key); } $view->pri_opt = $priority_option; } $compose_options = array(); if ($registry->hasMethod('contacts/search')) { $compose_options[] = array('url' => $blank_url->copy()->link(array('class' => 'widget', 'id' => 'addressbook_popup')), 'img' => Horde_Themes_Image::tag('addressbook_browse.png'), 'label' => _("Address Book")); $js_vars['ImpCompose.contacts_url'] = strval(IMP_Basic_Contacts::url()->setRaw(true)); } if ($spellcheck) { $compose_options[] = array('url' => $blank_url->copy()->link(array('class' => 'widget', 'id' => 'spellcheck')), 'img' => '', 'label' => ''); } if ($attach_upload) { $url = new Horde_Url('#attachments'); $compose_options[] = array('url' => $url->link(array('class' => 'widget')), 'img' => Horde_Themes_Image::tag('attachment.png'), 'label' => _("Attachments")); } $view->compose_options = $compose_options; if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS) && !$prefs->isLocked('save_sent_mail')) { $view->ssm = true; if ($readonly_sentmail) { $notification->push(sprintf(_("Cannot save sent-mail message to \"%s\" as that mailbox is read-only.", $sent_mail->display), 'horde.warning')); } $view->ssm_selected = $reload ? $save_sent_mail : $sent_mail && $identity->saveSentmail(); if ($this->vars->sent_mail) { $sent_mail = IMP_Mailbox::formFrom($this->vars->sent_mail); } if (!$prefs->isLocked(IMP_Mailbox::MBOX_SENT)) { $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree')); $iterator->add($iterator::NONIMAP); $iterator->mboxes = array('INBOX'); $ssm_options = array('abbrev' => false, 'basename' => true, 'iterator' => $iterator, 'selected' => $sent_mail); /* Check to make sure the sent-mail mailbox is created - * it needs to exist to show up in drop-down list. */ if ($sent_mail) { $sent_mail->create(); } $view->ssm_mboxes = new IMP_Ftree_Select($ssm_options); } else { if ($sent_mail) { $sent_mail = '"' . $sent_mail->display_html . '"'; } $view->ssm_mbox = $sent_mail; } } $view->rrr_selected = $prefs->isLocked('request_mdn') ? null : $prefs->getValue('request_mdn') == 'always' || $request_read_receipt; if (!is_null($rtemode) && !$prefs->isLocked('compose_html')) { $view->compose_html = true; $view->html_switch = $blank_url->copy()->link(array('id' => 'rte_toggle', 'title' => _("Switch Composition Method"))); $view->rtemode = $rtemode; } if (isset($replyauto_all)) { $view->replyauto_all = $replyauto_all; } elseif (isset($replyauto_list)) { $view->replyauto_list = true; if (isset($replyauto_list_id)) { $view->replyauto_list_id = $replyauto_list_id; } } if (isset($reply_lang)) { $view->reply_lang = implode(',', $reply_lang); } $view->message = $msg; if ($signatureChanged) { $view->signatureContent = $signature; } if ($prefs->getValue('use_pgp') || $prefs->getValue('use_smime')) { if ($prefs->isLocked('default_encrypt')) { $view->use_encrypt = false; } else { $view->use_encrypt = true; $view->encrypt_options = $imp_ui->encryptList($encrypt_options); } if ($prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')) { $view->pgp_options = true; $view->pgp_attach_pubkey = $reload ? $this->vars->pgp_attach_pubkey : $prefs->getValue('pgp_attach_pubkey'); } } if ($registry->hasMethod('contacts/ownVCard')) { $view->vcard = true; $view->attach_vcard = $this->vars->vcard; } if ($attach_upload) { $view->attach_size = IMP::numberFormat($imp_compose->maxAttachmentSize(), 0); $view->maxattachmentnumber = !$max_attach; $save_attach = $prefs->getValue('save_attachments'); if ($view->ssm && !$prefs->isLocked('save_attachments')) { $view->show_link_save_attach = true; $view->attach_options = array(array('label' => _("Save attachments with message in sent-mail mailbox?"), 'name' => 'save_attachments_select', 'val' => $reload ? $this->vars->save_attachments_select : $save_attach == 'always')); } if (count($imp_compose)) { $view->numberattach = true; $atc = array(); $v = $injector->getInstance('IMP_Factory_MimeViewer'); foreach ($imp_compose as $data) { $mime = $data->getPart(); $type = $mime->getType(); $entry = array('name' => $mime->getName(true), 'icon' => $v->getIcon($type), 'number' => $data->id, 'type' => $type, 'size' => $mime->getSize(), 'description' => $mime->getDescription(true)); if (!(isset($fwd_msg) && $fwd_msg['type'] != IMP_Compose::FORWARD_BODY) && $type != 'application/octet-stream') { $entry['name'] = $data->viewUrl()->link(array('class' => 'link', 'target' => 'compose_preview_window', 'title' => _("Preview"))) . htmlspecialchars($entry['name']) . '</a>'; } $atc[] = $entry; } $view->atc = $atc; } } $this->output = $view->render('basic/compose/compose'); } $page_output->addScriptPackage('IMP_Script_Package_ComposeBase'); $page_output->addScriptFile('compose.js'); $page_output->addScriptFile('editor.js'); $page_output->addScriptFile('imp.js'); $page_output->addInlineJsVars($js_vars); if (!$redirect) { $imp_ui->addIdentityJs(); } if ($rtemode && !$redirect) { $page_output->addScriptPackage('IMP_Script_Package_Editor'); } }
/** */ protected function _init() { global $injector, $notification, $page_output, $prefs, $registry, $session; $mailbox = $this->indices->mailbox; /* Call the mailbox redirection hook, if requested. */ try { $redirect = $injector->getInstance('Horde_Core_Hooks')->callHook('mbox_redirect', 'imp', array($mailbox)); if (!empty($redirect)) { Horde::url($redirect, true)->redirect(); } } catch (Horde_Exception_HookNotSet $e) { } $mailbox_url = Horde::url('basic.php')->add('page', 'mailbox'); $mailbox_imp_url = $mailbox->url('mailbox')->add('newmail', 1); $imp_flags = $injector->getInstance('IMP_Flags'); $imp_imap = $mailbox->imp_imap; $imp_search = $injector->getInstance('IMP_Search'); /* Run through the action handlers */ if (($actionID = $this->vars->actionID) && $actionID != 'message_missing') { try { $session->checkToken($this->vars->token); } catch (Horde_Exception $e) { $notification->push($e); $actionID = null; } } /* We know we are going to be exclusively dealing with this mailbox, * so select it on the IMAP server (saves some STATUS calls). Open * R/W to clear the RECENT flag. This call will catch invalid * mailboxes. */ $imp_imap->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE); $imp_mailbox = $mailbox->list_ob; /* Determine if mailbox is readonly. */ $readonly = $mailbox->readonly; switch ($actionID) { case 'change_sort': $mailbox->setSort($this->vars->sortby, $this->vars->sortdir); break; case 'blacklist': $injector->getInstance('IMP_Filter')->blacklistMessage($this->indices); break; case 'whitelist': $injector->getInstance('IMP_Filter')->whitelistMessage($this->indices); break; case 'spam_report': $injector->getInstance('IMP_Factory_Spam')->create(IMP_Spam::SPAM)->report($this->indices); break; case 'innocent_report': $injector->getInstance('IMP_Factory_Spam')->create(IMP_Spam::INNOCENT)->report($this->indices); break; case 'message_missing': $notification->push(_("Requested message not found."), 'horde.error'); break; case 'fwd_digest': case 'redirect_messages': case 'template_edit': if (count($this->indices)) { $compose_actions = array('fwd_digest' => 'fwd_digest', 'redirect_messages' => 'redirect_compose', 'template_edit' => 'template_edit'); $clink = new IMP_Compose_Link($this->vars); $options = array_merge(array('actionID' => $compose_actions[$actionID], 'muid' => strval($this->indices)), $clink->args); if ($prefs->getValue('compose_popup')) { $page_output->addInlineScript(array(Horde::popupJs(IMP_Basic_Compose::url(), array('novoid' => true, 'params' => array_merge(array('popup' => 1), $options)))), true); } else { IMP_Basic_Compose::url()->add($options)->redirect(); } } break; case 'delete_messages': $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox)); break; case 'undelete_messages': $injector->getInstance('IMP_Message')->undelete($this->indices); break; case 'move_messages': case 'copy_messages': if (isset($this->vars->targetMbox) && count($this->indices) && (!$readonly || $actionID == 'copy_messages')) { $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox); if (!empty($this->vars->newMbox) && $this->vars->newMbox == 1) { $targetMbox = IMP_Mailbox::get($this->vars->targetMbox)->namespace_append; $newMbox = true; } else { $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox); $newMbox = false; } $injector->getInstance('IMP_Message')->copy($targetMbox, $actionID == 'move_messages' ? 'move' : 'copy', $this->indices, array('create' => $newMbox, 'mailboxob' => $imp_mailbox)); } break; case 'flag_messages': if (!$readonly && $this->vars->flag && count($this->indices)) { $flag = $imp_flags->parseFormId($this->vars->flag); $injector->getInstance('IMP_Message')->flag(array($flag['set'] ? 'add' : 'remove' => array($flag['flag'])), $this->indices); } break; case 'filter_messages': if (!$readonly) { $filter = IMP_Mailbox::formFrom($this->vars->filter); $q_ob = null; if (strpos($filter, self::FLAG_FILTER_PREFIX) === 0) { /* Flag filtering. */ $flag_filter = $imp_flags->parseFormId(substr($filter, strpos($filter, "") + 1)); try { $q_ob = $imp_search->createQuery(array(new IMP_Search_Element_Flag($flag_filter['flag'], $flag_filter['set'])), array('mboxes' => array($mailbox), 'type' => IMP_Search::CREATE_QUERY)); } catch (InvalidArgumentException $e) { } } else { /* Pre-defined filters. */ try { $q_ob = $imp_search->applyFilter($filter, array($mailbox)); } catch (InvalidArgumentException $e) { } } if ($q_ob) { IMP_Mailbox::get($q_ob)->url('mailbox')->redirect(); exit; } } break; case 'hide_deleted': $mailbox->setHideDeletedMsgs(!$prefs->getValue('delhide')); break; case 'expunge_mailbox': $injector->getInstance('IMP_Message')->expungeMailbox(array(strval($mailbox) => 1), array('mailboxob' => $imp_mailbox)); break; case 'filter': $mailbox->filter(); break; case 'empty_mailbox': $injector->getInstance('IMP_Message')->emptyMailbox(array(strval($mailbox))); break; case 'view_messages': $mailbox->url(IMP_Basic_Thread::url(), null, false)->add(array('mode' => 'msgview', 'muid' => strval($this->indices)))->redirect(); break; } /* Token to use in requests. */ $token = $session->getToken(); $search_mbox = $mailbox->search; /* Deal with filter options. */ if (!$readonly && IMP_Filter::canApplyFilters() && !$mailbox->filterOnDisplay() && ($mailbox->inbox || $prefs->getValue('filter_any_mailbox') && !$search_mbox)) { $filter_url = $mailbox_imp_url->copy()->add(array('actionID' => 'filter', 'token' => $token)); } /* Generate folder options list. */ if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree')); $iterator->add($iterator::NONIMAP); $folder_options = new IMP_Ftree_Select(array('heading' => _("Messages to"), 'inc_notepads' => true, 'inc_tasklists' => true, 'iterator' => $iterator, 'new_mbox' => true)); } /* Build the list of messages in the mailbox. */ $pageOb = $imp_mailbox->buildMailboxPage($this->vars->mpage, $this->vars->start); $show_preview = $prefs->getValue('preview_enabled'); $mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array('headers' => true, 'preview' => (int) $show_preview, 'type' => $prefs->getValue('atc_flag'))); /* Determine sorting preferences. */ $sortpref = $mailbox->getSort(); $thread_sort = $sortpref->sortby == Horde_Imap_Client::SORT_THREAD; /* Determine if we are going to show the Hide/Purge Deleted Message * links. */ if (!($use_trash = $prefs->getValue('use_trash')) && !$mailbox->vinbox) { $showdelete = array('hide' => true, 'purge' => $mailbox->access_expunge); } else { $showdelete = array('hide' => false, 'purge' => false); } if ($showdelete['hide'] && !$prefs->isLocked('delhide')) { if ($prefs->getValue('delhide')) { $deleted_prompt = _("Show Deleted"); } else { $deleted_prompt = _("Hide Deleted"); } } /* Generate paging links. */ if ($pageOb['pagecount']) { if ($pageOb['page'] == 1) { $url_first = $url_prev = null; $pages_first = 'navfirstgreyImg'; $pages_prev = 'navleftgreyImg'; } else { $url_first = $mailbox_imp_url->copy()->add('mpage', 1); $pages_first = 'navfirstImg'; $url_prev = $mailbox_imp_url->copy()->add('mpage', $pageOb['page'] - 1); $pages_prev = 'navleftImg'; } if ($pageOb['page'] == $pageOb['pagecount']) { $url_last = $url_next = null; $pages_last = 'navlastgreyImg'; $pages_next = 'navrightgreyImg'; } else { $url_next = $mailbox_imp_url->copy()->add('mpage', $pageOb['page'] + 1); $pages_next = 'navrightImg'; $url_last = $mailbox_imp_url->copy()->add('mpage', $pageOb['pagecount']); $pages_last = 'navlastImg'; } } /* Generate RSS link. */ if ($mailbox->inbox) { $rss_box = ''; } else { $ns_info = $mailbox->namespace_info; if (is_null($ns_info)) { $rss_box = null; } else { $rss_box = str_replace(rawurlencode($ns_info->delimiter), '/', rawurlencode($ns_info->delimiter . ($ns_info->type == $ns_info::NS_PERSONAL ? $ns_info->stripNamespace($mailbox) : $mailbox))); } } if (!is_null($rss_box)) { $page_output->addLinkTag(array('href' => Horde::url('rss.php', true, -1) . $rss_box)); } /* If user wants the mailbox to be refreshed, set time here. */ $refresh_url = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']); if (isset($filter_url)) { $filter_url->add('mpage', $pageOb['page']); } /* Determine if we are showing previews. */ $preview_tooltip = $show_preview ? $prefs->getValue('preview_show_tooltip') : false; if (!$preview_tooltip) { $strip_preview = $prefs->getValue('preview_strip_nl'); } $unread = $imp_mailbox->unseenMessages(Horde_Imap_Client::SEARCH_RESULTS_COUNT); $page_output->addInlineJsVars(array('ImpMailbox.pop3' => intval(!$mailbox->is_imap), 'ImpMailbox.text' => array('delete_messages' => _("Are you sure you wish to PERMANENTLY delete these messages?"), 'delete_all' => _("Are you sure you wish to delete all mail in this mailbox?"), 'delete_vfolder' => _("Are you sure you want to delete this Virtual Folder Definition?"), 'innocent_report' => _("Are you sure you wish to report this message as innocent?"), 'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"), 'newmbox' => _("You are copying/moving to a new mailbox.") . "\n" . _("Please enter a name for the new mailbox:") . "\n", 'no' => _("No"), 'selectone' => _("You must select at least one message first."), 'selectonlyone' => _("You must select only one message for this action."), 'spam_report' => _("Are you sure you wish to report this message as spam?"), 'submit' => _("You must select at least one message first."), 'target_mbox' => _("You must select a target mailbox first.")), 'ImpMailbox.unread' => intval($unread))); $pagetitle = $this->title = $mailbox->label; if ($mailbox->editvfolder) { $query_text = wordwrap($imp_search[$mailbox]->querytext); $pagetitle .= ' [' . Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . _("Virtual Folder") . '</a>]'; $this->title .= ' [' . _("Virtual Folder") . ']'; } elseif ($mailbox->editquery) { $query_text = wordwrap($imp_search[$mailbox]->querytext); $pagetitle = Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . $pagetitle . '</a>'; } else { $pagetitle = $this->title = htmlspecialchars($this->title); } /* Generate mailbox summary string. */ $subinfo = new IMP_View_Subinfo(array('mailbox' => $mailbox)); $subinfo->value = $pagetitle . ' ('; if (empty($pageOb['end'])) { $subinfo->value .= _("No Messages"); } else { $subinfo->value .= $pageOb['pagecount'] > 1 ? sprintf(_("%d Messages"), $pageOb['msgcount']) . ' / ' . sprintf(_("Page %d of %d"), $pageOb['page'], $pageOb['pagecount']) : sprintf(_("%d Messages"), $pageOb['msgcount']); } $subinfo->value .= ')'; $injector->getInstance('Horde_View_Topbar')->subinfo = $subinfo->render(); $page_output->addScriptFile('hordecore.js', 'horde'); $page_output->addScriptFile('mailbox.js'); $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog'); $page_output->metaRefresh($prefs->getValue('refresh_time'), $refresh_url); /* Prepare the header template. */ $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/mailbox')); $view->addHelper('FormTag'); $view->addHelper('Horde_Core_View_Helper_Accesskey'); $view->addHelper('Tag'); $hdr_view = clone $view; $hdr_view->readonly = $readonly; $hdr_view->refresh_url = $refresh_url; if (isset($filter_url)) { $hdr_view->filter_url = $filter_url; } if ($mailbox->access_search) { if (!$search_mbox) { $hdr_view->search_url = $mailbox->url(IMP_Basic_Searchbasic::url()); } else { if ($mailbox->editvfolder) { $edit_search = _("Edit Virtual Folder"); } elseif ($mailbox->query) { if ($mailbox->editquery) { $edit_search = _("Edit Search Query"); } else { /* Basic search results. */ $search_mailbox = IMP_Mailbox::get($imp_search[$mailbox]->mboxes[0]); $hdr_view->search_url = $search_mailbox->url(IMP_Basic_Searchbasic::url()); $hdr_view->searchclose = $search_mailbox->url('mailbox'); } } if (isset($edit_search)) { $hdr_view->edit_search_url = $imp_search->editUrl($mailbox); $hdr_view->edit_search_title = $edit_search; } } } if ($mailbox->access_empty) { $hdr_view->empty = $mailbox_imp_url->copy()->add(array('actionID' => 'empty_mailbox', 'token' => $token)); } $this->output = $hdr_view->render('header'); /* If no messages, exit immediately. */ if (empty($pageOb['end'])) { if ($pageOb['anymsg'] && isset($deleted_prompt)) { /* Show 'Show Deleted' prompt if mailbox has no viewable * message but has hidden, deleted messages. */ $del_view = clone $view; $del_view->hide = Horde::widget(array('url' => $refresh_url->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt)); if ($mailbox->access_expunge) { $del_view->purge = Horde::widget(array('url' => $refresh_url->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted"))); } $this->output .= $del_view->render('actions_deleted'); } $empty_view = clone $view; $empty_view->search_mbox = $search_mbox; $this->output .= $empty_view->render('empty_mailbox'); return; } $clink_ob = new IMP_Compose_Link(); $clink = $clink_ob->link(); /* Display the navbar and actions if there is at least 1 message in * mailbox. */ if ($pageOb['msgcount']) { /* Prepare the navbar template. */ $n_view = clone $view; $n_view->id = 1; $n_view->readonly = $readonly; $filtermsg = false; if ($mailbox->access_flags) { $args = array('imap' => true, 'mailbox' => $search_mbox ? null : $mailbox); $form_set = $form_unset = array(); foreach ($imp_flags->getList($args) as $val) { if ($val->canset) { $form_set[] = array('f' => $val->form_set, 'l' => $val->label, 'v' => IMP_Mailbox::formTo(self::FLAG_FILTER_PREFIX . $val->form_set)); $form_unset[] = array('f' => $val->form_unset, 'l' => $val->label, 'v' => IMP_Mailbox::formTo(self::FLAG_FILTER_PREFIX . $val->form_unset)); } } $n_view->flaglist_set = $form_set; $n_view->flaglist_unset = $form_unset; if (!$search_mbox && $mailbox->access_search) { $filtermsg = $n_view->flag_filter = true; } } if (!$search_mbox && $mailbox->access_filters) { $filters = array(); $iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::FILTER); foreach ($iterator as $val) { $filters[] = array('l' => $val->label, 'v' => IMP_Mailbox::formTo($val)); } if (!empty($filters)) { $filtermsg = true; $n_view->filters = $filters; } } $n_view->filtermsg = $filtermsg; if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { $n_view->move = Horde::widget(array('url' => '#', 'class' => 'moveAction', 'title' => _("Move"), 'nocheck' => true)); $n_view->copy = Horde::widget(array('url' => '#', 'class' => 'copyAction', 'title' => _("Copy"), 'nocheck' => true)); $n_view->folder_options = $folder_options; } $n_view->mailbox_url = $mailbox_url; $n_view->mailbox = $mailbox->form_to; if ($pageOb['pagecount'] > 1) { $n_view->multiple_page = true; $n_view->pages_first = $pages_first; $n_view->url_first = $url_first; $n_view->pages_prev = $pages_prev; $n_view->url_prev = $url_prev; $n_view->pages_next = $pages_next; $n_view->url_next = $url_next; $n_view->pages_last = $pages_last; $n_view->url_last = $url_last; $n_view->page_val = $pageOb['page']; $n_view->page_size = Horde_String::length($pageOb['pagecount']); } $this->output .= $n_view->render('navbar'); /* Prepare the actions template. */ $a_view = clone $view; if ($mailbox->access_deletemsgs) { $del_class = $use_trash && $mailbox->trash ? 'permdeleteAction' : 'deleteAction'; $a_view->delete = Horde::widget(array('url' => '#', 'class' => $del_class, 'title' => _("_Delete"))); } if ($showdelete['purge'] || $mailbox->vtrash) { $a_view->undelete = Horde::widget(array('url' => '#', 'class' => 'undeleteAction', 'title' => _("_Undelete"))); } $mboxactions = array(); if ($showdelete['purge']) { $mailbox_link = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']); if (isset($deleted_prompt)) { $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt)); } $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted"))); } if (!$sortpref->sortby_locked && $sortpref->sortby != Horde_Imap_Client::SORT_SEQUENCE) { $mboxactions[] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('sortby' => Horde_Imap_Client::SORT_SEQUENCE, 'actionID' => 'change_sort', 'token' => $token)), 'title' => _("Clear Sort"))); } if ($mailbox->templates) { $a_view->templateedit = Horde::widget(array('url' => '#', 'class' => 'templateeditAction', 'title' => _("Edit Template"))); $mboxactions[] = Horde::widget(array('url' => $clink->copy()->add(array('actionID' => 'template_new')), 'title' => _("Create New Template"))); } $a_view->mboxactions = $mboxactions; if ($registry->hasMethod('mail/blacklistFrom')) { $a_view->blacklist = Horde::widget(array('url' => '#', 'class' => 'blacklistAction', 'title' => _("_Blacklist"))); } if ($registry->hasMethod('mail/whitelistFrom')) { $a_view->whitelist = Horde::widget(array('url' => '#', 'class' => 'whitelistAction', 'title' => _("_Whitelist"))); } if (IMP_Compose::canCompose()) { $a_view->forward = Horde::widget(array('url' => '#', 'class' => 'forwardAction', 'title' => _("Fo_rward"))); $a_view->redirect = Horde::widget(array('url' => '#', 'class' => 'redirectAction', 'title' => _("Redirect"))); } if ($mailbox->spam_show) { $a_view->spam = Horde::widget(array('url' => '#', 'class' => 'spamAction', 'title' => _("Report as Spam"))); } if ($mailbox->innocent_show) { $a_view->innocent = Horde::widget(array('url' => '#', 'class' => 'innocentAction', 'title' => _("Report as Innocent"))); } $a_view->view_messages = Horde::widget(array('url' => '#', 'class' => 'viewAction', 'title' => _("View Messages"))); $this->output .= $a_view->render('actions'); } /* Define some variables now so we don't have to keep redefining in * the foreach loop or the templates. */ $lastMbox = ''; $mh_count = 0; $sortImg = $sortpref->sortdir ? 'sortup' : 'sortdown'; $headers = array(Horde_Imap_Client::SORT_TO => array('id' => 'mboxto', 'stext' => _("Sort by To Address"), 'text' => _("To")), Horde_Imap_Client::SORT_FROM => array('id' => 'mboxfrom', 'stext' => _("Sort by From Address"), 'text' => _("Fro_m")), Horde_Imap_Client::SORT_THREAD => array('id' => 'mboxthread', 'stext' => _("Sort by Thread"), 'text' => _("_Thread")), Horde_Imap_Client::SORT_SUBJECT => array('id' => 'mboxsubject', 'stext' => _("Sort by Subject"), 'text' => _("Sub_ject")), IMP::IMAP_SORT_DATE => array('id' => 'mboxdate', 'stext' => _("Sort by Date"), 'text' => _("Dat_e")), Horde_Imap_Client::SORT_SIZE => array('id' => 'mboxsize', 'stext' => _("Sort by Message Size"), 'text' => _("Si_ze"))); /* If this is the Drafts or Sent-Mail mailbox, sort by To instead of * From. */ if ($mailbox->special_outgoing) { unset($headers[Horde_Imap_Client::SORT_FROM]); } else { unset($headers[Horde_Imap_Client::SORT_TO]); } /* Determine which of Subject/Thread to emphasize. */ if (!$mailbox->access_sortthread || $sortpref->sortby_locked) { unset($headers[Horde_Imap_Client::SORT_THREAD]); if ($sortpref->sortby_locked && $thread_sort) { $sortpref->sortby = Horde_Imap_Client::SORT_SUBJECT; } } else { if ($thread_sort) { $extra = Horde_Imap_Client::SORT_SUBJECT; $standard = Horde_Imap_Client::SORT_THREAD; } else { $extra = Horde_Imap_Client::SORT_THREAD; $standard = Horde_Imap_Client::SORT_SUBJECT; } $headers[$standard]['altsort'] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('actionID' => 'change_sort', 'token' => $token, 'sortby' => $extra)), 'title' => $headers[$extra]['text'])); unset($headers[$extra]); } foreach ($headers as $key => $val) { $ptr =& $headers[$key]; if ($sortpref->sortby == $key) { $csl_icon = '<span class="iconImg ' . $sortImg . '"></span>'; if ($sortpref->sortdir_locked) { $ptr['change_sort_link'] = $csl_icon; $ptr['change_sort_widget'] = Horde::stripAccessKey($val['text']); } else { $tmp = $mailbox_imp_url->copy()->add(array('sortby' => $key, 'sortdir' => intval(!$sortpref->sortdir), 'actionID' => 'change_sort', 'token' => $token)); $ptr['change_sort_link'] = Horde::link($tmp, $val['stext'], null, null, null, $val['stext']) . $csl_icon . '</a>'; $ptr['change_sort_widget'] = Horde::widget(array('url' => $tmp, 'title' => $val['text'])); } } else { $ptr['change_sort_link'] = null; $ptr['change_sort_widget'] = $sortpref->sortby_locked ? Horde::stripAccessKey($val['text']) : Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('actionID' => 'change_sort', 'token' => $token, 'sortby' => $key)), 'title' => $val['text'])); } $ptr['class'] = 'horde-split-left'; } /* Output the form start. */ $f_view = clone $view; $f_view->mailbox = $mailbox->form_to; $f_view->mailbox_url = $mailbox_url; $f_view->page = $pageOb['page']; $f_view->token = $token; $this->output .= $f_view->render('form_start'); /* Prepare the message headers template. */ $mh_view = clone $view; $mh_view->headers = $headers; if (!$search_mbox) { $mh_view->show_checkbox = !$mh_count++; $this->output .= $mh_view->render('message_headers'); } /* Initialize repetitively used variables. */ $fromlinkstyle = $prefs->getValue('from_link'); $imp_ui = new IMP_Mailbox_Ui($mailbox); /* Display message information. */ $msgs = array(); $search_view = clone $view; $summary_view = clone $view; while (list(, $ob) = each($mbox_info['overview'])) { if ($search_mbox) { if (empty($lastMbox) || $ob['mailbox'] != $lastMbox) { if (!empty($lastMbox)) { $this->_outputSummaries($msgs, $summary_view); $msgs = array(); } $mbox = IMP_Mailbox::get($ob['mailbox']); $search_view->mbox_link = Horde::link($mbox->url($mailbox_url), sprintf(_("View messages in %s"), $mbox->display), 'smallheader') . $mbox->display_html . '</a>'; $this->output .= $search_view->render('searchmbox'); $mh_view->show_checkbox = !$mh_count++; $this->output .= $mh_view->render('message_headers'); } } $lastMbox = $ob['mailbox']; /* Initialize the data fields. */ $msg = array('bg' => '', 'buid' => $imp_mailbox->getBuid($ob['mailbox'], $ob['uid']), 'class' => '', 'date' => $imp_ui->getDate($ob['envelope']->date), 'preview' => '', 'status' => '', 'size' => IMP::sizeFormat($ob['size'])); /* Generate the target link. */ if ($mailbox->drafts || $mailbox->templates) { $clink_copy = clone $clink_ob; $clink_copy->args['buid'] = $msg['buid']; $clink_copy->args['mailbox'] = $mailbox; $target = $clink_copy->link()->add(array('actionID' => $mailbox->drafts ? 'draft' : 'template')); } else { $target = $mailbox->url('message', $msg['buid']); } /* Get all the flag information. */ $flag_parse = $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'runhook' => $ob, 'personal' => $ob['envelope']->to)); $css_class = $subject_flags = array(); foreach ($flag_parse as $val) { if ($val instanceof IMP_Flag_User) { $subject_flags[] = $val; } else { if (!$val->bgdefault) { $msg['bg'] = $val->bgcolor; } $css_class[] = $val->css; $msg['status'] .= $val->span; } } $msg['class'] = implode(' ', $css_class); /* Show message preview? */ if ($show_preview && isset($ob['preview'])) { if (empty($ob['preview'])) { $ptext = '[[' . _("No Preview Text") . ']]'; } else { $ptext = empty($strip_preview) ? str_replace("\r", '', $ob['preview']) : preg_replace(array('/\\n/', '/(\\s)+/'), array(' ', '$1'), str_replace("\r", "\n", $ob['preview'])); if (!$preview_tooltip) { $ptext = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($ptext, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML)); } $maxlen = $prefs->getValue('preview_maxlen'); if (Horde_String::length($ptext) > $maxlen) { $ptext = Horde_String::truncate($ptext, $maxlen); } elseif (empty($ob['previewcut'])) { $ptext .= '[[' . _("END") . ']]'; } } $msg['preview'] = $ptext; } /* Format the From: Header. */ $getfrom = $imp_ui->getFrom($ob['envelope']); $msg['from'] = htmlspecialchars($getfrom['from'], ENT_QUOTES, 'UTF-8'); switch ($fromlinkstyle) { case 0: $from_tmp = array(); foreach ($getfrom['from_list']->base_addresses as $from_ob) { $from_tmp[] = call_user_func_array(array('Horde', $preview_tooltip ? 'linkTooltip' : 'link'), array($clink->copy()->add(array('actionID' => 'mailto_link', 'to' => strval($from_ob))), sprintf(_("New Message to %s"), $from_ob->label))) . htmlspecialchars($from_ob->label, ENT_QUOTES, 'UTF-8') . '</a>'; } if (!empty($from_tmp)) { $msg['from'] = implode(', ', $from_tmp); } break; default: $from_uri = $mailbox->url('message', $msg['buid']); $msg['from'] = Horde::link($from_uri) . $msg['from'] . '</a>'; break; } /* Format the Subject: Header. */ $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject, true); $msg['subject'] = $preview_tooltip ? substr(Horde::linkTooltip($target, $msg['preview'], '', '', '', $msg['preview']), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' : substr(Horde::link($target, $imp_ui->getSubject($ob['envelope']->subject)), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' . (!empty($msg['preview']) ? '<br /><small>' . $msg['preview'] . '</small>' : ''); /* Add subject flags. */ foreach ($subject_flags as $val) { $flag_label = Horde_String::truncate($val->label, 12); $msg['subject'] = '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '" title="' . htmlspecialchars($val->label) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject']; } /* Set up threading tree now. */ if ($thread_sort) { $t_ob = $imp_mailbox->getThreadOb($ob['idx']); $msg['subject'] = ($sortpref->sortdir ? $t_ob->reverse_img : $t_ob->img) . ' ' . $msg['subject']; } $msgs[$msg['buid']] = $msg; } $this->_outputSummaries($msgs, $summary_view); $this->output .= '</form>'; /* If there are 20 messages or less, don't show the actions/navbar * again. */ if ($pageOb['end'] - $pageOb['begin'] >= 20) { $this->output .= $a_view->render('actions'); $n_view->id = 2; $this->output .= $n_view->render('navbar'); } }
/** */ protected function _node($doc, $node) { parent::_node($doc, $node); if (empty($this->_imptmp) || !$node instanceof DOMElement) { if ($node instanceof DOMText && $node->length > 1) { /* Filter bad language. */ $text = IMP::filterText($node->data); if ($node->data != $text) { $node->replaceData(0, $node->length, $text); } } return; } $tag = Horde_String::lower($node->tagName); /* Remove 'height' styles from HTML messages, because it can break * sizing of IFRAME. */ foreach ($node->attributes as $key => $val) { if ($key == 'style') { /* Do simplistic style parsing here. */ $parts = array_filter(explode(';', $val->value)); foreach ($parts as $k2 => $v2) { if (preg_match("/^\\s*height:\\s*/i", $v2)) { unset($parts[$k2]); } } $val->value = implode(';', $parts); } } switch ($tag) { case 'a': case 'area': /* Convert links to open in new windows. Ignore mailto: links and * links that already have a target. */ if ($node->hasAttribute('href')) { $url = parse_url($node->getAttribute('href')); if (isset($url['scheme']) && $url['scheme'] == 'mailto') { /* We don't include HordePopup in IFRAME, so need to use * 'simple' links. */ $clink = new IMP_Compose_Link($node->getAttribute('href')); $node->setAttribute('href', $clink->link(true)); $node->removeAttribute('target'); } elseif (!empty($this->_imptmp['inline']) && isset($url['fragment']) && empty($url['path']) && $GLOBALS['browser']->isBrowser('mozilla')) { /* See Bug #8695: internal anchors are broken in * Mozilla. */ $node->removeAttribute('href'); } elseif (empty($url)) { /* Empty URL - remove href/target so the link is not * clickable. */ $node->removeAttribute('href'); $node->removeAttribute('target'); } else { $node->setAttribute('target', strval(new Horde_Support_Randomid())); } } break; case 'body': $style = $node->hasAttribute('style') ? rtrim($node->getAttribute('style'), ';') . ';' : ''; $node->setAttribute('style', $style . 'width:auto !important'); break; case 'img': case 'input': if ($node->hasAttribute('src')) { $val = $node->getAttribute('src'); /* Multipart/related. */ if ($tag == 'img' && ($id = $this->_cidSearch($val))) { $val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array('ctype' => 'image/*', 'id' => $id, 'imp_img_view' => 'data'))); } /* Block images.*/ if ($this->_imgBlock()) { if (Horde_Url_Data::isData($val)) { $url = new Horde_Url_Data($val); } else { /* Check for relative URLs. These won't be loaded and * will cause unnecessary 404 hits to the local web * server. */ $parsed_url = parse_url($val); if (isset($parsed_url['host'])) { $url = new Horde_Url($val); $url->setScheme(); } else { $url = null; } } if ($url) { $node->setAttribute(self::IMGBLOCK, $url); $node->setAttribute('src', $this->_imgBlockImg()); $this->_imptmp['imgblock'] = true; } else { $node->parentNode->removeChild($node); $this->_imptmp['imgbroken'] = true; } } else { $node->removeAttribute('src'); $node->setAttribute('data-src', $val); } } /* IMG only */ if ($tag == 'img' && $this->_imgBlock() && $node->hasAttribute('srcset')) { $node->setAttribute(self::SRCSETBLOCK, $node->getAttribute('srcset')); $node->setAttribute('srcset', ''); $this->_imptmp['imgblock'] = true; } break; case 'link': /* Block all link tags that reference foreign URLs, other than * CSS. There's no inherently wrong with linking to a foreign * CSS file other than privacy concerns. Therefore, block * linking until requested by the user. */ $delete_link = true; switch (Horde_String::lower($node->getAttribute('type'))) { case 'text/css': if ($node->hasAttribute('href')) { $tmp = $node->getAttribute('href'); if ($id = $this->_cidSearch($tmp, false)) { $this->_imptmp['style'][] = $this->getConfigParam('imp_contents')->getMIMEPart($id)->getContents(); } elseif ($this->_imgBlock()) { $node->setAttribute(self::CSSBLOCK, $node->getAttribute('href')); $node->removeAttribute('href'); $this->_imptmp['cssblock'] = true; $delete_link = false; } } break; } if ($delete_link && $node->hasAttribute('href') && $node->parentNode) { $node->parentNode->removeChild($node); } break; case 'style': switch (Horde_String::lower($node->getAttribute('type'))) { case 'text/css': $this->_imptmp['style'][] = str_replace(array('<!--', '-->'), '', $node->nodeValue); $node->parentNode->removeChild($node); break; } break; case 'table': /* If displaying inline (in IFRAME), tables with 100% height seems * to confuse many browsers re: the IFRAME internal height. */ if (!empty($this->_imptmp['inline']) && $node->hasAttribute('height') && $node->getAttribute('height') == '100%') { $node->removeAttribute('height'); } // Fall-through // Fall-through case 'body': case 'td': if ($node->hasAttribute('background')) { $val = $node->getAttribute('background'); /* Multipart/related. */ if ($id = $this->_cidSearch($val)) { $val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array('id' => $id, 'imp_img_view' => 'data'))); $node->setAttribute('background', $val); } /* Block images.*/ if ($this->_imgBlock()) { $node->setAttribute(self::IMGBLOCK, $val); $node->setAttribute('background', $this->_imgBlockImg()); $this->_imptmp['imgblock'] = true; } } break; } $remove = array(); foreach ($node->attributes as $val) { /* Catch random mailto: strings in attributes that will cause * problems with e-mail linking. */ if (stripos($val->value, 'mailto:') === 0) { $remove[] = $val->name; } } foreach ($remove as $val) { $node->removeAttribute($val); } if ($node->hasAttribute('style')) { if (strpos($node->getAttribute('style'), 'content:') !== false) { // TODO: Figure out way to unblock? $node->removeAttribute('style'); } elseif (!empty($this->_imptmp['cid']) || $this->_imgBlock()) { $this->_imptmp['node'] = $node; $style = preg_replace_callback(self::CSS_BG_PREG, array($this, '_styleCallback'), $node->getAttribute('style'), -1, $matches); if ($matches) { $node->setAttribute('style', $style); } } } }
/** */ protected function _addMailboxVars() { global $injector, $prefs, $registry; /* Does server support ACLs? */ $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create(); $acl = $imp_imap->access(IMP_Imap::ACCESS_ACL); $subscribe = $prefs->getValue('subscribe'); $this->js_conf += array_filter(array('URI_LISTINFO' => strval(IMP_Basic_Listinfo::url()->setRaw(true)), 'URI_MESSAGE' => strval(IMP_Dynamic_Message::url()->setRaw(true)), 'URI_PORTAL' => strval($registry->getServiceLink('portal')->setRaw(true)), 'URI_PREFS_IMP' => strval($registry->getServiceLink('prefs', 'imp')->setRaw(true)), 'URI_SEARCH' => strval(IMP_Basic_Search::url()->setRaw(true)), 'URI_THREAD' => strval(IMP_Basic_Thread::url()->setRaw(true)), 'FLAG_DELETED' => Horde_Imap_Client::FLAG_DELETED, 'FLAG_DRAFT' => Horde_Imap_Client::FLAG_DRAFT, 'FLAG_INNOCENT' => Horde_Imap_Client::FLAG_NOTJUNK, 'FLAG_SEEN' => Horde_Imap_Client::FLAG_SEEN, 'FLAG_SPAM' => Horde_Imap_Client::FLAG_JUNK, 'msglist_template_horiz' => file_get_contents(IMP_TEMPLATES . '/dynamic/msglist_horiz.html'), 'msglist_template_vert' => file_get_contents(IMP_TEMPLATES . '/dynamic/msglist_vert.html'), 'acl' => $acl, 'filter_any' => intval($prefs->getValue('filter_any_mailbox')), 'fsearchid' => IMP_Mailbox::formTo(IMP_Search::MBOX_PREFIX . IMP_Search::FILTERSEARCH), 'initial_page' => is_null($initial_page = IMP::getInitialPage()->mbox) ? null : $initial_page->form_to, 'mbox_expand' => intval($prefs->getValue('nav_expanded') == 2), 'name' => $registry->get('name', 'imp'), 'poll_alter' => intval(!$prefs->isLocked('nav_poll') && !$prefs->getValue('nav_poll_all')), 'qsearchid' => IMP_Mailbox::formTo(IMP_Search::MBOX_PREFIX . IMP_Search::QUICKSEARCH), 'refresh_time' => intval($prefs->getValue('refresh_time')), 'sidebar_width' => max(intval($prefs->getValue('sidebar_width')), 150), 'sort' => array('from' => array('c' => 'msgFrom', 't' => _("From"), 'v' => Horde_Imap_Client::SORT_FROM), 'to' => array('c' => 'msgFrom', 'ec' => 'msgFromTo', 't' => _("To"), 'v' => Horde_Imap_Client::SORT_TO), 'subject' => array('c' => 'msgSubject', 't' => _("Subject"), 'v' => Horde_Imap_Client::SORT_SUBJECT), 'thread' => array('c' => 'msgSubject', 'v' => Horde_Imap_Client::SORT_THREAD), 'date' => array('c' => 'msgDate', 't' => _("Date"), 'v' => IMP::IMAP_SORT_DATE), 'msgarrival' => array('c' => 'msgDate', 'v' => Horde_Imap_Client::SORT_ARRIVAL), 'msgdate' => array('c' => 'msgDate', 'v' => Horde_Imap_Client::SORT_DATE), 'sequence' => array('v' => Horde_Imap_Client::SORT_SEQUENCE), 'size' => array('c' => 'msgSize', 't' => _("Size"), 'v' => Horde_Imap_Client::SORT_SIZE)), 'subscribe' => intval($subscribe))); $context = array('ctx_container' => array('_mbox' => '', '_sep1' => null, 'create' => _("Create subfolder"), 'rename' => _("Rename"), 'delete' => _("Delete subfolders"), '_sep2' => null, 'search' => _("Search"), '_sep3' => null, 'expand' => _("Expand All"), 'collapse' => _("Collapse All")), 'ctx_datesort' => array('*msgarrival' => _("Arrival Time"), '*msgdate' => _("Message Date")), 'ctx_flag' => array(), 'ctx_flagunset' => array(), 'ctx_flag_search' => array(), 'ctx_mbox_flag' => array('seen' => _("Seen"), 'unseen' => _("Unseen")), 'ctx_noactions' => array('_mbox' => '', '_sep1' => null, 'noaction' => _("No actions available")), 'ctx_remoteauth' => array('_mbox' => '', '_sep1' => null, 'create' => _("Create Mailbox"), 'logout' => _("Log Out")), 'ctx_sortopts' => array('from' => _("From"), 'to' => _("To"), 'subject' => _("Subject"), 'thread' => _("Thread"), 'msgarrival' => _("Date (Arrival)"), 'msgdate' => _("Date (Message)"), 'size' => _("Size"), '_sep1' => null, 'sequence' => _("No Sort")), 'ctx_subjectsort' => array('thread' => _("Thread Sort")), 'ctx_template' => array('edit' => _("Edit Template"), 'new' => _("Create New Template")), 'ctx_vcontainer' => array('_mbox' => _("Virtual Folders"), '_sep1' => null, 'edit' => _("Edit Virtual Folders")), 'ctx_vfolder' => array('_mbox' => '', '_sep1' => null, 'edit' => _("Edit Virtual Folder"), 'delete' => _("Delete Virtual Folder"))); /* Folder options context menu. */ if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { $context['ctx_folderopts'] = array('new' => _("Create Mailbox"), 'sub' => _("Hide Unsubscribed"), 'unsub' => _("Show All Mailboxes"), 'expand' => _("Expand All"), 'collapse' => _("Collapse All"), '_sep1' => null, 'reload' => _("Rebuild Folder List")); } if (!$subscribe) { unset($context['ctx_folderopts']['sub'], $context['ctx_folderopts']['unsub']); } /* Message context menu. */ $context['ctx_message'] = array('_sub1' => array('resume' => _("Resume Draft"), 'template' => _("Use Template"), 'template_edit' => _("Edit Template"), 'view' => _("View Message")), 'reply' => _("Reply"), 'forward' => _("Forward"), '_sub2' => array('_sep1' => null, 'setflag' => _("Mark as") . '...', 'unsetflag' => _("Unmark as") . '...'), '_sep2' => null, 'spam' => _("Report as Spam"), 'innocent' => _("Report as Innocent"), 'blacklist' => _("Blacklist"), 'whitelist' => _("Whitelist"), 'addfilter' => _("Create Filter"), 'delete' => _("Delete"), 'undelete' => _("Undelete"), '_sub3' => array('_sep3' => null, 'source' => _("View Source"))); if (empty($imp_imap->config->spam_params)) { unset($context['ctx_message']['spam']); } if (empty($imp_imap->config->innocent_params)) { unset($context['ctx_message']['innocent']); } if (!$registry->hasLink('mail/newEmailFilter')) { unset($context['ctx_message']['addfilter']); } $view_source = $injector->getInstance('Horde_Core_Perms')->hasAppPermission('view_msg_source'); if (!$view_source) { unset($context['ctx_message']['_sub3']); } /* Mailbox context menu. */ $context['ctx_mbox'] = array('_mbox' => '', '_sep1' => null, 'create' => _("Create subfolder"), 'rename' => _("Rename"), 'empty' => _("Empty"), 'delete' => _("Delete"), '_sep2' => null, 'setflag' => _("Mark all as"), '_sep3' => null, 'poll' => _("Check for New Mail"), 'nopoll' => _("Do Not Check for New Mail"), 'sub' => _("Subscribe"), 'unsub' => _("Unsubscribe"), '_sep4' => null, 'search' => _("Search"), '_sub1' => array('_sep5' => null, 'expand' => _("Expand All"), 'collapse' => _("Collapse All")), '_sep6' => null, 'export' => _("Export"), 'import' => _("Import"), '_sep7' => null, 'size' => _("Mailbox Size"), '_sub2' => array('_sep8' => null, 'acl' => _("Edit ACL"))); if (!$subscribe) { unset($context['ctx_mbox']['sub'], $context['ctx_mbox']['unsub']); } if (!$imp_imap->access(IMP_Imap::ACCESS_IMPORT)) { unset($context['ctx_mbox']['import']); } if (!$imp_imap->access(IMP_Imap::ACCESS_FLAGS)) { unset($context['ctx_mbox']['_sep2'], $context['ctx_mbox']['setflag'], $context['ctx_mbox']['_sep3'], $context['ctx_mbox']['poll'], $context['ctx_mbox']['nopoll']); } if (!$imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { unset($context['ctx_mbox']['_sep7'], $context['ctx_mbox']['size']); } if (!$imp_imap->access(IMP_Imap::ACCESS_SEARCH)) { unset($context['ctx_mbox']['_sep4'], $context['ctx_mbox']['search']); } if (!$imp_imap->access(IMP_Imap::ACCESS_FLAGS) || $prefs->isLocked('acl')) { unset($context['ctx_mbox']['_sub2']); } /* Other Actions context menu. */ $context['ctx_oa'] = array('preview_hide' => _("Hide Preview"), 'preview_show' => _("Show Preview"), 'layout_horiz' => _("Horizontal Layout"), 'layout_vert' => _("Vertical Layout"), '_sub1' => array('_sep1' => null, 'setflag' => _("Mark as") . '...', 'unsetflag' => _("Unmark as") . '...'), 'blacklist' => _("Blacklist"), 'whitelist' => _("Whitelist"), '_sub2' => array('_sep2' => null, 'purge_deleted' => _("Purge Deleted"), 'undelete' => _("Undelete")), 'show_deleted' => _("Show Deleted"), 'hide_deleted' => _("Hide Deleted"), '_sub3' => array('_sep3' => null, 'clear_sort' => _("Clear Sort"))); if ($prefs->isLocked('delhide')) { unset($context['ctx_oa']['hide_deleted']); } /* Shared between message and other actions menus. */ if (!$registry->hasMethod('mail/blacklistFrom')) { unset($context['ctx_message']['blacklist'], $context['ctx_oa']['blacklist']); } if (!$registry->hasMethod('mail/whitelistFrom')) { unset($context['ctx_message']['whitelist'], $context['ctx_oa']['whitelist']); } /* Preview context menu. */ $context['ctx_preview'] = array('save' => _("Save"), 'viewsource' => _("View Source"), 'allparts' => _("All Parts"), 'thread' => _("View Thread"), 'listinfo' => _("List Info")); if (!$view_source) { unset($context['ctx_preview']['viewsource']); } /* Search related context menus. */ if ($imp_imap->access(IMP_Imap::ACCESS_SEARCH)) { $context['ctx_filteropts'] = array('*filter' => _("Filter By"), '*flag' => _("Show Only"), '*flagnot' => _("Don't Show")); if (IMP_Filter::canApplyFilters()) { $context['ctx_filteropts']['_sub1'] = array('_sep1' => null, 'applyfilters' => _("Apply Filters")); } $context['ctx_qsearchopts'] = array('*all' => _("Entire Message"), '*body' => _("Body"), '*from' => _("From"), '*recip' => _("Recipients (To/Cc/Bcc)"), '*subject' => _("Subject"), '_sep1' => null, '*advanced' => _("Advanced Search...")); /* Generate filter array. */ $iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::FILTER); $context['ctx_filter'] = array(); foreach ($iterator as $val) { if ($val->enabled) { $context['ctx_filter']['*' . $val->id] = $val->label; } } } /* Remote accounts context menu. */ if ($imp_imap->access(IMP_Imap::ACCESS_REMOTE)) { $context['ctx_rcontainer'] = array('*prefs' => _("Manage Remote Accounts")); } $this->js_context = array_merge($context, $this->js_context); $this->js_text += array('atc_downloadall' => _("Download All (%s)"), 'badaddr' => _("Invalid Address"), 'badsubject' => _("Invalid Subject"), 'baselevel' => _("base level of the folder tree"), 'check' => _("Checking..."), 'copyto' => _("Copy %s to %s"), 'create_prompt' => _("Create mailbox:"), 'createsub_prompt' => _("Create subfolder of %s:"), 'delete_mbox' => _("Permanently delete %s?"), 'download_mbox' => _("All messages in this mailbox will be downloaded into the format that you choose. Depending on the size of the mailbox, this action may take awhile."), 'empty_mbox' => _("Permanently delete all %d messages in %s?"), 'import_mbox' => _("Mbox or .eml file:"), 'import_mbox_loading' => _("Importing (this may take some time)..."), 'listmsg_wait' => _("The server is still generating the message list."), 'listmsg_timeout' => _("The server was unable to generate the message list."), 'loading' => _("Loading..."), 'message_0' => _("No messages"), 'message_1' => _("1 message"), 'message_2' => _("%d messages"), 'mboxsize' => _("%s is: %s."), 'moveto' => _("Move %s to %s"), 'newflag_name' => _("Flag Name:"), 'newflag_wait' => _("Creating New Flag..."), 'no_folder_name' => _("Must enter a folder name"), 'onlogout' => _("Logging Out..."), 'portal' => _("Portal"), 'prefs' => _("User Options"), 'remote_password' => _("Password for %s:"), 'rename_prompt' => _("Rename %s to:"), 'search' => _("Search"), 'search_input' => _("Search (%s)"), 'search_time' => _("Results are %d Minutes Old"), 'selected' => _("%s selected."), 'slidertext' => _("Messages %d - %d"), 'vfolder' => _("Virtual Folder: %s"), 'vp_empty' => _("There are no messages in this mailbox."), 'vp_empty_search' => _("No messages matched the search query.")); if ($subscribe) { $this->js_text += array('subscribe_mbox' => _("Subscribe to %s?"), 'subscribe_mbox_subfolders' => _("Subscribe to all subfolders of %s?"), 'unsubscribe_mbox' => _("Unsubscribe to %s?"), 'unsubscribe_mbox_subfolders' => _("Unsubscribe to all subfolders of %s?")); } }