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