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/Core/Phone.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
d31fb4e3 | 9 | * (GenCodeChecksum:600322e85619a002b34c9faf0f02e5c8) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the Phone entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Core_DAO_Phone extends CRM_Core_DAO { |
929a1c14 CW |
16 | const EXT = 'civicrm'; |
17 | const TABLE_ADDED = '1.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_phone'; |
c3fc2621 | 25 | |
449c4e6b CW |
26 | /** |
27 | * Icon associated with this entity. | |
28 | * | |
29 | * @var string | |
30 | */ | |
31 | public static $_icon = 'fa-phone'; | |
32 | ||
e501603b | 33 | /** |
f41f0342 | 34 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b | 35 | * |
c3fc2621 | 36 | * @var bool |
e501603b | 37 | */ |
fa45b5b9 | 38 | public static $_log = TRUE; |
c3fc2621 | 39 | |
e501603b TO |
40 | /** |
41 | * Unique Phone ID | |
42 | * | |
e6ca0a57 | 43 | * @var int |
e501603b TO |
44 | */ |
45 | public $id; | |
c3fc2621 | 46 | |
e501603b TO |
47 | /** |
48 | * FK to Contact ID | |
49 | * | |
e6ca0a57 | 50 | * @var int |
e501603b TO |
51 | */ |
52 | public $contact_id; | |
c3fc2621 | 53 | |
e501603b TO |
54 | /** |
55 | * Which Location does this phone belong to. | |
56 | * | |
e6ca0a57 | 57 | * @var int |
e501603b TO |
58 | */ |
59 | public $location_type_id; | |
c3fc2621 | 60 | |
e501603b TO |
61 | /** |
62 | * Is this the primary phone for this contact and location. | |
63 | * | |
e6ca0a57 | 64 | * @var bool |
e501603b TO |
65 | */ |
66 | public $is_primary; | |
c3fc2621 | 67 | |
e501603b TO |
68 | /** |
69 | * Is this the billing? | |
70 | * | |
e6ca0a57 | 71 | * @var bool |
e501603b TO |
72 | */ |
73 | public $is_billing; | |
c3fc2621 | 74 | |
e501603b TO |
75 | /** |
76 | * Which Mobile Provider does this phone belong to. | |
77 | * | |
e6ca0a57 | 78 | * @var int |
e501603b TO |
79 | */ |
80 | public $mobile_provider_id; | |
c3fc2621 | 81 | |
e501603b TO |
82 | /** |
83 | * Complete phone number. | |
84 | * | |
85 | * @var string | |
86 | */ | |
87 | public $phone; | |
c3fc2621 | 88 | |
e501603b TO |
89 | /** |
90 | * Optional extension for a phone number. | |
91 | * | |
92 | * @var string | |
93 | */ | |
94 | public $phone_ext; | |
c3fc2621 | 95 | |
e501603b TO |
96 | /** |
97 | * Phone number stripped of all whitespace, letters, and punctuation. | |
98 | * | |
99 | * @var string | |
100 | */ | |
101 | public $phone_numeric; | |
c3fc2621 | 102 | |
e501603b TO |
103 | /** |
104 | * Which type of phone does this number belongs. | |
105 | * | |
e6ca0a57 | 106 | * @var int |
e501603b TO |
107 | */ |
108 | public $phone_type_id; | |
c3fc2621 | 109 | |
e501603b | 110 | /** |
f41f0342 | 111 | * Class constructor. |
e501603b | 112 | */ |
c3fc2621 | 113 | public function __construct() { |
e501603b TO |
114 | $this->__table = 'civicrm_phone'; |
115 | parent::__construct(); | |
116 | } | |
c3fc2621 | 117 | |
449c4e6b CW |
118 | /** |
119 | * Returns localized title of this entity. | |
7b66c3b5 AH |
120 | * |
121 | * @param bool $plural | |
122 | * Whether to return the plural version of the title. | |
449c4e6b | 123 | */ |
7b66c3b5 AH |
124 | public static function getEntityTitle($plural = FALSE) { |
125 | return $plural ? ts('Phones') : ts('Phone'); | |
449c4e6b CW |
126 | } |
127 | ||
e501603b | 128 | /** |
f41f0342 | 129 | * Returns foreign keys and entity references. |
e501603b TO |
130 | * |
131 | * @return array | |
132 | * [CRM_Core_Reference_Interface] | |
133 | */ | |
c3fc2621 | 134 | public static function getReferenceColumns() { |
346aaaba | 135 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
fa45b5b9 | 136 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
c3fc2621 | 137 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); |
346aaaba | 138 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 139 | } |
346aaaba | 140 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 141 | } |
c3fc2621 | 142 | |
e501603b TO |
143 | /** |
144 | * Returns all the column names of this table | |
145 | * | |
146 | * @return array | |
147 | */ | |
c3fc2621 | 148 | public static function &fields() { |
346aaaba | 149 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
150 | Civi::$statics[__CLASS__]['fields'] = [ |
151 | 'id' => [ | |
e501603b TO |
152 | 'name' => 'id', |
153 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 154 | 'title' => ts('Phone ID'), |
215b423e | 155 | 'description' => ts('Unique Phone ID'), |
c3fc2621 | 156 | 'required' => TRUE, |
a36434b9 | 157 | 'where' => 'civicrm_phone.id', |
522a26c9 | 158 | 'table_name' => 'civicrm_phone', |
159 | 'entity' => 'Phone', | |
160 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 161 | 'localizable' => 0, |
a9d0587b | 162 | 'add' => '1.1', |
c3fc2621 CW |
163 | ], |
164 | 'contact_id' => [ | |
e501603b TO |
165 | 'name' => 'contact_id', |
166 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 167 | 'title' => ts('Phone Contact'), |
215b423e | 168 | 'description' => ts('FK to Contact ID'), |
a36434b9 | 169 | 'where' => 'civicrm_phone.contact_id', |
522a26c9 | 170 | 'table_name' => 'civicrm_phone', |
171 | 'entity' => 'Phone', | |
172 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 173 | 'localizable' => 0, |
e501603b | 174 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
a9d0587b | 175 | 'add' => '2.0', |
c3fc2621 CW |
176 | ], |
177 | 'location_type_id' => [ | |
e501603b TO |
178 | 'name' => 'location_type_id', |
179 | 'type' => CRM_Utils_Type::T_INT, | |
9ac33d0f | 180 | 'title' => ts('Phone Location Type ID'), |
215b423e | 181 | 'description' => ts('Which Location does this phone belong to.'), |
a36434b9 | 182 | 'where' => 'civicrm_phone.location_type_id', |
522a26c9 | 183 | 'table_name' => 'civicrm_phone', |
184 | 'entity' => 'Phone', | |
185 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 186 | 'localizable' => 0, |
c3fc2621 | 187 | 'html' => [ |
e501603b | 188 | 'type' => 'Select', |
9ac33d0f | 189 | 'label' => ts("Phone Location Type"), |
c3fc2621 CW |
190 | ], |
191 | 'pseudoconstant' => [ | |
e501603b TO |
192 | 'table' => 'civicrm_location_type', |
193 | 'keyColumn' => 'id', | |
194 | 'labelColumn' => 'display_name', | |
e6ca0a57 | 195 | ], |
a9d0587b | 196 | 'add' => '2.0', |
c3fc2621 CW |
197 | ], |
198 | 'is_primary' => [ | |
e501603b TO |
199 | 'name' => 'is_primary', |
200 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
b6673dcd | 201 | 'title' => ts('Primary phone'), |
215b423e | 202 | 'description' => ts('Is this the primary phone for this contact and location.'), |
a36434b9 | 203 | 'where' => 'civicrm_phone.is_primary', |
45a83e42 | 204 | 'default' => '0', |
522a26c9 | 205 | 'table_name' => 'civicrm_phone', |
206 | 'entity' => 'Phone', | |
207 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 208 | 'localizable' => 0, |
b6673dcd CW |
209 | 'html' => [ |
210 | 'type' => 'Radio', | |
211 | ], | |
a9d0587b | 212 | 'add' => '1.1', |
c3fc2621 CW |
213 | ], |
214 | 'is_billing' => [ | |
e501603b TO |
215 | 'name' => 'is_billing', |
216 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 217 | 'title' => ts('Is Billing Phone'), |
215b423e | 218 | 'description' => ts('Is this the billing?'), |
a36434b9 | 219 | 'where' => 'civicrm_phone.is_billing', |
45a83e42 | 220 | 'default' => '0', |
522a26c9 | 221 | 'table_name' => 'civicrm_phone', |
222 | 'entity' => 'Phone', | |
223 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 224 | 'localizable' => 0, |
a9d0587b | 225 | 'add' => '2.0', |
c3fc2621 CW |
226 | ], |
227 | 'mobile_provider_id' => [ | |
e501603b TO |
228 | 'name' => 'mobile_provider_id', |
229 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 230 | 'title' => ts('Mobile Provider'), |
215b423e | 231 | 'description' => ts('Which Mobile Provider does this phone belong to.'), |
a36434b9 | 232 | 'where' => 'civicrm_phone.mobile_provider_id', |
522a26c9 | 233 | 'table_name' => 'civicrm_phone', |
234 | 'entity' => 'Phone', | |
235 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 236 | 'localizable' => 0, |
a9d0587b | 237 | 'add' => '1.1', |
c3fc2621 CW |
238 | ], |
239 | 'phone' => [ | |
e501603b TO |
240 | 'name' => 'phone', |
241 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 242 | 'title' => ts('Phone'), |
215b423e | 243 | 'description' => ts('Complete phone number.'), |
e501603b TO |
244 | 'maxlength' => 32, |
245 | 'size' => CRM_Utils_Type::MEDIUM, | |
c3fc2621 | 246 | 'import' => TRUE, |
e501603b TO |
247 | 'where' => 'civicrm_phone.phone', |
248 | 'headerPattern' => '/phone/i', | |
249 | 'dataPattern' => '/^[\d\(\)\-\.\s]+$/', | |
c3fc2621 | 250 | 'export' => TRUE, |
522a26c9 | 251 | 'table_name' => 'civicrm_phone', |
252 | 'entity' => 'Phone', | |
253 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 254 | 'localizable' => 0, |
c3fc2621 | 255 | 'html' => [ |
e501603b | 256 | 'type' => 'Text', |
c3fc2621 | 257 | ], |
a9d0587b | 258 | 'add' => '1.1', |
c3fc2621 CW |
259 | ], |
260 | 'phone_ext' => [ | |
e501603b TO |
261 | 'name' => 'phone_ext', |
262 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 263 | 'title' => ts('Phone Extension'), |
215b423e | 264 | 'description' => ts('Optional extension for a phone number.'), |
e501603b TO |
265 | 'maxlength' => 16, |
266 | 'size' => 4, | |
c3fc2621 | 267 | 'import' => TRUE, |
e501603b TO |
268 | 'where' => 'civicrm_phone.phone_ext', |
269 | 'headerPattern' => '/extension/i', | |
270 | 'dataPattern' => '/^\d+$/', | |
c3fc2621 | 271 | 'export' => TRUE, |
522a26c9 | 272 | 'table_name' => 'civicrm_phone', |
273 | 'entity' => 'Phone', | |
274 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 275 | 'localizable' => 0, |
c3fc2621 | 276 | 'html' => [ |
e501603b | 277 | 'type' => 'Text', |
c3fc2621 | 278 | ], |
a9d0587b | 279 | 'add' => '3.3', |
c3fc2621 CW |
280 | ], |
281 | 'phone_numeric' => [ | |
e501603b TO |
282 | 'name' => 'phone_numeric', |
283 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 284 | 'title' => ts('Phone Numeric'), |
215b423e | 285 | 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'), |
e501603b TO |
286 | 'maxlength' => 32, |
287 | 'size' => CRM_Utils_Type::MEDIUM, | |
a36434b9 | 288 | 'where' => 'civicrm_phone.phone_numeric', |
522a26c9 | 289 | 'table_name' => 'civicrm_phone', |
290 | 'entity' => 'Phone', | |
291 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 292 | 'localizable' => 0, |
a9d0587b | 293 | 'add' => '4.3', |
c3fc2621 CW |
294 | ], |
295 | 'phone_type_id' => [ | |
e501603b TO |
296 | 'name' => 'phone_type_id', |
297 | 'type' => CRM_Utils_Type::T_INT, | |
0b23ab2b | 298 | 'title' => ts('Phone Type ID'), |
215b423e | 299 | 'description' => ts('Which type of phone does this number belongs.'), |
219c47d6 | 300 | 'where' => 'civicrm_phone.phone_type_id', |
a36434b9 | 301 | 'export' => TRUE, |
522a26c9 | 302 | 'table_name' => 'civicrm_phone', |
303 | 'entity' => 'Phone', | |
304 | 'bao' => 'CRM_Core_BAO_Phone', | |
6a7e5e5d | 305 | 'localizable' => 0, |
c3fc2621 | 306 | 'html' => [ |
e501603b | 307 | 'type' => 'Select', |
9ac33d0f | 308 | 'label' => ts("Phone Type"), |
c3fc2621 CW |
309 | ], |
310 | 'pseudoconstant' => [ | |
e501603b TO |
311 | 'optionGroupName' => 'phone_type', |
312 | 'optionEditPath' => 'civicrm/admin/options/phone_type', | |
e6ca0a57 | 313 | ], |
a9d0587b | 314 | 'add' => '2.2', |
c3fc2621 CW |
315 | ], |
316 | ]; | |
346aaaba | 317 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 318 | } |
346aaaba | 319 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 320 | } |
c3fc2621 | 321 | |
e501603b | 322 | /** |
bd8e0b14 | 323 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
324 | * |
325 | * @return array | |
bd8e0b14 | 326 | * Array(string $name => string $uniqueName). |
e501603b | 327 | */ |
c3fc2621 | 328 | public static function &fieldKeys() { |
bd8e0b14 TO |
329 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
330 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 331 | } |
bd8e0b14 | 332 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 333 | } |
c3fc2621 | 334 | |
e501603b TO |
335 | /** |
336 | * Returns the names of this table | |
337 | * | |
338 | * @return string | |
339 | */ | |
c3fc2621 | 340 | public static function getTableName() { |
e501603b TO |
341 | return self::$_tableName; |
342 | } | |
c3fc2621 | 343 | |
e501603b TO |
344 | /** |
345 | * Returns if this table needs to be logged | |
346 | * | |
c3fc2621 | 347 | * @return bool |
e501603b | 348 | */ |
c3fc2621 | 349 | public function getLog() { |
e501603b TO |
350 | return self::$_log; |
351 | } | |
c3fc2621 | 352 | |
e501603b TO |
353 | /** |
354 | * Returns the list of fields that can be imported | |
355 | * | |
356 | * @param bool $prefix | |
357 | * | |
358 | * @return array | |
359 | */ | |
c3fc2621 CW |
360 | public static function &import($prefix = FALSE) { |
361 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []); | |
60808919 | 362 | return $r; |
e501603b | 363 | } |
c3fc2621 | 364 | |
e501603b TO |
365 | /** |
366 | * Returns the list of fields that can be exported | |
367 | * | |
368 | * @param bool $prefix | |
369 | * | |
370 | * @return array | |
371 | */ | |
c3fc2621 CW |
372 | public static function &export($prefix = FALSE) { |
373 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []); | |
60808919 | 374 | return $r; |
e501603b | 375 | } |
c3fc2621 | 376 | |
e7a6b91a AS |
377 | /** |
378 | * Returns the list of indices | |
c3fc2621 CW |
379 | * |
380 | * @param bool $localize | |
381 | * | |
382 | * @return array | |
e7a6b91a AS |
383 | */ |
384 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
385 | $indices = [ |
386 | 'index_location_type' => [ | |
e7a6b91a | 387 | 'name' => 'index_location_type', |
c3fc2621 | 388 | 'field' => [ |
e7a6b91a | 389 | 0 => 'location_type_id', |
c3fc2621 CW |
390 | ], |
391 | 'localizable' => FALSE, | |
e7a6b91a | 392 | 'sig' => 'civicrm_phone::0::location_type_id', |
c3fc2621 CW |
393 | ], |
394 | 'index_is_primary' => [ | |
e7a6b91a | 395 | 'name' => 'index_is_primary', |
c3fc2621 | 396 | 'field' => [ |
e7a6b91a | 397 | 0 => 'is_primary', |
c3fc2621 CW |
398 | ], |
399 | 'localizable' => FALSE, | |
e7a6b91a | 400 | 'sig' => 'civicrm_phone::0::is_primary', |
c3fc2621 CW |
401 | ], |
402 | 'index_is_billing' => [ | |
e7a6b91a | 403 | 'name' => 'index_is_billing', |
c3fc2621 | 404 | 'field' => [ |
e7a6b91a | 405 | 0 => 'is_billing', |
c3fc2621 CW |
406 | ], |
407 | 'localizable' => FALSE, | |
e7a6b91a | 408 | 'sig' => 'civicrm_phone::0::is_billing', |
c3fc2621 CW |
409 | ], |
410 | 'UI_mobile_provider_id' => [ | |
e7a6b91a | 411 | 'name' => 'UI_mobile_provider_id', |
c3fc2621 | 412 | 'field' => [ |
e7a6b91a | 413 | 0 => 'mobile_provider_id', |
c3fc2621 CW |
414 | ], |
415 | 'localizable' => FALSE, | |
e7a6b91a | 416 | 'sig' => 'civicrm_phone::0::mobile_provider_id', |
c3fc2621 CW |
417 | ], |
418 | 'index_phone_numeric' => [ | |
e7a6b91a | 419 | 'name' => 'index_phone_numeric', |
c3fc2621 | 420 | 'field' => [ |
e7a6b91a | 421 | 0 => 'phone_numeric', |
c3fc2621 CW |
422 | ], |
423 | 'localizable' => FALSE, | |
e7a6b91a | 424 | 'sig' => 'civicrm_phone::0::phone_numeric', |
c3fc2621 CW |
425 | ], |
426 | ]; | |
e7a6b91a AS |
427 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
428 | } | |
c3fc2621 | 429 | |
e501603b | 430 | } |