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