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:9719ec84435a76decf1937f7a389ac7f)
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;
41 * Internal name of Contact Type (or Subtype).
48 * localized Name of Contact Type.
55 * localized Optional verbose description of the type.
62 * URL of image if any.
69 * Optional FK to parent contact type.
76 * Is this entry active?
83 * Is this contact type a predefined system type
92 public function __construct() {
93 $this->__table
= 'civicrm_contact_type';
94 parent
::__construct();
98 * Returns localized title of this entity.
100 * @param bool $plural
101 * Whether to return the plural version of the title.
103 public static function getEntityTitle($plural = FALSE) {
104 return $plural ?
ts('Contact Types') : ts('Contact Type');
108 * Returns foreign keys and entity references.
111 * [CRM_Core_Reference_Interface]
113 public static function getReferenceColumns() {
114 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
115 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
116 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
117 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
119 return Civi
::$statics[__CLASS__
]['links'];
123 * Returns all the column names of this table
127 public static function &fields() {
128 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
129 Civi
::$statics[__CLASS__
]['fields'] = [
132 'type' => CRM_Utils_Type
::T_INT
,
133 'title' => ts('Contact Type ID'),
134 'description' => ts('Contact Type ID'),
136 'where' => 'civicrm_contact_type.id',
137 'table_name' => 'civicrm_contact_type',
138 'entity' => 'ContactType',
139 'bao' => 'CRM_Contact_BAO_ContactType',
145 'type' => CRM_Utils_Type
::T_STRING
,
146 'title' => ts('Name'),
147 'description' => ts('Internal name of Contact Type (or Subtype).'),
150 'size' => CRM_Utils_Type
::BIG
,
151 'where' => 'civicrm_contact_type.name',
152 'table_name' => 'civicrm_contact_type',
153 'entity' => 'ContactType',
154 'bao' => 'CRM_Contact_BAO_ContactType',
160 'type' => CRM_Utils_Type
::T_STRING
,
161 'title' => ts('Contact Type Label'),
162 'description' => ts('localized Name of Contact Type.'),
164 'size' => CRM_Utils_Type
::BIG
,
165 'where' => 'civicrm_contact_type.label',
166 'table_name' => 'civicrm_contact_type',
167 'entity' => 'ContactType',
168 'bao' => 'CRM_Contact_BAO_ContactType',
173 'name' => 'description',
174 'type' => CRM_Utils_Type
::T_TEXT
,
175 'title' => ts('Contact Type Description'),
176 'description' => ts('localized Optional verbose description of the type.'),
179 'where' => 'civicrm_contact_type.description',
180 'table_name' => 'civicrm_contact_type',
181 'entity' => 'ContactType',
182 'bao' => 'CRM_Contact_BAO_ContactType',
185 'type' => 'TextArea',
190 'name' => 'image_URL',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Contact Type Image URL'),
193 'description' => ts('URL of image if any.'),
195 'size' => CRM_Utils_Type
::HUGE
,
196 'where' => 'civicrm_contact_type.image_URL',
197 'table_name' => 'civicrm_contact_type',
198 'entity' => 'ContactType',
199 'bao' => 'CRM_Contact_BAO_ContactType',
204 'name' => 'parent_id',
205 'type' => CRM_Utils_Type
::T_INT
,
206 'title' => ts('Contact Type Parent'),
207 'description' => ts('Optional FK to parent contact type.'),
208 'where' => 'civicrm_contact_type.parent_id',
209 'table_name' => 'civicrm_contact_type',
210 'entity' => 'ContactType',
211 'bao' => 'CRM_Contact_BAO_ContactType',
213 'FKClassName' => 'CRM_Contact_DAO_ContactType',
214 'pseudoconstant' => [
215 'table' => 'civicrm_contact_type',
217 'labelColumn' => 'label',
218 'condition' => 'parent_id IS NULL',
223 'name' => 'is_active',
224 'type' => CRM_Utils_Type
::T_BOOLEAN
,
225 'title' => ts('Contact Type Is Active?'),
226 'description' => ts('Is this entry active?'),
227 'where' => 'civicrm_contact_type.is_active',
229 'table_name' => 'civicrm_contact_type',
230 'entity' => 'ContactType',
231 'bao' => 'CRM_Contact_BAO_ContactType',
236 'name' => 'is_reserved',
237 'type' => CRM_Utils_Type
::T_BOOLEAN
,
238 'title' => ts('Contact Type is Reserved?'),
239 'description' => ts('Is this contact type a predefined system type'),
240 'where' => 'civicrm_contact_type.is_reserved',
242 'table_name' => 'civicrm_contact_type',
243 'entity' => 'ContactType',
244 'bao' => 'CRM_Contact_BAO_ContactType',
249 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
251 return Civi
::$statics[__CLASS__
]['fields'];
255 * Return a mapping from field-name to the corresponding key (as used in fields()).
258 * Array(string $name => string $uniqueName).
260 public static function &fieldKeys() {
261 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
262 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
264 return Civi
::$statics[__CLASS__
]['fieldKeys'];
268 * Returns the names of this table
272 public static function getTableName() {
273 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
277 * Returns if this table needs to be logged
281 public function getLog() {
286 * Returns the list of fields that can be imported
288 * @param bool $prefix
292 public static function &import($prefix = FALSE) {
293 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact_type', $prefix, []);
298 * Returns the list of fields that can be exported
300 * @param bool $prefix
304 public static function &export($prefix = FALSE) {
305 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact_type', $prefix, []);
310 * Returns the list of indices
312 * @param bool $localize
316 public static function indices($localize = TRUE) {
319 'name' => 'contact_type',
323 'localizable' => FALSE,
325 'sig' => 'civicrm_contact_type::1::name',
328 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;