manual merge of fixes for CRM-13981
[civicrm-core.git] / CRM / Contribute / Form / Task / Batch.php
index 92c90bb9de059142fceb8d7a2067ddfbab57d525..c0a3975ac2a3c466735eceb3ebda328766e14c5f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -65,8 +65,8 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
    */
   function preProcess() {
     /*
-         * initialize the task and row fields
-         */
+     * initialize the task and row fields
+     */
     parent::preProcess();
 
     //get the contact read only fields to display.
@@ -141,7 +141,6 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
 
     $this->assign('profileTitle', $this->_title);
     $this->assign('componentIds', $this->_contributionIds);
-    $fileFieldExists = FALSE;
 
     //load all campaigns.
     if (array_key_exists('contribution_campaign_id', $this->_fields)) {
@@ -156,17 +155,17 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
     //fix for CRM-2752
     $customFields = CRM_Core_BAO_CustomField::getFields('Contribution');
     foreach ($this->_contributionIds as $contributionId) {
-            $typeId = CRM_Core_DAO::getFieldValue( "CRM_Contribute_DAO_Contribution", $contributionId, 'financial_type_id' ); 
+      $typeId = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $contributionId, 'financial_type_id');
       foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
           $customValue = CRM_Utils_Array::value($customFieldID, $customFields);
-          if (CRM_Utils_Array::value('extends_entity_column_value', $customValue)) {
+          if (!empty($customValue['extends_entity_column_value'])) {
             $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR,
               $customValue['extends_entity_column_value']
             );
           }
 
-          if (CRM_Utils_Array::value($typeId, $entityColumnValue) ||
+          if (!empty($entityColumnValue[$typeId]) ||
             CRM_Utils_System::isNull($entityColumnValue[$typeId])
           ) {
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contributionId);
@@ -196,7 +195,7 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   function setDefaultValues() {
     if (empty($this->_fields)) {
@@ -217,7 +216,7 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
    *
    * @access public
    *
-   * @return None
+   * @return void
    */
   public function postProcess() {
     $params = $this->exportValues();
@@ -242,24 +241,24 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
             $value[$val] = CRM_Utils_Date::processDate($value[$val]);
           }
         }
-        if (CRM_Utils_Array::value('financial_type', $value)) {
+        if (!empty($value['financial_type'])) {
           $value['financial_type_id'] = $value['financial_type'];
         }
 
-        if (CRM_Utils_Array::value('payment_instrument', $value)) {
+        if (!empty($value['payment_instrument'])) {
           $value['payment_instrument_id'] = $value['payment_instrument'];
         }
 
-        if (CRM_Utils_Array::value('contribution_source', $value)) {
+        if (!empty($value['contribution_source'])) {
           $value['source'] = $value['contribution_source'];
         }
 
-                unset($value['financial_type']);
+        unset($value['financial_type']);
         unset($value['contribution_source']);
         $contribution = CRM_Contribute_BAO_Contribution::add($value, $ids);
 
         // add custom field values
-        if (CRM_Utils_Array::value('custom', $value) &&
+        if (!empty($value['custom']) &&
           is_array($value['custom'])
         ) {
           CRM_Core_BAO_CustomValueTable::store($value['custom'], 'civicrm_contribution', $contribution->id);