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