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