Merge pull request #23178 from civicrm/5.49
[civicrm-core.git] / CRM / Contact / DAO / ContactType.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/ContactType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:c2f6858290ecb933caba200b565c69bd)
10 */
11
12 /**
13 * Database access object for the ContactType entity.
14 */
15 class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_contact_type';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Contact Type ID
35 *
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
39 */
40 public $id;
41
42 /**
43 * Internal name of Contact Type (or Subtype).
44 *
45 * @var string
46 * (SQL type: varchar(64))
47 * Note that values will be retrieved from the database as a string.
48 */
49 public $name;
50
51 /**
52 * localized Name of Contact Type.
53 *
54 * @var string|null
55 * (SQL type: varchar(64))
56 * Note that values will be retrieved from the database as a string.
57 */
58 public $label;
59
60 /**
61 * localized Optional verbose description of the type.
62 *
63 * @var string|null
64 * (SQL type: text)
65 * Note that values will be retrieved from the database as a string.
66 */
67 public $description;
68
69 /**
70 * URL of image if any.
71 *
72 * @var string|null
73 * (SQL type: varchar(255))
74 * Note that values will be retrieved from the database as a string.
75 */
76 public $image_URL;
77
78 /**
79 * crm-i icon class representing this contact type
80 *
81 * @var string|null
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
84 */
85 public $icon;
86
87 /**
88 * Optional FK to parent contact type.
89 *
90 * @var int|string|null
91 * (SQL type: int unsigned)
92 * Note that values will be retrieved from the database as a string.
93 */
94 public $parent_id;
95
96 /**
97 * Is this entry active?
98 *
99 * @var bool|string
100 * (SQL type: tinyint)
101 * Note that values will be retrieved from the database as a string.
102 */
103 public $is_active;
104
105 /**
106 * Is this contact type a predefined system type
107 *
108 * @var bool|string
109 * (SQL type: tinyint)
110 * Note that values will be retrieved from the database as a string.
111 */
112 public $is_reserved;
113
114 /**
115 * Class constructor.
116 */
117 public function __construct() {
118 $this->__table = 'civicrm_contact_type';
119 parent::__construct();
120 }
121
122 /**
123 * Returns localized title of this entity.
124 *
125 * @param bool $plural
126 * Whether to return the plural version of the title.
127 */
128 public static function getEntityTitle($plural = FALSE) {
129 return $plural ? ts('Contact Types') : ts('Contact Type');
130 }
131
132 /**
133 * Returns foreign keys and entity references.
134 *
135 * @return array
136 * [CRM_Core_Reference_Interface]
137 */
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']);
143 }
144 return Civi::$statics[__CLASS__]['links'];
145 }
146
147 /**
148 * Returns all the column names of this table
149 *
150 * @return array
151 */
152 public static function &fields() {
153 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
154 Civi::$statics[__CLASS__]['fields'] = [
155 'id' => [
156 'name' => 'id',
157 'type' => CRM_Utils_Type::T_INT,
158 'title' => ts('Contact Type ID'),
159 'description' => ts('Contact Type ID'),
160 'required' => TRUE,
161 'where' => 'civicrm_contact_type.id',
162 'table_name' => 'civicrm_contact_type',
163 'entity' => 'ContactType',
164 'bao' => 'CRM_Contact_BAO_ContactType',
165 'localizable' => 0,
166 'html' => [
167 'type' => 'Number',
168 ],
169 'readonly' => TRUE,
170 'add' => '1.1',
171 ],
172 'name' => [
173 'name' => 'name',
174 'type' => CRM_Utils_Type::T_STRING,
175 'title' => ts('Name'),
176 'description' => ts('Internal name of Contact Type (or Subtype).'),
177 'required' => TRUE,
178 'maxlength' => 64,
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',
184 'localizable' => 0,
185 'html' => [
186 'label' => ts("Name"),
187 ],
188 'add' => '3.1',
189 ],
190 'label' => [
191 'name' => 'label',
192 'type' => CRM_Utils_Type::T_STRING,
193 'title' => ts('Contact Type Label'),
194 'description' => ts('localized Name of Contact Type.'),
195 'maxlength' => 64,
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',
201 'localizable' => 1,
202 'add' => '3.1',
203 ],
204 'description' => [
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.'),
209 'rows' => 2,
210 'cols' => 60,
211 'where' => 'civicrm_contact_type.description',
212 'table_name' => 'civicrm_contact_type',
213 'entity' => 'ContactType',
214 'bao' => 'CRM_Contact_BAO_ContactType',
215 'localizable' => 1,
216 'html' => [
217 'type' => 'TextArea',
218 ],
219 'add' => '3.1',
220 ],
221 'image_URL' => [
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.'),
226 'maxlength' => 255,
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',
232 'localizable' => 0,
233 'add' => '3.1',
234 ],
235 'icon' => [
236 'name' => 'icon',
237 'type' => CRM_Utils_Type::T_STRING,
238 'title' => ts('Icon'),
239 'description' => ts('crm-i icon class representing this contact type'),
240 'maxlength' => 255,
241 'size' => CRM_Utils_Type::HUGE,
242 'where' => 'civicrm_contact_type.icon',
243 'default' => NULL,
244 'table_name' => 'civicrm_contact_type',
245 'entity' => 'ContactType',
246 'bao' => 'CRM_Contact_BAO_ContactType',
247 'localizable' => 0,
248 'add' => '5.49',
249 ],
250 'parent_id' => [
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',
259 'localizable' => 0,
260 'FKClassName' => 'CRM_Contact_DAO_ContactType',
261 'html' => [
262 'label' => ts("Parent"),
263 ],
264 'pseudoconstant' => [
265 'table' => 'civicrm_contact_type',
266 'keyColumn' => 'id',
267 'labelColumn' => 'label',
268 'condition' => 'parent_id IS NULL',
269 ],
270 'add' => '3.1',
271 ],
272 'is_active' => [
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?'),
277 'required' => TRUE,
278 'where' => 'civicrm_contact_type.is_active',
279 'default' => '1',
280 'table_name' => 'civicrm_contact_type',
281 'entity' => 'ContactType',
282 'bao' => 'CRM_Contact_BAO_ContactType',
283 'localizable' => 0,
284 'add' => '3.1',
285 ],
286 'is_reserved' => [
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'),
291 'required' => TRUE,
292 'where' => 'civicrm_contact_type.is_reserved',
293 'default' => '0',
294 'table_name' => 'civicrm_contact_type',
295 'entity' => 'ContactType',
296 'bao' => 'CRM_Contact_BAO_ContactType',
297 'localizable' => 0,
298 'add' => '3.1',
299 ],
300 ];
301 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
302 }
303 return Civi::$statics[__CLASS__]['fields'];
304 }
305
306 /**
307 * Return a mapping from field-name to the corresponding key (as used in fields()).
308 *
309 * @return array
310 * Array(string $name => string $uniqueName).
311 */
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()));
315 }
316 return Civi::$statics[__CLASS__]['fieldKeys'];
317 }
318
319 /**
320 * Returns the names of this table
321 *
322 * @return string
323 */
324 public static function getTableName() {
325 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
326 }
327
328 /**
329 * Returns if this table needs to be logged
330 *
331 * @return bool
332 */
333 public function getLog() {
334 return self::$_log;
335 }
336
337 /**
338 * Returns the list of fields that can be imported
339 *
340 * @param bool $prefix
341 *
342 * @return array
343 */
344 public static function &import($prefix = FALSE) {
345 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, []);
346 return $r;
347 }
348
349 /**
350 * Returns the list of fields that can be exported
351 *
352 * @param bool $prefix
353 *
354 * @return array
355 */
356 public static function &export($prefix = FALSE) {
357 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, []);
358 return $r;
359 }
360
361 /**
362 * Returns the list of indices
363 *
364 * @param bool $localize
365 *
366 * @return array
367 */
368 public static function indices($localize = TRUE) {
369 $indices = [
370 'contact_type' => [
371 'name' => 'contact_type',
372 'field' => [
373 0 => 'name',
374 ],
375 'localizable' => FALSE,
376 'unique' => TRUE,
377 'sig' => 'civicrm_contact_type::1::name',
378 ],
379 ];
380 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
381 }
382
383 }