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