5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Tag.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:6bf223ca710a35bc6fb4c5e3f373b214)
13 * Database access object for the Tag entity.
15 class CRM_Core_DAO_Tag
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_tag';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-tag';
34 * Field to show when displaying a record.
38 public static $_labelField = 'name';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
62 * Optional verbose description of the tag.
69 * Optional parent id for this tag.
76 * Is this tag selectable / displayed
80 public $is_selectable;
98 * FK to civicrm_contact, who created this tag
105 * Hex color value e.g. #ffffff
112 * Date and time that tag was created.
116 public $created_date;
121 public function __construct() {
122 $this->__table
= 'civicrm_tag';
123 parent
::__construct();
127 * Returns localized title of this entity.
129 * @param bool $plural
130 * Whether to return the plural version of the title.
132 public static function getEntityTitle($plural = FALSE) {
133 return $plural ?
ts('Tags') : ts('Tag');
137 * Returns foreign keys and entity references.
140 * [CRM_Core_Reference_Interface]
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']);
149 return Civi
::$statics[__CLASS__
]['links'];
153 * Returns all the column names of this table
157 public static function &fields() {
158 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
159 Civi
::$statics[__CLASS__
]['fields'] = [
162 'type' => CRM_Utils_Type
::T_INT
,
163 'title' => ts('Tag ID'),
164 'description' => ts('Tag ID'),
166 'where' => 'civicrm_tag.id',
167 'table_name' => 'civicrm_tag',
169 'bao' => 'CRM_Core_BAO_Tag',
179 'type' => CRM_Utils_Type
::T_STRING
,
180 'title' => ts('Tag Name'),
181 'description' => ts('Name of Tag.'),
184 'size' => CRM_Utils_Type
::BIG
,
185 'where' => 'civicrm_tag.name',
186 'table_name' => 'civicrm_tag',
188 'bao' => 'CRM_Core_BAO_Tag',
193 'name' => 'description',
194 'type' => CRM_Utils_Type
::T_STRING
,
195 'title' => ts('Description'),
196 'description' => ts('Optional verbose description of the tag.'),
198 'size' => CRM_Utils_Type
::HUGE
,
199 'where' => 'civicrm_tag.description',
200 'table_name' => 'civicrm_tag',
202 'bao' => 'CRM_Core_BAO_Tag',
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',
213 'table_name' => 'civicrm_tag',
215 'bao' => 'CRM_Core_BAO_Tag',
217 'FKClassName' => 'CRM_Core_DAO_Tag',
219 'label' => ts("Parent Tag"),
221 'pseudoconstant' => [
222 'table' => 'civicrm_tag',
224 'labelColumn' => 'name',
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',
235 'table_name' => 'civicrm_tag',
237 'bao' => 'CRM_Core_BAO_Tag',
242 'name' => 'is_reserved',
243 'type' => CRM_Utils_Type
::T_BOOLEAN
,
244 'title' => ts('Reserved'),
245 'where' => 'civicrm_tag.is_reserved',
247 'table_name' => 'civicrm_tag',
249 'bao' => 'CRM_Core_BAO_Tag',
254 'name' => 'is_tagset',
255 'type' => CRM_Utils_Type
::T_BOOLEAN
,
256 'title' => ts('Tagset'),
257 'where' => 'civicrm_tag.is_tagset',
259 'table_name' => 'civicrm_tag',
261 'bao' => 'CRM_Core_BAO_Tag',
266 'name' => 'used_for',
267 'type' => CRM_Utils_Type
::T_STRING
,
268 'title' => ts('Used For'),
270 'size' => CRM_Utils_Type
::BIG
,
271 'where' => 'civicrm_tag.used_for',
273 'table_name' => 'civicrm_tag',
275 'bao' => 'CRM_Core_BAO_Tag',
277 'serialize' => self
::SERIALIZE_COMMA
,
281 'pseudoconstant' => [
282 'optionGroupName' => 'tag_used_for',
283 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
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',
295 'bao' => 'CRM_Core_BAO_Tag',
297 'FKClassName' => 'CRM_Contact_DAO_Contact',
299 'label' => ts("Created By"),
305 'type' => CRM_Utils_Type
::T_STRING
,
306 'title' => ts('Color'),
307 'description' => ts('Hex color value e.g. #ffffff'),
309 'size' => CRM_Utils_Type
::HUGE
,
310 'where' => 'civicrm_tag.color',
312 'table_name' => 'civicrm_tag',
314 'bao' => 'CRM_Core_BAO_Tag',
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',
326 'bao' => 'CRM_Core_BAO_Tag',
331 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
333 return Civi
::$statics[__CLASS__
]['fields'];
337 * Return a mapping from field-name to the corresponding key (as used in fields()).
340 * Array(string $name => string $uniqueName).
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()));
346 return Civi
::$statics[__CLASS__
]['fieldKeys'];
350 * Returns the names of this table
354 public static function getTableName() {
355 return self
::$_tableName;
359 * Returns if this table needs to be logged
363 public function getLog() {
368 * Returns the list of fields that can be imported
370 * @param bool $prefix
374 public static function &import($prefix = FALSE) {
375 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'tag', $prefix, []);
380 * Returns the list of fields that can be exported
382 * @param bool $prefix
386 public static function &export($prefix = FALSE) {
387 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'tag', $prefix, []);
392 * Returns the list of indices
394 * @param bool $localize
398 public static function indices($localize = TRUE) {
405 'localizable' => FALSE,
407 'sig' => 'civicrm_tag::1::name',
410 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;