Merge pull request #21993 from mattwire/aclcachequery2
[civicrm-core.git] / CRM / Core / DAO / Note.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Note.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5f542bdf0c411eeefbf3ec22514d7407)
10 */
11
12 /**
13 * Database access object for the Note entity.
14 */
15 class CRM_Core_DAO_Note extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_note';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-sticky-note';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = TRUE;
39
40 /**
41 * Note ID
42 *
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
46 */
47 public $id;
48
49 /**
50 * Name of table where item being referenced is stored.
51 *
52 * @var string
53 * (SQL type: varchar(64))
54 * Note that values will be retrieved from the database as a string.
55 */
56 public $entity_table;
57
58 /**
59 * Foreign key to the referenced item.
60 *
61 * @var int|string
62 * (SQL type: int unsigned)
63 * Note that values will be retrieved from the database as a string.
64 */
65 public $entity_id;
66
67 /**
68 * Note and/or Comment.
69 *
70 * @var string|null
71 * (SQL type: text)
72 * Note that values will be retrieved from the database as a string.
73 */
74 public $note;
75
76 /**
77 * FK to Contact ID creator
78 *
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
82 */
83 public $contact_id;
84
85 /**
86 * Date attached to the note
87 *
88 * @var string|null
89 * (SQL type: timestamp)
90 * Note that values will be retrieved from the database as a string.
91 */
92 public $note_date;
93
94 /**
95 * When the note was created.
96 *
97 * @var string
98 * (SQL type: timestamp)
99 * Note that values will be retrieved from the database as a string.
100 */
101 public $created_date;
102
103 /**
104 * When was this note last modified/edited
105 *
106 * @var string|null
107 * (SQL type: timestamp)
108 * Note that values will be retrieved from the database as a string.
109 */
110 public $modified_date;
111
112 /**
113 * subject of note description
114 *
115 * @var string|null
116 * (SQL type: varchar(255))
117 * Note that values will be retrieved from the database as a string.
118 */
119 public $subject;
120
121 /**
122 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
123 *
124 * @var string|null
125 * (SQL type: varchar(255))
126 * Note that values will be retrieved from the database as a string.
127 */
128 public $privacy;
129
130 /**
131 * Class constructor.
132 */
133 public function __construct() {
134 $this->__table = 'civicrm_note';
135 parent::__construct();
136 }
137
138 /**
139 * Returns localized title of this entity.
140 *
141 * @param bool $plural
142 * Whether to return the plural version of the title.
143 */
144 public static function getEntityTitle($plural = FALSE) {
145 return $plural ? ts('Notes') : ts('Note');
146 }
147
148 /**
149 * Returns foreign keys and entity references.
150 *
151 * @return array
152 * [CRM_Core_Reference_Interface]
153 */
154 public static function getReferenceColumns() {
155 if (!isset(Civi::$statics[__CLASS__]['links'])) {
156 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
157 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
158 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
159 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
160 }
161 return Civi::$statics[__CLASS__]['links'];
162 }
163
164 /**
165 * Returns all the column names of this table
166 *
167 * @return array
168 */
169 public static function &fields() {
170 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
171 Civi::$statics[__CLASS__]['fields'] = [
172 'id' => [
173 'name' => 'id',
174 'type' => CRM_Utils_Type::T_INT,
175 'title' => ts('Note ID'),
176 'description' => ts('Note ID'),
177 'required' => TRUE,
178 'where' => 'civicrm_note.id',
179 'table_name' => 'civicrm_note',
180 'entity' => 'Note',
181 'bao' => 'CRM_Core_BAO_Note',
182 'localizable' => 0,
183 'html' => [
184 'type' => 'Number',
185 ],
186 'readonly' => TRUE,
187 'add' => '1.1',
188 ],
189 'entity_table' => [
190 'name' => 'entity_table',
191 'type' => CRM_Utils_Type::T_STRING,
192 'title' => ts('Note Entity'),
193 'description' => ts('Name of table where item being referenced is stored.'),
194 'required' => TRUE,
195 'maxlength' => 64,
196 'size' => CRM_Utils_Type::BIG,
197 'where' => 'civicrm_note.entity_table',
198 'table_name' => 'civicrm_note',
199 'entity' => 'Note',
200 'bao' => 'CRM_Core_BAO_Note',
201 'localizable' => 0,
202 'pseudoconstant' => [
203 'optionGroupName' => 'note_used_for',
204 'optionEditPath' => 'civicrm/admin/options/note_used_for',
205 ],
206 'add' => '1.1',
207 ],
208 'entity_id' => [
209 'name' => 'entity_id',
210 'type' => CRM_Utils_Type::T_INT,
211 'title' => ts('Note Entity ID'),
212 'description' => ts('Foreign key to the referenced item.'),
213 'required' => TRUE,
214 'where' => 'civicrm_note.entity_id',
215 'table_name' => 'civicrm_note',
216 'entity' => 'Note',
217 'bao' => 'CRM_Core_BAO_Note',
218 'localizable' => 0,
219 'add' => '1.1',
220 ],
221 'note' => [
222 'name' => 'note',
223 'type' => CRM_Utils_Type::T_TEXT,
224 'title' => ts('Note'),
225 'description' => ts('Note and/or Comment.'),
226 'rows' => 4,
227 'cols' => 60,
228 'import' => TRUE,
229 'where' => 'civicrm_note.note',
230 'headerPattern' => '/Note|Comment/i',
231 'dataPattern' => '//',
232 'export' => TRUE,
233 'table_name' => 'civicrm_note',
234 'entity' => 'Note',
235 'bao' => 'CRM_Core_BAO_Note',
236 'localizable' => 0,
237 'html' => [
238 'type' => 'TextArea',
239 ],
240 'add' => '1.1',
241 ],
242 'contact_id' => [
243 'name' => 'contact_id',
244 'type' => CRM_Utils_Type::T_INT,
245 'title' => ts('Created By Contact ID'),
246 'description' => ts('FK to Contact ID creator'),
247 'where' => 'civicrm_note.contact_id',
248 'table_name' => 'civicrm_note',
249 'entity' => 'Note',
250 'bao' => 'CRM_Core_BAO_Note',
251 'localizable' => 0,
252 'FKClassName' => 'CRM_Contact_DAO_Contact',
253 'html' => [
254 'label' => ts("Created By"),
255 ],
256 'add' => '1.1',
257 ],
258 'note_date' => [
259 'name' => 'note_date',
260 'type' => CRM_Utils_Type::T_TIMESTAMP,
261 'title' => ts('Note Date'),
262 'description' => ts('Date attached to the note'),
263 'where' => 'civicrm_note.note_date',
264 'default' => 'CURRENT_TIMESTAMP',
265 'table_name' => 'civicrm_note',
266 'entity' => 'Note',
267 'bao' => 'CRM_Core_BAO_Note',
268 'localizable' => 0,
269 'html' => [
270 'type' => 'Select Date',
271 'formatType' => 'activityDateTime',
272 ],
273 'add' => '5.36',
274 ],
275 'created_date' => [
276 'name' => 'created_date',
277 'type' => CRM_Utils_Type::T_TIMESTAMP,
278 'title' => ts('Created Date'),
279 'description' => ts('When the note was created.'),
280 'required' => TRUE,
281 'where' => 'civicrm_note.created_date',
282 'default' => 'CURRENT_TIMESTAMP',
283 'table_name' => 'civicrm_note',
284 'entity' => 'Note',
285 'bao' => 'CRM_Core_BAO_Note',
286 'localizable' => 0,
287 'add' => '5.36',
288 ],
289 'modified_date' => [
290 'name' => 'modified_date',
291 'type' => CRM_Utils_Type::T_TIMESTAMP,
292 'title' => ts('Note Modified By'),
293 'description' => ts('When was this note last modified/edited'),
294 'where' => 'civicrm_note.modified_date',
295 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
296 'table_name' => 'civicrm_note',
297 'entity' => 'Note',
298 'bao' => 'CRM_Core_BAO_Note',
299 'localizable' => 0,
300 'readonly' => TRUE,
301 'add' => '1.1',
302 ],
303 'subject' => [
304 'name' => 'subject',
305 'type' => CRM_Utils_Type::T_STRING,
306 'title' => ts('Subject'),
307 'description' => ts('subject of note description'),
308 'maxlength' => 255,
309 'size' => 60,
310 'where' => 'civicrm_note.subject',
311 'table_name' => 'civicrm_note',
312 'entity' => 'Note',
313 'bao' => 'CRM_Core_BAO_Note',
314 'localizable' => 0,
315 'html' => [
316 'type' => 'Text',
317 ],
318 'add' => '1.5',
319 ],
320 'privacy' => [
321 'name' => 'privacy',
322 'type' => CRM_Utils_Type::T_STRING,
323 'title' => ts('Privacy'),
324 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
325 'maxlength' => 255,
326 'size' => CRM_Utils_Type::HUGE,
327 'where' => 'civicrm_note.privacy',
328 'table_name' => 'civicrm_note',
329 'entity' => 'Note',
330 'bao' => 'CRM_Core_BAO_Note',
331 'localizable' => 0,
332 'html' => [
333 'type' => 'Select',
334 ],
335 'pseudoconstant' => [
336 'optionGroupName' => 'note_privacy',
337 'optionEditPath' => 'civicrm/admin/options/note_privacy',
338 ],
339 'add' => '3.3',
340 ],
341 ];
342 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
343 }
344 return Civi::$statics[__CLASS__]['fields'];
345 }
346
347 /**
348 * Return a mapping from field-name to the corresponding key (as used in fields()).
349 *
350 * @return array
351 * Array(string $name => string $uniqueName).
352 */
353 public static function &fieldKeys() {
354 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
355 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
356 }
357 return Civi::$statics[__CLASS__]['fieldKeys'];
358 }
359
360 /**
361 * Returns the names of this table
362 *
363 * @return string
364 */
365 public static function getTableName() {
366 return self::$_tableName;
367 }
368
369 /**
370 * Returns if this table needs to be logged
371 *
372 * @return bool
373 */
374 public function getLog() {
375 return self::$_log;
376 }
377
378 /**
379 * Returns the list of fields that can be imported
380 *
381 * @param bool $prefix
382 *
383 * @return array
384 */
385 public static function &import($prefix = FALSE) {
386 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, []);
387 return $r;
388 }
389
390 /**
391 * Returns the list of fields that can be exported
392 *
393 * @param bool $prefix
394 *
395 * @return array
396 */
397 public static function &export($prefix = FALSE) {
398 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, []);
399 return $r;
400 }
401
402 /**
403 * Returns the list of indices
404 *
405 * @param bool $localize
406 *
407 * @return array
408 */
409 public static function indices($localize = TRUE) {
410 $indices = [
411 'index_entity' => [
412 'name' => 'index_entity',
413 'field' => [
414 0 => 'entity_table',
415 1 => 'entity_id',
416 ],
417 'localizable' => FALSE,
418 'sig' => 'civicrm_note::0::entity_table::entity_id',
419 ],
420 ];
421 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
422 }
423
424 }