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