UFGroup.php - Code cleanup
[civicrm-core.git] / CRM / Core / BAO / UFGroup.php
index b449f454e04b61dff2e1e55b7d4644e199d9a7c5..05fd61d48e280fcdbdaa39587dd3e771b310327e 100644 (file)
@@ -1178,9 +1178,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           }
           elseif ($fieldName == 'im') {
             $providerId = $detailName . '-provider_id';
-            $providerName = $imProviders[$details->$providerId];
-            if ($providerName) {
-              $values[$index] = $details->$detailName . " (" . $providerName . ")";
+            if (isset($imProviders[$details->$providerId])) {
+              $values[$index] = $details->$detailName . " (" . $imProviders[$details->$providerId] . ")";
             }
             else {
               $values[$index] = $details->$detailName;
@@ -1872,16 +1871,10 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         $form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required');
       }
     }
-    elseif ($fieldName === 'prefix_id') {
+    elseif ($fieldName === 'prefix_id' || $fieldName === 'suffix_id') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $required
-      );
-    }
-    elseif ($fieldName === 'suffix_id') {
-      $form->add('select', $name, $title,
-        array(
-          '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $required
+          '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_BAO_Contact', $fieldName), $required
       );
     }
     elseif ($fieldName === 'contact_sub_type') {
@@ -2367,13 +2360,15 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
                         $defaults[$fldName] = $value['county_id'];
                       }
                       elseif ($fieldName == 'country') {
-                        $defaults[$fldName] = $value['country_id'];
                         if (!isset($value['country_id']) || !$value['country_id']) {
                           $config = CRM_Core_Config::singleton();
                           if ($config->defaultContactCountry) {
                             $defaults[$fldName] = $config->defaultContactCountry;
                           }
                         }
+                        else {
+                          $defaults[$fldName] = $value['country_id'];
+                        }
                       }
                       elseif ($fieldName == 'phone') {
                         if ($phoneTypeId) {
@@ -3060,7 +3055,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    *
    * @return void.
    */
-  function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
+  public static function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
     if (!$componentId ||
       !in_array($component, array('Contribute', 'Membership', 'Event', 'Activity'))
     ) {