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