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