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:9e73096c6f34086fd42e8098649c7abc)
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 * When was this note last modified/edited
80 public $modified_date;
83 * subject of note description
90 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
99 public function __construct() {
100 $this->__table
= 'civicrm_note';
101 parent
::__construct();
105 * Returns localized title of this entity.
107 * @param bool $plural
108 * Whether to return the plural version of the title.
110 public static function getEntityTitle($plural = FALSE) {
111 return $plural ?
ts('Notes') : ts('Note');
115 * Returns foreign keys and entity references.
118 * [CRM_Core_Reference_Interface]
120 public static function getReferenceColumns() {
121 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
122 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
123 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
125 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
127 return Civi
::$statics[__CLASS__
]['links'];
131 * Returns all the column names of this table
135 public static function &fields() {
136 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
137 Civi
::$statics[__CLASS__
]['fields'] = [
140 'type' => CRM_Utils_Type
::T_INT
,
141 'title' => ts('Note ID'),
142 'description' => ts('Note ID'),
144 'where' => 'civicrm_note.id',
145 'table_name' => 'civicrm_note',
147 'bao' => 'CRM_Core_BAO_Note',
152 'name' => 'entity_table',
153 'type' => CRM_Utils_Type
::T_STRING
,
154 'title' => ts('Note Entity'),
155 'description' => ts('Name of table where item being referenced is stored.'),
158 'size' => CRM_Utils_Type
::BIG
,
159 'where' => 'civicrm_note.entity_table',
160 'table_name' => 'civicrm_note',
162 'bao' => 'CRM_Core_BAO_Note',
164 'pseudoconstant' => [
165 'callback' => 'CRM_Core_BAO_Note::entityTables',
170 'name' => 'entity_id',
171 'type' => CRM_Utils_Type
::T_INT
,
172 'title' => ts('Note Entity ID'),
173 'description' => ts('Foreign key to the referenced item.'),
175 'where' => 'civicrm_note.entity_id',
176 'table_name' => 'civicrm_note',
178 'bao' => 'CRM_Core_BAO_Note',
184 'type' => CRM_Utils_Type
::T_TEXT
,
185 'title' => ts('Note'),
186 'description' => ts('Note and/or Comment.'),
190 'where' => 'civicrm_note.note',
191 'headerPattern' => '/Note|Comment/i',
192 'dataPattern' => '//',
194 'table_name' => 'civicrm_note',
196 'bao' => 'CRM_Core_BAO_Note',
199 'type' => 'TextArea',
204 'name' => 'contact_id',
205 'type' => CRM_Utils_Type
::T_INT
,
206 'title' => ts('Note Created By'),
207 'description' => ts('FK to Contact ID creator'),
208 'where' => 'civicrm_note.contact_id',
209 'table_name' => 'civicrm_note',
211 'bao' => 'CRM_Core_BAO_Note',
213 'FKClassName' => 'CRM_Contact_DAO_Contact',
217 'name' => 'modified_date',
218 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
219 'title' => ts('Note Modified By'),
220 'description' => ts('When was this note last modified/edited'),
221 'where' => 'civicrm_note.modified_date',
222 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
223 'table_name' => 'civicrm_note',
225 'bao' => 'CRM_Core_BAO_Note',
231 'type' => CRM_Utils_Type
::T_STRING
,
232 'title' => ts('Subject'),
233 'description' => ts('subject of note description'),
236 'where' => 'civicrm_note.subject',
237 'table_name' => 'civicrm_note',
239 'bao' => 'CRM_Core_BAO_Note',
248 'type' => CRM_Utils_Type
::T_STRING
,
249 'title' => ts('Privacy'),
250 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
252 'size' => CRM_Utils_Type
::HUGE
,
253 'where' => 'civicrm_note.privacy',
254 'table_name' => 'civicrm_note',
256 'bao' => 'CRM_Core_BAO_Note',
261 'pseudoconstant' => [
262 'optionGroupName' => 'note_privacy',
263 'optionEditPath' => 'civicrm/admin/options/note_privacy',
268 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
270 return Civi
::$statics[__CLASS__
]['fields'];
274 * Return a mapping from field-name to the corresponding key (as used in fields()).
277 * Array(string $name => string $uniqueName).
279 public static function &fieldKeys() {
280 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
281 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
283 return Civi
::$statics[__CLASS__
]['fieldKeys'];
287 * Returns the names of this table
291 public static function getTableName() {
292 return self
::$_tableName;
296 * Returns if this table needs to be logged
300 public function getLog() {
305 * Returns the list of fields that can be imported
307 * @param bool $prefix
311 public static function &import($prefix = FALSE) {
312 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'note', $prefix, []);
317 * Returns the list of fields that can be exported
319 * @param bool $prefix
323 public static function &export($prefix = FALSE) {
324 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'note', $prefix, []);
329 * Returns the list of indices
331 * @param bool $localize
335 public static function indices($localize = TRUE) {
338 'name' => 'index_entity',
343 'localizable' => FALSE,
344 'sig' => 'civicrm_note::0::entity_table::entity_id',
347 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;