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