Merge pull request #13314 from colemanw/dev/core#337
[civicrm-core.git] / CRM / Core / DAO / File.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/File.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:994c11201c8b27ec0913d1ce505ef864)
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 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 static $_log = TRUE;
30
31 /**
32 * Unique ID
33 *
34 * @var int unsigned
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 unsigned
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 unsigned
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 foreign keys and entity references.
97 *
98 * @return array
99 * [CRM_Core_Reference_Interface]
100 */
101 public static function getReferenceColumns() {
102 if (!isset(Civi::$statics[__CLASS__]['links'])) {
103 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
104 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
105 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
106 }
107 return Civi::$statics[__CLASS__]['links'];
108 }
109
110 /**
111 * Returns all the column names of this table
112 *
113 * @return array
114 */
115 public static function &fields() {
116 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
117 Civi::$statics[__CLASS__]['fields'] = [
118 'id' => [
119 'name' => 'id',
120 'type' => CRM_Utils_Type::T_INT,
121 'title' => ts('File ID'),
122 'description' => ts('Unique ID'),
123 'required' => TRUE,
124 'table_name' => 'civicrm_file',
125 'entity' => 'File',
126 'bao' => 'CRM_Core_BAO_File',
127 'localizable' => 0,
128 ],
129 'file_type_id' => [
130 'name' => 'file_type_id',
131 'type' => CRM_Utils_Type::T_INT,
132 'title' => ts('File Type'),
133 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'),
134 'table_name' => 'civicrm_file',
135 'entity' => 'File',
136 'bao' => 'CRM_Core_BAO_File',
137 'localizable' => 0,
138 ],
139 'mime_type' => [
140 'name' => 'mime_type',
141 'type' => CRM_Utils_Type::T_STRING,
142 'title' => ts('Mime Type'),
143 'description' => ts('mime type of the document'),
144 'maxlength' => 255,
145 'size' => CRM_Utils_Type::HUGE,
146 'table_name' => 'civicrm_file',
147 'entity' => 'File',
148 'bao' => 'CRM_Core_BAO_File',
149 'localizable' => 0,
150 ],
151 'uri' => [
152 'name' => 'uri',
153 'type' => CRM_Utils_Type::T_STRING,
154 'title' => ts('Path'),
155 'description' => ts('uri of the file on disk'),
156 'maxlength' => 255,
157 'size' => CRM_Utils_Type::HUGE,
158 'table_name' => 'civicrm_file',
159 'entity' => 'File',
160 'bao' => 'CRM_Core_BAO_File',
161 'localizable' => 0,
162 ],
163 'document' => [
164 'name' => 'document',
165 'type' => CRM_Utils_Type::T_MEDIUMBLOB,
166 'title' => ts('File Contents'),
167 'description' => ts('contents of the document'),
168 'table_name' => 'civicrm_file',
169 'entity' => 'File',
170 'bao' => 'CRM_Core_BAO_File',
171 'localizable' => 0,
172 ],
173 'description' => [
174 'name' => 'description',
175 'type' => CRM_Utils_Type::T_STRING,
176 'title' => ts('File Description'),
177 'description' => ts('Additional descriptive text regarding this attachment (optional).'),
178 'maxlength' => 255,
179 'size' => CRM_Utils_Type::HUGE,
180 'table_name' => 'civicrm_file',
181 'entity' => 'File',
182 'bao' => 'CRM_Core_BAO_File',
183 'localizable' => 0,
184 ],
185 'upload_date' => [
186 'name' => 'upload_date',
187 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
188 'title' => ts('File Upload Date'),
189 'description' => ts('Date and time that this attachment was uploaded or written to server.'),
190 'table_name' => 'civicrm_file',
191 'entity' => 'File',
192 'bao' => 'CRM_Core_BAO_File',
193 'localizable' => 0,
194 ],
195 'created_id' => [
196 'name' => 'created_id',
197 'type' => CRM_Utils_Type::T_INT,
198 'title' => ts('Created By Contact ID'),
199 'description' => ts('FK to civicrm_contact, who uploaded this file'),
200 'table_name' => 'civicrm_file',
201 'entity' => 'File',
202 'bao' => 'CRM_Core_BAO_File',
203 'localizable' => 0,
204 'FKClassName' => 'CRM_Contact_DAO_Contact',
205 ],
206 ];
207 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
208 }
209 return Civi::$statics[__CLASS__]['fields'];
210 }
211
212 /**
213 * Return a mapping from field-name to the corresponding key (as used in fields()).
214 *
215 * @return array
216 * Array(string $name => string $uniqueName).
217 */
218 public static function &fieldKeys() {
219 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
220 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
221 }
222 return Civi::$statics[__CLASS__]['fieldKeys'];
223 }
224
225 /**
226 * Returns the names of this table
227 *
228 * @return string
229 */
230 public static function getTableName() {
231 return self::$_tableName;
232 }
233
234 /**
235 * Returns if this table needs to be logged
236 *
237 * @return bool
238 */
239 public function getLog() {
240 return self::$_log;
241 }
242
243 /**
244 * Returns the list of fields that can be imported
245 *
246 * @param bool $prefix
247 *
248 * @return array
249 */
250 public static function &import($prefix = FALSE) {
251 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'file', $prefix, []);
252 return $r;
253 }
254
255 /**
256 * Returns the list of fields that can be exported
257 *
258 * @param bool $prefix
259 *
260 * @return array
261 */
262 public static function &export($prefix = FALSE) {
263 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'file', $prefix, []);
264 return $r;
265 }
266
267 /**
268 * Returns the list of indices
269 *
270 * @param bool $localize
271 *
272 * @return array
273 */
274 public static function indices($localize = TRUE) {
275 $indices = [];
276 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
277 }
278
279 }