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