CRM-15172 - Refactor forms to use addChainSelect method
[civicrm-core.git] / CRM / Contribute / Form / Contribution / ThankYou.php
index 66d900e1b6e2aa81fe660f51b1a04bfd9420c678..ded9e83f7fe79937094392cd73f48250080fe589 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -63,7 +63,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     $this->assign('max_reminders', CRM_Utils_Array::value('max_reminders', $this->_values));
     $this->assign('initial_reminder_day', CRM_Utils_Array::value('initial_reminder_day', $this->_values));
     CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->_values));
-    // Make the contributionPageID avilable to the template
+    // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', $this->_values['is_share']);
 
@@ -119,36 +119,13 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     $this->assign('useForMember', $this->get('useForMember'));
 
     $params = $this->_params;
-    $honor_block_is_active = $this->get('honor_block_is_active');
-    if ($honor_block_is_active && !empty($params['soft_credit_type_id'])) {
+    if ($this->_honor_block_is_active && !empty($params['soft_credit_type_id'])) {
       $honorName = null;
       $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
 
-      $this->assign('honor_block_is_active', $honor_block_is_active);
+      $this->assign('honor_block_is_active', $this->_honor_block_is_active);
       $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]);
-      $profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
-      switch ($profileContactType) {
-        case 'Individual':
-          if (array_key_exists('prefix_id', $params['honor'])) {
-            $honorName = CRM_Utils_Array::value(CRM_Utils_Array::value('prefix_id',$params['honor']),
-              CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
-            );
-          }
-          $honorName .= ' ' . $params['honor']['first_name'] . ' ' . $params['honor']['last_name'];
-          if (array_key_exists('suffix_id', $params['honor'])) {
-            $honorName .= ' ' . CRM_Utils_Array::value(CRM_Utils_Array::value('suffix_id',$params['honor']),
-              CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
-            );
-          }
-          break;
-        case 'Organization':
-          $honorName = $params['honor']['organization_name'];
-          break;
-        case 'Household':
-          $honorName = $params['honor']['household_name'];
-          break;
-      }
-      $this->assign('honorName', $honorName);
+      CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($this, $params['honor'], $params['honoree_profile_id']);
 
       $fieldTypes = array('Contact');
       $fieldTypes[]  = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
@@ -249,9 +226,6 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
       }
     }
 
-    // now fix all state country selectors
-    CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
-
     $this->_submitValues = array_merge($this->_submitValues, $defaults);
     $this->setDefaults($defaults);