/** */ public function matchStructure(Horde_Mime_Part $data) { foreach ($data->partIterator() as $val) { if (IMP_Mime_Attachment::isAttachment($val)) { return true; } } return false; }
/** */ public function searchCallback(IMP_Mailbox $mbox, array $ids) { $fetch_query = new Horde_Imap_Client_Fetch_Query(); $fetch_query->structure(); $fetch_res = $mbox->imp_imap->fetch($mbox, $fetch_query, array('ids' => $mbox->imp_imap->getIdsOb($ids))); $out = array(); foreach ($ids as $v) { if (isset($fetch_res[$v])) { $atc = false; foreach ($fetch_res[$v]->getStructure()->partIterator() as $val) { if (IMP_Mime_Attachment::isAttachment($val)) { $atc = true; break; } } if ($this->_data && $atc || !$this->_data && !$atc) { continue; } } $out[] = $v; } return $out; }
/** * Generate inline message display. * * @param array $options Options: * - mask: (integer) The mask needed for a getSummary() call. * - mimeid: (string) Restrict output to this MIME ID (and children). * * @return array See getInlineOutput(). */ protected function _getInlineOutput(array $options) { global $prefs, $registry; $atc_parts = $display_ids = $i = $metadata = $msgtext = $wrap_ids = array(); $text_out = ''; $view = $registry->getView(); $contents_mask = isset($options['mask']) ? $options['mask'] : 0; $mimeid_filter = isset($options['mimeid']) ? new Horde_Mime_Id($options['mimeid']) : null; $show_parts = $prefs->getValue('parts_display'); foreach ($this->contents->getMIMEMessage()->partIterator() as $part) { $mime_id = $part->getMimeId(); $i[] = $mime_id; if (isset($display_ids[$mime_id]) || isset($atc_parts[$mime_id])) { continue; } if ($mimeid_filter && (strval($mimeid_filter) != $mime_id && !$mimeid_filter->isChild($mime_id))) { continue; } if (!($render_mode = $this->contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE_AUTO))) { if (IMP_Mime_Attachment::isAttachment($part)) { if ($show_parts == 'atc') { $atc_parts[$mime_id] = 1; } if ($contents_mask) { $msgtext[$mime_id] = array('text' => $this->_formatSummary($this->contents->getSummary($mime_id, $contents_mask), true)); } } continue; } $render_part = $this->contents->renderMIMEPart($mime_id, $render_mode); if ($show_parts == 'atc' && IMP_Mime_Attachment::isAttachment($part) && (empty($render_part) || !($render_mode & IMP_Contents::RENDER_INLINE))) { $atc_parts[$mime_id] = 1; } if (empty($render_part)) { if ($contents_mask && IMP_Mime_Attachment::isAttachment($part)) { $msgtext[$mime_id] = array('text' => $this->_formatSummary($this->contents->getSummary($mime_id, $contents_mask), true)); } continue; } reset($render_part); while (list($id, $info) = each($render_part)) { $display_ids[$id] = 1; if (empty($info)) { continue; } $part_text = $contents_mask && empty($info['nosummary']) ? $this->_formatSummary($this->contents->getSummary($id, $contents_mask), !empty($info['attach'])) : ''; if (empty($info['attach'])) { if (isset($info['status'])) { if (!is_array($info['status'])) { $info['status'] = array($info['status']); } $render_issues = array(); foreach ($info['status'] as $val) { if (in_array($view, $val->views)) { if ($val instanceof IMP_Mime_Status_RenderIssue) { $render_issues[] = $val; } else { $part_text .= strval($val); } } } if (!empty($render_issues)) { $render_issues_ob = new IMP_Mime_Status_RenderIssue_Display(); $render_issues_ob->addIssues($render_issues); $part_text .= strval($render_issues_ob); } } $part_text .= '<div class="mimePartData">' . $info['data'] . '</div>'; } elseif ($show_parts == 'atc') { $atc_parts[$id] = 1; } $msgtext[$id] = array('text' => $part_text, 'wrap' => empty($info['wrap']) ? null : $info['wrap']); if (isset($info['metadata'])) { /* Format: array(identifier, ...[data]...) */ $metadata = array_merge($metadata, $info['metadata']); } } } if (!empty($msgtext)) { uksort($msgtext, 'strnatcmp'); } reset($msgtext); while (list($id, $part) = each($msgtext)) { while (!empty($wrap_ids)) { $id_ob = new Horde_Mime_Id(end($wrap_ids)); if ($id_ob->isChild($id)) { break; } array_pop($wrap_ids); $text_out .= '</div>'; } if (!empty($part['wrap'])) { $text_out .= '<div class="' . $part['wrap'] . '" impcontentsmimeid="' . $id . '">'; $wrap_ids[] = $id; } $text_out .= '<div class="mimePartBase"' . (empty($part['wrap']) ? ' impcontentsmimeid="' . $id . '"' : '') . '>' . $part['text'] . '</div>'; } $text_out .= str_repeat('</div>', count($wrap_ids)); if (!strlen($text_out)) { $text_out = strval(new IMP_Mime_Status(null, _("There are no parts that can be shown inline."))); } $atc_parts = $show_parts == 'all' ? $i : array_keys($atc_parts); return array('atc_parts' => $atc_parts, 'display_ids' => array_keys($display_ids), 'metadata' => $metadata, 'msgtext' => $text_out, 'one_part' => count($i) === 1); }
/** * Get download all list. * * @return array An array of downloadable parts. */ public function downloadAllList() { $ret = array(); $this->_buildMessage(); foreach ($this->_message->partIterator() as $val) { if (IMP_Mime_Attachment::isAttachment($val)) { $ret[] = $val->getMimeId(); } } return $ret; }