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