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