-
Notifications
You must be signed in to change notification settings - Fork 127
/
AutoDetermine.php
127 lines (109 loc) · 2.55 KB
/
AutoDetermine.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Copyright 2014-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @category Horde
* @copyright 2014-2016 Horde LLC
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
/**
* Auto-determine attachment storage status based on IMP configuration and
* attachment data.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2014-2016 Horde LLC
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
class IMP_Compose_Attachment_Storage_AutoDetermine
extends IMP_Compose_Attachment_Storage
{
/**
* The underlying storage driver.
*
* @var IMP_Compose_Attachment_Storage
*/
protected $_storage;
/**
*/
public function __construct($user, $id = null)
{
global $injector;
parent::__construct($user, $id);
/* Default to linked storage. */
$factory = $injector->getInstance('IMP_Factory_ComposeAtc');
$this->_storage = new $factory->classLinked($this->_user, $this->_id);
}
/**
*/
public function __get($name)
{
switch ($name) {
case 'linked':
return ($this->_storage instanceof IMP_Compose_Attachment_Linked);
}
return parent::__get($name);
}
/**
*/
public function read()
{
return $this->_storage->read();
}
/**
*/
protected function _read()
{
}
/**
*/
public function write($filename, Horde_Mime_Part $part)
{
global $conf, $injector;
if (filesize($filename) < intval($conf['compose']['link_attach_threshold'])) {
$factory = $injector->getInstance('IMP_Factory_ComposeAtc');
$this->_storage = new $factory->classAtc($this->_user, $this->_id);
}
$this->_storage->write($filename, $part);
}
/**
*/
protected function _write($filename, Horde_Mime_Part $part)
{
}
/**
*/
public function delete()
{
$this->_storage->delete();
}
/**
*/
public function exists()
{
return $this->_storage->exists();
}
/**
*/
public function getMetadata()
{
return $this->_storage->getMetadata();
}
/**
*/
public function saveMetadata($md = null)
{
return $this->_storage->saveMetadata($md);
}
/**
*/
public function gc()
{
$this->_storage->gc();
}
}