Merge pull request #16230 from aydun/1511_event_show_location
[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:76a7202934e0d8aa7f4240c61a42e42c)
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
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this phone belong to.
47 *
48 * @var int
49 */
50 public $location_type_id;
51
52 /**
53 * Is this the primary phone for this contact and location.
54 *
55 * @var bool
56 */
57 public $is_primary;
58
59 /**
60 * Is this the billing?
61 *
62 * @var bool
63 */
64 public $is_billing;
65
66 /**
67 * Which Mobile Provider does this phone belong to.
68 *
69 * @var int
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
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('Primary phone'),
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 'html' => [
187 'type' => 'Radio',
188 ],
189 ],
190 'is_billing' => [
191 'name' => 'is_billing',
192 'type' => CRM_Utils_Type::T_BOOLEAN,
193 'title' => ts('Is Billing Phone'),
194 'description' => ts('Is this the billing?'),
195 'where' => 'civicrm_phone.is_billing',
196 'default' => '0',
197 'table_name' => 'civicrm_phone',
198 'entity' => 'Phone',
199 'bao' => 'CRM_Core_BAO_Phone',
200 'localizable' => 0,
201 ],
202 'mobile_provider_id' => [
203 'name' => 'mobile_provider_id',
204 'type' => CRM_Utils_Type::T_INT,
205 'title' => ts('Mobile Provider'),
206 'description' => ts('Which Mobile Provider does this phone belong to.'),
207 'where' => 'civicrm_phone.mobile_provider_id',
208 'table_name' => 'civicrm_phone',
209 'entity' => 'Phone',
210 'bao' => 'CRM_Core_BAO_Phone',
211 'localizable' => 0,
212 ],
213 'phone' => [
214 'name' => 'phone',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Phone'),
217 'description' => ts('Complete phone number.'),
218 'maxlength' => 32,
219 'size' => CRM_Utils_Type::MEDIUM,
220 'import' => TRUE,
221 'where' => 'civicrm_phone.phone',
222 'headerPattern' => '/phone/i',
223 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
224 'export' => TRUE,
225 'table_name' => 'civicrm_phone',
226 'entity' => 'Phone',
227 'bao' => 'CRM_Core_BAO_Phone',
228 'localizable' => 0,
229 'html' => [
230 'type' => 'Text',
231 ],
232 ],
233 'phone_ext' => [
234 'name' => 'phone_ext',
235 'type' => CRM_Utils_Type::T_STRING,
236 'title' => ts('Phone Extension'),
237 'description' => ts('Optional extension for a phone number.'),
238 'maxlength' => 16,
239 'size' => 4,
240 'import' => TRUE,
241 'where' => 'civicrm_phone.phone_ext',
242 'headerPattern' => '/extension/i',
243 'dataPattern' => '/^\d+$/',
244 'export' => TRUE,
245 'table_name' => 'civicrm_phone',
246 'entity' => 'Phone',
247 'bao' => 'CRM_Core_BAO_Phone',
248 'localizable' => 0,
249 'html' => [
250 'type' => 'Text',
251 ],
252 ],
253 'phone_numeric' => [
254 'name' => 'phone_numeric',
255 'type' => CRM_Utils_Type::T_STRING,
256 'title' => ts('Phone Numeric'),
257 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
258 'maxlength' => 32,
259 'size' => CRM_Utils_Type::MEDIUM,
260 'where' => 'civicrm_phone.phone_numeric',
261 'table_name' => 'civicrm_phone',
262 'entity' => 'Phone',
263 'bao' => 'CRM_Core_BAO_Phone',
264 'localizable' => 0,
265 ],
266 'phone_type_id' => [
267 'name' => 'phone_type_id',
268 'type' => CRM_Utils_Type::T_INT,
269 'title' => ts('Phone Type'),
270 'description' => ts('Which type of phone does this number belongs.'),
271 'where' => 'civicrm_phone.phone_type_id',
272 'export' => TRUE,
273 'table_name' => 'civicrm_phone',
274 'entity' => 'Phone',
275 'bao' => 'CRM_Core_BAO_Phone',
276 'localizable' => 0,
277 'html' => [
278 'type' => 'Select',
279 ],
280 'pseudoconstant' => [
281 'optionGroupName' => 'phone_type',
282 'optionEditPath' => 'civicrm/admin/options/phone_type',
283 ],
284 ],
285 ];
286 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
287 }
288 return Civi::$statics[__CLASS__]['fields'];
289 }
290
291 /**
292 * Return a mapping from field-name to the corresponding key (as used in fields()).
293 *
294 * @return array
295 * Array(string $name => string $uniqueName).
296 */
297 public static function &fieldKeys() {
298 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
299 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
300 }
301 return Civi::$statics[__CLASS__]['fieldKeys'];
302 }
303
304 /**
305 * Returns the names of this table
306 *
307 * @return string
308 */
309 public static function getTableName() {
310 return self::$_tableName;
311 }
312
313 /**
314 * Returns if this table needs to be logged
315 *
316 * @return bool
317 */
318 public function getLog() {
319 return self::$_log;
320 }
321
322 /**
323 * Returns the list of fields that can be imported
324 *
325 * @param bool $prefix
326 *
327 * @return array
328 */
329 public static function &import($prefix = FALSE) {
330 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []);
331 return $r;
332 }
333
334 /**
335 * Returns the list of fields that can be exported
336 *
337 * @param bool $prefix
338 *
339 * @return array
340 */
341 public static function &export($prefix = FALSE) {
342 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []);
343 return $r;
344 }
345
346 /**
347 * Returns the list of indices
348 *
349 * @param bool $localize
350 *
351 * @return array
352 */
353 public static function indices($localize = TRUE) {
354 $indices = [
355 'index_location_type' => [
356 'name' => 'index_location_type',
357 'field' => [
358 0 => 'location_type_id',
359 ],
360 'localizable' => FALSE,
361 'sig' => 'civicrm_phone::0::location_type_id',
362 ],
363 'index_is_primary' => [
364 'name' => 'index_is_primary',
365 'field' => [
366 0 => 'is_primary',
367 ],
368 'localizable' => FALSE,
369 'sig' => 'civicrm_phone::0::is_primary',
370 ],
371 'index_is_billing' => [
372 'name' => 'index_is_billing',
373 'field' => [
374 0 => 'is_billing',
375 ],
376 'localizable' => FALSE,
377 'sig' => 'civicrm_phone::0::is_billing',
378 ],
379 'UI_mobile_provider_id' => [
380 'name' => 'UI_mobile_provider_id',
381 'field' => [
382 0 => 'mobile_provider_id',
383 ],
384 'localizable' => FALSE,
385 'sig' => 'civicrm_phone::0::mobile_provider_id',
386 ],
387 'index_phone_numeric' => [
388 'name' => 'index_phone_numeric',
389 'field' => [
390 0 => 'phone_numeric',
391 ],
392 'localizable' => FALSE,
393 'sig' => 'civicrm_phone::0::phone_numeric',
394 ],
395 ];
396 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
397 }
398
399 }