Merge pull request #15998 from demeritcowboy/case-audit-skip-broken
[civicrm-core.git] / CRM / Contact / DAO / ContactType.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/ContactType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
f29bf4f3 9 * (GenCodeChecksum:3ad338181596a9b5e3a9f6549fd381c9)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the ContactType entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_contact_type';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = FALSE;
c3fc2621 30
e501603b
TO
31 /**
32 * Contact Type ID
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Internal name of Contact Type (or Subtype).
40 *
41 * @var string
42 */
43 public $name;
c3fc2621 44
e501603b
TO
45 /**
46 * localized Name of Contact Type.
47 *
48 * @var string
49 */
50 public $label;
c3fc2621 51
e501603b
TO
52 /**
53 * localized Optional verbose description of the type.
54 *
55 * @var text
56 */
57 public $description;
c3fc2621 58
e501603b
TO
59 /**
60 * URL of image if any.
61 *
62 * @var string
63 */
64 public $image_URL;
c3fc2621 65
e501603b
TO
66 /**
67 * Optional FK to parent contact type.
68 *
e6ca0a57 69 * @var int
e501603b
TO
70 */
71 public $parent_id;
c3fc2621 72
e501603b
TO
73 /**
74 * Is this entry active?
75 *
e6ca0a57 76 * @var bool
e501603b
TO
77 */
78 public $is_active;
c3fc2621 79
e501603b
TO
80 /**
81 * Is this contact type a predefined system type
82 *
e6ca0a57 83 * @var bool
e501603b
TO
84 */
85 public $is_reserved;
c3fc2621 86
e501603b 87 /**
f41f0342 88 * Class constructor.
e501603b 89 */
c3fc2621 90 public function __construct() {
e501603b
TO
91 $this->__table = 'civicrm_contact_type';
92 parent::__construct();
93 }
c3fc2621 94
e501603b 95 /**
f41f0342 96 * Returns foreign keys and entity references.
e501603b
TO
97 *
98 * @return array
99 * [CRM_Core_Reference_Interface]
100 */
c3fc2621 101 public static function getReferenceColumns() {
346aaaba 102 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 103 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 104 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
346aaaba 105 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 106 }
346aaaba 107 return Civi::$statics[__CLASS__]['links'];
e501603b 108 }
c3fc2621 109
e501603b
TO
110 /**
111 * Returns all the column names of this table
112 *
113 * @return array
114 */
c3fc2621 115 public static function &fields() {
346aaaba 116 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
117 Civi::$statics[__CLASS__]['fields'] = [
118 'id' => [
e501603b
TO
119 'name' => 'id',
120 'type' => CRM_Utils_Type::T_INT,
c3fc2621 121 'title' => ts('Contact Type ID'),
215b423e 122 'description' => ts('Contact Type ID'),
c3fc2621 123 'required' => TRUE,
a36434b9 124 'where' => 'civicrm_contact_type.id',
522a26c9 125 'table_name' => 'civicrm_contact_type',
126 'entity' => 'ContactType',
127 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 128 'localizable' => 0,
c3fc2621
CW
129 ],
130 'name' => [
e501603b
TO
131 'name' => 'name',
132 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 133 'title' => ts('Name'),
215b423e 134 'description' => ts('Internal name of Contact Type (or Subtype).'),
e501603b
TO
135 'maxlength' => 64,
136 'size' => CRM_Utils_Type::BIG,
a36434b9 137 'where' => 'civicrm_contact_type.name',
522a26c9 138 'table_name' => 'civicrm_contact_type',
139 'entity' => 'ContactType',
140 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 141 'localizable' => 0,
c3fc2621
CW
142 ],
143 'label' => [
e501603b
TO
144 'name' => 'label',
145 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 146 'title' => ts('Contact Type Label'),
215b423e 147 'description' => ts('localized Name of Contact Type.'),
e501603b
TO
148 'maxlength' => 64,
149 'size' => CRM_Utils_Type::BIG,
a36434b9 150 'where' => 'civicrm_contact_type.label',
522a26c9 151 'table_name' => 'civicrm_contact_type',
152 'entity' => 'ContactType',
153 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 154 'localizable' => 1,
c3fc2621
CW
155 ],
156 'description' => [
e501603b
TO
157 'name' => 'description',
158 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 159 'title' => ts('Contact Type Description'),
215b423e 160 'description' => ts('localized Optional verbose description of the type.'),
e501603b
TO
161 'rows' => 2,
162 'cols' => 60,
a36434b9 163 'where' => 'civicrm_contact_type.description',
522a26c9 164 'table_name' => 'civicrm_contact_type',
165 'entity' => 'ContactType',
166 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 167 'localizable' => 1,
c3fc2621 168 'html' => [
e501603b 169 'type' => 'TextArea',
c3fc2621
CW
170 ],
171 ],
172 'image_URL' => [
e501603b
TO
173 'name' => 'image_URL',
174 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 175 'title' => ts('Contact Type Image URL'),
215b423e 176 'description' => ts('URL of image if any.'),
e501603b
TO
177 'maxlength' => 255,
178 'size' => CRM_Utils_Type::HUGE,
a36434b9 179 'where' => 'civicrm_contact_type.image_URL',
522a26c9 180 'table_name' => 'civicrm_contact_type',
181 'entity' => 'ContactType',
182 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 183 'localizable' => 0,
c3fc2621
CW
184 ],
185 'parent_id' => [
e501603b
TO
186 'name' => 'parent_id',
187 'type' => CRM_Utils_Type::T_INT,
c3fc2621 188 'title' => ts('Contact Type Parent'),
215b423e 189 'description' => ts('Optional FK to parent contact type.'),
a36434b9 190 'where' => 'civicrm_contact_type.parent_id',
522a26c9 191 'table_name' => 'civicrm_contact_type',
192 'entity' => 'ContactType',
193 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 194 'localizable' => 0,
e501603b 195 'FKClassName' => 'CRM_Contact_DAO_ContactType',
c3fc2621 196 'pseudoconstant' => [
e501603b
TO
197 'table' => 'civicrm_contact_type',
198 'keyColumn' => 'id',
199 'labelColumn' => 'label',
200 'condition' => 'parent_id IS NULL',
e6ca0a57 201 ],
c3fc2621
CW
202 ],
203 'is_active' => [
e501603b
TO
204 'name' => 'is_active',
205 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 206 'title' => ts('Contact Type Is Active?'),
215b423e 207 'description' => ts('Is this entry active?'),
a36434b9 208 'where' => 'civicrm_contact_type.is_active',
522a26c9 209 'table_name' => 'civicrm_contact_type',
210 'entity' => 'ContactType',
211 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 212 'localizable' => 0,
c3fc2621
CW
213 ],
214 'is_reserved' => [
e501603b
TO
215 'name' => 'is_reserved',
216 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 217 'title' => ts('Contact Type is Reserved?'),
215b423e 218 'description' => ts('Is this contact type a predefined system type'),
a36434b9 219 'where' => 'civicrm_contact_type.is_reserved',
522a26c9 220 'table_name' => 'civicrm_contact_type',
221 'entity' => 'ContactType',
222 'bao' => 'CRM_Contact_BAO_ContactType',
6a7e5e5d 223 'localizable' => 0,
c3fc2621
CW
224 ],
225 ];
346aaaba 226 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 227 }
346aaaba 228 return Civi::$statics[__CLASS__]['fields'];
e501603b 229 }
c3fc2621 230
e501603b 231 /**
bd8e0b14 232 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
233 *
234 * @return array
bd8e0b14 235 * Array(string $name => string $uniqueName).
e501603b 236 */
c3fc2621 237 public static function &fieldKeys() {
bd8e0b14
TO
238 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
239 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 240 }
bd8e0b14 241 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 242 }
c3fc2621 243
e501603b
TO
244 /**
245 * Returns the names of this table
246 *
247 * @return string
248 */
c3fc2621 249 public static function getTableName() {
e501603b
TO
250 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
251 }
c3fc2621 252
e501603b
TO
253 /**
254 * Returns if this table needs to be logged
255 *
c3fc2621 256 * @return bool
e501603b 257 */
c3fc2621 258 public function getLog() {
e501603b
TO
259 return self::$_log;
260 }
c3fc2621 261
e501603b
TO
262 /**
263 * Returns the list of fields that can be imported
264 *
265 * @param bool $prefix
266 *
267 * @return array
268 */
c3fc2621
CW
269 public static function &import($prefix = FALSE) {
270 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, []);
60808919 271 return $r;
e501603b 272 }
c3fc2621 273
e501603b
TO
274 /**
275 * Returns the list of fields that can be exported
276 *
277 * @param bool $prefix
278 *
279 * @return array
280 */
c3fc2621
CW
281 public static function &export($prefix = FALSE) {
282 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, []);
60808919 283 return $r;
e501603b 284 }
c3fc2621 285
e7a6b91a
AS
286 /**
287 * Returns the list of indices
c3fc2621
CW
288 *
289 * @param bool $localize
290 *
291 * @return array
e7a6b91a
AS
292 */
293 public static function indices($localize = TRUE) {
c3fc2621
CW
294 $indices = [
295 'contact_type' => [
e7a6b91a 296 'name' => 'contact_type',
c3fc2621 297 'field' => [
e7a6b91a 298 0 => 'name',
c3fc2621
CW
299 ],
300 'localizable' => FALSE,
301 'unique' => TRUE,
e7a6b91a 302 'sig' => 'civicrm_contact_type::1::name',
c3fc2621
CW
303 ],
304 ];
e7a6b91a
AS
305 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
306 }
c3fc2621 307
e501603b 308}