Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
8c9251b3 | 5 | * @copyright CiviCRM LLC (c) 2004-2018 |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Core/File.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
ae2c7e00 | 9 | * (GenCodeChecksum:7fd8d2643aa05e33a38983f719c09111) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the File entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Core_DAO_File extends CRM_Core_DAO { |
c3fc2621 | 16 | |
e501603b | 17 | /** |
f41f0342 | 18 | * Static instance to hold the table name. |
e501603b TO |
19 | * |
20 | * @var string | |
21 | */ | |
22 | static $_tableName = 'civicrm_file'; | |
c3fc2621 | 23 | |
e501603b | 24 | /** |
f41f0342 | 25 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b | 26 | * |
c3fc2621 | 27 | * @var bool |
e501603b | 28 | */ |
c3fc2621 CW |
29 | static $_log = TRUE; |
30 | ||
e501603b TO |
31 | /** |
32 | * Unique ID | |
33 | * | |
34 | * @var int unsigned | |
35 | */ | |
36 | public $id; | |
c3fc2621 | 37 | |
e501603b TO |
38 | /** |
39 | * Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value. | |
40 | * | |
41 | * @var int unsigned | |
42 | */ | |
43 | public $file_type_id; | |
c3fc2621 | 44 | |
e501603b TO |
45 | /** |
46 | * mime type of the document | |
47 | * | |
48 | * @var string | |
49 | */ | |
50 | public $mime_type; | |
c3fc2621 | 51 | |
e501603b TO |
52 | /** |
53 | * uri of the file on disk | |
54 | * | |
55 | * @var string | |
56 | */ | |
57 | public $uri; | |
c3fc2621 | 58 | |
e501603b TO |
59 | /** |
60 | * contents of the document | |
61 | * | |
62 | * @var mediumblob | |
63 | */ | |
64 | public $document; | |
c3fc2621 | 65 | |
e501603b TO |
66 | /** |
67 | * Additional descriptive text regarding this attachment (optional). | |
68 | * | |
69 | * @var string | |
70 | */ | |
71 | public $description; | |
c3fc2621 | 72 | |
e501603b TO |
73 | /** |
74 | * Date and time that this attachment was uploaded or written to server. | |
75 | * | |
76 | * @var datetime | |
77 | */ | |
78 | public $upload_date; | |
c3fc2621 | 79 | |
c3438d19 DA |
80 | /** |
81 | * FK to civicrm_contact, who uploaded this file | |
82 | * | |
83 | * @var int unsigned | |
84 | */ | |
85 | public $created_id; | |
ae2c7e00 | 86 | |
e501603b | 87 | /** |
f41f0342 | 88 | * Class constructor. |
e501603b | 89 | */ |
c3fc2621 | 90 | public function __construct() { |
e501603b TO |
91 | $this->__table = 'civicrm_file'; |
92 | parent::__construct(); | |
93 | } | |
c3fc2621 | 94 | |
c3438d19 DA |
95 | /** |
96 | * Returns foreign keys and entity references. | |
97 | * | |
98 | * @return array | |
99 | * [CRM_Core_Reference_Interface] | |
100 | */ | |
ae2c7e00 | 101 | public static function getReferenceColumns() { |
c3438d19 DA |
102 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
103 | Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); | |
ae2c7e00 | 104 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); |
c3438d19 DA |
105 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
106 | } | |
107 | return Civi::$statics[__CLASS__]['links']; | |
108 | } | |
ae2c7e00 | 109 | |
e501603b TO |
110 | /** |
111 | * Returns all the column names of this table | |
112 | * | |
113 | * @return array | |
114 | */ | |
c3fc2621 | 115 | public static function &fields() { |
346aaaba | 116 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
117 | Civi::$statics[__CLASS__]['fields'] = [ |
118 | 'id' => [ | |
e501603b TO |
119 | 'name' => 'id', |
120 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 121 | 'title' => ts('File ID'), |
215b423e | 122 | 'description' => ts('Unique ID'), |
c3fc2621 | 123 | 'required' => TRUE, |
522a26c9 | 124 | 'table_name' => 'civicrm_file', |
125 | 'entity' => 'File', | |
126 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 127 | 'localizable' => 0, |
c3fc2621 CW |
128 | ], |
129 | 'file_type_id' => [ | |
e501603b TO |
130 | 'name' => 'file_type_id', |
131 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 132 | 'title' => ts('File Type'), |
215b423e | 133 | 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'), |
522a26c9 | 134 | 'table_name' => 'civicrm_file', |
135 | 'entity' => 'File', | |
136 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 137 | 'localizable' => 0, |
c3fc2621 CW |
138 | ], |
139 | 'mime_type' => [ | |
e501603b TO |
140 | 'name' => 'mime_type', |
141 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 142 | 'title' => ts('Mime Type'), |
215b423e | 143 | 'description' => ts('mime type of the document'), |
e501603b TO |
144 | 'maxlength' => 255, |
145 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 146 | 'table_name' => 'civicrm_file', |
147 | 'entity' => 'File', | |
148 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 149 | 'localizable' => 0, |
c3fc2621 CW |
150 | ], |
151 | 'uri' => [ | |
e501603b TO |
152 | 'name' => 'uri', |
153 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 154 | 'title' => ts('Path'), |
215b423e | 155 | 'description' => ts('uri of the file on disk'), |
e501603b TO |
156 | 'maxlength' => 255, |
157 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 158 | 'table_name' => 'civicrm_file', |
159 | 'entity' => 'File', | |
160 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 161 | 'localizable' => 0, |
c3fc2621 CW |
162 | ], |
163 | 'document' => [ | |
e501603b TO |
164 | 'name' => 'document', |
165 | 'type' => CRM_Utils_Type::T_MEDIUMBLOB, | |
c3fc2621 | 166 | 'title' => ts('File Contents'), |
215b423e | 167 | 'description' => ts('contents of the document'), |
522a26c9 | 168 | 'table_name' => 'civicrm_file', |
169 | 'entity' => 'File', | |
170 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 171 | 'localizable' => 0, |
c3fc2621 CW |
172 | ], |
173 | 'description' => [ | |
e501603b TO |
174 | 'name' => 'description', |
175 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 176 | 'title' => ts('File Description'), |
215b423e | 177 | 'description' => ts('Additional descriptive text regarding this attachment (optional).'), |
e501603b TO |
178 | 'maxlength' => 255, |
179 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 180 | 'table_name' => 'civicrm_file', |
181 | 'entity' => 'File', | |
182 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 183 | 'localizable' => 0, |
c3fc2621 CW |
184 | ], |
185 | 'upload_date' => [ | |
e501603b TO |
186 | 'name' => 'upload_date', |
187 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
c3fc2621 | 188 | 'title' => ts('File Upload Date'), |
215b423e | 189 | 'description' => ts('Date and time that this attachment was uploaded or written to server.'), |
522a26c9 | 190 | 'table_name' => 'civicrm_file', |
191 | 'entity' => 'File', | |
192 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 193 | 'localizable' => 0, |
c3fc2621 | 194 | ], |
c3438d19 DA |
195 | 'created_id' => [ |
196 | 'name' => 'created_id', | |
197 | 'type' => CRM_Utils_Type::T_INT, | |
ae2c7e00 | 198 | 'title' => ts('Created By Contact ID'), |
215b423e | 199 | 'description' => ts('FK to civicrm_contact, who uploaded this file'), |
c3438d19 DA |
200 | 'table_name' => 'civicrm_file', |
201 | 'entity' => 'File', | |
202 | 'bao' => 'CRM_Core_BAO_File', | |
ae2c7e00 | 203 | 'localizable' => 0, |
c3438d19 DA |
204 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
205 | ], | |
c3fc2621 | 206 | ]; |
346aaaba | 207 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 208 | } |
346aaaba | 209 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 210 | } |
c3fc2621 | 211 | |
e501603b | 212 | /** |
bd8e0b14 | 213 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
214 | * |
215 | * @return array | |
bd8e0b14 | 216 | * Array(string $name => string $uniqueName). |
e501603b | 217 | */ |
c3fc2621 | 218 | public static function &fieldKeys() { |
bd8e0b14 TO |
219 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
220 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 221 | } |
bd8e0b14 | 222 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 223 | } |
c3fc2621 | 224 | |
e501603b TO |
225 | /** |
226 | * Returns the names of this table | |
227 | * | |
228 | * @return string | |
229 | */ | |
c3fc2621 | 230 | public static function getTableName() { |
e501603b TO |
231 | return self::$_tableName; |
232 | } | |
c3fc2621 | 233 | |
e501603b TO |
234 | /** |
235 | * Returns if this table needs to be logged | |
236 | * | |
c3fc2621 | 237 | * @return bool |
e501603b | 238 | */ |
c3fc2621 | 239 | public function getLog() { |
e501603b TO |
240 | return self::$_log; |
241 | } | |
c3fc2621 | 242 | |
e501603b TO |
243 | /** |
244 | * Returns the list of fields that can be imported | |
245 | * | |
246 | * @param bool $prefix | |
247 | * | |
248 | * @return array | |
249 | */ | |
c3fc2621 CW |
250 | public static function &import($prefix = FALSE) { |
251 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'file', $prefix, []); | |
60808919 | 252 | return $r; |
e501603b | 253 | } |
c3fc2621 | 254 | |
e501603b TO |
255 | /** |
256 | * Returns the list of fields that can be exported | |
257 | * | |
258 | * @param bool $prefix | |
259 | * | |
260 | * @return array | |
261 | */ | |
c3fc2621 CW |
262 | public static function &export($prefix = FALSE) { |
263 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'file', $prefix, []); | |
60808919 | 264 | return $r; |
e501603b | 265 | } |
c3fc2621 | 266 | |
e7a6b91a AS |
267 | /** |
268 | * Returns the list of indices | |
c3fc2621 CW |
269 | * |
270 | * @param bool $localize | |
271 | * | |
272 | * @return array | |
e7a6b91a AS |
273 | */ |
274 | public static function indices($localize = TRUE) { | |
c3fc2621 | 275 | $indices = []; |
e7a6b91a AS |
276 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
277 | } | |
c3fc2621 | 278 | |
e501603b | 279 | } |