Merge pull request #20229 from pradpnayak/usercreate
[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:93f7d0a057e66114cd7b2086c511f0fd)
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 'callback' => 'CRM_Core_BAO_Note::entityTables',
184 ],
185 'add' => '1.1',
186 ],
187 'entity_id' => [
188 'name' => 'entity_id',
189 'type' => CRM_Utils_Type::T_INT,
190 'title' => ts('Note Entity ID'),
191 'description' => ts('Foreign key to the referenced item.'),
192 'required' => TRUE,
193 'where' => 'civicrm_note.entity_id',
194 'table_name' => 'civicrm_note',
195 'entity' => 'Note',
196 'bao' => 'CRM_Core_BAO_Note',
197 'localizable' => 0,
198 'add' => '1.1',
199 ],
200 'note' => [
201 'name' => 'note',
202 'type' => CRM_Utils_Type::T_TEXT,
203 'title' => ts('Note'),
204 'description' => ts('Note and/or Comment.'),
205 'rows' => 4,
206 'cols' => 60,
207 'import' => TRUE,
208 'where' => 'civicrm_note.note',
209 'headerPattern' => '/Note|Comment/i',
210 'dataPattern' => '//',
211 'export' => TRUE,
212 'table_name' => 'civicrm_note',
213 'entity' => 'Note',
214 'bao' => 'CRM_Core_BAO_Note',
215 'localizable' => 0,
216 'html' => [
217 'type' => 'TextArea',
218 ],
219 'add' => '1.1',
220 ],
221 'contact_id' => [
222 'name' => 'contact_id',
223 'type' => CRM_Utils_Type::T_INT,
224 'title' => ts('Created By Contact ID'),
225 'description' => ts('FK to Contact ID creator'),
226 'where' => 'civicrm_note.contact_id',
227 'table_name' => 'civicrm_note',
228 'entity' => 'Note',
229 'bao' => 'CRM_Core_BAO_Note',
230 'localizable' => 0,
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
232 'html' => [
233 'label' => ts("Created By"),
234 ],
235 'add' => '1.1',
236 ],
237 'note_date' => [
238 'name' => 'note_date',
239 'type' => CRM_Utils_Type::T_TIMESTAMP,
240 'title' => ts('Note Date'),
241 'description' => ts('Date attached to the note'),
242 'where' => 'civicrm_note.note_date',
243 'default' => 'CURRENT_TIMESTAMP',
244 'table_name' => 'civicrm_note',
245 'entity' => 'Note',
246 'bao' => 'CRM_Core_BAO_Note',
247 'localizable' => 0,
248 'html' => [
249 'type' => 'Select Date',
250 'formatType' => 'activityDateTime',
251 ],
252 'add' => '5.36',
253 ],
254 'created_date' => [
255 'name' => 'created_date',
256 'type' => CRM_Utils_Type::T_TIMESTAMP,
257 'title' => ts('Created Date'),
258 'description' => ts('When the note was created.'),
259 'required' => TRUE,
260 'where' => 'civicrm_note.created_date',
261 'default' => 'CURRENT_TIMESTAMP',
262 'table_name' => 'civicrm_note',
263 'entity' => 'Note',
264 'bao' => 'CRM_Core_BAO_Note',
265 'localizable' => 0,
266 'add' => '5.36',
267 ],
268 'modified_date' => [
269 'name' => 'modified_date',
270 'type' => CRM_Utils_Type::T_TIMESTAMP,
271 'title' => ts('Note Modified By'),
272 'description' => ts('When was this note last modified/edited'),
273 'where' => 'civicrm_note.modified_date',
274 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
275 'table_name' => 'civicrm_note',
276 'entity' => 'Note',
277 'bao' => 'CRM_Core_BAO_Note',
278 'localizable' => 0,
279 'readonly' => TRUE,
280 'add' => '1.1',
281 ],
282 'subject' => [
283 'name' => 'subject',
284 'type' => CRM_Utils_Type::T_STRING,
285 'title' => ts('Subject'),
286 'description' => ts('subject of note description'),
287 'maxlength' => 255,
288 'size' => 60,
289 'where' => 'civicrm_note.subject',
290 'table_name' => 'civicrm_note',
291 'entity' => 'Note',
292 'bao' => 'CRM_Core_BAO_Note',
293 'localizable' => 0,
294 'html' => [
295 'type' => 'Text',
296 ],
297 'add' => '1.5',
298 ],
299 'privacy' => [
300 'name' => 'privacy',
301 'type' => CRM_Utils_Type::T_STRING,
302 'title' => ts('Privacy'),
303 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
304 'maxlength' => 255,
305 'size' => CRM_Utils_Type::HUGE,
306 'where' => 'civicrm_note.privacy',
307 'table_name' => 'civicrm_note',
308 'entity' => 'Note',
309 'bao' => 'CRM_Core_BAO_Note',
310 'localizable' => 0,
311 'html' => [
312 'type' => 'Select',
313 ],
314 'pseudoconstant' => [
315 'optionGroupName' => 'note_privacy',
316 'optionEditPath' => 'civicrm/admin/options/note_privacy',
317 ],
318 'add' => '3.3',
319 ],
320 ];
321 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
322 }
323 return Civi::$statics[__CLASS__]['fields'];
324 }
325
326 /**
327 * Return a mapping from field-name to the corresponding key (as used in fields()).
328 *
329 * @return array
330 * Array(string $name => string $uniqueName).
331 */
332 public static function &fieldKeys() {
333 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
334 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
335 }
336 return Civi::$statics[__CLASS__]['fieldKeys'];
337 }
338
339 /**
340 * Returns the names of this table
341 *
342 * @return string
343 */
344 public static function getTableName() {
345 return self::$_tableName;
346 }
347
348 /**
349 * Returns if this table needs to be logged
350 *
351 * @return bool
352 */
353 public function getLog() {
354 return self::$_log;
355 }
356
357 /**
358 * Returns the list of fields that can be imported
359 *
360 * @param bool $prefix
361 *
362 * @return array
363 */
364 public static function &import($prefix = FALSE) {
365 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, []);
366 return $r;
367 }
368
369 /**
370 * Returns the list of fields that can be exported
371 *
372 * @param bool $prefix
373 *
374 * @return array
375 */
376 public static function &export($prefix = FALSE) {
377 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, []);
378 return $r;
379 }
380
381 /**
382 * Returns the list of indices
383 *
384 * @param bool $localize
385 *
386 * @return array
387 */
388 public static function indices($localize = TRUE) {
389 $indices = [
390 'index_entity' => [
391 'name' => 'index_entity',
392 'field' => [
393 0 => 'entity_table',
394 1 => 'entity_id',
395 ],
396 'localizable' => FALSE,
397 'sig' => 'civicrm_note::0::entity_table::entity_id',
398 ],
399 ];
400 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
401 }
402
403 }