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:f77d3ef5985c8945730c2fe22bb3fa45)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
55 * Which Location does this phone belong to.
59 public $location_type_id;
62 * Is this the primary phone for this contact and location.
69 * Is this the billing?
76 * Which Mobile Provider does this phone belong to.
80 public $mobile_provider_id;
83 * Complete phone number.
90 * Optional extension for a phone number.
97 * Phone number stripped of all whitespace, letters, and punctuation.
101 public $phone_numeric;
104 * Which type of phone does this number belongs.
108 public $phone_type_id;
113 public function __construct() {
114 $this->__table
= 'civicrm_phone';
115 parent
::__construct();
119 * Returns localized title of this entity.
121 * @param bool $plural
122 * Whether to return the plural version of the title.
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ?
ts('Phones') : ts('Phone');
129 * Returns foreign keys and entity references.
132 * [CRM_Core_Reference_Interface]
134 public static function getReferenceColumns() {
135 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
136 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
137 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
138 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
140 return Civi
::$statics[__CLASS__
]['links'];
144 * Returns all the column names of this table
148 public static function &fields() {
149 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
150 Civi
::$statics[__CLASS__
]['fields'] = [
153 'type' => CRM_Utils_Type
::T_INT
,
154 'title' => ts('Phone ID'),
155 'description' => ts('Unique Phone ID'),
157 'where' => 'civicrm_phone.id',
158 'table_name' => 'civicrm_phone',
160 'bao' => 'CRM_Core_BAO_Phone',
165 'name' => 'contact_id',
166 'type' => CRM_Utils_Type
::T_INT
,
167 'title' => ts('Phone Contact'),
168 'description' => ts('FK to Contact ID'),
169 'where' => 'civicrm_phone.contact_id',
170 'table_name' => 'civicrm_phone',
172 'bao' => 'CRM_Core_BAO_Phone',
174 'FKClassName' => 'CRM_Contact_DAO_Contact',
177 'location_type_id' => [
178 'name' => 'location_type_id',
179 'type' => CRM_Utils_Type
::T_INT
,
180 'title' => ts('Phone Location Type ID'),
181 'description' => ts('Which Location does this phone belong to.'),
182 'where' => 'civicrm_phone.location_type_id',
183 'table_name' => 'civicrm_phone',
185 'bao' => 'CRM_Core_BAO_Phone',
189 'label' => ts("Phone Location Type"),
191 'pseudoconstant' => [
192 'table' => 'civicrm_location_type',
194 'labelColumn' => 'display_name',
199 'name' => 'is_primary',
200 'type' => CRM_Utils_Type
::T_BOOLEAN
,
201 'title' => ts('Primary phone'),
202 'description' => ts('Is this the primary phone for this contact and location.'),
203 'where' => 'civicrm_phone.is_primary',
205 'table_name' => 'civicrm_phone',
207 'bao' => 'CRM_Core_BAO_Phone',
215 'name' => 'is_billing',
216 'type' => CRM_Utils_Type
::T_BOOLEAN
,
217 'title' => ts('Is Billing Phone'),
218 'description' => ts('Is this the billing?'),
219 'where' => 'civicrm_phone.is_billing',
221 'table_name' => 'civicrm_phone',
223 'bao' => 'CRM_Core_BAO_Phone',
227 'mobile_provider_id' => [
228 'name' => 'mobile_provider_id',
229 'type' => CRM_Utils_Type
::T_INT
,
230 'title' => ts('Mobile Provider'),
231 'description' => ts('Which Mobile Provider does this phone belong to.'),
232 'where' => 'civicrm_phone.mobile_provider_id',
233 'table_name' => 'civicrm_phone',
235 'bao' => 'CRM_Core_BAO_Phone',
241 'type' => CRM_Utils_Type
::T_STRING
,
242 'title' => ts('Phone'),
243 'description' => ts('Complete phone number.'),
245 'size' => CRM_Utils_Type
::MEDIUM
,
247 'where' => 'civicrm_phone.phone',
248 'headerPattern' => '/phone/i',
249 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
251 'table_name' => 'civicrm_phone',
253 'bao' => 'CRM_Core_BAO_Phone',
261 'name' => 'phone_ext',
262 'type' => CRM_Utils_Type
::T_STRING
,
263 'title' => ts('Phone Extension'),
264 'description' => ts('Optional extension for a phone number.'),
268 'where' => 'civicrm_phone.phone_ext',
269 'headerPattern' => '/extension/i',
270 'dataPattern' => '/^\d+$/',
272 'table_name' => 'civicrm_phone',
274 'bao' => 'CRM_Core_BAO_Phone',
282 'name' => 'phone_numeric',
283 'type' => CRM_Utils_Type
::T_STRING
,
284 'title' => ts('Phone Numeric'),
285 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
287 'size' => CRM_Utils_Type
::MEDIUM
,
288 'where' => 'civicrm_phone.phone_numeric',
289 'table_name' => 'civicrm_phone',
291 'bao' => 'CRM_Core_BAO_Phone',
296 'name' => 'phone_type_id',
297 'type' => CRM_Utils_Type
::T_INT
,
298 'title' => ts('Phone Type ID'),
299 'description' => ts('Which type of phone does this number belongs.'),
300 'where' => 'civicrm_phone.phone_type_id',
302 'table_name' => 'civicrm_phone',
304 'bao' => 'CRM_Core_BAO_Phone',
308 'label' => ts("Phone Type"),
310 'pseudoconstant' => [
311 'optionGroupName' => 'phone_type',
312 'optionEditPath' => 'civicrm/admin/options/phone_type',
317 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
319 return Civi
::$statics[__CLASS__
]['fields'];
323 * Return a mapping from field-name to the corresponding key (as used in fields()).
326 * Array(string $name => string $uniqueName).
328 public static function &fieldKeys() {
329 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
330 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
332 return Civi
::$statics[__CLASS__
]['fieldKeys'];
336 * Returns the names of this table
340 public static function getTableName() {
341 return self
::$_tableName;
345 * Returns if this table needs to be logged
349 public function getLog() {
354 * Returns the list of fields that can be imported
356 * @param bool $prefix
360 public static function &import($prefix = FALSE) {
361 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
366 * Returns the list of fields that can be exported
368 * @param bool $prefix
372 public static function &export($prefix = FALSE) {
373 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
378 * Returns the list of indices
380 * @param bool $localize
384 public static function indices($localize = TRUE) {
386 'index_location_type' => [
387 'name' => 'index_location_type',
389 0 => 'location_type_id',
391 'localizable' => FALSE,
392 'sig' => 'civicrm_phone::0::location_type_id',
394 'index_is_primary' => [
395 'name' => 'index_is_primary',
399 'localizable' => FALSE,
400 'sig' => 'civicrm_phone::0::is_primary',
402 'index_is_billing' => [
403 'name' => 'index_is_billing',
407 'localizable' => FALSE,
408 'sig' => 'civicrm_phone::0::is_billing',
410 'UI_mobile_provider_id' => [
411 'name' => 'UI_mobile_provider_id',
413 0 => 'mobile_provider_id',
415 'localizable' => FALSE,
416 'sig' => 'civicrm_phone::0::mobile_provider_id',
418 'index_phone_numeric' => [
419 'name' => 'index_phone_numeric',
421 0 => 'phone_numeric',
423 'localizable' => FALSE,
424 'sig' => 'civicrm_phone::0::phone_numeric',
427 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;