Merge pull request #19205 from eileenmcnaughton/mem_forms
[civicrm-core.git] / CRM / Core / DAO / Tag.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Tag.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1de963194e3e392448445fac3eac82c8)
10 */
11
12 /**
13 * Database access object for the Tag entity.
14 */
15 class CRM_Core_DAO_Tag 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_tag';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-tag';
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 * Tag ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * Name of Tag.
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * Optional verbose description of the tag.
56 *
57 * @var string
58 */
59 public $description;
60
61 /**
62 * Optional parent id for this tag.
63 *
64 * @var int
65 */
66 public $parent_id;
67
68 /**
69 * Is this tag selectable / displayed
70 *
71 * @var bool
72 */
73 public $is_selectable;
74
75 /**
76 * @var bool
77 */
78 public $is_reserved;
79
80 /**
81 * @var bool
82 */
83 public $is_tagset;
84
85 /**
86 * @var string
87 */
88 public $used_for;
89
90 /**
91 * FK to civicrm_contact, who created this tag
92 *
93 * @var int
94 */
95 public $created_id;
96
97 /**
98 * Hex color value e.g. #ffffff
99 *
100 * @var string
101 */
102 public $color;
103
104 /**
105 * Date and time that tag was created.
106 *
107 * @var datetime
108 */
109 public $created_date;
110
111 /**
112 * Class constructor.
113 */
114 public function __construct() {
115 $this->__table = 'civicrm_tag';
116 parent::__construct();
117 }
118
119 /**
120 * Returns localized title of this entity.
121 *
122 * @param bool $plural
123 * Whether to return the plural version of the title.
124 */
125 public static function getEntityTitle($plural = FALSE) {
126 return $plural ? ts('Tags') : ts('Tag');
127 }
128
129 /**
130 * Returns foreign keys and entity references.
131 *
132 * @return array
133 * [CRM_Core_Reference_Interface]
134 */
135 public static function getReferenceColumns() {
136 if (!isset(Civi::$statics[__CLASS__]['links'])) {
137 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
138 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_tag', 'id');
139 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
140 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
141 }
142 return Civi::$statics[__CLASS__]['links'];
143 }
144
145 /**
146 * Returns all the column names of this table
147 *
148 * @return array
149 */
150 public static function &fields() {
151 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
152 Civi::$statics[__CLASS__]['fields'] = [
153 'id' => [
154 'name' => 'id',
155 'type' => CRM_Utils_Type::T_INT,
156 'title' => ts('Tag ID'),
157 'description' => ts('Tag ID'),
158 'required' => TRUE,
159 'where' => 'civicrm_tag.id',
160 'table_name' => 'civicrm_tag',
161 'entity' => 'Tag',
162 'bao' => 'CRM_Core_BAO_Tag',
163 'localizable' => 0,
164 'add' => '1.1',
165 ],
166 'name' => [
167 'name' => 'name',
168 'type' => CRM_Utils_Type::T_STRING,
169 'title' => ts('Tag Name'),
170 'description' => ts('Name of Tag.'),
171 'required' => TRUE,
172 'maxlength' => 64,
173 'size' => CRM_Utils_Type::BIG,
174 'where' => 'civicrm_tag.name',
175 'table_name' => 'civicrm_tag',
176 'entity' => 'Tag',
177 'bao' => 'CRM_Core_BAO_Tag',
178 'localizable' => 0,
179 'add' => '1.1',
180 ],
181 'description' => [
182 'name' => 'description',
183 'type' => CRM_Utils_Type::T_STRING,
184 'title' => ts('Description'),
185 'description' => ts('Optional verbose description of the tag.'),
186 'maxlength' => 255,
187 'size' => CRM_Utils_Type::HUGE,
188 'where' => 'civicrm_tag.description',
189 'table_name' => 'civicrm_tag',
190 'entity' => 'Tag',
191 'bao' => 'CRM_Core_BAO_Tag',
192 'localizable' => 0,
193 'add' => '1.1',
194 ],
195 'parent_id' => [
196 'name' => 'parent_id',
197 'type' => CRM_Utils_Type::T_INT,
198 'title' => ts('Parent Tag'),
199 'description' => ts('Optional parent id for this tag.'),
200 'where' => 'civicrm_tag.parent_id',
201 'default' => 'NULL',
202 'table_name' => 'civicrm_tag',
203 'entity' => 'Tag',
204 'bao' => 'CRM_Core_BAO_Tag',
205 'localizable' => 0,
206 'FKClassName' => 'CRM_Core_DAO_Tag',
207 'pseudoconstant' => [
208 'table' => 'civicrm_tag',
209 'keyColumn' => 'id',
210 'labelColumn' => 'name',
211 ],
212 'add' => '1.1',
213 ],
214 'is_selectable' => [
215 'name' => 'is_selectable',
216 'type' => CRM_Utils_Type::T_BOOLEAN,
217 'title' => ts('Display Tag?'),
218 'description' => ts('Is this tag selectable / displayed'),
219 'where' => 'civicrm_tag.is_selectable',
220 'default' => '1',
221 'table_name' => 'civicrm_tag',
222 'entity' => 'Tag',
223 'bao' => 'CRM_Core_BAO_Tag',
224 'localizable' => 0,
225 'add' => '2.1',
226 ],
227 'is_reserved' => [
228 'name' => 'is_reserved',
229 'type' => CRM_Utils_Type::T_BOOLEAN,
230 'title' => ts('Reserved'),
231 'where' => 'civicrm_tag.is_reserved',
232 'default' => '0',
233 'table_name' => 'civicrm_tag',
234 'entity' => 'Tag',
235 'bao' => 'CRM_Core_BAO_Tag',
236 'localizable' => 0,
237 'add' => '3.2',
238 ],
239 'is_tagset' => [
240 'name' => 'is_tagset',
241 'type' => CRM_Utils_Type::T_BOOLEAN,
242 'title' => ts('Tagset'),
243 'where' => 'civicrm_tag.is_tagset',
244 'default' => '0',
245 'table_name' => 'civicrm_tag',
246 'entity' => 'Tag',
247 'bao' => 'CRM_Core_BAO_Tag',
248 'localizable' => 0,
249 'add' => '3.2',
250 ],
251 'used_for' => [
252 'name' => 'used_for',
253 'type' => CRM_Utils_Type::T_STRING,
254 'title' => ts('Used For'),
255 'maxlength' => 64,
256 'size' => CRM_Utils_Type::BIG,
257 'where' => 'civicrm_tag.used_for',
258 'default' => 'NULL',
259 'table_name' => 'civicrm_tag',
260 'entity' => 'Tag',
261 'bao' => 'CRM_Core_BAO_Tag',
262 'localizable' => 0,
263 'serialize' => self::SERIALIZE_COMMA,
264 'html' => [
265 'type' => 'Select',
266 ],
267 'pseudoconstant' => [
268 'optionGroupName' => 'tag_used_for',
269 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
270 ],
271 'add' => '3.2',
272 ],
273 'created_id' => [
274 'name' => 'created_id',
275 'type' => CRM_Utils_Type::T_INT,
276 'title' => ts('Tag Created By'),
277 'description' => ts('FK to civicrm_contact, who created this tag'),
278 'where' => 'civicrm_tag.created_id',
279 'table_name' => 'civicrm_tag',
280 'entity' => 'Tag',
281 'bao' => 'CRM_Core_BAO_Tag',
282 'localizable' => 0,
283 'FKClassName' => 'CRM_Contact_DAO_Contact',
284 'add' => '3.4',
285 ],
286 'color' => [
287 'name' => 'color',
288 'type' => CRM_Utils_Type::T_STRING,
289 'title' => ts('Color'),
290 'description' => ts('Hex color value e.g. #ffffff'),
291 'maxlength' => 255,
292 'size' => CRM_Utils_Type::HUGE,
293 'where' => 'civicrm_tag.color',
294 'default' => 'NULL',
295 'table_name' => 'civicrm_tag',
296 'entity' => 'Tag',
297 'bao' => 'CRM_Core_BAO_Tag',
298 'localizable' => 0,
299 'add' => '4.7',
300 ],
301 'created_date' => [
302 'name' => 'created_date',
303 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
304 'title' => ts('Tag Created Date'),
305 'description' => ts('Date and time that tag was created.'),
306 'where' => 'civicrm_tag.created_date',
307 'table_name' => 'civicrm_tag',
308 'entity' => 'Tag',
309 'bao' => 'CRM_Core_BAO_Tag',
310 'localizable' => 0,
311 'add' => '3.4',
312 ],
313 ];
314 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
315 }
316 return Civi::$statics[__CLASS__]['fields'];
317 }
318
319 /**
320 * Return a mapping from field-name to the corresponding key (as used in fields()).
321 *
322 * @return array
323 * Array(string $name => string $uniqueName).
324 */
325 public static function &fieldKeys() {
326 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
327 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
328 }
329 return Civi::$statics[__CLASS__]['fieldKeys'];
330 }
331
332 /**
333 * Returns the names of this table
334 *
335 * @return string
336 */
337 public static function getTableName() {
338 return self::$_tableName;
339 }
340
341 /**
342 * Returns if this table needs to be logged
343 *
344 * @return bool
345 */
346 public function getLog() {
347 return self::$_log;
348 }
349
350 /**
351 * Returns the list of fields that can be imported
352 *
353 * @param bool $prefix
354 *
355 * @return array
356 */
357 public static function &import($prefix = FALSE) {
358 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'tag', $prefix, []);
359 return $r;
360 }
361
362 /**
363 * Returns the list of fields that can be exported
364 *
365 * @param bool $prefix
366 *
367 * @return array
368 */
369 public static function &export($prefix = FALSE) {
370 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'tag', $prefix, []);
371 return $r;
372 }
373
374 /**
375 * Returns the list of indices
376 *
377 * @param bool $localize
378 *
379 * @return array
380 */
381 public static function indices($localize = TRUE) {
382 $indices = [
383 'UI_name' => [
384 'name' => 'UI_name',
385 'field' => [
386 0 => 'name',
387 ],
388 'localizable' => FALSE,
389 'unique' => TRUE,
390 'sig' => 'civicrm_tag::1::name',
391 ],
392 ];
393 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
394 }
395
396 }