1<?php
2/**
3 * Copyright 2011-2017 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file COPYING for license information (GPL). If you
6 * did not receive this file, see http://www.horde.org/licenses/gpl.
7 *
8 * @category  Horde
9 * @copyright 2011-2017 Horde LLC
10 * @license   http://www.horde.org/licenses/gpl GPL
11 * @package   IMP
12 */
13
14/**
15 * Renderer for message/external-body (RFC 2046 [5.2.3]) data.
16 *
17 * @author    Michael Slusarz <slusarz@horde.org>
18 * @category  Horde
19 * @copyright 2011-2017 Horde LLC
20 * @license   http://www.horde.org/licenses/gpl GPL
21 * @package   IMP
22 */
23class IMP_Mime_Viewer_Externalbody extends Horde_Mime_Viewer_Base
24{
25    /**
26     */
27    protected $_metadata = array(
28        'compressed' => false,
29        'embedded' => true,
30        'forceinline' => true
31    );
32
33    /**
34     */
35    protected function _getEmbeddedMimeParts()
36    {
37        switch ($this->_mimepart->getContentTypeParameter('access-type')) {
38        case 'anon-ftp':
39        case 'ftp':
40        case 'local-file':
41        case 'mail-server':
42        case 'tftp':
43            // RFC 2046 [5.2.3.1]: Unsupported.
44            break;
45
46        case 'content-id':
47            // RFC 1873
48            $imp_contents = $this->getConfigParam('imp_contents');
49            $base_part = $imp_contents->getMIMEMessage();
50            $cid = $this->_mimepart->getContentId();
51
52            foreach (array_keys($base_part->contentTypeMap(true)) as $key) {
53                if (($part = $base_part->getPart($key)) &&
54                    ($part->getContentId() == $cid) &&
55                    ($part->getType() != 'message/external-body')) {
56                    $full_part = clone $imp_contents->getMIMEPart($key);
57                    $full_part->setMimeId($this->_mimepart->getMimeId());
58                    // TODO: Add headers from referring body part.
59                    return $full_part;
60                }
61            }
62            break;
63        }
64
65        return null;
66    }
67
68}
69