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