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