fix PHP 5.4 static warnings
[civicrm-core.git] / CRM / Core / BAO / UFGroup.php
index 210d92e411aaa1e65b5e80e3f76bd7158b06b694..2c03cd1b37cbe84e3c034aa0959d269faee0dc13 100644 (file)
@@ -380,8 +380,6 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
 
     $formattedFields = array();
     foreach ($fieldArrs as $fieldArr) {
-      //$field = new CRM_Core_DAO_UFField();
-      //$field->copyValues($fieldArr); // no... converts string('') to string('null')
       $field = (object) $fieldArr;
       if (!self::filterUFField($field, $searchable, $showAll, $visibility)) {
         continue;
@@ -447,6 +445,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     $formattedField = array(
       'name' => $name,
       'groupTitle' => $group->title,
+      'groupName'  => $group->name,
       'groupHelpPre' => empty($group->help_pre) ? '' : $group->help_pre,
       'groupHelpPost' => empty($group->help_post) ? '' : $group->help_post,
       'title' => $title,
@@ -462,10 +461,19 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
       'location_type_id' => isset($field->location_type_id) ? $field->location_type_id : NULL,
       'phone_type_id' => isset($field->phone_type_id) ? $field->phone_type_id : NULL,
       'group_id' => $group->id,
-      'add_to_group_id' => isset($field->add_to_group_id) ? $field->add_to_group_id : NULL,
-      'add_captcha' => isset($field->add_captcha) ? $field->add_captcha : NULL,
+      'add_to_group_id' => isset($group->add_to_group_id) ? $group->add_to_group_id : NULL,
+      'add_captcha' => isset($group->add_captcha) ? $group->add_captcha : NULL,
       'field_type' => $field->field_type,
       'field_id' => $field->id,
+      'pseudoconstant' => CRM_Utils_Array::value(
+        'pseudoconstant',
+        CRM_Utils_Array::value($field->field_name, $importableFields)
+      ),
+      // obsolete this when we remove the name / dbName discrepancy with gender/suffix/prefix
+      'dbName' => CRM_Utils_Array::value(
+        'dbName',
+        CRM_Utils_Array::value($field->field_name, $importableFields)
+      ),
       'skipDisplay' => 0,
     );
 
@@ -905,9 +913,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
 
     $config = CRM_Core_Config::singleton();
 
-    $locationTypes = CRM_Core_PseudoConstant::locationType();
+    $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $imProviders   = CRM_Core_PseudoConstant::IMProvider();
-    $websiteTypes  = CRM_Core_PseudoConstant::websiteType();
+    $websiteTypes  = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
 
     $multipleFields = array('url');
     $nullIndex = $nullValueIndex = ' ';
@@ -1830,7 +1838,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
     elseif ($fieldName === 'gender') {
       $genderOptions = array();
-      $gender = CRM_Core_PseudoConstant::gender();
+      $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
       foreach ($gender as $key => $var) {
         $genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key);
       }
@@ -1842,13 +1850,13 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     elseif ($fieldName === 'individual_prefix') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Core_PseudoConstant::individualPrefix(), $required
+          '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $required
       );
     }
     elseif ($fieldName === 'individual_suffix') {
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Core_PseudoConstant::individualSuffix(), $required
+          '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $required
       );
     }
     elseif ($fieldName === 'contact_sub_type') {
@@ -1966,10 +1974,10 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         if (substr($name, -1) == ']') {
           $websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
         }
-        $form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType());
+        $form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'));
       }
       else {
-        $form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType());
+        $form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'));
       }
     }
     // Note should be rendered as textarea
@@ -2017,9 +2025,19 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       );
     }
     elseif ($fieldName == 'contribution_status_id') {
+      $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
+      $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
+      foreach (array(
+                 'In Progress',
+                 'Overdue',
+                 'Refunded'
+               ) as $suppress) {
+        unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
+      }
+      
       $form->add('select', $name, $title,
         array(
-          '' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required
+          '' => ts('- select -')) + $contributionStatuses, $required
       );
     }
     elseif ($fieldName == 'currency') {
@@ -2526,15 +2544,15 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
    * @access public
    */
   static function setRegisterDefaults(&$fields, &$defaults) {
+    $config = CRM_Core_Config::singleton();
     foreach ($fields as $name => $field) {
       if (substr($name, 0, 8) == 'country-') {
-        $config = CRM_Core_Config::singleton();
-        if ($config->defaultContactCountry) {
+        if (!empty($config->defaultContactCountry)) {
           $defaults[$name] = $config->defaultContactCountry;
         }
       }
       elseif (substr($name, 0, 15) == 'state_province-') {
-        if ($config->defaultContactStateProvince) {
+        if (!empty($config->defaultContactStateProvince)) {
           $defaults[$name] = $config->defaultContactStateProvince;
         }
       }