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