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