Merge pull request #11304 from JMAConsulting/CRM-21461
[civicrm-core.git] / CRM / Core / DAO / File.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2017
6 *
7 * Generated from xml/schema/CRM/Core/File.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:996b2702471b24fb13c740ef104ea1f9)
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 * Class constructor.
82 */
83 public function __construct() {
84 $this->__table = 'civicrm_file';
85 parent::__construct();
86 }
87
88 /**
89 * Returns all the column names of this table
90 *
91 * @return array
92 */
93 public static function &fields() {
94 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
95 Civi::$statics[__CLASS__]['fields'] = [
96 'id' => [
97 'name' => 'id',
98 'type' => CRM_Utils_Type::T_INT,
99 'title' => ts('File ID'),
100 'description' => 'Unique ID',
101 'required' => TRUE,
102 'table_name' => 'civicrm_file',
103 'entity' => 'File',
104 'bao' => 'CRM_Core_BAO_File',
105 'localizable' => 0,
106 ],
107 'file_type_id' => [
108 'name' => 'file_type_id',
109 'type' => CRM_Utils_Type::T_INT,
110 'title' => ts('File Type'),
111 'description' => 'Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.',
112 'table_name' => 'civicrm_file',
113 'entity' => 'File',
114 'bao' => 'CRM_Core_BAO_File',
115 'localizable' => 0,
116 ],
117 'mime_type' => [
118 'name' => 'mime_type',
119 'type' => CRM_Utils_Type::T_STRING,
120 'title' => ts('Mime Type'),
121 'description' => 'mime type of the document',
122 'maxlength' => 255,
123 'size' => CRM_Utils_Type::HUGE,
124 'table_name' => 'civicrm_file',
125 'entity' => 'File',
126 'bao' => 'CRM_Core_BAO_File',
127 'localizable' => 0,
128 ],
129 'uri' => [
130 'name' => 'uri',
131 'type' => CRM_Utils_Type::T_STRING,
132 'title' => ts('Path'),
133 'description' => 'uri of the file on disk',
134 'maxlength' => 255,
135 'size' => CRM_Utils_Type::HUGE,
136 'table_name' => 'civicrm_file',
137 'entity' => 'File',
138 'bao' => 'CRM_Core_BAO_File',
139 'localizable' => 0,
140 ],
141 'document' => [
142 'name' => 'document',
143 'type' => CRM_Utils_Type::T_MEDIUMBLOB,
144 'title' => ts('File Contents'),
145 'description' => 'contents of the document',
146 'table_name' => 'civicrm_file',
147 'entity' => 'File',
148 'bao' => 'CRM_Core_BAO_File',
149 'localizable' => 0,
150 ],
151 'description' => [
152 'name' => 'description',
153 'type' => CRM_Utils_Type::T_STRING,
154 'title' => ts('File Description'),
155 'description' => 'Additional descriptive text regarding this attachment (optional).',
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 'upload_date' => [
164 'name' => 'upload_date',
165 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
166 'title' => ts('File Upload Date'),
167 'description' => 'Date and time that this attachment was uploaded or written to server.',
168 'table_name' => 'civicrm_file',
169 'entity' => 'File',
170 'bao' => 'CRM_Core_BAO_File',
171 'localizable' => 0,
172 ],
173 ];
174 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
175 }
176 return Civi::$statics[__CLASS__]['fields'];
177 }
178
179 /**
180 * Return a mapping from field-name to the corresponding key (as used in fields()).
181 *
182 * @return array
183 * Array(string $name => string $uniqueName).
184 */
185 public static function &fieldKeys() {
186 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
187 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
188 }
189 return Civi::$statics[__CLASS__]['fieldKeys'];
190 }
191
192 /**
193 * Returns the names of this table
194 *
195 * @return string
196 */
197 public static function getTableName() {
198 return self::$_tableName;
199 }
200
201 /**
202 * Returns if this table needs to be logged
203 *
204 * @return bool
205 */
206 public function getLog() {
207 return self::$_log;
208 }
209
210 /**
211 * Returns the list of fields that can be imported
212 *
213 * @param bool $prefix
214 *
215 * @return array
216 */
217 public static function &import($prefix = FALSE) {
218 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'file', $prefix, []);
219 return $r;
220 }
221
222 /**
223 * Returns the list of fields that can be exported
224 *
225 * @param bool $prefix
226 *
227 * @return array
228 */
229 public static function &export($prefix = FALSE) {
230 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'file', $prefix, []);
231 return $r;
232 }
233
234 /**
235 * Returns the list of indices
236 *
237 * @param bool $localize
238 *
239 * @return array
240 */
241 public static function indices($localize = TRUE) {
242 $indices = [];
243 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
244 }
245
246 }