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