5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:751f23f392f8fe789e580096ae7522b7)
13 * Database access object for the Phone entity.
15 class CRM_Core_DAO_Phone
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_phone';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-phone';
34 * Field to show when displaying a record.
38 public static $_labelField = 'phone';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
62 * Which Location does this phone belong to.
66 public $location_type_id;
69 * Is this the primary phone for this contact and location.
76 * Is this the billing?
83 * Which Mobile Provider does this phone belong to.
87 public $mobile_provider_id;
90 * Complete phone number.
97 * Optional extension for a phone number.
104 * Phone number stripped of all whitespace, letters, and punctuation.
108 public $phone_numeric;
111 * Which type of phone does this number belongs.
115 public $phone_type_id;
120 public function __construct() {
121 $this->__table
= 'civicrm_phone';
122 parent
::__construct();
126 * Returns localized title of this entity.
128 * @param bool $plural
129 * Whether to return the plural version of the title.
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ?
ts('Phones') : ts('Phone');
136 * Returns foreign keys and entity references.
139 * [CRM_Core_Reference_Interface]
141 public static function getReferenceColumns() {
142 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
143 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
144 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
145 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
147 return Civi
::$statics[__CLASS__
]['links'];
151 * Returns all the column names of this table
155 public static function &fields() {
156 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
157 Civi
::$statics[__CLASS__
]['fields'] = [
160 'type' => CRM_Utils_Type
::T_INT
,
161 'title' => ts('Phone ID'),
162 'description' => ts('Unique Phone ID'),
164 'where' => 'civicrm_phone.id',
165 'table_name' => 'civicrm_phone',
167 'bao' => 'CRM_Core_BAO_Phone',
172 'name' => 'contact_id',
173 'type' => CRM_Utils_Type
::T_INT
,
174 'title' => ts('Phone Contact'),
175 'description' => ts('FK to Contact ID'),
176 'where' => 'civicrm_phone.contact_id',
177 'table_name' => 'civicrm_phone',
179 'bao' => 'CRM_Core_BAO_Phone',
181 'FKClassName' => 'CRM_Contact_DAO_Contact',
184 'location_type_id' => [
185 'name' => 'location_type_id',
186 'type' => CRM_Utils_Type
::T_INT
,
187 'title' => ts('Phone Location Type ID'),
188 'description' => ts('Which Location does this phone belong to.'),
189 'where' => 'civicrm_phone.location_type_id',
190 'table_name' => 'civicrm_phone',
192 'bao' => 'CRM_Core_BAO_Phone',
196 'label' => ts("Phone Location Type"),
198 'pseudoconstant' => [
199 'table' => 'civicrm_location_type',
201 'labelColumn' => 'display_name',
206 'name' => 'is_primary',
207 'type' => CRM_Utils_Type
::T_BOOLEAN
,
208 'title' => ts('Primary phone'),
209 'description' => ts('Is this the primary phone for this contact and location.'),
210 'where' => 'civicrm_phone.is_primary',
212 'table_name' => 'civicrm_phone',
214 'bao' => 'CRM_Core_BAO_Phone',
222 'name' => 'is_billing',
223 'type' => CRM_Utils_Type
::T_BOOLEAN
,
224 'title' => ts('Is Billing Phone'),
225 'description' => ts('Is this the billing?'),
226 'where' => 'civicrm_phone.is_billing',
228 'table_name' => 'civicrm_phone',
230 'bao' => 'CRM_Core_BAO_Phone',
234 'mobile_provider_id' => [
235 'name' => 'mobile_provider_id',
236 'type' => CRM_Utils_Type
::T_INT
,
237 'title' => ts('Mobile Provider'),
238 'description' => ts('Which Mobile Provider does this phone belong to.'),
239 'where' => 'civicrm_phone.mobile_provider_id',
240 'table_name' => 'civicrm_phone',
242 'bao' => 'CRM_Core_BAO_Phone',
248 'type' => CRM_Utils_Type
::T_STRING
,
249 'title' => ts('Phone'),
250 'description' => ts('Complete phone number.'),
252 'size' => CRM_Utils_Type
::MEDIUM
,
254 'where' => 'civicrm_phone.phone',
255 'headerPattern' => '/phone/i',
256 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
258 'table_name' => 'civicrm_phone',
260 'bao' => 'CRM_Core_BAO_Phone',
268 'name' => 'phone_ext',
269 'type' => CRM_Utils_Type
::T_STRING
,
270 'title' => ts('Phone Extension'),
271 'description' => ts('Optional extension for a phone number.'),
275 'where' => 'civicrm_phone.phone_ext',
276 'headerPattern' => '/extension/i',
277 'dataPattern' => '/^\d+$/',
279 'table_name' => 'civicrm_phone',
281 'bao' => 'CRM_Core_BAO_Phone',
289 'name' => 'phone_numeric',
290 'type' => CRM_Utils_Type
::T_STRING
,
291 'title' => ts('Phone Numeric'),
292 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
294 'size' => CRM_Utils_Type
::MEDIUM
,
295 'where' => 'civicrm_phone.phone_numeric',
296 'table_name' => 'civicrm_phone',
298 'bao' => 'CRM_Core_BAO_Phone',
303 'name' => 'phone_type_id',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('Phone Type ID'),
306 'description' => ts('Which type of phone does this number belongs.'),
307 'where' => 'civicrm_phone.phone_type_id',
309 'table_name' => 'civicrm_phone',
311 'bao' => 'CRM_Core_BAO_Phone',
315 'label' => ts("Phone Type"),
317 'pseudoconstant' => [
318 'optionGroupName' => 'phone_type',
319 'optionEditPath' => 'civicrm/admin/options/phone_type',
324 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
326 return Civi
::$statics[__CLASS__
]['fields'];
330 * Return a mapping from field-name to the corresponding key (as used in fields()).
333 * Array(string $name => string $uniqueName).
335 public static function &fieldKeys() {
336 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
337 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
339 return Civi
::$statics[__CLASS__
]['fieldKeys'];
343 * Returns the names of this table
347 public static function getTableName() {
348 return self
::$_tableName;
352 * Returns if this table needs to be logged
356 public function getLog() {
361 * Returns the list of fields that can be imported
363 * @param bool $prefix
367 public static function &import($prefix = FALSE) {
368 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
373 * Returns the list of fields that can be exported
375 * @param bool $prefix
379 public static function &export($prefix = FALSE) {
380 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
385 * Returns the list of indices
387 * @param bool $localize
391 public static function indices($localize = TRUE) {
393 'index_location_type' => [
394 'name' => 'index_location_type',
396 0 => 'location_type_id',
398 'localizable' => FALSE,
399 'sig' => 'civicrm_phone::0::location_type_id',
401 'index_is_primary' => [
402 'name' => 'index_is_primary',
406 'localizable' => FALSE,
407 'sig' => 'civicrm_phone::0::is_primary',
409 'index_is_billing' => [
410 'name' => 'index_is_billing',
414 'localizable' => FALSE,
415 'sig' => 'civicrm_phone::0::is_billing',
417 'UI_mobile_provider_id' => [
418 'name' => 'UI_mobile_provider_id',
420 0 => 'mobile_provider_id',
422 'localizable' => FALSE,
423 'sig' => 'civicrm_phone::0::mobile_provider_id',
425 'index_phone_numeric' => [
426 'name' => 'index_phone_numeric',
428 0 => 'phone_numeric',
430 'localizable' => FALSE,
431 'sig' => 'civicrm_phone::0::phone_numeric',
434 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;