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