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