Merge pull request #12056 from eileenmcnaughton/pcp
[civicrm-core.git] / CRM / Core / DAO / Phone.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e7a6b91a 9 * (GenCodeChecksum:661faad4886dd1a40784d465b906f447)
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 */
22 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 */
c3fc2621
CW
29 static $_log = TRUE;
30
e501603b
TO
31 /**
32 * Unique Phone ID
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
c3fc2621 44
e501603b
TO
45 /**
46 * Which Location does this phone belong to.
47 *
48 * @var int unsigned
49 */
50 public $location_type_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Is this the primary phone for this contact and location.
54 *
55 * @var boolean
56 */
57 public $is_primary;
c3fc2621 58
e501603b
TO
59 /**
60 * Is this the billing?
61 *
62 * @var boolean
63 */
64 public $is_billing;
c3fc2621 65
e501603b
TO
66 /**
67 * Which Mobile Provider does this phone belong to.
68 *
69 * @var int unsigned
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 *
97 * @var int unsigned
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
TO
116 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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'),
e501603b 136 'description' => 'Unique Phone ID',
c3fc2621 137 'required' => TRUE,
522a26c9 138 'table_name' => 'civicrm_phone',
139 'entity' => 'Phone',
140 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 141 'localizable' => 0,
c3fc2621
CW
142 ],
143 'contact_id' => [
e501603b
TO
144 'name' => 'contact_id',
145 'type' => CRM_Utils_Type::T_INT,
c3fc2621 146 'title' => ts('Phone Contact'),
e501603b 147 'description' => 'FK to Contact ID',
522a26c9 148 'table_name' => 'civicrm_phone',
149 'entity' => 'Phone',
150 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 151 'localizable' => 0,
e501603b 152 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
153 ],
154 'location_type_id' => [
e501603b
TO
155 'name' => 'location_type_id',
156 'type' => CRM_Utils_Type::T_INT,
c3fc2621 157 'title' => ts('Phone Location Type'),
e501603b 158 'description' => 'Which Location does this phone belong to.',
522a26c9 159 'table_name' => 'civicrm_phone',
160 'entity' => 'Phone',
161 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 162 'localizable' => 0,
c3fc2621 163 'html' => [
e501603b 164 'type' => 'Select',
c3fc2621
CW
165 ],
166 'pseudoconstant' => [
e501603b
TO
167 'table' => 'civicrm_location_type',
168 'keyColumn' => 'id',
169 'labelColumn' => 'display_name',
c3fc2621
CW
170 ]
171 ],
172 'is_primary' => [
e501603b
TO
173 'name' => 'is_primary',
174 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 175 'title' => ts('Is Phone Primary?'),
e501603b 176 'description' => 'Is this the primary phone for this contact and location.',
522a26c9 177 'table_name' => 'civicrm_phone',
178 'entity' => 'Phone',
179 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 180 'localizable' => 0,
c3fc2621
CW
181 ],
182 'is_billing' => [
e501603b
TO
183 'name' => 'is_billing',
184 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 185 'title' => ts('Is Billing Phone'),
e501603b 186 'description' => 'Is this the billing?',
522a26c9 187 'table_name' => 'civicrm_phone',
188 'entity' => 'Phone',
189 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 190 'localizable' => 0,
c3fc2621
CW
191 ],
192 'mobile_provider_id' => [
e501603b
TO
193 'name' => 'mobile_provider_id',
194 'type' => CRM_Utils_Type::T_INT,
c3fc2621 195 'title' => ts('Mobile Provider'),
e501603b 196 'description' => 'Which Mobile Provider does this phone belong to.',
522a26c9 197 'table_name' => 'civicrm_phone',
198 'entity' => 'Phone',
199 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 200 'localizable' => 0,
c3fc2621
CW
201 ],
202 'phone' => [
e501603b
TO
203 'name' => 'phone',
204 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 205 'title' => ts('Phone'),
e501603b
TO
206 'description' => 'Complete phone number.',
207 'maxlength' => 32,
208 'size' => CRM_Utils_Type::MEDIUM,
c3fc2621 209 'import' => TRUE,
e501603b
TO
210 'where' => 'civicrm_phone.phone',
211 'headerPattern' => '/phone/i',
212 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
c3fc2621 213 'export' => TRUE,
522a26c9 214 'table_name' => 'civicrm_phone',
215 'entity' => 'Phone',
216 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 217 'localizable' => 0,
c3fc2621 218 'html' => [
e501603b 219 'type' => 'Text',
c3fc2621
CW
220 ],
221 ],
222 'phone_ext' => [
e501603b
TO
223 'name' => 'phone_ext',
224 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 225 'title' => ts('Phone Extension'),
e501603b
TO
226 'description' => 'Optional extension for a phone number.',
227 'maxlength' => 16,
228 'size' => 4,
c3fc2621 229 'import' => TRUE,
e501603b
TO
230 'where' => 'civicrm_phone.phone_ext',
231 'headerPattern' => '/extension/i',
232 'dataPattern' => '/^\d+$/',
c3fc2621 233 'export' => TRUE,
522a26c9 234 'table_name' => 'civicrm_phone',
235 'entity' => 'Phone',
236 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 237 'localizable' => 0,
c3fc2621 238 'html' => [
e501603b 239 'type' => 'Text',
c3fc2621
CW
240 ],
241 ],
242 'phone_numeric' => [
e501603b
TO
243 'name' => 'phone_numeric',
244 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 245 'title' => ts('Phone Numeric'),
e501603b
TO
246 'description' => 'Phone number stripped of all whitespace, letters, and punctuation.',
247 'maxlength' => 32,
248 'size' => CRM_Utils_Type::MEDIUM,
522a26c9 249 'table_name' => 'civicrm_phone',
250 'entity' => 'Phone',
251 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 252 'localizable' => 0,
c3fc2621
CW
253 ],
254 'phone_type_id' => [
e501603b
TO
255 'name' => 'phone_type_id',
256 'type' => CRM_Utils_Type::T_INT,
c3fc2621 257 'title' => ts('Phone Type'),
e501603b 258 'description' => 'Which type of phone does this number belongs.',
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' => 'Select',
c3fc2621
CW
265 ],
266 'pseudoconstant' => [
e501603b
TO
267 'optionGroupName' => 'phone_type',
268 'optionEditPath' => 'civicrm/admin/options/phone_type',
c3fc2621
CW
269 ]
270 ],
271 ];
346aaaba 272 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 273 }
346aaaba 274 return Civi::$statics[__CLASS__]['fields'];
e501603b 275 }
c3fc2621 276
e501603b 277 /**
bd8e0b14 278 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
279 *
280 * @return array
bd8e0b14 281 * Array(string $name => string $uniqueName).
e501603b 282 */
c3fc2621 283 public static function &fieldKeys() {
bd8e0b14
TO
284 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
285 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 286 }
bd8e0b14 287 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 288 }
c3fc2621 289
e501603b
TO
290 /**
291 * Returns the names of this table
292 *
293 * @return string
294 */
c3fc2621 295 public static function getTableName() {
e501603b
TO
296 return self::$_tableName;
297 }
c3fc2621 298
e501603b
TO
299 /**
300 * Returns if this table needs to be logged
301 *
c3fc2621 302 * @return bool
e501603b 303 */
c3fc2621 304 public function getLog() {
e501603b
TO
305 return self::$_log;
306 }
c3fc2621 307
e501603b
TO
308 /**
309 * Returns the list of fields that can be imported
310 *
311 * @param bool $prefix
312 *
313 * @return array
314 */
c3fc2621
CW
315 public static function &import($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []);
60808919 317 return $r;
e501603b 318 }
c3fc2621 319
e501603b
TO
320 /**
321 * Returns the list of fields that can be exported
322 *
323 * @param bool $prefix
324 *
325 * @return array
326 */
c3fc2621
CW
327 public static function &export($prefix = FALSE) {
328 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []);
60808919 329 return $r;
e501603b 330 }
c3fc2621 331
e7a6b91a
AS
332 /**
333 * Returns the list of indices
c3fc2621
CW
334 *
335 * @param bool $localize
336 *
337 * @return array
e7a6b91a
AS
338 */
339 public static function indices($localize = TRUE) {
c3fc2621
CW
340 $indices = [
341 'index_location_type' => [
e7a6b91a 342 'name' => 'index_location_type',
c3fc2621 343 'field' => [
e7a6b91a 344 0 => 'location_type_id',
c3fc2621
CW
345 ],
346 'localizable' => FALSE,
e7a6b91a 347 'sig' => 'civicrm_phone::0::location_type_id',
c3fc2621
CW
348 ],
349 'index_is_primary' => [
e7a6b91a 350 'name' => 'index_is_primary',
c3fc2621 351 'field' => [
e7a6b91a 352 0 => 'is_primary',
c3fc2621
CW
353 ],
354 'localizable' => FALSE,
e7a6b91a 355 'sig' => 'civicrm_phone::0::is_primary',
c3fc2621
CW
356 ],
357 'index_is_billing' => [
e7a6b91a 358 'name' => 'index_is_billing',
c3fc2621 359 'field' => [
e7a6b91a 360 0 => 'is_billing',
c3fc2621
CW
361 ],
362 'localizable' => FALSE,
e7a6b91a 363 'sig' => 'civicrm_phone::0::is_billing',
c3fc2621
CW
364 ],
365 'UI_mobile_provider_id' => [
e7a6b91a 366 'name' => 'UI_mobile_provider_id',
c3fc2621 367 'field' => [
e7a6b91a 368 0 => 'mobile_provider_id',
c3fc2621
CW
369 ],
370 'localizable' => FALSE,
e7a6b91a 371 'sig' => 'civicrm_phone::0::mobile_provider_id',
c3fc2621
CW
372 ],
373 'index_phone_numeric' => [
e7a6b91a 374 'name' => 'index_phone_numeric',
c3fc2621 375 'field' => [
e7a6b91a 376 0 => 'phone_numeric',
c3fc2621
CW
377 ],
378 'localizable' => FALSE,
e7a6b91a 379 'sig' => 'civicrm_phone::0::phone_numeric',
c3fc2621
CW
380 ],
381 ];
e7a6b91a
AS
382 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
383 }
c3fc2621 384
e501603b 385}