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