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 | |
7b66c3b5 | 9 | * (GenCodeChecksum:dd8a70727f67481339dd514fdca6aae5) |
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, |
a9d0587b | 141 | 'add' => '1.5', |
c3fc2621 CW |
142 | ], |
143 | 'file_type_id' => [ | |
e501603b TO |
144 | 'name' => 'file_type_id', |
145 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 146 | 'title' => ts('File Type'), |
215b423e | 147 | 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'), |
a36434b9 | 148 | 'where' => 'civicrm_file.file_type_id', |
522a26c9 | 149 | 'table_name' => 'civicrm_file', |
150 | 'entity' => 'File', | |
151 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 152 | 'localizable' => 0, |
a9d0587b | 153 | 'add' => '1.5', |
c3fc2621 CW |
154 | ], |
155 | 'mime_type' => [ | |
e501603b TO |
156 | 'name' => 'mime_type', |
157 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 158 | 'title' => ts('Mime Type'), |
215b423e | 159 | 'description' => ts('mime type of the document'), |
e501603b TO |
160 | 'maxlength' => 255, |
161 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 162 | 'where' => 'civicrm_file.mime_type', |
522a26c9 | 163 | 'table_name' => 'civicrm_file', |
164 | 'entity' => 'File', | |
165 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 166 | 'localizable' => 0, |
a9d0587b | 167 | 'add' => '1.5', |
c3fc2621 CW |
168 | ], |
169 | 'uri' => [ | |
e501603b TO |
170 | 'name' => 'uri', |
171 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 172 | 'title' => ts('Path'), |
215b423e | 173 | 'description' => ts('uri of the file on disk'), |
e501603b TO |
174 | 'maxlength' => 255, |
175 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 176 | 'where' => 'civicrm_file.uri', |
522a26c9 | 177 | 'table_name' => 'civicrm_file', |
178 | 'entity' => 'File', | |
179 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 180 | 'localizable' => 0, |
a9d0587b | 181 | 'add' => '1.5', |
c3fc2621 CW |
182 | ], |
183 | 'document' => [ | |
e501603b TO |
184 | 'name' => 'document', |
185 | 'type' => CRM_Utils_Type::T_MEDIUMBLOB, | |
c3fc2621 | 186 | 'title' => ts('File Contents'), |
215b423e | 187 | 'description' => ts('contents of the document'), |
a36434b9 | 188 | 'where' => 'civicrm_file.document', |
522a26c9 | 189 | 'table_name' => 'civicrm_file', |
190 | 'entity' => 'File', | |
191 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 192 | 'localizable' => 0, |
a9d0587b | 193 | 'add' => '1.5', |
c3fc2621 CW |
194 | ], |
195 | 'description' => [ | |
e501603b TO |
196 | 'name' => 'description', |
197 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 198 | 'title' => ts('File Description'), |
215b423e | 199 | 'description' => ts('Additional descriptive text regarding this attachment (optional).'), |
e501603b TO |
200 | 'maxlength' => 255, |
201 | 'size' => CRM_Utils_Type::HUGE, | |
a36434b9 | 202 | 'where' => 'civicrm_file.description', |
522a26c9 | 203 | 'table_name' => 'civicrm_file', |
204 | 'entity' => 'File', | |
205 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 206 | 'localizable' => 0, |
a9d0587b | 207 | 'add' => '1.5', |
c3fc2621 CW |
208 | ], |
209 | 'upload_date' => [ | |
e501603b TO |
210 | 'name' => 'upload_date', |
211 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
c3fc2621 | 212 | 'title' => ts('File Upload Date'), |
215b423e | 213 | 'description' => ts('Date and time that this attachment was uploaded or written to server.'), |
a36434b9 | 214 | 'where' => 'civicrm_file.upload_date', |
522a26c9 | 215 | 'table_name' => 'civicrm_file', |
216 | 'entity' => 'File', | |
217 | 'bao' => 'CRM_Core_BAO_File', | |
6a7e5e5d | 218 | 'localizable' => 0, |
a9d0587b | 219 | 'add' => '1.5', |
c3fc2621 | 220 | ], |
c3438d19 DA |
221 | 'created_id' => [ |
222 | 'name' => 'created_id', | |
223 | 'type' => CRM_Utils_Type::T_INT, | |
ae2c7e00 | 224 | 'title' => ts('Created By Contact ID'), |
215b423e | 225 | 'description' => ts('FK to civicrm_contact, who uploaded this file'), |
a36434b9 | 226 | 'where' => 'civicrm_file.created_id', |
c3438d19 DA |
227 | 'table_name' => 'civicrm_file', |
228 | 'entity' => 'File', | |
229 | 'bao' => 'CRM_Core_BAO_File', | |
ae2c7e00 | 230 | 'localizable' => 0, |
c3438d19 | 231 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
a9d0587b | 232 | 'add' => '5.3', |
c3438d19 | 233 | ], |
c3fc2621 | 234 | ]; |
346aaaba | 235 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 236 | } |
346aaaba | 237 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 238 | } |
c3fc2621 | 239 | |
e501603b | 240 | /** |
bd8e0b14 | 241 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
242 | * |
243 | * @return array | |
bd8e0b14 | 244 | * Array(string $name => string $uniqueName). |
e501603b | 245 | */ |
c3fc2621 | 246 | public static function &fieldKeys() { |
bd8e0b14 TO |
247 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
248 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 249 | } |
bd8e0b14 | 250 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 251 | } |
c3fc2621 | 252 | |
e501603b TO |
253 | /** |
254 | * Returns the names of this table | |
255 | * | |
256 | * @return string | |
257 | */ | |
c3fc2621 | 258 | public static function getTableName() { |
e501603b TO |
259 | return self::$_tableName; |
260 | } | |
c3fc2621 | 261 | |
e501603b TO |
262 | /** |
263 | * Returns if this table needs to be logged | |
264 | * | |
c3fc2621 | 265 | * @return bool |
e501603b | 266 | */ |
c3fc2621 | 267 | public function getLog() { |
e501603b TO |
268 | return self::$_log; |
269 | } | |
c3fc2621 | 270 | |
e501603b TO |
271 | /** |
272 | * Returns the list of fields that can be imported | |
273 | * | |
274 | * @param bool $prefix | |
275 | * | |
276 | * @return array | |
277 | */ | |
c3fc2621 CW |
278 | public static function &import($prefix = FALSE) { |
279 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'file', $prefix, []); | |
60808919 | 280 | return $r; |
e501603b | 281 | } |
c3fc2621 | 282 | |
e501603b TO |
283 | /** |
284 | * Returns the list of fields that can be exported | |
285 | * | |
286 | * @param bool $prefix | |
287 | * | |
288 | * @return array | |
289 | */ | |
c3fc2621 CW |
290 | public static function &export($prefix = FALSE) { |
291 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'file', $prefix, []); | |
60808919 | 292 | return $r; |
e501603b | 293 | } |
c3fc2621 | 294 | |
e7a6b91a AS |
295 | /** |
296 | * Returns the list of indices | |
c3fc2621 CW |
297 | * |
298 | * @param bool $localize | |
299 | * | |
300 | * @return array | |
e7a6b91a AS |
301 | */ |
302 | public static function indices($localize = TRUE) { | |
c3fc2621 | 303 | $indices = []; |
e7a6b91a AS |
304 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
305 | } | |
c3fc2621 | 306 | |
e501603b | 307 | } |