| 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:18f8021635fed59be1eabc246f6b88cb) |
| 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 | 'pseudoconstant' => [ |
| 186 | 'table' => 'civicrm_tag', |
| 187 | 'keyColumn' => 'id', |
| 188 | 'labelColumn' => 'name', |
| 189 | ], |
| 190 | ], |
| 191 | 'is_selectable' => [ |
| 192 | 'name' => 'is_selectable', |
| 193 | 'type' => CRM_Utils_Type::T_BOOLEAN, |
| 194 | 'title' => ts('Display Tag?'), |
| 195 | 'description' => ts('Is this tag selectable / displayed'), |
| 196 | 'where' => 'civicrm_tag.is_selectable', |
| 197 | 'default' => '1', |
| 198 | 'table_name' => 'civicrm_tag', |
| 199 | 'entity' => 'Tag', |
| 200 | 'bao' => 'CRM_Core_BAO_Tag', |
| 201 | 'localizable' => 0, |
| 202 | ], |
| 203 | 'is_reserved' => [ |
| 204 | 'name' => 'is_reserved', |
| 205 | 'type' => CRM_Utils_Type::T_BOOLEAN, |
| 206 | 'title' => ts('Reserved'), |
| 207 | 'where' => 'civicrm_tag.is_reserved', |
| 208 | 'default' => '0', |
| 209 | 'table_name' => 'civicrm_tag', |
| 210 | 'entity' => 'Tag', |
| 211 | 'bao' => 'CRM_Core_BAO_Tag', |
| 212 | 'localizable' => 0, |
| 213 | ], |
| 214 | 'is_tagset' => [ |
| 215 | 'name' => 'is_tagset', |
| 216 | 'type' => CRM_Utils_Type::T_BOOLEAN, |
| 217 | 'title' => ts('Tagset'), |
| 218 | 'where' => 'civicrm_tag.is_tagset', |
| 219 | 'default' => '0', |
| 220 | 'table_name' => 'civicrm_tag', |
| 221 | 'entity' => 'Tag', |
| 222 | 'bao' => 'CRM_Core_BAO_Tag', |
| 223 | 'localizable' => 0, |
| 224 | ], |
| 225 | 'used_for' => [ |
| 226 | 'name' => 'used_for', |
| 227 | 'type' => CRM_Utils_Type::T_STRING, |
| 228 | 'title' => ts('Used For'), |
| 229 | 'maxlength' => 64, |
| 230 | 'size' => CRM_Utils_Type::BIG, |
| 231 | 'where' => 'civicrm_tag.used_for', |
| 232 | 'default' => 'NULL', |
| 233 | 'table_name' => 'civicrm_tag', |
| 234 | 'entity' => 'Tag', |
| 235 | 'bao' => 'CRM_Core_BAO_Tag', |
| 236 | 'localizable' => 0, |
| 237 | 'serialize' => self::SERIALIZE_COMMA, |
| 238 | 'html' => [ |
| 239 | 'type' => 'Select', |
| 240 | ], |
| 241 | 'pseudoconstant' => [ |
| 242 | 'optionGroupName' => 'tag_used_for', |
| 243 | 'optionEditPath' => 'civicrm/admin/options/tag_used_for', |
| 244 | ], |
| 245 | ], |
| 246 | 'created_id' => [ |
| 247 | 'name' => 'created_id', |
| 248 | 'type' => CRM_Utils_Type::T_INT, |
| 249 | 'title' => ts('Tag Created By'), |
| 250 | 'description' => ts('FK to civicrm_contact, who created this tag'), |
| 251 | 'where' => 'civicrm_tag.created_id', |
| 252 | 'table_name' => 'civicrm_tag', |
| 253 | 'entity' => 'Tag', |
| 254 | 'bao' => 'CRM_Core_BAO_Tag', |
| 255 | 'localizable' => 0, |
| 256 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
| 257 | ], |
| 258 | 'color' => [ |
| 259 | 'name' => 'color', |
| 260 | 'type' => CRM_Utils_Type::T_STRING, |
| 261 | 'title' => ts('Color'), |
| 262 | 'description' => ts('Hex color value e.g. #ffffff'), |
| 263 | 'maxlength' => 255, |
| 264 | 'size' => CRM_Utils_Type::HUGE, |
| 265 | 'where' => 'civicrm_tag.color', |
| 266 | 'default' => 'NULL', |
| 267 | 'table_name' => 'civicrm_tag', |
| 268 | 'entity' => 'Tag', |
| 269 | 'bao' => 'CRM_Core_BAO_Tag', |
| 270 | 'localizable' => 0, |
| 271 | ], |
| 272 | 'created_date' => [ |
| 273 | 'name' => 'created_date', |
| 274 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, |
| 275 | 'title' => ts('Tag Created Date'), |
| 276 | 'description' => ts('Date and time that tag was created.'), |
| 277 | 'where' => 'civicrm_tag.created_date', |
| 278 | 'table_name' => 'civicrm_tag', |
| 279 | 'entity' => 'Tag', |
| 280 | 'bao' => 'CRM_Core_BAO_Tag', |
| 281 | 'localizable' => 0, |
| 282 | ], |
| 283 | ]; |
| 284 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
| 285 | } |
| 286 | return Civi::$statics[__CLASS__]['fields']; |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
| 291 | * |
| 292 | * @return array |
| 293 | * Array(string $name => string $uniqueName). |
| 294 | */ |
| 295 | public static function &fieldKeys() { |
| 296 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
| 297 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); |
| 298 | } |
| 299 | return Civi::$statics[__CLASS__]['fieldKeys']; |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Returns the names of this table |
| 304 | * |
| 305 | * @return string |
| 306 | */ |
| 307 | public static function getTableName() { |
| 308 | return self::$_tableName; |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Returns if this table needs to be logged |
| 313 | * |
| 314 | * @return bool |
| 315 | */ |
| 316 | public function getLog() { |
| 317 | return self::$_log; |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * Returns the list of fields that can be imported |
| 322 | * |
| 323 | * @param bool $prefix |
| 324 | * |
| 325 | * @return array |
| 326 | */ |
| 327 | public static function &import($prefix = FALSE) { |
| 328 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'tag', $prefix, []); |
| 329 | return $r; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Returns the list of fields that can be exported |
| 334 | * |
| 335 | * @param bool $prefix |
| 336 | * |
| 337 | * @return array |
| 338 | */ |
| 339 | public static function &export($prefix = FALSE) { |
| 340 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'tag', $prefix, []); |
| 341 | return $r; |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Returns the list of indices |
| 346 | * |
| 347 | * @param bool $localize |
| 348 | * |
| 349 | * @return array |
| 350 | */ |
| 351 | public static function indices($localize = TRUE) { |
| 352 | $indices = [ |
| 353 | 'UI_name' => [ |
| 354 | 'name' => 'UI_name', |
| 355 | 'field' => [ |
| 356 | 0 => 'name', |
| 357 | ], |
| 358 | 'localizable' => FALSE, |
| 359 | 'unique' => TRUE, |
| 360 | 'sig' => 'civicrm_tag::1::name', |
| 361 | ], |
| 362 | ]; |
| 363 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
| 364 | } |
| 365 | |
| 366 | } |