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:93f7d0a057e66114cd7b2086c511f0fd)
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;
48 * Name of table where item being referenced is stored.
55 * Foreign key to the referenced item.
62 * Note and/or Comment.
69 * FK to Contact ID creator
76 * Date attached to the note
83 * When the note was created.
90 * When was this note last modified/edited
94 public $modified_date;
97 * subject of note description
104 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
113 public function __construct() {
114 $this->__table
= 'civicrm_note';
115 parent
::__construct();
119 * Returns localized title of this entity.
121 * @param bool $plural
122 * Whether to return the plural version of the title.
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ?
ts('Notes') : ts('Note');
129 * Returns foreign keys and entity references.
132 * [CRM_Core_Reference_Interface]
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']);
141 return Civi
::$statics[__CLASS__
]['links'];
145 * Returns all the column names of this table
149 public static function &fields() {
150 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
151 Civi
::$statics[__CLASS__
]['fields'] = [
154 'type' => CRM_Utils_Type
::T_INT
,
155 'title' => ts('Note ID'),
156 'description' => ts('Note ID'),
158 'where' => 'civicrm_note.id',
159 'table_name' => 'civicrm_note',
161 'bao' => 'CRM_Core_BAO_Note',
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.'),
176 'size' => CRM_Utils_Type
::BIG
,
177 'where' => 'civicrm_note.entity_table',
178 'table_name' => 'civicrm_note',
180 'bao' => 'CRM_Core_BAO_Note',
182 'pseudoconstant' => [
183 'callback' => 'CRM_Core_BAO_Note::entityTables',
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.'),
193 'where' => 'civicrm_note.entity_id',
194 'table_name' => 'civicrm_note',
196 'bao' => 'CRM_Core_BAO_Note',
202 'type' => CRM_Utils_Type
::T_TEXT
,
203 'title' => ts('Note'),
204 'description' => ts('Note and/or Comment.'),
208 'where' => 'civicrm_note.note',
209 'headerPattern' => '/Note|Comment/i',
210 'dataPattern' => '//',
212 'table_name' => 'civicrm_note',
214 'bao' => 'CRM_Core_BAO_Note',
217 'type' => 'TextArea',
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',
229 'bao' => 'CRM_Core_BAO_Note',
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
233 'label' => ts("Created By"),
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',
246 'bao' => 'CRM_Core_BAO_Note',
249 'type' => 'Select Date',
250 'formatType' => 'activityDateTime',
255 'name' => 'created_date',
256 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
257 'title' => ts('Created Date'),
258 'description' => ts('When the note was created.'),
260 'where' => 'civicrm_note.created_date',
261 'default' => 'CURRENT_TIMESTAMP',
262 'table_name' => 'civicrm_note',
264 'bao' => 'CRM_Core_BAO_Note',
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',
277 'bao' => 'CRM_Core_BAO_Note',
284 'type' => CRM_Utils_Type
::T_STRING
,
285 'title' => ts('Subject'),
286 'description' => ts('subject of note description'),
289 'where' => 'civicrm_note.subject',
290 'table_name' => 'civicrm_note',
292 'bao' => 'CRM_Core_BAO_Note',
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)'),
305 'size' => CRM_Utils_Type
::HUGE
,
306 'where' => 'civicrm_note.privacy',
307 'table_name' => 'civicrm_note',
309 'bao' => 'CRM_Core_BAO_Note',
314 'pseudoconstant' => [
315 'optionGroupName' => 'note_privacy',
316 'optionEditPath' => 'civicrm/admin/options/note_privacy',
321 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
323 return Civi
::$statics[__CLASS__
]['fields'];
327 * Return a mapping from field-name to the corresponding key (as used in fields()).
330 * Array(string $name => string $uniqueName).
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()));
336 return Civi
::$statics[__CLASS__
]['fieldKeys'];
340 * Returns the names of this table
344 public static function getTableName() {
345 return self
::$_tableName;
349 * Returns if this table needs to be logged
353 public function getLog() {
358 * Returns the list of fields that can be imported
360 * @param bool $prefix
364 public static function &import($prefix = FALSE) {
365 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'note', $prefix, []);
370 * Returns the list of fields that can be exported
372 * @param bool $prefix
376 public static function &export($prefix = FALSE) {
377 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'note', $prefix, []);
382 * Returns the list of indices
384 * @param bool $localize
388 public static function indices($localize = TRUE) {
391 'name' => 'index_entity',
396 'localizable' => FALSE,
397 'sig' => 'civicrm_note::0::entity_table::entity_id',
400 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;