Merge pull request #17951 from eileenmcnaughton/export_im
[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
a9d0587b 9 * (GenCodeChecksum:3c1f1743128af72b009c6cf4effc1da2)
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 {
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,
a9d0587b 157 'add' => '1.1',
c3fc2621
CW
158 ],
159 'contact_id' => [
e501603b
TO
160 'name' => 'contact_id',
161 'type' => CRM_Utils_Type::T_INT,
c3fc2621 162 'title' => ts('Phone Contact'),
215b423e 163 'description' => ts('FK to Contact ID'),
a36434b9 164 'where' => 'civicrm_phone.contact_id',
522a26c9 165 'table_name' => 'civicrm_phone',
166 'entity' => 'Phone',
167 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 168 'localizable' => 0,
e501603b 169 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 170 'add' => '2.0',
c3fc2621
CW
171 ],
172 'location_type_id' => [
e501603b
TO
173 'name' => 'location_type_id',
174 'type' => CRM_Utils_Type::T_INT,
c3fc2621 175 'title' => ts('Phone Location Type'),
215b423e 176 'description' => ts('Which Location does this phone belong to.'),
a36434b9 177 'where' => 'civicrm_phone.location_type_id',
522a26c9 178 'table_name' => 'civicrm_phone',
179 'entity' => 'Phone',
180 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 181 'localizable' => 0,
c3fc2621 182 'html' => [
e501603b 183 'type' => 'Select',
c3fc2621
CW
184 ],
185 'pseudoconstant' => [
e501603b
TO
186 'table' => 'civicrm_location_type',
187 'keyColumn' => 'id',
188 'labelColumn' => 'display_name',
e6ca0a57 189 ],
a9d0587b 190 'add' => '2.0',
c3fc2621
CW
191 ],
192 'is_primary' => [
e501603b
TO
193 'name' => 'is_primary',
194 'type' => CRM_Utils_Type::T_BOOLEAN,
b6673dcd 195 'title' => ts('Primary phone'),
215b423e 196 'description' => ts('Is this the primary phone for this contact and location.'),
a36434b9 197 'where' => 'civicrm_phone.is_primary',
45a83e42 198 'default' => '0',
522a26c9 199 'table_name' => 'civicrm_phone',
200 'entity' => 'Phone',
201 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 202 'localizable' => 0,
b6673dcd
CW
203 'html' => [
204 'type' => 'Radio',
205 ],
a9d0587b 206 'add' => '1.1',
c3fc2621
CW
207 ],
208 'is_billing' => [
e501603b
TO
209 'name' => 'is_billing',
210 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 211 'title' => ts('Is Billing Phone'),
215b423e 212 'description' => ts('Is this the billing?'),
a36434b9 213 'where' => 'civicrm_phone.is_billing',
45a83e42 214 'default' => '0',
522a26c9 215 'table_name' => 'civicrm_phone',
216 'entity' => 'Phone',
217 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 218 'localizable' => 0,
a9d0587b 219 'add' => '2.0',
c3fc2621
CW
220 ],
221 'mobile_provider_id' => [
e501603b
TO
222 'name' => 'mobile_provider_id',
223 'type' => CRM_Utils_Type::T_INT,
c3fc2621 224 'title' => ts('Mobile Provider'),
215b423e 225 'description' => ts('Which Mobile Provider does this phone belong to.'),
a36434b9 226 'where' => 'civicrm_phone.mobile_provider_id',
522a26c9 227 'table_name' => 'civicrm_phone',
228 'entity' => 'Phone',
229 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 230 'localizable' => 0,
a9d0587b 231 'add' => '1.1',
c3fc2621
CW
232 ],
233 'phone' => [
e501603b
TO
234 'name' => 'phone',
235 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 236 'title' => ts('Phone'),
215b423e 237 'description' => ts('Complete phone number.'),
e501603b
TO
238 'maxlength' => 32,
239 'size' => CRM_Utils_Type::MEDIUM,
c3fc2621 240 'import' => TRUE,
e501603b
TO
241 'where' => 'civicrm_phone.phone',
242 'headerPattern' => '/phone/i',
243 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
c3fc2621 244 'export' => TRUE,
522a26c9 245 'table_name' => 'civicrm_phone',
246 'entity' => 'Phone',
247 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 248 'localizable' => 0,
c3fc2621 249 'html' => [
e501603b 250 'type' => 'Text',
c3fc2621 251 ],
a9d0587b 252 'add' => '1.1',
c3fc2621
CW
253 ],
254 'phone_ext' => [
e501603b
TO
255 'name' => 'phone_ext',
256 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 257 'title' => ts('Phone Extension'),
215b423e 258 'description' => ts('Optional extension for a phone number.'),
e501603b
TO
259 'maxlength' => 16,
260 'size' => 4,
c3fc2621 261 'import' => TRUE,
e501603b
TO
262 'where' => 'civicrm_phone.phone_ext',
263 'headerPattern' => '/extension/i',
264 'dataPattern' => '/^\d+$/',
c3fc2621 265 'export' => TRUE,
522a26c9 266 'table_name' => 'civicrm_phone',
267 'entity' => 'Phone',
268 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 269 'localizable' => 0,
c3fc2621 270 'html' => [
e501603b 271 'type' => 'Text',
c3fc2621 272 ],
a9d0587b 273 'add' => '3.3',
c3fc2621
CW
274 ],
275 'phone_numeric' => [
e501603b
TO
276 'name' => 'phone_numeric',
277 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 278 'title' => ts('Phone Numeric'),
215b423e 279 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
e501603b
TO
280 'maxlength' => 32,
281 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 282 'where' => 'civicrm_phone.phone_numeric',
522a26c9 283 'table_name' => 'civicrm_phone',
284 'entity' => 'Phone',
285 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 286 'localizable' => 0,
a9d0587b 287 'add' => '4.3',
c3fc2621
CW
288 ],
289 'phone_type_id' => [
e501603b
TO
290 'name' => 'phone_type_id',
291 'type' => CRM_Utils_Type::T_INT,
c3fc2621 292 'title' => ts('Phone Type'),
215b423e 293 'description' => ts('Which type of phone does this number belongs.'),
219c47d6 294 'where' => 'civicrm_phone.phone_type_id',
a36434b9 295 'export' => TRUE,
522a26c9 296 'table_name' => 'civicrm_phone',
297 'entity' => 'Phone',
298 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 299 'localizable' => 0,
c3fc2621 300 'html' => [
e501603b 301 'type' => 'Select',
c3fc2621
CW
302 ],
303 'pseudoconstant' => [
e501603b
TO
304 'optionGroupName' => 'phone_type',
305 'optionEditPath' => 'civicrm/admin/options/phone_type',
e6ca0a57 306 ],
a9d0587b 307 'add' => '2.2',
c3fc2621
CW
308 ],
309 ];
346aaaba 310 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 311 }
346aaaba 312 return Civi::$statics[__CLASS__]['fields'];
e501603b 313 }
c3fc2621 314
e501603b 315 /**
bd8e0b14 316 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
317 *
318 * @return array
bd8e0b14 319 * Array(string $name => string $uniqueName).
e501603b 320 */
c3fc2621 321 public static function &fieldKeys() {
bd8e0b14
TO
322 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
323 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 324 }
bd8e0b14 325 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 326 }
c3fc2621 327
e501603b
TO
328 /**
329 * Returns the names of this table
330 *
331 * @return string
332 */
c3fc2621 333 public static function getTableName() {
e501603b
TO
334 return self::$_tableName;
335 }
c3fc2621 336
e501603b
TO
337 /**
338 * Returns if this table needs to be logged
339 *
c3fc2621 340 * @return bool
e501603b 341 */
c3fc2621 342 public function getLog() {
e501603b
TO
343 return self::$_log;
344 }
c3fc2621 345
e501603b
TO
346 /**
347 * Returns the list of fields that can be imported
348 *
349 * @param bool $prefix
350 *
351 * @return array
352 */
c3fc2621
CW
353 public static function &import($prefix = FALSE) {
354 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []);
60808919 355 return $r;
e501603b 356 }
c3fc2621 357
e501603b
TO
358 /**
359 * Returns the list of fields that can be exported
360 *
361 * @param bool $prefix
362 *
363 * @return array
364 */
c3fc2621
CW
365 public static function &export($prefix = FALSE) {
366 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []);
60808919 367 return $r;
e501603b 368 }
c3fc2621 369
e7a6b91a
AS
370 /**
371 * Returns the list of indices
c3fc2621
CW
372 *
373 * @param bool $localize
374 *
375 * @return array
e7a6b91a
AS
376 */
377 public static function indices($localize = TRUE) {
c3fc2621
CW
378 $indices = [
379 'index_location_type' => [
e7a6b91a 380 'name' => 'index_location_type',
c3fc2621 381 'field' => [
e7a6b91a 382 0 => 'location_type_id',
c3fc2621
CW
383 ],
384 'localizable' => FALSE,
e7a6b91a 385 'sig' => 'civicrm_phone::0::location_type_id',
c3fc2621
CW
386 ],
387 'index_is_primary' => [
e7a6b91a 388 'name' => 'index_is_primary',
c3fc2621 389 'field' => [
e7a6b91a 390 0 => 'is_primary',
c3fc2621
CW
391 ],
392 'localizable' => FALSE,
e7a6b91a 393 'sig' => 'civicrm_phone::0::is_primary',
c3fc2621
CW
394 ],
395 'index_is_billing' => [
e7a6b91a 396 'name' => 'index_is_billing',
c3fc2621 397 'field' => [
e7a6b91a 398 0 => 'is_billing',
c3fc2621
CW
399 ],
400 'localizable' => FALSE,
e7a6b91a 401 'sig' => 'civicrm_phone::0::is_billing',
c3fc2621
CW
402 ],
403 'UI_mobile_provider_id' => [
e7a6b91a 404 'name' => 'UI_mobile_provider_id',
c3fc2621 405 'field' => [
e7a6b91a 406 0 => 'mobile_provider_id',
c3fc2621
CW
407 ],
408 'localizable' => FALSE,
e7a6b91a 409 'sig' => 'civicrm_phone::0::mobile_provider_id',
c3fc2621
CW
410 ],
411 'index_phone_numeric' => [
e7a6b91a 412 'name' => 'index_phone_numeric',
c3fc2621 413 'field' => [
e7a6b91a 414 0 => 'phone_numeric',
c3fc2621
CW
415 ],
416 'localizable' => FALSE,
e7a6b91a 417 'sig' => 'civicrm_phone::0::phone_numeric',
c3fc2621
CW
418 ],
419 ];
e7a6b91a
AS
420 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
421 }
c3fc2621 422
e501603b 423}