/** * Fetch the content, message parts, and headers for the supplied message */ public function process() { list($success, $form) = $this->process_form(array('imap_server_id', 'imap_msg_uid', 'folder')); if ($success) { $this->out('msg_text_uid', $form['imap_msg_uid']); $this->out('msg_server_id', $form['imap_server_id']); $this->out('msg_folder', $form['folder']); $part = false; $prefetch = false; if (isset($this->request->post['imap_msg_part']) && preg_match("/[0-9\\.]+/", $this->request->post['imap_msg_part'])) { $part = $this->request->post['imap_msg_part']; } elseif (isset($this->request->post['imap_prefetch']) && $this->request->post['imap_prefetch']) { $prefetch = true; } $cache = Hm_IMAP_List::get_cache($this->session, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); if ($imap) { $imap->read_only = $prefetch; if ($imap->select_mailbox($form['folder'])) { $msg_struct = $imap->get_message_structure($form['imap_msg_uid']); $this->out('msg_struct', $msg_struct); if ($part !== false) { if ($part == 0) { $max = 500000; } else { $max = false; } $struct = $imap->search_bodystructure($msg_struct, array('imap_part_number' => $part)); $msg_struct_current = array_shift($struct); $msg_text = $imap->get_message_content($form['imap_msg_uid'], $part, $max, $msg_struct_current); if (isset($msg_struct_current['subtype']) && strtolower($msg_struct_current['subtype'] == 'html')) { $msg_text = add_attached_images($msg_text, $form['imap_msg_uid'], $msg_struct, $imap); } } else { list($part, $msg_text) = $imap->get_first_message_part($form['imap_msg_uid'], 'text', false, $msg_struct); $struct = $imap->search_bodystructure($msg_struct, array('imap_part_number' => $part)); $msg_struct_current = array_shift($struct); } $msg_headers = $imap->get_message_headers($form['imap_msg_uid']); $this->out('msg_headers', $msg_headers); $this->out('imap_msg_part', "{$part}"); if ($msg_struct_current) { $this->out('msg_struct_current', $msg_struct_current); } $this->out('msg_text', $msg_text); $this->out('msg_download_args', sprintf("page=message&uid=%d&list_path=imap_%d_%s&imap_download_message=1", $form['imap_msg_uid'], $form['imap_server_id'], $form['folder'])); if (!$prefetch) { $this->session->set('reply_details', array('msg_struct' => $msg_struct_current, 'msg_text' => $msg_text, 'msg_headers' => $msg_headers)); } } } } }