Merge pull request #22298 from colemanw/fixApi3ValidateString
[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
8ced16c7 9 * (GenCodeChecksum:49a15912788803e8ccf5298fe93932aa)
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 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $id;
c3fc2621 46
e501603b
TO
47 /**
48 * Name of table where item being referenced is stored.
49 *
50 * @var string
51 */
52 public $entity_table;
c3fc2621 53
e501603b
TO
54 /**
55 * Foreign key to the referenced item.
56 *
e6ca0a57 57 * @var int
e501603b
TO
58 */
59 public $entity_id;
c3fc2621 60
e501603b
TO
61 /**
62 * Note and/or Comment.
63 *
64 * @var text
65 */
66 public $note;
c3fc2621 67
e501603b
TO
68 /**
69 * FK to Contact ID creator
70 *
e6ca0a57 71 * @var int
e501603b
TO
72 */
73 public $contact_id;
c3fc2621 74
5bfc73d6
JP
75 /**
76 * Date attached to the note
77 *
78 * @var timestamp
79 */
80 public $note_date;
81
82 /**
83 * When the note was created.
84 *
85 * @var timestamp
86 */
87 public $created_date;
88
e501603b
TO
89 /**
90 * When was this note last modified/edited
91 *
95ae25b9 92 * @var timestamp
e501603b
TO
93 */
94 public $modified_date;
c3fc2621 95
e501603b
TO
96 /**
97 * subject of note description
98 *
99 * @var string
100 */
101 public $subject;
c3fc2621 102
e501603b
TO
103 /**
104 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
105 *
106 * @var string
107 */
108 public $privacy;
c3fc2621 109
e501603b 110 /**
f41f0342 111 * Class constructor.
e501603b 112 */
c3fc2621 113 public function __construct() {
e501603b
TO
114 $this->__table = 'civicrm_note';
115 parent::__construct();
116 }
c3fc2621 117
449c4e6b
CW
118 /**
119 * Returns localized title of this entity.
7b66c3b5
AH
120 *
121 * @param bool $plural
122 * Whether to return the plural version of the title.
449c4e6b 123 */
7b66c3b5
AH
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ? ts('Notes') : ts('Note');
449c4e6b
CW
126 }
127
e501603b 128 /**
f41f0342 129 * Returns foreign keys and entity references.
e501603b
TO
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
c3fc2621 134 public static function getReferenceColumns() {
346aaaba 135 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 136 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
138 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 139 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 140 }
346aaaba 141 return Civi::$statics[__CLASS__]['links'];
e501603b 142 }
c3fc2621 143
e501603b
TO
144 /**
145 * Returns all the column names of this table
146 *
147 * @return array
148 */
c3fc2621 149 public static function &fields() {
346aaaba 150 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
151 Civi::$statics[__CLASS__]['fields'] = [
152 'id' => [
e501603b
TO
153 'name' => 'id',
154 'type' => CRM_Utils_Type::T_INT,
c3fc2621 155 'title' => ts('Note ID'),
215b423e 156 'description' => ts('Note ID'),
c3fc2621 157 'required' => TRUE,
a36434b9 158 'where' => 'civicrm_note.id',
522a26c9 159 'table_name' => 'civicrm_note',
160 'entity' => 'Note',
161 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 162 'localizable' => 0,
2cbbebe8
A
163 'html' => [
164 'type' => 'Number',
165 ],
1fe423d6 166 'readonly' => TRUE,
a9d0587b 167 'add' => '1.1',
c3fc2621
CW
168 ],
169 'entity_table' => [
e501603b
TO
170 'name' => 'entity_table',
171 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 172 'title' => ts('Note Entity'),
215b423e 173 'description' => ts('Name of table where item being referenced is stored.'),
c3fc2621 174 'required' => TRUE,
e501603b
TO
175 'maxlength' => 64,
176 'size' => CRM_Utils_Type::BIG,
a36434b9 177 'where' => 'civicrm_note.entity_table',
522a26c9 178 'table_name' => 'civicrm_note',
179 'entity' => 'Note',
180 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 181 'localizable' => 0,
c3fc2621 182 'pseudoconstant' => [
8ced16c7
CW
183 'optionGroupName' => 'note_used_for',
184 'optionEditPath' => 'civicrm/admin/options/note_used_for',
e6ca0a57 185 ],
a9d0587b 186 'add' => '1.1',
c3fc2621
CW
187 ],
188 'entity_id' => [
e501603b
TO
189 'name' => 'entity_id',
190 'type' => CRM_Utils_Type::T_INT,
c3fc2621 191 'title' => ts('Note Entity ID'),
215b423e 192 'description' => ts('Foreign key to the referenced item.'),
c3fc2621 193 'required' => TRUE,
a36434b9 194 'where' => 'civicrm_note.entity_id',
522a26c9 195 'table_name' => 'civicrm_note',
196 'entity' => 'Note',
197 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 198 'localizable' => 0,
a9d0587b 199 'add' => '1.1',
c3fc2621
CW
200 ],
201 'note' => [
e501603b
TO
202 'name' => 'note',
203 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 204 'title' => ts('Note'),
215b423e 205 'description' => ts('Note and/or Comment.'),
e501603b
TO
206 'rows' => 4,
207 'cols' => 60,
c3fc2621 208 'import' => TRUE,
e501603b
TO
209 'where' => 'civicrm_note.note',
210 'headerPattern' => '/Note|Comment/i',
211 'dataPattern' => '//',
c3fc2621 212 'export' => TRUE,
522a26c9 213 'table_name' => 'civicrm_note',
214 'entity' => 'Note',
215 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 216 'localizable' => 0,
c3fc2621 217 'html' => [
e501603b 218 'type' => 'TextArea',
c3fc2621 219 ],
a9d0587b 220 'add' => '1.1',
c3fc2621
CW
221 ],
222 'contact_id' => [
e501603b
TO
223 'name' => 'contact_id',
224 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 225 'title' => ts('Created By Contact ID'),
215b423e 226 'description' => ts('FK to Contact ID creator'),
a36434b9 227 'where' => 'civicrm_note.contact_id',
522a26c9 228 'table_name' => 'civicrm_note',
229 'entity' => 'Note',
230 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 231 'localizable' => 0,
e501603b 232 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
233 'html' => [
234 'label' => ts("Created By"),
235 ],
a9d0587b 236 'add' => '1.1',
c3fc2621 237 ],
5bfc73d6
JP
238 'note_date' => [
239 'name' => 'note_date',
240 'type' => CRM_Utils_Type::T_TIMESTAMP,
241 'title' => ts('Note Date'),
242 'description' => ts('Date attached to the note'),
243 'where' => 'civicrm_note.note_date',
244 'default' => 'CURRENT_TIMESTAMP',
245 'table_name' => 'civicrm_note',
246 'entity' => 'Note',
247 'bao' => 'CRM_Core_BAO_Note',
248 'localizable' => 0,
249 'html' => [
250 'type' => 'Select Date',
251 'formatType' => 'activityDateTime',
252 ],
253 'add' => '5.36',
254 ],
255 'created_date' => [
256 'name' => 'created_date',
257 'type' => CRM_Utils_Type::T_TIMESTAMP,
258 'title' => ts('Created Date'),
259 'description' => ts('When the note was created.'),
260 'required' => TRUE,
261 'where' => 'civicrm_note.created_date',
262 'default' => 'CURRENT_TIMESTAMP',
263 'table_name' => 'civicrm_note',
264 'entity' => 'Note',
265 'bao' => 'CRM_Core_BAO_Note',
266 'localizable' => 0,
267 'add' => '5.36',
268 ],
c3fc2621 269 'modified_date' => [
e501603b 270 'name' => 'modified_date',
95ae25b9 271 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 272 'title' => ts('Note Modified By'),
215b423e 273 'description' => ts('When was this note last modified/edited'),
a36434b9 274 'where' => 'civicrm_note.modified_date',
95ae25b9 275 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
522a26c9 276 'table_name' => 'civicrm_note',
277 'entity' => 'Note',
278 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 279 'localizable' => 0,
a0e733f3 280 'readonly' => TRUE,
a9d0587b 281 'add' => '1.1',
c3fc2621
CW
282 ],
283 'subject' => [
e501603b
TO
284 'name' => 'subject',
285 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 286 'title' => ts('Subject'),
215b423e 287 'description' => ts('subject of note description'),
e501603b
TO
288 'maxlength' => 255,
289 'size' => 60,
a36434b9 290 'where' => 'civicrm_note.subject',
522a26c9 291 'table_name' => 'civicrm_note',
292 'entity' => 'Note',
293 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 294 'localizable' => 0,
c3fc2621 295 'html' => [
e501603b 296 'type' => 'Text',
c3fc2621 297 ],
a9d0587b 298 'add' => '1.5',
c3fc2621
CW
299 ],
300 'privacy' => [
e501603b
TO
301 'name' => 'privacy',
302 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 303 'title' => ts('Privacy'),
215b423e 304 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
e501603b
TO
305 'maxlength' => 255,
306 'size' => CRM_Utils_Type::HUGE,
a36434b9 307 'where' => 'civicrm_note.privacy',
522a26c9 308 'table_name' => 'civicrm_note',
309 'entity' => 'Note',
310 'bao' => 'CRM_Core_BAO_Note',
6a7e5e5d 311 'localizable' => 0,
afbbfe95
PN
312 'html' => [
313 'type' => 'Select',
314 ],
c3fc2621 315 'pseudoconstant' => [
e501603b
TO
316 'optionGroupName' => 'note_privacy',
317 'optionEditPath' => 'civicrm/admin/options/note_privacy',
e6ca0a57 318 ],
a9d0587b 319 'add' => '3.3',
c3fc2621
CW
320 ],
321 ];
346aaaba 322 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 323 }
346aaaba 324 return Civi::$statics[__CLASS__]['fields'];
e501603b 325 }
c3fc2621 326
e501603b 327 /**
bd8e0b14 328 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
329 *
330 * @return array
bd8e0b14 331 * Array(string $name => string $uniqueName).
e501603b 332 */
c3fc2621 333 public static function &fieldKeys() {
bd8e0b14
TO
334 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
335 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 336 }
bd8e0b14 337 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 338 }
c3fc2621 339
e501603b
TO
340 /**
341 * Returns the names of this table
342 *
343 * @return string
344 */
c3fc2621 345 public static function getTableName() {
e501603b
TO
346 return self::$_tableName;
347 }
c3fc2621 348
e501603b
TO
349 /**
350 * Returns if this table needs to be logged
351 *
c3fc2621 352 * @return bool
e501603b 353 */
c3fc2621 354 public function getLog() {
e501603b
TO
355 return self::$_log;
356 }
c3fc2621 357
e501603b
TO
358 /**
359 * Returns the list of fields that can be imported
360 *
361 * @param bool $prefix
362 *
363 * @return array
364 */
c3fc2621
CW
365 public static function &import($prefix = FALSE) {
366 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, []);
60808919 367 return $r;
e501603b 368 }
c3fc2621 369
e501603b
TO
370 /**
371 * Returns the list of fields that can be exported
372 *
373 * @param bool $prefix
374 *
375 * @return array
376 */
c3fc2621
CW
377 public static function &export($prefix = FALSE) {
378 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, []);
60808919 379 return $r;
e501603b 380 }
c3fc2621 381
e7a6b91a
AS
382 /**
383 * Returns the list of indices
c3fc2621
CW
384 *
385 * @param bool $localize
386 *
387 * @return array
e7a6b91a
AS
388 */
389 public static function indices($localize = TRUE) {
c3fc2621
CW
390 $indices = [
391 'index_entity' => [
e7a6b91a 392 'name' => 'index_entity',
c3fc2621 393 'field' => [
e7a6b91a
AS
394 0 => 'entity_table',
395 1 => 'entity_id',
c3fc2621
CW
396 ],
397 'localizable' => FALSE,
e7a6b91a 398 'sig' => 'civicrm_note::0::entity_table::entity_id',
c3fc2621
CW
399 ],
400 ];
e7a6b91a
AS
401 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
402 }
c3fc2621 403
e501603b 404}