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:8a5eeefa40273898a4e3661b1ef43b3d)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
55 * Optional verbose description of the tag.
62 * Optional parent id for this tag.
69 * Is this tag selectable / displayed
73 public $is_selectable;
91 * FK to civicrm_contact, who created this tag
98 * Hex color value e.g. #ffffff
105 * Date and time that tag was created.
109 public $created_date;
114 public function __construct() {
115 $this->__table
= 'civicrm_tag';
116 parent
::__construct();
120 * Returns localized title of this entity.
122 * @param bool $plural
123 * Whether to return the plural version of the title.
125 public static function getEntityTitle($plural = FALSE) {
126 return $plural ?
ts('Tags') : ts('Tag');
130 * Returns foreign keys and entity references.
133 * [CRM_Core_Reference_Interface]
135 public static function getReferenceColumns() {
136 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
137 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
138 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_tag', 'id');
139 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
140 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
142 return Civi
::$statics[__CLASS__
]['links'];
146 * Returns all the column names of this table
150 public static function &fields() {
151 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
152 Civi
::$statics[__CLASS__
]['fields'] = [
155 'type' => CRM_Utils_Type
::T_INT
,
156 'title' => ts('Tag ID'),
157 'description' => ts('Tag ID'),
159 'where' => 'civicrm_tag.id',
160 'table_name' => 'civicrm_tag',
162 'bao' => 'CRM_Core_BAO_Tag',
168 'type' => CRM_Utils_Type
::T_STRING
,
169 'title' => ts('Tag Name'),
170 'description' => ts('Name of Tag.'),
173 'size' => CRM_Utils_Type
::BIG
,
174 'where' => 'civicrm_tag.name',
175 'table_name' => 'civicrm_tag',
177 'bao' => 'CRM_Core_BAO_Tag',
182 'name' => 'description',
183 'type' => CRM_Utils_Type
::T_STRING
,
184 'title' => ts('Description'),
185 'description' => ts('Optional verbose description of the tag.'),
187 'size' => CRM_Utils_Type
::HUGE
,
188 'where' => 'civicrm_tag.description',
189 'table_name' => 'civicrm_tag',
191 'bao' => 'CRM_Core_BAO_Tag',
196 'name' => 'parent_id',
197 'type' => CRM_Utils_Type
::T_INT
,
198 'title' => ts('Parent Tag'),
199 'description' => ts('Optional parent id for this tag.'),
200 'where' => 'civicrm_tag.parent_id',
202 'table_name' => 'civicrm_tag',
204 'bao' => 'CRM_Core_BAO_Tag',
206 'FKClassName' => 'CRM_Core_DAO_Tag',
207 'pseudoconstant' => [
208 'table' => 'civicrm_tag',
210 'labelColumn' => 'name',
215 'name' => 'is_selectable',
216 'type' => CRM_Utils_Type
::T_BOOLEAN
,
217 'title' => ts('Display Tag?'),
218 'description' => ts('Is this tag selectable / displayed'),
219 'where' => 'civicrm_tag.is_selectable',
221 'table_name' => 'civicrm_tag',
223 'bao' => 'CRM_Core_BAO_Tag',
228 'name' => 'is_reserved',
229 'type' => CRM_Utils_Type
::T_BOOLEAN
,
230 'title' => ts('Reserved'),
231 'where' => 'civicrm_tag.is_reserved',
233 'table_name' => 'civicrm_tag',
235 'bao' => 'CRM_Core_BAO_Tag',
240 'name' => 'is_tagset',
241 'type' => CRM_Utils_Type
::T_BOOLEAN
,
242 'title' => ts('Tagset'),
243 'where' => 'civicrm_tag.is_tagset',
245 'table_name' => 'civicrm_tag',
247 'bao' => 'CRM_Core_BAO_Tag',
252 'name' => 'used_for',
253 'type' => CRM_Utils_Type
::T_STRING
,
254 'title' => ts('Used For'),
256 'size' => CRM_Utils_Type
::BIG
,
257 'where' => 'civicrm_tag.used_for',
259 'table_name' => 'civicrm_tag',
261 'bao' => 'CRM_Core_BAO_Tag',
263 'serialize' => self
::SERIALIZE_COMMA
,
267 'pseudoconstant' => [
268 'optionGroupName' => 'tag_used_for',
269 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
274 'name' => 'created_id',
275 'type' => CRM_Utils_Type
::T_INT
,
276 'title' => ts('Tag Created By'),
277 'description' => ts('FK to civicrm_contact, who created this tag'),
278 'where' => 'civicrm_tag.created_id',
279 'table_name' => 'civicrm_tag',
281 'bao' => 'CRM_Core_BAO_Tag',
283 'FKClassName' => 'CRM_Contact_DAO_Contact',
288 'type' => CRM_Utils_Type
::T_STRING
,
289 'title' => ts('Color'),
290 'description' => ts('Hex color value e.g. #ffffff'),
292 'size' => CRM_Utils_Type
::HUGE
,
293 'where' => 'civicrm_tag.color',
295 'table_name' => 'civicrm_tag',
297 'bao' => 'CRM_Core_BAO_Tag',
302 'name' => 'created_date',
303 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
304 'title' => ts('Tag Created Date'),
305 'description' => ts('Date and time that tag was created.'),
306 'where' => 'civicrm_tag.created_date',
307 'table_name' => 'civicrm_tag',
309 'bao' => 'CRM_Core_BAO_Tag',
314 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
316 return Civi
::$statics[__CLASS__
]['fields'];
320 * Return a mapping from field-name to the corresponding key (as used in fields()).
323 * Array(string $name => string $uniqueName).
325 public static function &fieldKeys() {
326 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
327 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
329 return Civi
::$statics[__CLASS__
]['fieldKeys'];
333 * Returns the names of this table
337 public static function getTableName() {
338 return self
::$_tableName;
342 * Returns if this table needs to be logged
346 public function getLog() {
351 * Returns the list of fields that can be imported
353 * @param bool $prefix
357 public static function &import($prefix = FALSE) {
358 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'tag', $prefix, []);
363 * Returns the list of fields that can be exported
365 * @param bool $prefix
369 public static function &export($prefix = FALSE) {
370 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'tag', $prefix, []);
375 * Returns the list of indices
377 * @param bool $localize
381 public static function indices($localize = TRUE) {
388 'localizable' => FALSE,
390 'sig' => 'civicrm_tag::1::name',
393 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;