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:632e24c7c46ff01ecb1acab879bcf625)
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',
176 'name' => 'contact_id',
177 'type' => CRM_Utils_Type
::T_INT
,
178 'title' => ts('Contact ID'),
179 'description' => ts('FK to Contact ID'),
180 'where' => 'civicrm_phone.contact_id',
181 'table_name' => 'civicrm_phone',
183 'bao' => 'CRM_Core_BAO_Phone',
185 'FKClassName' => 'CRM_Contact_DAO_Contact',
187 'label' => ts("Contact"),
191 'location_type_id' => [
192 'name' => 'location_type_id',
193 'type' => CRM_Utils_Type
::T_INT
,
194 'title' => ts('Location Type ID'),
195 'description' => ts('Which Location does this phone belong to.'),
196 'where' => 'civicrm_phone.location_type_id',
197 'table_name' => 'civicrm_phone',
199 'bao' => 'CRM_Core_BAO_Phone',
203 'label' => ts("Location Type"),
205 'pseudoconstant' => [
206 'table' => 'civicrm_location_type',
208 'labelColumn' => 'display_name',
213 'name' => 'is_primary',
214 'type' => CRM_Utils_Type
::T_BOOLEAN
,
215 'title' => ts('Primary phone'),
216 'description' => ts('Is this the primary phone for this contact and location.'),
217 'where' => 'civicrm_phone.is_primary',
219 'table_name' => 'civicrm_phone',
221 'bao' => 'CRM_Core_BAO_Phone',
229 'name' => 'is_billing',
230 'type' => CRM_Utils_Type
::T_BOOLEAN
,
231 'title' => ts('Is Billing Phone'),
232 'description' => ts('Is this the billing?'),
233 'where' => 'civicrm_phone.is_billing',
235 'table_name' => 'civicrm_phone',
237 'bao' => 'CRM_Core_BAO_Phone',
241 'mobile_provider_id' => [
242 'name' => 'mobile_provider_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Mobile Provider'),
245 'description' => ts('Which Mobile Provider does this phone belong to.'),
246 'where' => 'civicrm_phone.mobile_provider_id',
247 'table_name' => 'civicrm_phone',
249 'bao' => 'CRM_Core_BAO_Phone',
255 'type' => CRM_Utils_Type
::T_STRING
,
256 'title' => ts('Phone'),
257 'description' => ts('Complete phone number.'),
259 'size' => CRM_Utils_Type
::MEDIUM
,
261 'where' => 'civicrm_phone.phone',
262 'headerPattern' => '/phone/i',
263 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
265 'table_name' => 'civicrm_phone',
267 'bao' => 'CRM_Core_BAO_Phone',
271 'label' => ts("Phone"),
276 'name' => 'phone_ext',
277 'type' => CRM_Utils_Type
::T_STRING
,
278 'title' => ts('Phone Extension'),
279 'description' => ts('Optional extension for a phone number.'),
283 'where' => 'civicrm_phone.phone_ext',
284 'headerPattern' => '/extension/i',
285 'dataPattern' => '/^\d+$/',
287 'table_name' => 'civicrm_phone',
289 'bao' => 'CRM_Core_BAO_Phone',
297 'name' => 'phone_numeric',
298 'type' => CRM_Utils_Type
::T_STRING
,
299 'title' => ts('Phone Numeric'),
300 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
302 'size' => CRM_Utils_Type
::MEDIUM
,
303 'where' => 'civicrm_phone.phone_numeric',
304 'table_name' => 'civicrm_phone',
306 'bao' => 'CRM_Core_BAO_Phone',
309 'label' => ts("Numeric"),
314 'name' => 'phone_type_id',
315 'type' => CRM_Utils_Type
::T_INT
,
316 'title' => ts('Phone Type ID'),
317 'description' => ts('Which type of phone does this number belongs.'),
318 'where' => 'civicrm_phone.phone_type_id',
320 'table_name' => 'civicrm_phone',
322 'bao' => 'CRM_Core_BAO_Phone',
326 'label' => ts("Phone Type"),
328 'pseudoconstant' => [
329 'optionGroupName' => 'phone_type',
330 'optionEditPath' => 'civicrm/admin/options/phone_type',
335 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
337 return Civi
::$statics[__CLASS__
]['fields'];
341 * Return a mapping from field-name to the corresponding key (as used in fields()).
344 * Array(string $name => string $uniqueName).
346 public static function &fieldKeys() {
347 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
348 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
350 return Civi
::$statics[__CLASS__
]['fieldKeys'];
354 * Returns the names of this table
358 public static function getTableName() {
359 return self
::$_tableName;
363 * Returns if this table needs to be logged
367 public function getLog() {
372 * Returns the list of fields that can be imported
374 * @param bool $prefix
378 public static function &import($prefix = FALSE) {
379 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
384 * Returns the list of fields that can be exported
386 * @param bool $prefix
390 public static function &export($prefix = FALSE) {
391 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
396 * Returns the list of indices
398 * @param bool $localize
402 public static function indices($localize = TRUE) {
404 'index_location_type' => [
405 'name' => 'index_location_type',
407 0 => 'location_type_id',
409 'localizable' => FALSE,
410 'sig' => 'civicrm_phone::0::location_type_id',
412 'index_is_primary' => [
413 'name' => 'index_is_primary',
417 'localizable' => FALSE,
418 'sig' => 'civicrm_phone::0::is_primary',
420 'index_is_billing' => [
421 'name' => 'index_is_billing',
425 'localizable' => FALSE,
426 'sig' => 'civicrm_phone::0::is_billing',
428 'UI_mobile_provider_id' => [
429 'name' => 'UI_mobile_provider_id',
431 0 => 'mobile_provider_id',
433 'localizable' => FALSE,
434 'sig' => 'civicrm_phone::0::mobile_provider_id',
436 'index_phone_numeric' => [
437 'name' => 'index_phone_numeric',
439 0 => 'phone_numeric',
441 'localizable' => FALSE,
442 'sig' => 'civicrm_phone::0::phone_numeric',
445 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;