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