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