5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/ContactType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:c2f6858290ecb933caba200b565c69bd)
13 * Database access object for the ContactType entity.
15 class CRM_Contact_DAO_ContactType
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '3.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_contact_type';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = FALSE;
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
43 * Internal name of Contact Type (or Subtype).
46 * (SQL type: varchar(64))
47 * Note that values will be retrieved from the database as a string.
52 * localized Name of Contact Type.
55 * (SQL type: varchar(64))
56 * Note that values will be retrieved from the database as a string.
61 * localized Optional verbose description of the type.
65 * Note that values will be retrieved from the database as a string.
70 * URL of image if any.
73 * (SQL type: varchar(255))
74 * Note that values will be retrieved from the database as a string.
79 * crm-i icon class representing this contact type
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
88 * Optional FK to parent contact type.
90 * @var int|string|null
91 * (SQL type: int unsigned)
92 * Note that values will be retrieved from the database as a string.
97 * Is this entry active?
100 * (SQL type: tinyint)
101 * Note that values will be retrieved from the database as a string.
106 * Is this contact type a predefined system type
109 * (SQL type: tinyint)
110 * Note that values will be retrieved from the database as a string.
117 public function __construct() {
118 $this->__table
= 'civicrm_contact_type';
119 parent
::__construct();
123 * Returns localized title of this entity.
125 * @param bool $plural
126 * Whether to return the plural version of the title.
128 public static function getEntityTitle($plural = FALSE) {
129 return $plural ?
ts('Contact Types') : ts('Contact Type');
133 * Returns foreign keys and entity references.
136 * [CRM_Core_Reference_Interface]
138 public static function getReferenceColumns() {
139 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
140 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
141 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
142 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
144 return Civi
::$statics[__CLASS__
]['links'];
148 * Returns all the column names of this table
152 public static function &fields() {
153 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
154 Civi
::$statics[__CLASS__
]['fields'] = [
157 'type' => CRM_Utils_Type
::T_INT
,
158 'title' => ts('Contact Type ID'),
159 'description' => ts('Contact Type ID'),
161 'where' => 'civicrm_contact_type.id',
162 'table_name' => 'civicrm_contact_type',
163 'entity' => 'ContactType',
164 'bao' => 'CRM_Contact_BAO_ContactType',
174 'type' => CRM_Utils_Type
::T_STRING
,
175 'title' => ts('Name'),
176 'description' => ts('Internal name of Contact Type (or Subtype).'),
179 'size' => CRM_Utils_Type
::BIG
,
180 'where' => 'civicrm_contact_type.name',
181 'table_name' => 'civicrm_contact_type',
182 'entity' => 'ContactType',
183 'bao' => 'CRM_Contact_BAO_ContactType',
186 'label' => ts("Name"),
192 'type' => CRM_Utils_Type
::T_STRING
,
193 'title' => ts('Contact Type Label'),
194 'description' => ts('localized Name of Contact Type.'),
196 'size' => CRM_Utils_Type
::BIG
,
197 'where' => 'civicrm_contact_type.label',
198 'table_name' => 'civicrm_contact_type',
199 'entity' => 'ContactType',
200 'bao' => 'CRM_Contact_BAO_ContactType',
205 'name' => 'description',
206 'type' => CRM_Utils_Type
::T_TEXT
,
207 'title' => ts('Contact Type Description'),
208 'description' => ts('localized Optional verbose description of the type.'),
211 'where' => 'civicrm_contact_type.description',
212 'table_name' => 'civicrm_contact_type',
213 'entity' => 'ContactType',
214 'bao' => 'CRM_Contact_BAO_ContactType',
217 'type' => 'TextArea',
222 'name' => 'image_URL',
223 'type' => CRM_Utils_Type
::T_STRING
,
224 'title' => ts('Contact Type Image URL'),
225 'description' => ts('URL of image if any.'),
227 'size' => CRM_Utils_Type
::HUGE
,
228 'where' => 'civicrm_contact_type.image_URL',
229 'table_name' => 'civicrm_contact_type',
230 'entity' => 'ContactType',
231 'bao' => 'CRM_Contact_BAO_ContactType',
237 'type' => CRM_Utils_Type
::T_STRING
,
238 'title' => ts('Icon'),
239 'description' => ts('crm-i icon class representing this contact type'),
241 'size' => CRM_Utils_Type
::HUGE
,
242 'where' => 'civicrm_contact_type.icon',
244 'table_name' => 'civicrm_contact_type',
245 'entity' => 'ContactType',
246 'bao' => 'CRM_Contact_BAO_ContactType',
251 'name' => 'parent_id',
252 'type' => CRM_Utils_Type
::T_INT
,
253 'title' => ts('Parent ID'),
254 'description' => ts('Optional FK to parent contact type.'),
255 'where' => 'civicrm_contact_type.parent_id',
256 'table_name' => 'civicrm_contact_type',
257 'entity' => 'ContactType',
258 'bao' => 'CRM_Contact_BAO_ContactType',
260 'FKClassName' => 'CRM_Contact_DAO_ContactType',
262 'label' => ts("Parent"),
264 'pseudoconstant' => [
265 'table' => 'civicrm_contact_type',
267 'labelColumn' => 'label',
268 'condition' => 'parent_id IS NULL',
273 'name' => 'is_active',
274 'type' => CRM_Utils_Type
::T_BOOLEAN
,
275 'title' => ts('Contact Type Is Active?'),
276 'description' => ts('Is this entry active?'),
278 'where' => 'civicrm_contact_type.is_active',
280 'table_name' => 'civicrm_contact_type',
281 'entity' => 'ContactType',
282 'bao' => 'CRM_Contact_BAO_ContactType',
287 'name' => 'is_reserved',
288 'type' => CRM_Utils_Type
::T_BOOLEAN
,
289 'title' => ts('Contact Type is Reserved?'),
290 'description' => ts('Is this contact type a predefined system type'),
292 'where' => 'civicrm_contact_type.is_reserved',
294 'table_name' => 'civicrm_contact_type',
295 'entity' => 'ContactType',
296 'bao' => 'CRM_Contact_BAO_ContactType',
301 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
303 return Civi
::$statics[__CLASS__
]['fields'];
307 * Return a mapping from field-name to the corresponding key (as used in fields()).
310 * Array(string $name => string $uniqueName).
312 public static function &fieldKeys() {
313 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
314 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
316 return Civi
::$statics[__CLASS__
]['fieldKeys'];
320 * Returns the names of this table
324 public static function getTableName() {
325 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
329 * Returns if this table needs to be logged
333 public function getLog() {
338 * Returns the list of fields that can be imported
340 * @param bool $prefix
344 public static function &import($prefix = FALSE) {
345 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact_type', $prefix, []);
350 * Returns the list of fields that can be exported
352 * @param bool $prefix
356 public static function &export($prefix = FALSE) {
357 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact_type', $prefix, []);
362 * Returns the list of indices
364 * @param bool $localize
368 public static function indices($localize = TRUE) {
371 'name' => 'contact_type',
375 'localizable' => FALSE,
377 'sig' => 'civicrm_contact_type::1::name',
380 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;