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