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