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