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:49a15912788803e8ccf5298fe93932aa)
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 'optionGroupName' => 'note_used_for',
184 'optionEditPath' => 'civicrm/admin/options/note_used_for',
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.'),
194 'where' => 'civicrm_note.entity_id',
195 'table_name' => 'civicrm_note',
197 'bao' => 'CRM_Core_BAO_Note',
203 'type' => CRM_Utils_Type
::T_TEXT
,
204 'title' => ts('Note'),
205 'description' => ts('Note and/or Comment.'),
209 'where' => 'civicrm_note.note',
210 'headerPattern' => '/Note|Comment/i',
211 'dataPattern' => '//',
213 'table_name' => 'civicrm_note',
215 'bao' => 'CRM_Core_BAO_Note',
218 'type' => 'TextArea',
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',
230 'bao' => 'CRM_Core_BAO_Note',
232 'FKClassName' => 'CRM_Contact_DAO_Contact',
234 'label' => ts("Created By"),
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',
247 'bao' => 'CRM_Core_BAO_Note',
250 'type' => 'Select Date',
251 'formatType' => 'activityDateTime',
256 'name' => 'created_date',
257 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
258 'title' => ts('Created Date'),
259 'description' => ts('When the note was created.'),
261 'where' => 'civicrm_note.created_date',
262 'default' => 'CURRENT_TIMESTAMP',
263 'table_name' => 'civicrm_note',
265 'bao' => 'CRM_Core_BAO_Note',
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',
278 'bao' => 'CRM_Core_BAO_Note',
285 'type' => CRM_Utils_Type
::T_STRING
,
286 'title' => ts('Subject'),
287 'description' => ts('subject of note description'),
290 'where' => 'civicrm_note.subject',
291 'table_name' => 'civicrm_note',
293 'bao' => 'CRM_Core_BAO_Note',
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)'),
306 'size' => CRM_Utils_Type
::HUGE
,
307 'where' => 'civicrm_note.privacy',
308 'table_name' => 'civicrm_note',
310 'bao' => 'CRM_Core_BAO_Note',
315 'pseudoconstant' => [
316 'optionGroupName' => 'note_privacy',
317 'optionEditPath' => 'civicrm/admin/options/note_privacy',
322 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
324 return Civi
::$statics[__CLASS__
]['fields'];
328 * Return a mapping from field-name to the corresponding key (as used in fields()).
331 * Array(string $name => string $uniqueName).
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()));
337 return Civi
::$statics[__CLASS__
]['fieldKeys'];
341 * Returns the names of this table
345 public static function getTableName() {
346 return self
::$_tableName;
350 * Returns if this table needs to be logged
354 public function getLog() {
359 * Returns the list of fields that can be imported
361 * @param bool $prefix
365 public static function &import($prefix = FALSE) {
366 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'note', $prefix, []);
371 * Returns the list of fields that can be exported
373 * @param bool $prefix
377 public static function &export($prefix = FALSE) {
378 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'note', $prefix, []);
383 * Returns the list of indices
385 * @param bool $localize
389 public static function indices($localize = TRUE) {
392 'name' => 'index_entity',
397 'localizable' => FALSE,
398 'sig' => 'civicrm_note::0::entity_table::entity_id',
401 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;