5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Note.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5f542bdf0c411eeefbf3ec22514d7407)
13 * Database access object for the Note entity.
15 class CRM_Core_DAO_Note
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_note';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-sticky-note';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
50 * Name of table where item being referenced is stored.
53 * (SQL type: varchar(64))
54 * Note that values will be retrieved from the database as a string.
59 * Foreign key to the referenced item.
62 * (SQL type: int unsigned)
63 * Note that values will be retrieved from the database as a string.
68 * Note and/or Comment.
72 * Note that values will be retrieved from the database as a string.
77 * FK to Contact ID creator
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
86 * Date attached to the note
89 * (SQL type: timestamp)
90 * Note that values will be retrieved from the database as a string.
95 * When the note was created.
98 * (SQL type: timestamp)
99 * Note that values will be retrieved from the database as a string.
101 public $created_date;
104 * When was this note last modified/edited
107 * (SQL type: timestamp)
108 * Note that values will be retrieved from the database as a string.
110 public $modified_date;
113 * subject of note description
116 * (SQL type: varchar(255))
117 * Note that values will be retrieved from the database as a string.
122 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
125 * (SQL type: varchar(255))
126 * Note that values will be retrieved from the database as a string.
133 public function __construct() {
134 $this->__table
= 'civicrm_note';
135 parent
::__construct();
139 * Returns localized title of this entity.
141 * @param bool $plural
142 * Whether to return the plural version of the title.
144 public static function getEntityTitle($plural = FALSE) {
145 return $plural ?
ts('Notes') : ts('Note');
149 * Returns foreign keys and entity references.
152 * [CRM_Core_Reference_Interface]
154 public static function getReferenceColumns() {
155 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
156 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
157 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
158 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
159 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
161 return Civi
::$statics[__CLASS__
]['links'];
165 * Returns all the column names of this table
169 public static function &fields() {
170 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
171 Civi
::$statics[__CLASS__
]['fields'] = [
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Note ID'),
176 'description' => ts('Note ID'),
178 'where' => 'civicrm_note.id',
179 'table_name' => 'civicrm_note',
181 'bao' => 'CRM_Core_BAO_Note',
190 'name' => 'entity_table',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Note Entity'),
193 'description' => ts('Name of table where item being referenced is stored.'),
196 'size' => CRM_Utils_Type
::BIG
,
197 'where' => 'civicrm_note.entity_table',
198 'table_name' => 'civicrm_note',
200 'bao' => 'CRM_Core_BAO_Note',
202 'pseudoconstant' => [
203 'optionGroupName' => 'note_used_for',
204 'optionEditPath' => 'civicrm/admin/options/note_used_for',
209 'name' => 'entity_id',
210 'type' => CRM_Utils_Type
::T_INT
,
211 'title' => ts('Note Entity ID'),
212 'description' => ts('Foreign key to the referenced item.'),
214 'where' => 'civicrm_note.entity_id',
215 'table_name' => 'civicrm_note',
217 'bao' => 'CRM_Core_BAO_Note',
223 'type' => CRM_Utils_Type
::T_TEXT
,
224 'title' => ts('Note'),
225 'description' => ts('Note and/or Comment.'),
229 'where' => 'civicrm_note.note',
230 'headerPattern' => '/Note|Comment/i',
231 'dataPattern' => '//',
233 'table_name' => 'civicrm_note',
235 'bao' => 'CRM_Core_BAO_Note',
238 'type' => 'TextArea',
243 'name' => 'contact_id',
244 'type' => CRM_Utils_Type
::T_INT
,
245 'title' => ts('Created By Contact ID'),
246 'description' => ts('FK to Contact ID creator'),
247 'where' => 'civicrm_note.contact_id',
248 'table_name' => 'civicrm_note',
250 'bao' => 'CRM_Core_BAO_Note',
252 'FKClassName' => 'CRM_Contact_DAO_Contact',
254 'label' => ts("Created By"),
259 'name' => 'note_date',
260 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
261 'title' => ts('Note Date'),
262 'description' => ts('Date attached to the note'),
263 'where' => 'civicrm_note.note_date',
264 'default' => 'CURRENT_TIMESTAMP',
265 'table_name' => 'civicrm_note',
267 'bao' => 'CRM_Core_BAO_Note',
270 'type' => 'Select Date',
271 'formatType' => 'activityDateTime',
276 'name' => 'created_date',
277 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
278 'title' => ts('Created Date'),
279 'description' => ts('When the note was created.'),
281 'where' => 'civicrm_note.created_date',
282 'default' => 'CURRENT_TIMESTAMP',
283 'table_name' => 'civicrm_note',
285 'bao' => 'CRM_Core_BAO_Note',
290 'name' => 'modified_date',
291 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
292 'title' => ts('Note Modified By'),
293 'description' => ts('When was this note last modified/edited'),
294 'where' => 'civicrm_note.modified_date',
295 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
296 'table_name' => 'civicrm_note',
298 'bao' => 'CRM_Core_BAO_Note',
305 'type' => CRM_Utils_Type
::T_STRING
,
306 'title' => ts('Subject'),
307 'description' => ts('subject of note description'),
310 'where' => 'civicrm_note.subject',
311 'table_name' => 'civicrm_note',
313 'bao' => 'CRM_Core_BAO_Note',
322 'type' => CRM_Utils_Type
::T_STRING
,
323 'title' => ts('Privacy'),
324 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
326 'size' => CRM_Utils_Type
::HUGE
,
327 'where' => 'civicrm_note.privacy',
328 'table_name' => 'civicrm_note',
330 'bao' => 'CRM_Core_BAO_Note',
335 'pseudoconstant' => [
336 'optionGroupName' => 'note_privacy',
337 'optionEditPath' => 'civicrm/admin/options/note_privacy',
342 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
344 return Civi
::$statics[__CLASS__
]['fields'];
348 * Return a mapping from field-name to the corresponding key (as used in fields()).
351 * Array(string $name => string $uniqueName).
353 public static function &fieldKeys() {
354 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
355 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
357 return Civi
::$statics[__CLASS__
]['fieldKeys'];
361 * Returns the names of this table
365 public static function getTableName() {
366 return self
::$_tableName;
370 * Returns if this table needs to be logged
374 public function getLog() {
379 * Returns the list of fields that can be imported
381 * @param bool $prefix
385 public static function &import($prefix = FALSE) {
386 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'note', $prefix, []);
391 * Returns the list of fields that can be exported
393 * @param bool $prefix
397 public static function &export($prefix = FALSE) {
398 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'note', $prefix, []);
403 * Returns the list of indices
405 * @param bool $localize
409 public static function indices($localize = TRUE) {
412 'name' => 'index_entity',
417 'localizable' => FALSE,
418 'sig' => 'civicrm_note::0::entity_table::entity_id',
421 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;