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