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