Refactor phone type CRM-12464
authorColeman Watts <coleman@civicrm.org>
Tue, 30 Apr 2013 22:07:34 +0000 (15:07 -0700)
committerColeman Watts <coleman@civicrm.org>
Wed, 29 May 2013 21:46:54 +0000 (14:46 -0700)
----------------------------------------
* CRM-12464: Search improvements in 4.4
  http://issues.civicrm.org/jira/browse/CRM-12464

15 files changed:
CRM/Contact/BAO/Contact.php
CRM/Contact/Form/Edit/Phone.php
CRM/Contact/Form/Search/Criteria.php
CRM/Contact/Import/Form/MapField.php
CRM/Contact/Import/Form/Preview.php
CRM/Contact/Import/ImportJob.php
CRM/Contact/Page/Inline/Phone.php
CRM/Core/BAO/Mapping.php
CRM/Core/BAO/Phone.php
CRM/Core/PseudoConstant.php
CRM/Export/BAO/Export.php
CRM/Logging/Differ.php
CRM/SMS/Provider.php
CRM/UF/Form/Field.php
CRM/UF/Page/ProfileEditor.php

index ebd47655d09e8f97044d3bd173b1997ca2538428..c721066b012c7caaddaf91f434f4729714afdc06 100644 (file)
@@ -618,7 +618,7 @@ WHERE     civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
         if ($name == 'phone') {
           CRM_Utils_Array::lookupValue($values,
             'phone_type',
-            CRM_Core_PseudoConstant::phoneType(),
+            CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'),
             $reverse
           );
         }
index 1cd598eb2b2c3f8b07a5c1b71d36dbea8e03a537..c767282e16231eae6888032f5299a8c1cd26de54 100644 (file)
@@ -61,7 +61,7 @@ class CRM_Contact_Form_Edit_Phone {
     $form->applyFilter('__ALL__', 'trim');
 
     //phone type select
-    $form->addElement('select', "phone[$blockId][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::phoneType());
+    $form->addElement('select', "phone[$blockId][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
 
     //main phone number with crm_phone class
     $form->addElement('text', "phone[$blockId][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve')));
index a26658000298f80661a84623f0ed7b89b31f2797..d95e97c50cc3fbd4d1947054ee9a7c44a1dec73a 100644 (file)
@@ -260,7 +260,7 @@ class CRM_Contact_Form_Search_Criteria {
     // Phone search
     $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
     $locationType = CRM_Core_PseudoConstant::locationType();
-    $phoneType = CRM_Core_PseudoConstant::phoneType();
+    $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType);
     $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType);
   }
index 113bc6e9ae6801fe930c6988c764e49749606500..42b2ed1546f23e6ee656a96c67dc6517b390d986 100644 (file)
@@ -353,7 +353,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Core_Form {
     $sel1 = $this->_mapperFields;
     $sel2[''] = NULL;
 
-    $phoneTypes   = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes   = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders  = CRM_Core_PseudoConstant::IMProvider();
     $websiteTypes = CRM_Core_PseudoConstant::websiteType();
 
@@ -761,7 +761,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Core_Form {
     $mapperKeys     = $this->controller->exportValue($this->_name, 'mapper');
     $mapperKeysMain = array();
 
-    $phoneTypes    = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes    = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders   = CRM_Core_PseudoConstant::IMProvider();
     $websiteTypes  = CRM_Core_PseudoConstant::websiteType();
     $locationTypes = CRM_Core_PseudoConstant::locationType();
index 16d67500e4048e8a8b3f2829783e57a5622d4583..cba79d017cab4277326f3aa90e122d4e96690ab3 100644 (file)
@@ -412,7 +412,7 @@ class CRM_Contact_Import_Form_Preview extends CRM_Core_Form {
     $mapFields = $this->get('fields');
 
     $locationTypes = CRM_Core_PseudoConstant::locationType();
-    $phoneTypes = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
 
     foreach ($mapper as $key => $value) {
       $header = array();
index fdf82831573ebb8532452860017c851a5629a422..ceeac286e8297034d501e6f7334ca171599783ba 100644 (file)
@@ -144,7 +144,7 @@ class CRM_Contact_Import_ImportJob {
   public function runImport(&$form, $timeout = 55) {
     $mapper        = $this->_mapper;
     $mapperFields  = array();
-    $phoneTypes    = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes    = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders   = CRM_Core_PseudoConstant::IMProvider();
     $websiteTypes  = CRM_Core_PseudoConstant::websiteType();
     $locationTypes = CRM_Core_PseudoConstant::locationType();
index b93e6d043eca842dd2306fd0394428f59493e48a..142b055acc809b6f89d4e15b7dbae7134c461925 100644 (file)
@@ -53,7 +53,7 @@ class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page {
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
 
     $locationTypes = CRM_Core_PseudoConstant::locationDisplayName();
-    $phoneTypes = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
 
     $entityBlock = array('contact_id' => $contactId);
     $phones = CRM_Core_BAO_Phone::getValues($entityBlock);
index 8f1094059f958886df2c6fd2019ba63fce2e8ff4..326f4443e4fbb014f4051f83ded88a06e5f3f17d 100644 (file)
@@ -565,7 +565,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
 
     $sel3['']    = NULL;
     $sel5['']    = NULL;
-    $phoneTypes  = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes  = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::IMProvider();
     asort($phoneTypes);
 
index 14572de4e2d1a81a5058688c54ebb76d154d0218..4189aa06535edaad2210dd199652e4c3c37823be 100644 (file)
@@ -109,7 +109,7 @@ class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone {
 
     $cond = NULL;
     if ($type) {
-      $phoneTypeId = array_search($type, CRM_Core_PseudoConstant::phoneType());
+      $phoneTypeId = array_search($type, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
       if ($phoneTypeId) {
         $cond = " AND civicrm_phone.phone_type_id = $phoneTypeId";
       }
@@ -179,7 +179,7 @@ ORDER BY civicrm_phone.is_primary DESC,  phone_id ASC ";
 
     $cond = NULL;
     if ($type) {
-      $phoneTypeId = array_search($type, CRM_Core_PseudoConstant::phoneType());
+      $phoneTypeId = array_search($type, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
       if ($phoneTypeId) {
         $cond = " AND civicrm_phone.phone_type_id = $phoneTypeId";
       }
index 42eb63d8525597e2b0dd36089c3a87e24d2da9d0..6bd6d44bc5efe2be04548b5b33969ec5fe01c388 100644 (file)
@@ -280,13 +280,6 @@ class CRM_Core_PseudoConstant {
    */
   private static $mappingType;
 
-  /**
-   * Phone Types
-   * @var array
-   * @static
-   */
-  private static $phoneType;
-
   /**
    * Visibility
    * @var array
@@ -710,26 +703,6 @@ class CRM_Core_PseudoConstant {
     return self::$component;
   }
 
-  /**
-   * Get all phone type
-   * The static array phoneType is returned
-   *
-   * @access public
-   * @static
-   *
-   * @param boolean $all - get All phone type - default is to get
-   * only active ones.
-   *
-   * @return array - array reference of all phone types.
-   *
-   */
-  public static function &phoneType() {
-    if (!self::$phoneType) {
-      self::$phoneType = CRM_Core_OptionGroup::values('phone_type');
-    }
-    return self::$phoneType;
-  }
-
   /**
    * Get all the IM Providers from database.
    *
index 1c03b59303f51108eb383f16565607d6ba1641aa..f4f73c5986fcb6ca9cf901a08c4bce05cd4399b4 100644 (file)
@@ -83,7 +83,7 @@ class CRM_Export_BAO_Export {
     $allCampaigns = array();
     $exportCampaign = FALSE;
 
-    $phoneTypes = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::IMProvider();
     $contactRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(
       NULL,
index e723280ffb7415c4bed551f5cec432047325a51f..74c6447f1d6f3ed7d2afe8e3979ad32da060146e 100644 (file)
@@ -237,7 +237,7 @@ WHERE log_conn_id = %1 AND
           'gender_id' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'),
           'location_type_id' => CRM_Core_PseudoConstant::locationType(),
           'payment_instrument_id' => CRM_Contribute_PseudoConstant::paymentInstrument(),
-          'phone_type_id' => CRM_Core_PseudoConstant::phoneType(),
+          'phone_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'),
           'preferred_communication_method' => CRM_Core_PseudoConstant::pcm(),
           'preferred_language' => CRM_Core_PseudoConstant::languages(),
           'prefix_id' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'),
index e26afced8d299dfe19803a68cb8fe50fb6b071b8..f524ec68c09510db1486c81487692076fdf22b15 100644 (file)
@@ -168,21 +168,23 @@ INNER JOIN civicrm_mailing_job mj ON mj.mailing_id = m.id AND mj.id = %1";
       // unknown mobile sender -- create new contact
       // use fake @mobile.sms email address for new contact since civi
       // requires email or name for all contacts
-      $locationTypes =& CRM_Core_PseudoConstant::locationType();
-      $phoneTypes    =& CRM_Core_PseudoConstant::phoneType();
-      $phoneloc  = array_search( 'Home',  $locationTypes );
-      $phonetype = array_search( 'Mobile', $phoneTypes );
+      $locationTypes = CRM_Core_PseudoConstant::locationType();
+      $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
+      $phoneloc = array_search('Home', $locationTypes);
+      $phonetype = array_search('Mobile', $phoneTypes);
       $stripFrom = $this->stripPhone($from);
-      $contactparams =
-        Array ( 'contact_type' => 'Individual',
-                'email' => Array ( 1 => Array ( 'location_type_id' => $phoneloc,
-                                                'email' => $stripFrom . '@mobile.sms' )
-                                   ),
-                'phone' => Array ( 1 => Array( 'phone_type_id' => $phonetype,
-                                               'location_type_id' => $phoneloc,
-                                               'phone' => $stripFrom )
-                                   )
-                );
+      $contactparams = array(
+        'contact_type' => 'Individual',
+        'email' => array(1 => array(
+          'location_type_id' => $phoneloc,
+          'email' => $stripFrom . '@mobile.sms'
+        )),
+        'phone' => array(1 => array(
+          'phone_type_id' => $phonetype,
+          'location_type_id' => $phoneloc,
+          'phone' => $stripFrom
+        )),
+      );
       $fromContact = CRM_Contact_BAO_Contact::create($contactparams, FALSE, TRUE, FALSE);
       $fromContactID = $fromContact->id;
     }
index bde9c82a7e2f168d4bd910c5274298ec4092b48e..ba6c29b0c91efc259026444bd6508ff4789f6ded 100644 (file)
@@ -331,7 +331,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form {
       }
     }
     $sel3[''] = NULL;
-    $phoneTypes = CRM_Core_PseudoConstant::phoneType();
+    $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     ksort($phoneTypes);
 
     foreach ($sel1 as $k => $sel) {
index 5dc05d059e9fdbc1d4c2bab8969772516bc445f3..fd1dda2f347598f9b183a4dccc4bec8818396ea0 100644 (file)
@@ -23,7 +23,7 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page {
         return array(
           'PseudoConstant' => array(
             'locationType' => CRM_Core_PseudoConstant::locationType(),
-            'phoneType' => CRM_Core_PseudoConstant::phoneType(),
+            'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'),
           ),
           'initialProfileList' => civicrm_api('UFGroup', 'get', array(
             'version' => 3,