Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
8c9251b3 | 5 | * @copyright CiviCRM LLC (c) 2004-2018 |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Core/Tag.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
e380ee3b | 9 | * (GenCodeChecksum:e66cd3973c4f223dd201904b3c59b233) |
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 | */ | |
22 | 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 | */ |
c3fc2621 CW |
29 | static $_log = TRUE; |
30 | ||
e501603b TO |
31 | /** |
32 | * Tag ID | |
33 | * | |
34 | * @var int unsigned | |
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 | * | |
55 | * @var int unsigned | |
56 | */ | |
57 | public $parent_id; | |
c3fc2621 | 58 | |
e501603b TO |
59 | /** |
60 | * Is this tag selectable / displayed | |
61 | * | |
62 | * @var boolean | |
63 | */ | |
64 | public $is_selectable; | |
c3fc2621 | 65 | |
e501603b | 66 | /** |
e501603b TO |
67 | * @var boolean |
68 | */ | |
69 | public $is_reserved; | |
c3fc2621 | 70 | |
e501603b | 71 | /** |
e501603b TO |
72 | * @var boolean |
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 | * | |
84 | * @var int unsigned | |
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 TO |
117 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
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, |
522a26c9 | 140 | 'table_name' => 'civicrm_tag', |
141 | 'entity' => 'Tag', | |
142 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 143 | 'localizable' => 0, |
c3fc2621 CW |
144 | ], |
145 | 'name' => [ | |
e501603b TO |
146 | 'name' => 'name', |
147 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 148 | 'title' => ts('Tag Name'), |
215b423e | 149 | 'description' => ts('Name of Tag.'), |
c3fc2621 | 150 | 'required' => TRUE, |
e501603b TO |
151 | 'maxlength' => 64, |
152 | 'size' => CRM_Utils_Type::BIG, | |
522a26c9 | 153 | 'table_name' => 'civicrm_tag', |
154 | 'entity' => 'Tag', | |
155 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 156 | 'localizable' => 0, |
c3fc2621 CW |
157 | ], |
158 | 'description' => [ | |
e501603b TO |
159 | 'name' => 'description', |
160 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 161 | 'title' => ts('Description'), |
215b423e | 162 | 'description' => ts('Optional verbose description of the tag.'), |
e501603b TO |
163 | 'maxlength' => 255, |
164 | 'size' => CRM_Utils_Type::HUGE, | |
522a26c9 | 165 | 'table_name' => 'civicrm_tag', |
166 | 'entity' => 'Tag', | |
167 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 168 | 'localizable' => 0, |
c3fc2621 CW |
169 | ], |
170 | 'parent_id' => [ | |
e501603b TO |
171 | 'name' => 'parent_id', |
172 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 173 | 'title' => ts('Parent Tag'), |
215b423e | 174 | 'description' => ts('Optional parent id for this tag.'), |
e501603b | 175 | 'default' => 'NULL', |
522a26c9 | 176 | 'table_name' => 'civicrm_tag', |
177 | 'entity' => 'Tag', | |
178 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 179 | 'localizable' => 0, |
e501603b | 180 | 'FKClassName' => 'CRM_Core_DAO_Tag', |
c3fc2621 CW |
181 | ], |
182 | 'is_selectable' => [ | |
e501603b TO |
183 | 'name' => 'is_selectable', |
184 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 185 | 'title' => ts('Display Tag?'), |
215b423e | 186 | 'description' => ts('Is this tag selectable / displayed'), |
e501603b | 187 | 'default' => '1', |
522a26c9 | 188 | 'table_name' => 'civicrm_tag', |
189 | 'entity' => 'Tag', | |
190 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 191 | 'localizable' => 0, |
c3fc2621 CW |
192 | ], |
193 | 'is_reserved' => [ | |
e501603b TO |
194 | 'name' => 'is_reserved', |
195 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 196 | 'title' => ts('Reserved'), |
45a83e42 | 197 | 'default' => '0', |
522a26c9 | 198 | 'table_name' => 'civicrm_tag', |
199 | 'entity' => 'Tag', | |
200 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 201 | 'localizable' => 0, |
c3fc2621 CW |
202 | ], |
203 | 'is_tagset' => [ | |
e501603b TO |
204 | 'name' => 'is_tagset', |
205 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 206 | 'title' => ts('Tagset'), |
45a83e42 | 207 | 'default' => '0', |
522a26c9 | 208 | 'table_name' => 'civicrm_tag', |
209 | 'entity' => 'Tag', | |
210 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 211 | 'localizable' => 0, |
c3fc2621 CW |
212 | ], |
213 | 'used_for' => [ | |
e501603b TO |
214 | 'name' => 'used_for', |
215 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 216 | 'title' => ts('Used For'), |
e501603b TO |
217 | 'maxlength' => 64, |
218 | 'size' => CRM_Utils_Type::BIG, | |
219 | 'default' => 'NULL', | |
522a26c9 | 220 | 'table_name' => 'civicrm_tag', |
221 | 'entity' => 'Tag', | |
222 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 223 | 'localizable' => 0, |
c3fc2621 | 224 | 'html' => [ |
e501603b | 225 | 'type' => 'Select', |
c3fc2621 CW |
226 | ], |
227 | 'pseudoconstant' => [ | |
e501603b TO |
228 | 'optionGroupName' => 'tag_used_for', |
229 | 'optionEditPath' => 'civicrm/admin/options/tag_used_for', | |
c3fc2621 CW |
230 | ] |
231 | ], | |
232 | 'created_id' => [ | |
e501603b TO |
233 | 'name' => 'created_id', |
234 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 235 | 'title' => ts('Tag Created By'), |
215b423e | 236 | 'description' => ts('FK to civicrm_contact, who created this tag'), |
522a26c9 | 237 | 'table_name' => 'civicrm_tag', |
238 | 'entity' => 'Tag', | |
239 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 240 | 'localizable' => 0, |
e501603b | 241 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
c3fc2621 CW |
242 | ], |
243 | 'color' => [ | |
d73974ac CW |
244 | 'name' => 'color', |
245 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 246 | 'title' => ts('Color'), |
215b423e | 247 | 'description' => ts('Hex color value e.g. #ffffff'), |
d73974ac CW |
248 | 'maxlength' => 255, |
249 | 'size' => CRM_Utils_Type::HUGE, | |
250 | 'default' => 'NULL', | |
522a26c9 | 251 | 'table_name' => 'civicrm_tag', |
252 | 'entity' => 'Tag', | |
253 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 254 | 'localizable' => 0, |
c3fc2621 CW |
255 | ], |
256 | 'created_date' => [ | |
e501603b TO |
257 | 'name' => 'created_date', |
258 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
c3fc2621 | 259 | 'title' => ts('Tag Created Date'), |
215b423e | 260 | 'description' => ts('Date and time that tag was created.'), |
522a26c9 | 261 | 'table_name' => 'civicrm_tag', |
262 | 'entity' => 'Tag', | |
263 | 'bao' => 'CRM_Core_BAO_Tag', | |
6a7e5e5d | 264 | 'localizable' => 0, |
c3fc2621 CW |
265 | ], |
266 | ]; | |
346aaaba | 267 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 268 | } |
346aaaba | 269 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 270 | } |
c3fc2621 | 271 | |
e501603b | 272 | /** |
bd8e0b14 | 273 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
274 | * |
275 | * @return array | |
bd8e0b14 | 276 | * Array(string $name => string $uniqueName). |
e501603b | 277 | */ |
c3fc2621 | 278 | public static function &fieldKeys() { |
bd8e0b14 TO |
279 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
280 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 281 | } |
bd8e0b14 | 282 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 283 | } |
c3fc2621 | 284 | |
e501603b TO |
285 | /** |
286 | * Returns the names of this table | |
287 | * | |
288 | * @return string | |
289 | */ | |
c3fc2621 | 290 | public static function getTableName() { |
e501603b TO |
291 | return self::$_tableName; |
292 | } | |
c3fc2621 | 293 | |
e501603b TO |
294 | /** |
295 | * Returns if this table needs to be logged | |
296 | * | |
c3fc2621 | 297 | * @return bool |
e501603b | 298 | */ |
c3fc2621 | 299 | public function getLog() { |
e501603b TO |
300 | return self::$_log; |
301 | } | |
c3fc2621 | 302 | |
e501603b TO |
303 | /** |
304 | * Returns the list of fields that can be imported | |
305 | * | |
306 | * @param bool $prefix | |
307 | * | |
308 | * @return array | |
309 | */ | |
c3fc2621 CW |
310 | public static function &import($prefix = FALSE) { |
311 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'tag', $prefix, []); | |
60808919 | 312 | return $r; |
e501603b | 313 | } |
c3fc2621 | 314 | |
e501603b TO |
315 | /** |
316 | * Returns the list of fields that can be exported | |
317 | * | |
318 | * @param bool $prefix | |
319 | * | |
320 | * @return array | |
321 | */ | |
c3fc2621 CW |
322 | public static function &export($prefix = FALSE) { |
323 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'tag', $prefix, []); | |
60808919 | 324 | return $r; |
e501603b | 325 | } |
c3fc2621 | 326 | |
e7a6b91a AS |
327 | /** |
328 | * Returns the list of indices | |
c3fc2621 CW |
329 | * |
330 | * @param bool $localize | |
331 | * | |
332 | * @return array | |
e7a6b91a AS |
333 | */ |
334 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
335 | $indices = [ |
336 | 'UI_name' => [ | |
e7a6b91a | 337 | 'name' => 'UI_name', |
c3fc2621 | 338 | 'field' => [ |
e7a6b91a | 339 | 0 => 'name', |
c3fc2621 CW |
340 | ], |
341 | 'localizable' => FALSE, | |
342 | 'unique' => TRUE, | |
e7a6b91a | 343 | 'sig' => 'civicrm_tag::1::name', |
c3fc2621 CW |
344 | ], |
345 | ]; | |
e7a6b91a AS |
346 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
347 | } | |
c3fc2621 | 348 | |
e501603b | 349 | } |