Merge pull request #17634 from civicrm/5.27
[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:fd649e023be90204b62cc283886fa400)
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 ],
145 'entity_table' => [
146 'name' => 'entity_table',
147 'type' => CRM_Utils_Type::T_STRING,
148 'title' => ts('Note Entity'),
149 'description' => ts('Name of table where item being referenced is stored.'),
150 'required' => TRUE,
151 'maxlength' => 64,
152 'size' => CRM_Utils_Type::BIG,
153 'where' => 'civicrm_note.entity_table',
154 'table_name' => 'civicrm_note',
155 'entity' => 'Note',
156 'bao' => 'CRM_Core_BAO_Note',
157 'localizable' => 0,
158 'pseudoconstant' => [
159 'callback' => 'CRM_Core_BAO_Note::entityTables',
160 ],
161 ],
162 'entity_id' => [
163 'name' => 'entity_id',
164 'type' => CRM_Utils_Type::T_INT,
165 'title' => ts('Note Entity ID'),
166 'description' => ts('Foreign key to the referenced item.'),
167 'required' => TRUE,
168 'where' => 'civicrm_note.entity_id',
169 'table_name' => 'civicrm_note',
170 'entity' => 'Note',
171 'bao' => 'CRM_Core_BAO_Note',
172 'localizable' => 0,
173 ],
174 'note' => [
175 'name' => 'note',
176 'type' => CRM_Utils_Type::T_TEXT,
177 'title' => ts('Note'),
178 'description' => ts('Note and/or Comment.'),
179 'rows' => 4,
180 'cols' => 60,
181 'import' => TRUE,
182 'where' => 'civicrm_note.note',
183 'headerPattern' => '/Note|Comment/i',
184 'dataPattern' => '//',
185 'export' => TRUE,
186 'table_name' => 'civicrm_note',
187 'entity' => 'Note',
188 'bao' => 'CRM_Core_BAO_Note',
189 'localizable' => 0,
190 'html' => [
191 'type' => 'TextArea',
192 ],
193 ],
194 'contact_id' => [
195 'name' => 'contact_id',
196 'type' => CRM_Utils_Type::T_INT,
197 'title' => ts('Note Created By'),
198 'description' => ts('FK to Contact ID creator'),
199 'where' => 'civicrm_note.contact_id',
200 'table_name' => 'civicrm_note',
201 'entity' => 'Note',
202 'bao' => 'CRM_Core_BAO_Note',
203 'localizable' => 0,
204 'FKClassName' => 'CRM_Contact_DAO_Contact',
205 ],
206 'modified_date' => [
207 'name' => 'modified_date',
208 'type' => CRM_Utils_Type::T_TIMESTAMP,
209 'title' => ts('Note Modified By'),
210 'description' => ts('When was this note last modified/edited'),
211 'where' => 'civicrm_note.modified_date',
212 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
213 'table_name' => 'civicrm_note',
214 'entity' => 'Note',
215 'bao' => 'CRM_Core_BAO_Note',
216 'localizable' => 0,
217 ],
218 'subject' => [
219 'name' => 'subject',
220 'type' => CRM_Utils_Type::T_STRING,
221 'title' => ts('Subject'),
222 'description' => ts('subject of note description'),
223 'maxlength' => 255,
224 'size' => 60,
225 'where' => 'civicrm_note.subject',
226 'table_name' => 'civicrm_note',
227 'entity' => 'Note',
228 'bao' => 'CRM_Core_BAO_Note',
229 'localizable' => 0,
230 'html' => [
231 'type' => 'Text',
232 ],
233 ],
234 'privacy' => [
235 'name' => 'privacy',
236 'type' => CRM_Utils_Type::T_STRING,
237 'title' => ts('Privacy'),
238 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
239 'maxlength' => 255,
240 'size' => CRM_Utils_Type::HUGE,
241 'where' => 'civicrm_note.privacy',
242 'table_name' => 'civicrm_note',
243 'entity' => 'Note',
244 'bao' => 'CRM_Core_BAO_Note',
245 'localizable' => 0,
246 'html' => [
247 'type' => 'Select',
248 ],
249 'pseudoconstant' => [
250 'optionGroupName' => 'note_privacy',
251 'optionEditPath' => 'civicrm/admin/options/note_privacy',
252 ],
253 ],
254 ];
255 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
256 }
257 return Civi::$statics[__CLASS__]['fields'];
258 }
259
260 /**
261 * Return a mapping from field-name to the corresponding key (as used in fields()).
262 *
263 * @return array
264 * Array(string $name => string $uniqueName).
265 */
266 public static function &fieldKeys() {
267 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
268 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
269 }
270 return Civi::$statics[__CLASS__]['fieldKeys'];
271 }
272
273 /**
274 * Returns the names of this table
275 *
276 * @return string
277 */
278 public static function getTableName() {
279 return self::$_tableName;
280 }
281
282 /**
283 * Returns if this table needs to be logged
284 *
285 * @return bool
286 */
287 public function getLog() {
288 return self::$_log;
289 }
290
291 /**
292 * Returns the list of fields that can be imported
293 *
294 * @param bool $prefix
295 *
296 * @return array
297 */
298 public static function &import($prefix = FALSE) {
299 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, []);
300 return $r;
301 }
302
303 /**
304 * Returns the list of fields that can be exported
305 *
306 * @param bool $prefix
307 *
308 * @return array
309 */
310 public static function &export($prefix = FALSE) {
311 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, []);
312 return $r;
313 }
314
315 /**
316 * Returns the list of indices
317 *
318 * @param bool $localize
319 *
320 * @return array
321 */
322 public static function indices($localize = TRUE) {
323 $indices = [
324 'index_entity' => [
325 'name' => 'index_entity',
326 'field' => [
327 0 => 'entity_table',
328 1 => 'entity_id',
329 ],
330 'localizable' => FALSE,
331 'sig' => 'civicrm_note::0::entity_table::entity_id',
332 ],
333 ];
334 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
335 }
336
337 }