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