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