Pass menubar preference as a param. Simplify cache mechanics. (#8)
[civicrm-core.git] / CRM / Core / DAO / Note.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/Note.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:daafebd13390de67d82735263e9fa886)
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 unsigned
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 unsigned
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 unsigned
63 */
64 public $contact_id;
65
66 /**
67 * When was this note last modified/edited
68 *
69 * @var date
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 'table_name' => 'civicrm_note',
126 'entity' => 'Note',
127 'bao' => 'CRM_Core_BAO_Note',
128 'localizable' => 0,
129 ],
130 'entity_table' => [
131 'name' => 'entity_table',
132 'type' => CRM_Utils_Type::T_STRING,
133 'title' => ts('Note Entity'),
134 'description' => ts('Name of table where item being referenced is stored.'),
135 'required' => TRUE,
136 'maxlength' => 64,
137 'size' => CRM_Utils_Type::BIG,
138 'table_name' => 'civicrm_note',
139 'entity' => 'Note',
140 'bao' => 'CRM_Core_BAO_Note',
141 'localizable' => 0,
142 'pseudoconstant' => [
143 'callback' => 'CRM_Core_BAO_Note::entityTables',
144 ]
145 ],
146 'entity_id' => [
147 'name' => 'entity_id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('Note Entity ID'),
150 'description' => ts('Foreign key to the referenced item.'),
151 'required' => TRUE,
152 'table_name' => 'civicrm_note',
153 'entity' => 'Note',
154 'bao' => 'CRM_Core_BAO_Note',
155 'localizable' => 0,
156 ],
157 'note' => [
158 'name' => 'note',
159 'type' => CRM_Utils_Type::T_TEXT,
160 'title' => ts('Note'),
161 'description' => ts('Note and/or Comment.'),
162 'rows' => 4,
163 'cols' => 60,
164 'import' => TRUE,
165 'where' => 'civicrm_note.note',
166 'headerPattern' => '/Note|Comment/i',
167 'dataPattern' => '//',
168 'export' => TRUE,
169 'table_name' => 'civicrm_note',
170 'entity' => 'Note',
171 'bao' => 'CRM_Core_BAO_Note',
172 'localizable' => 0,
173 'html' => [
174 'type' => 'TextArea',
175 ],
176 ],
177 'contact_id' => [
178 'name' => 'contact_id',
179 'type' => CRM_Utils_Type::T_INT,
180 'title' => ts('Note Created By'),
181 'description' => ts('FK to Contact ID creator'),
182 'table_name' => 'civicrm_note',
183 'entity' => 'Note',
184 'bao' => 'CRM_Core_BAO_Note',
185 'localizable' => 0,
186 'FKClassName' => 'CRM_Contact_DAO_Contact',
187 ],
188 'modified_date' => [
189 'name' => 'modified_date',
190 'type' => CRM_Utils_Type::T_DATE,
191 'title' => ts('Note Modified By'),
192 'description' => ts('When was this note last modified/edited'),
193 'table_name' => 'civicrm_note',
194 'entity' => 'Note',
195 'bao' => 'CRM_Core_BAO_Note',
196 'localizable' => 0,
197 ],
198 'subject' => [
199 'name' => 'subject',
200 'type' => CRM_Utils_Type::T_STRING,
201 'title' => ts('Subject'),
202 'description' => ts('subject of note description'),
203 'maxlength' => 255,
204 'size' => 60,
205 'table_name' => 'civicrm_note',
206 'entity' => 'Note',
207 'bao' => 'CRM_Core_BAO_Note',
208 'localizable' => 0,
209 'html' => [
210 'type' => 'Text',
211 ],
212 ],
213 'privacy' => [
214 'name' => 'privacy',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Privacy'),
217 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
218 'maxlength' => 255,
219 'size' => CRM_Utils_Type::HUGE,
220 'table_name' => 'civicrm_note',
221 'entity' => 'Note',
222 'bao' => 'CRM_Core_BAO_Note',
223 'localizable' => 0,
224 'html' => [
225 'type' => 'Select',
226 ],
227 'pseudoconstant' => [
228 'optionGroupName' => 'note_privacy',
229 'optionEditPath' => 'civicrm/admin/options/note_privacy',
230 ]
231 ],
232 ];
233 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
234 }
235 return Civi::$statics[__CLASS__]['fields'];
236 }
237
238 /**
239 * Return a mapping from field-name to the corresponding key (as used in fields()).
240 *
241 * @return array
242 * Array(string $name => string $uniqueName).
243 */
244 public static function &fieldKeys() {
245 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
246 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
247 }
248 return Civi::$statics[__CLASS__]['fieldKeys'];
249 }
250
251 /**
252 * Returns the names of this table
253 *
254 * @return string
255 */
256 public static function getTableName() {
257 return self::$_tableName;
258 }
259
260 /**
261 * Returns if this table needs to be logged
262 *
263 * @return bool
264 */
265 public function getLog() {
266 return self::$_log;
267 }
268
269 /**
270 * Returns the list of fields that can be imported
271 *
272 * @param bool $prefix
273 *
274 * @return array
275 */
276 public static function &import($prefix = FALSE) {
277 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'note', $prefix, []);
278 return $r;
279 }
280
281 /**
282 * Returns the list of fields that can be exported
283 *
284 * @param bool $prefix
285 *
286 * @return array
287 */
288 public static function &export($prefix = FALSE) {
289 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'note', $prefix, []);
290 return $r;
291 }
292
293 /**
294 * Returns the list of indices
295 *
296 * @param bool $localize
297 *
298 * @return array
299 */
300 public static function indices($localize = TRUE) {
301 $indices = [
302 'index_entity' => [
303 'name' => 'index_entity',
304 'field' => [
305 0 => 'entity_table',
306 1 => 'entity_id',
307 ],
308 'localizable' => FALSE,
309 'sig' => 'civicrm_note::0::entity_table::entity_id',
310 ],
311 ];
312 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
313 }
314
315 }