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