Merge pull request #23825 from colemanw/profileExport
[civicrm-core.git] / CRM / Core / DAO / Phone.php
CommitLineData
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
c1e814c7 9 * (GenCodeChecksum:b55a8820477e7df5db59b4ac8dc6adb6)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Phone entity.
f41f0342 14 */
e501603b 15class 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 *
c1e814c7 77 * @var bool|string
28979d65
CW
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 *
c1e814c7 86 * @var bool|string
28979d65
CW
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.'),
c1e814c7 237 'required' => TRUE,
a36434b9 238 'where' => 'civicrm_phone.is_primary',
45a83e42 239 'default' => '0',
522a26c9 240 'table_name' => 'civicrm_phone',
241 'entity' => 'Phone',
242 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 243 'localizable' => 0,
b6673dcd
CW
244 'html' => [
245 'type' => 'Radio',
246 ],
a9d0587b 247 'add' => '1.1',
c3fc2621
CW
248 ],
249 'is_billing' => [
e501603b
TO
250 'name' => 'is_billing',
251 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 252 'title' => ts('Is Billing Phone'),
215b423e 253 'description' => ts('Is this the billing?'),
c1e814c7 254 'required' => TRUE,
a36434b9 255 'where' => 'civicrm_phone.is_billing',
45a83e42 256 'default' => '0',
522a26c9 257 'table_name' => 'civicrm_phone',
258 'entity' => 'Phone',
259 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 260 'localizable' => 0,
a9d0587b 261 'add' => '2.0',
c3fc2621
CW
262 ],
263 'mobile_provider_id' => [
e501603b
TO
264 'name' => 'mobile_provider_id',
265 'type' => CRM_Utils_Type::T_INT,
c3fc2621 266 'title' => ts('Mobile Provider'),
215b423e 267 'description' => ts('Which Mobile Provider does this phone belong to.'),
a36434b9 268 'where' => 'civicrm_phone.mobile_provider_id',
522a26c9 269 'table_name' => 'civicrm_phone',
270 'entity' => 'Phone',
271 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 272 'localizable' => 0,
a9d0587b 273 'add' => '1.1',
c3fc2621
CW
274 ],
275 'phone' => [
e501603b
TO
276 'name' => 'phone',
277 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 278 'title' => ts('Phone'),
215b423e 279 'description' => ts('Complete phone number.'),
e501603b
TO
280 'maxlength' => 32,
281 'size' => CRM_Utils_Type::MEDIUM,
c3fc2621 282 'import' => TRUE,
e501603b
TO
283 'where' => 'civicrm_phone.phone',
284 'headerPattern' => '/phone/i',
285 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
c3fc2621 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' => 'Text',
c23563e3 293 'label' => ts("Phone"),
c3fc2621 294 ],
a9d0587b 295 'add' => '1.1',
c3fc2621
CW
296 ],
297 'phone_ext' => [
e501603b
TO
298 'name' => 'phone_ext',
299 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 300 'title' => ts('Phone Extension'),
215b423e 301 'description' => ts('Optional extension for a phone number.'),
e501603b
TO
302 'maxlength' => 16,
303 'size' => 4,
c3fc2621 304 'import' => TRUE,
e501603b
TO
305 'where' => 'civicrm_phone.phone_ext',
306 'headerPattern' => '/extension/i',
307 'dataPattern' => '/^\d+$/',
c3fc2621 308 'export' => TRUE,
522a26c9 309 'table_name' => 'civicrm_phone',
310 'entity' => 'Phone',
311 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 312 'localizable' => 0,
c3fc2621 313 'html' => [
e501603b 314 'type' => 'Text',
c3fc2621 315 ],
a9d0587b 316 'add' => '3.3',
c3fc2621
CW
317 ],
318 'phone_numeric' => [
e501603b
TO
319 'name' => 'phone_numeric',
320 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 321 'title' => ts('Phone Numeric'),
215b423e 322 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
e501603b
TO
323 'maxlength' => 32,
324 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 325 'where' => 'civicrm_phone.phone_numeric',
522a26c9 326 'table_name' => 'civicrm_phone',
327 'entity' => 'Phone',
328 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 329 'localizable' => 0,
c23563e3
SL
330 'html' => [
331 'label' => ts("Numeric"),
332 ],
a9d0587b 333 'add' => '4.3',
c3fc2621
CW
334 ],
335 'phone_type_id' => [
e501603b
TO
336 'name' => 'phone_type_id',
337 'type' => CRM_Utils_Type::T_INT,
0b23ab2b 338 'title' => ts('Phone Type ID'),
215b423e 339 'description' => ts('Which type of phone does this number belongs.'),
219c47d6 340 'where' => 'civicrm_phone.phone_type_id',
a36434b9 341 'export' => TRUE,
522a26c9 342 'table_name' => 'civicrm_phone',
343 'entity' => 'Phone',
344 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 345 'localizable' => 0,
c3fc2621 346 'html' => [
e501603b 347 'type' => 'Select',
9ac33d0f 348 'label' => ts("Phone Type"),
c3fc2621
CW
349 ],
350 'pseudoconstant' => [
e501603b
TO
351 'optionGroupName' => 'phone_type',
352 'optionEditPath' => 'civicrm/admin/options/phone_type',
e6ca0a57 353 ],
a9d0587b 354 'add' => '2.2',
c3fc2621
CW
355 ],
356 ];
346aaaba 357 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 358 }
346aaaba 359 return Civi::$statics[__CLASS__]['fields'];
e501603b 360 }
c3fc2621 361
e501603b 362 /**
bd8e0b14 363 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
364 *
365 * @return array
bd8e0b14 366 * Array(string $name => string $uniqueName).
e501603b 367 */
c3fc2621 368 public static function &fieldKeys() {
bd8e0b14
TO
369 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
370 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 371 }
bd8e0b14 372 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 373 }
c3fc2621 374
e501603b
TO
375 /**
376 * Returns the names of this table
377 *
378 * @return string
379 */
c3fc2621 380 public static function getTableName() {
e501603b
TO
381 return self::$_tableName;
382 }
c3fc2621 383
e501603b
TO
384 /**
385 * Returns if this table needs to be logged
386 *
c3fc2621 387 * @return bool
e501603b 388 */
c3fc2621 389 public function getLog() {
e501603b
TO
390 return self::$_log;
391 }
c3fc2621 392
e501603b
TO
393 /**
394 * Returns the list of fields that can be imported
395 *
396 * @param bool $prefix
397 *
398 * @return array
399 */
c3fc2621
CW
400 public static function &import($prefix = FALSE) {
401 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []);
60808919 402 return $r;
e501603b 403 }
c3fc2621 404
e501603b
TO
405 /**
406 * Returns the list of fields that can be exported
407 *
408 * @param bool $prefix
409 *
410 * @return array
411 */
c3fc2621
CW
412 public static function &export($prefix = FALSE) {
413 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []);
60808919 414 return $r;
e501603b 415 }
c3fc2621 416
e7a6b91a
AS
417 /**
418 * Returns the list of indices
c3fc2621
CW
419 *
420 * @param bool $localize
421 *
422 * @return array
e7a6b91a
AS
423 */
424 public static function indices($localize = TRUE) {
c3fc2621
CW
425 $indices = [
426 'index_location_type' => [
e7a6b91a 427 'name' => 'index_location_type',
c3fc2621 428 'field' => [
e7a6b91a 429 0 => 'location_type_id',
c3fc2621
CW
430 ],
431 'localizable' => FALSE,
e7a6b91a 432 'sig' => 'civicrm_phone::0::location_type_id',
c3fc2621
CW
433 ],
434 'index_is_primary' => [
e7a6b91a 435 'name' => 'index_is_primary',
c3fc2621 436 'field' => [
e7a6b91a 437 0 => 'is_primary',
c3fc2621
CW
438 ],
439 'localizable' => FALSE,
e7a6b91a 440 'sig' => 'civicrm_phone::0::is_primary',
c3fc2621
CW
441 ],
442 'index_is_billing' => [
e7a6b91a 443 'name' => 'index_is_billing',
c3fc2621 444 'field' => [
e7a6b91a 445 0 => 'is_billing',
c3fc2621
CW
446 ],
447 'localizable' => FALSE,
e7a6b91a 448 'sig' => 'civicrm_phone::0::is_billing',
c3fc2621
CW
449 ],
450 'UI_mobile_provider_id' => [
e7a6b91a 451 'name' => 'UI_mobile_provider_id',
c3fc2621 452 'field' => [
e7a6b91a 453 0 => 'mobile_provider_id',
c3fc2621
CW
454 ],
455 'localizable' => FALSE,
e7a6b91a 456 'sig' => 'civicrm_phone::0::mobile_provider_id',
c3fc2621
CW
457 ],
458 'index_phone_numeric' => [
e7a6b91a 459 'name' => 'index_phone_numeric',
c3fc2621 460 'field' => [
e7a6b91a 461 0 => 'phone_numeric',
c3fc2621
CW
462 ],
463 'localizable' => FALSE,
e7a6b91a 464 'sig' => 'civicrm_phone::0::phone_numeric',
c3fc2621
CW
465 ],
466 ];
e7a6b91a
AS
467 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
468 }
c3fc2621 469
e501603b 470}