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