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