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