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