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