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