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