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