API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[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:0e43e07bfbf7de4e7fa48f4d24a923fd)
10 */
11
12 /**
13 * Database access object for the Note entity.
14 */
15 class CRM_Core_DAO_Note extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_note';
23
24 /**
25 * Icon associated with this entity.
26 *
27 * @var string
28 */
29 public static $_icon = 'fa-sticky-note';
30
31 /**
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
33 *
34 * @var bool
35 */
36 public static $_log = TRUE;
37
38 /**
39 * Note ID
40 *
41 * @var int
42 */
43 public $id;
44
45 /**
46 * Name of table where item being referenced is stored.
47 *
48 * @var string
49 */
50 public $entity_table;
51
52 /**
53 * Foreign key to the referenced item.
54 *
55 * @var int
56 */
57 public $entity_id;
58
59 /**
60 * Note and/or Comment.
61 *
62 * @var text
63 */
64 public $note;
65
66 /**
67 * FK to Contact ID creator
68 *
69 * @var int
70 */
71 public $contact_id;
72
73 /**
74 * When was this note last modified/edited
75 *
76 * @var timestamp
77 */
78 public $modified_date;
79
80 /**
81 * subject of note description
82 *
83 * @var string
84 */
85 public $subject;
86
87 /**
88 * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)
89 *
90 * @var string
91 */
92 public $privacy;
93
94 /**
95 * Class constructor.
96 */
97 public function __construct() {
98 $this->__table = 'civicrm_note';
99 parent::__construct();
100 }
101
102 /**
103 * Returns localized title of this entity.
104 */
105 public static function getEntityTitle() {
106 return ts('Notes');
107 }
108
109 /**
110 * Returns foreign keys and entity references.
111 *
112 * @return array
113 * [CRM_Core_Reference_Interface]
114 */
115 public static function getReferenceColumns() {
116 if (!isset(Civi::$statics[__CLASS__]['links'])) {
117 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
118 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
119 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
120 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
121 }
122 return Civi::$statics[__CLASS__]['links'];
123 }
124
125 /**
126 * Returns all the column names of this table
127 *
128 * @return array
129 */
130 public static function &fields() {
131 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
132 Civi::$statics[__CLASS__]['fields'] = [
133 'id' => [
134 'name' => 'id',
135 'type' => CRM_Utils_Type::T_INT,
136 'title' => ts('Note ID'),
137 'description' => ts('Note ID'),
138 'required' => TRUE,
139 'where' => 'civicrm_note.id',
140 'table_name' => 'civicrm_note',
141 'entity' => 'Note',
142 'bao' => 'CRM_Core_BAO_Note',
143 'localizable' => 0,
144 'add' => '1.1',
145 ],
146 'entity_table' => [
147 'name' => 'entity_table',
148 'type' => CRM_Utils_Type::T_STRING,
149 'title' => ts('Note Entity'),
150 'description' => ts('Name of table where item being referenced is stored.'),
151 'required' => TRUE,
152 'maxlength' => 64,
153 'size' => CRM_Utils_Type::BIG,
154 'where' => 'civicrm_note.entity_table',
155 'table_name' => 'civicrm_note',
156 'entity' => 'Note',
157 'bao' => 'CRM_Core_BAO_Note',
158 'localizable' => 0,
159 'pseudoconstant' => [
160 'callback' => 'CRM_Core_BAO_Note::entityTables',
161 ],
162 'add' => '1.1',
163 ],
164 'entity_id' => [
165 'name' => 'entity_id',
166 'type' => CRM_Utils_Type::T_INT,
167 'title' => ts('Note Entity ID'),
168 'description' => ts('Foreign key to the referenced item.'),
169 'required' => TRUE,
170 'where' => 'civicrm_note.entity_id',
171 'table_name' => 'civicrm_note',
172 'entity' => 'Note',
173 'bao' => 'CRM_Core_BAO_Note',
174 'localizable' => 0,
175 'add' => '1.1',
176 ],
177 'note' => [
178 'name' => 'note',
179 'type' => CRM_Utils_Type::T_TEXT,
180 'title' => ts('Note'),
181 'description' => ts('Note and/or Comment.'),
182 'rows' => 4,
183 'cols' => 60,
184 'import' => TRUE,
185 'where' => 'civicrm_note.note',
186 'headerPattern' => '/Note|Comment/i',
187 'dataPattern' => '//',
188 'export' => TRUE,
189 'table_name' => 'civicrm_note',
190 'entity' => 'Note',
191 'bao' => 'CRM_Core_BAO_Note',
192 'localizable' => 0,
193 'html' => [
194 'type' => 'TextArea',
195 ],
196 'add' => '1.1',
197 ],
198 'contact_id' => [
199 'name' => 'contact_id',
200 'type' => CRM_Utils_Type::T_INT,
201 'title' => ts('Note Created By'),
202 'description' => ts('FK to Contact ID creator'),
203 'where' => 'civicrm_note.contact_id',
204 'table_name' => 'civicrm_note',
205 'entity' => 'Note',
206 'bao' => 'CRM_Core_BAO_Note',
207 'localizable' => 0,
208 'FKClassName' => 'CRM_Contact_DAO_Contact',
209 'add' => '1.1',
210 ],
211 'modified_date' => [
212 'name' => 'modified_date',
213 'type' => CRM_Utils_Type::T_TIMESTAMP,
214 'title' => ts('Note Modified By'),
215 'description' => ts('When was this note last modified/edited'),
216 'where' => 'civicrm_note.modified_date',
217 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
218 'table_name' => 'civicrm_note',
219 'entity' => 'Note',
220 'bao' => 'CRM_Core_BAO_Note',
221 'localizable' => 0,
222 'add' => '1.1',
223 ],
224 'subject' => [
225 'name' => 'subject',
226 'type' => CRM_Utils_Type::T_STRING,
227 'title' => ts('Subject'),
228 'description' => ts('subject of note description'),
229 'maxlength' => 255,
230 'size' => 60,
231 'where' => 'civicrm_note.subject',
232 'table_name' => 'civicrm_note',
233 'entity' => 'Note',
234 'bao' => 'CRM_Core_BAO_Note',
235 'localizable' => 0,
236 'html' => [
237 'type' => 'Text',
238 ],
239 'add' => '1.5',
240 ],
241 'privacy' => [
242 'name' => 'privacy',
243 'type' => CRM_Utils_Type::T_STRING,
244 'title' => ts('Privacy'),
245 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
246 'maxlength' => 255,
247 'size' => CRM_Utils_Type::HUGE,
248 'where' => 'civicrm_note.privacy',
249 'table_name' => 'civicrm_note',
250 'entity' => 'Note',
251 'bao' => 'CRM_Core_BAO_Note',
252 'localizable' => 0,
253 'html' => [
254 'type' => 'Select',
255 ],
256 'pseudoconstant' => [
257 'optionGroupName' => 'note_privacy',
258 'optionEditPath' => 'civicrm/admin/options/note_privacy',
259 ],
260 'add' => '3.3',
261 ],
262 ];
263 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
264 }
265 return Civi::$statics[__CLASS__]['fields'];
266 }
267
268 /**
269 * Return a mapping from field-name to the corresponding key (as used in fields()).
270 *
271 * @return array
272 * Array(string $name => string $uniqueName).
273 */
274 public static function &fieldKeys() {
275 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
276 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
277 }
278 return Civi::$statics[__CLASS__]['fieldKeys'];
279 }
280
281 /**
282 * Returns the names of this table
283 *
284 * @return string
285 */
286 public static function getTableName() {
287 return self::$_tableName;
288 }
289
290 /**
291 * Returns if this table needs to be logged
292 *
293 * @return bool
294 */
295 public function getLog() {
296 return self::$_log;
297 }
298
299 /**
300 * Returns the list of fields that can be imported
301 *
302 * @param bool $prefix
303 *
304 * @return array
305 */
306 public static function &import($prefix = FALSE) {
307 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, []);
308 return $r;
309 }
310
311 /**
312 * Returns the list of fields that can be exported
313 *
314 * @param bool $prefix
315 *
316 * @return array
317 */
318 public static function &export($prefix = FALSE) {
319 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, []);
320 return $r;
321 }
322
323 /**
324 * Returns the list of indices
325 *
326 * @param bool $localize
327 *
328 * @return array
329 */
330 public static function indices($localize = TRUE) {
331 $indices = [
332 'index_entity' => [
333 'name' => 'index_entity',
334 'field' => [
335 0 => 'entity_table',
336 1 => 'entity_id',
337 ],
338 'localizable' => FALSE,
339 'sig' => 'civicrm_note::0::entity_table::entity_id',
340 ],
341 ];
342 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
343 }
344
345 }