}
/* Add print link? */
- if ($mask && self::SUMMARY_PRINT) {
- $part['print'] = $this->linkViewJS($mime_part, 'view_attach', '', array('css' => 'printAtc', 'onload' => 'IMP.printWindow', 'jstext' => _("Print"), 'params' => $param_array));
+ if (($mask && self::SUMMARY_PRINT) &&
+ $this->canDisplay($id, self::RENDER_FULL)) {
+ $part['print'] = $this->linkViewJS($mime_part, 'print_attach', '', array('css' => 'printAtc', 'jstext' => _("Print"), 'onload' => 'IMP.printWindow', 'params' => $param_array, 'print' => true));
}
/* Strip Attachment? Allow stripping of base parts other than the
* fully loaded.
* 'params' - (array) A list of any additional parameters that need to be
* passed to view.php. (key = name)
+ * 'print' - (boolean) Generate link to print page?
+ * DEFAULT: Link to view page.
* 'widget' - (boolean) If true use Horde::widget() to generate,
* Horde::link() otherwise.
* </pre>
$options['jstext'] = sprintf(_("View %s"), $mime_part->getDescription(true));
}
- $url = Horde::popupJs(Horde::applicationUrl('view.php'), array('menu' => true, 'onload' => empty($options['onload']) ? '' : $options['onload'], 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)) . 'return false;';
+ $url = Horde::popupJs(Horde::applicationUrl(empty($options['print']) ? 'view.php' : 'print.php'), array('menu' => true, 'onload' => empty($options['onload']) ? '' : $options['onload'], 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)) . 'return false;';
return empty($options['widget'])
? Horde::link('#', $options['jstext'], empty($options['css']) ? null : $options['css'], null, $url) . $text . '</a>'
--- /dev/null
+<?php
+/**
+ * Print a message part.
+ *
+ * <pre>
+ * URL parameters:
+ * ---------------
+ * 'id' - (string) The MIME ID of the part to print.
+ * 'mailbox' - (string) The mailbox of the message.
+ * 'mode' - (string) The print mode to use ('content', 'headers', empty).
+ * DEFAULT: Prints frameset page
+ * 'uid' - (integer) The UID of the message.
+ * </pre>
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('imp', array('session_control' => 'readonly'));
+
+$vars = Horde_Variables::getDefaultVariables();
+
+/* Bug #8708 - Mozilla can't print multipage data in frames. No choice but
+ * to output just the data with no header information. */
+if ($browser->isBrowser('mozilla')) {
+ $vars->mode = 'content';
+}
+
+switch ($vars->mode) {
+case 'content':
+case 'headers':
+ if (!$vars->uid || !$vars->mailbox || !$vars->id) {
+ exit;
+ }
+
+ $contents = IMP_Contents::singleton($vars->uid . IMP::IDX_SEP . $vars->mailbox);
+
+ switch ($vars->mode) {
+ case 'content':
+ $render = $contents->renderMIMEPart($vars->id, IMP_Contents::RENDER_FULL);
+ if (!empty($render)) {
+ reset($render);
+ $key = key($render);
+ $browser->downloadHeaders($render[$key]['name'], $render[$key]['type'], true, strlen($render[$key]['data']));
+ echo $render[$key]['data'];
+ }
+ break;
+
+ case 'headers':
+ $imp_ui = new IMP_Ui_Message();
+ $basic_headers = $imp_ui->basicHeaders();
+ unset($basic_headers['bcc'], $basic_headers['reply-to']);
+ $headerob = $contents->getHeaderOb();
+
+ $headers = array();
+ foreach ($basic_headers as $key => $val) {
+ if ($hdr_val = $headerob->getValue($key)) {
+ $headers[] = array(
+ 'header' => htmlspecialchars($val),
+ 'value' => htmlspecialchars($hdr_val)
+ );
+ }
+ }
+
+ if (!empty($conf['print']['add_printedby'])) {
+ $user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'));
+ $headers[] = array(
+ 'header' => htmlspecialchars(_("Printed By")),
+ 'value' => htmlspecialchars($user_identity->getFullname() ? $user_identity->getFullname() : Horde_Auth::getAuth())
+ );
+ }
+
+ $t = $injector->createInstance('Horde_Template');
+ $t->set('css', Horde_Util::bufferOutput(array('Horde', 'includeStylesheetFiles')));
+
+ $t->set('headers', $headers);
+
+ echo $t->fetch(IMP_TEMPLATES . '/print/headers.html');
+ break;
+ }
+ break;
+
+default:
+ $self_url = Horde::selfUrl(true, true);
+ $t = $injector->createInstance('Horde_Template');
+ $t->set('headers', $self_url->copy()->add('mode', 'headers'));
+ $t->set('content', $self_url->copy()->add('mode', 'content'));
+ echo $t->fetch(IMP_TEMPLATES . '/print/print.html');
+ break;
+}