diff --git a/modules/core/message_list_functions.php b/modules/core/message_list_functions.php
index eac7e95a2f..3a2960d6f9 100644
--- a/modules/core/message_list_functions.php
+++ b/modules/core/message_list_functions.php
@@ -295,15 +295,23 @@ function checkbox_callback($vals, $style, $output_mod) {
if (!hm_exists('subject_callback')) {
function subject_callback($vals, $style, $output_mod) {
$img = '';
+ $preview_msg = '';
+ $subject = '';
if (count($vals) == 4 && $vals[3]) {
$img = '';
}
- $subject = $output_mod->html_safe($vals[0]);
+ if (is_array($vals[0])) {
+ $preview_msg = $output_mod->html_safe($vals[0]['preview_msg']);
+ $subject = $output_mod->html_safe($vals[0]['subject']);
+ } else {
+ $subject = $output_mod->html_safe($vals[0]);
+ }
+
$hl_subject = preg_replace("/^(\[[^\]]+\])/", '$1', $subject);
if ($style == 'news') {
- return sprintf('
', $output_mod->html_safe(implode(' ', $vals[2])), $subject, $img, $output_mod->html_safe($vals[1]), $hl_subject);
+ return sprintf('', $output_mod->html_safe(implode(' ', $vals[2])), $subject, $img, $output_mod->html_safe($vals[1]), $hl_subject);
}
- return sprintf(' | ', $output_mod->html_safe(implode(' ', $vals[2])), $subject, $output_mod->html_safe($vals[1]), $hl_subject);
+ return sprintf(' | ', $output_mod->html_safe(implode(' ', $vals[2])), $subject, $output_mod->html_safe($vals[1]), $hl_subject);
}}
/**
diff --git a/modules/imap/functions.php b/modules/imap/functions.php
index 107f95daec..34cd753584 100644
--- a/modules/imap/functions.php
+++ b/modules/imap/functions.php
@@ -216,6 +216,11 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false,
$msg['subject'] = '[No Subject]';
}
$subject = $msg['subject'];
+ $preview_msg = "";
+ if (isset($msg['preview_msg'])) {
+ $preview_msg = $msg['preview_msg'];
+ }
+
if ($parent_list == 'sent') {
$icon = 'sent';
$from = $msg['to'];
@@ -291,7 +296,7 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false,
$res[$id] = message_list_row(array(
array('checkbox_callback', $id),
array('icon_callback', $flags),
- array('subject_callback', $subject, $url, $flags, $icon),
+ array('subject_callback', array("subject" => $subject, "preview_msg" => $preview_msg), $url, $flags, $icon),
array('safe_output_callback', 'source', $source),
array('safe_output_callback', 'from'.$nofrom, $from, null, str_replace(array($from, '<', '>'), '', $msg['from'])),
array('date_callback', $date, $timestamp),
@@ -307,7 +312,7 @@ function format_imap_message_list($msg_list, $output_module, $parent_list=false,
array('checkbox_callback', $id),
array('safe_output_callback', 'source', $source, $icon),
array('safe_output_callback', 'from'.$nofrom, $from, null, str_replace(array($from, '<', '>'), '', $msg['from'])),
- array('subject_callback', $subject, $url, $flags),
+ array('subject_callback', array("subject" => $subject, "preview_msg" => $preview_msg), $url, $flags),
array('date_callback', $date, $timestamp, $is_snoozed),
array('icon_callback', $flags)
),
diff --git a/modules/imap/handler_modules.php b/modules/imap/handler_modules.php
index 9008f4e99a..96a48ffd8a 100644
--- a/modules/imap/handler_modules.php
+++ b/modules/imap/handler_modules.php
@@ -852,6 +852,14 @@ public function process() {
$msg['server_id'] = $form['imap_server_id'];
$msg['server_name'] = $details['name'];
$msg['folder'] = $form['folder'];
+ $uid = $msg['uid'];
+ $part = true;
+ $max = 87;
+ $msg_struct = $imap->get_message_structure($uid);
+ $struct = $imap->search_bodystructure($msg_struct, array('imap_part_number' => $part));
+ $msg_struct_current = array_shift($struct);
+ $msg_text = $imap->get_message_content($uid, $part, $max, $msg_struct_current);
+ $msg['preview_msg'] = $msg_text;
$msgs[] = $msg;
}
if ($imap->selected_mailbox) {
@@ -2191,3 +2199,4 @@ function process_move_messages_in_screen_email_enabled_callback($val) { return $
process_site_setting('move_messages_in_screen_email', $this, 'process_move_messages_in_screen_email_enabled_callback', true, true);
}
}
+
diff --git a/modules/imap/site.js b/modules/imap/site.js
index 5017f139dc..0723c1e1a7 100644
--- a/modules/imap/site.js
+++ b/modules/imap/site.js
@@ -1378,7 +1378,7 @@ var add_email_in_contact_trusted = function(list_email) {
}
);
}
- };
+};
$('.screen-email-unlike').on("click", function() { imap_screen_email(); return false; });
diff --git a/tests/phpunit/modules/core/message_list_functions.php b/tests/phpunit/modules/core/message_list_functions.php
index f27acb3ffb..38919e29c4 100644
--- a/tests/phpunit/modules/core/message_list_functions.php
+++ b/tests/phpunit/modules/core/message_list_functions.php
@@ -80,8 +80,8 @@ public function test_checkbox_callback() {
*/
public function test_subject_callback() {
$mod = new Hm_Output_Test(array('foo' => 'bar', 'bar' => 'foo'), array('bar'));
- $this->assertEquals(' | ', subject_callback(array('foo', 'bar', array()), 'email', $mod));
- $this->assertEquals('', subject_callback(array('foo', 'bar', array(), 'code'), 'news', $mod));
+ $this->assertEquals(' | ', subject_callback(array('foo', 'bar', array()), 'email', $mod));
+ $this->assertEquals('', subject_callback(array('foo', 'bar', array(), 'code'), 'news', $mod));
}
/**
* @preserveGlobalState disabled