1: <?php
2: /**
3: * This class is designed to provide a place to store common code shared among
4: * various MIME Viewers relating to image viewing preferences.
5: *
6: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/gpl GPL
14: * @package IMP
15: */
16: class IMP_Ui_Imageview
17: {
18: /**
19: * Show inline images in messages?
20: *
21: * @param IMP_Contents $contents The contents object containing the
22: * message.
23: *
24: * @return boolean True if inline image should be shown.
25: */
26: public function showInlineImage($contents)
27: {
28: global $injector, $prefs, $registry;
29:
30: if (!$prefs->getValue('image_replacement')) {
31: return true;
32: }
33:
34: if (!$contents) {
35: return false;
36: }
37:
38: $from = Horde_Mime_Address::bareAddress($contents->getHeader()->getValue('from'));
39: if ($prefs->getValue('image_addrbook') &&
40: $registry->hasMethod('contacts/getField')) {
41: $params = IMP::getAddressbookSearchParams();
42: try {
43: if ($registry->call('contacts/getField', array($from, '__key', $params['sources'], true, true))) {
44: return true;
45: }
46: } catch (Horde_Exception $e) {}
47: }
48:
49: /* Check admin defined e-mail list. */
50: list(, $config) = $injector->getInstance('Horde_Core_Factory_MimeViewer')->getViewerConfig('image/*', 'imp');
51: return (!empty($config['safe_addrs']) && in_array($from, $config['safe_addrs']));
52: }
53:
54: }
55: