fix CRM-11994 and also a bunch of php 5.4 notices
authorDonald A. Lobo <lobo@civicrm.org>
Tue, 5 Mar 2013 21:54:26 +0000 (13:54 -0800)
committerDonald A. Lobo <lobo@civicrm.org>
Tue, 5 Mar 2013 21:54:26 +0000 (13:54 -0800)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/ContributionPage/Settings.php
CRM/Member/BAO/Membership.php
CRM/Price/BAO/Set.php

index 271d89bcf6ab96d1631ba6e55014997baf7c9b9e..6d921c2a828872a40b1cc21fab43561ab14fe992 100644 (file)
@@ -55,11 +55,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
   public function preProcess() {
     $config = CRM_Core_Config::singleton();
     parent::preProcess();
-    
+
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     $this->_paymentProcessor = $this->get('paymentProcessor');
-    
+
     if ($this->_contributeMode == 'express') {
       // rfp == redirect from paypal
       $rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean',
@@ -74,7 +74,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $this->_params['payer_status'] = $expressParams['payer_status'];
 
         CRM_Core_Payment_Form::mapParams($this->_bltID, $expressParams, $this->_params, FALSE);
-        
+
         // fix state and country id if present
         if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"]) && $this->_params["billing_state_province_id-{$this->_bltID}"]) {
           $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
@@ -140,7 +140,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $this->_params['amount'] = $this->get('amount');
 
       $this->_useForMember = $this->get('useForMember');
-      
+
       if (isset($this->_params['amount'])) {
         $priceField = new CRM_Price_DAO_Field();
         $priceField->price_set_id = $this->_params['priceSetId'];
@@ -208,21 +208,21 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
           if ($locType == 'Primary') {
             $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
             $locType = $defaultLocationType->id;
-          }        
-          
+          }
+
           if ($field == 'country') {
             $value = CRM_Core_PseudoConstant::countryIsoCode($value);
           }
           elseif ($field == 'state_province') {
             $value = CRM_Core_PseudoConstant::stateProvinceAbbreviation($value);
           }
-          
+
           $isPrimary = 1;
           if (isset($this->_params['onbehalf_location']['address'])
                && count($this->_params['onbehalf_location']['address']) > 0) {
             $isPrimary = 0;
           }
-                    
+
           $this->_params['onbehalf_location']['address'][$locType][$field] = $value;
           if (!CRM_Utils_Array::value('is_primary', $this->_params['onbehalf_location']['address'][$locType])) {
             $this->_params['onbehalf_location']['address'][$locType]['is_primary'] = $isPrimary;
@@ -682,7 +682,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         foreach ($params['onbehalf'] as $fld => $values) {
           if (strstr($fld, 'custom_')) {
             $behalfOrganization[$fld] = $values;
-          }  
+          }
           elseif (!(strstr($fld, '-'))) {
             if (in_array($fld, array(
               'contribution_campaign_id', 'member_campaign_id'))) {
@@ -690,7 +690,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
             }
             else {
               $behalfOrganization[$fld] = $values;
-            } 
+            }
             $this->_params[$fld] = $values;
           }
         }
@@ -770,7 +770,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     }
     else {
       $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type');
-      $contactID = &CRM_Contact_BAO_Contact::createProfileContact($params,
+      $contactID = CRM_Contact_BAO_Contact::createProfileContact($params,
         $fields,
         $contactID,
         $addToGroups,
@@ -906,10 +906,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $membershipParams['types_terms'] = $membershipTypeTerms;
       }
       if (CRM_Utils_Array::value('selectMembership', $membershipParams)) {
-      CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
-        $this, $premiumParams, $customFieldsFormatted,
-        $fieldTypes
-      );
+        CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
+          $this, $premiumParams, $customFieldsFormatted,
+          $fieldTypes
+        );
     }
     }
     else {
@@ -963,7 +963,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $this->assign('option', CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams));
 
       $periodType = $productDAO->period_type;
-      
+
       if ($periodType) {
         $fixed_period_start_day = $productDAO->fixed_period_start_day;
         $duration_unit = $productDAO->duration_unit;
@@ -1039,9 +1039,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       if ($daoContrProd->find(TRUE)) {
         $params['id'] = $daoContrProd->id;
       }
-      
+
       CRM_Contribute_BAO_Contribution::addPremium($params);
-      if ($productDAO->cost && CRM_Utils_Array::value('financial_type_id', $params)) {    
+      if ($productDAO->cost && CRM_Utils_Array::value('financial_type_id', $params)) {
         $trxnParams = array(
           'cost' => $productDAO->cost,
           'currency' => $productDAO->currency,
@@ -1277,13 +1277,13 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
     if ($params['amount']) {
       $contribParams['line_item'] = $form->_lineItem;
-      //add contribution record
-      $contribution = &CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
+      h//add contribution record
+      $contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
     }
-    
+
     // process soft credit / pcp pages
     CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
-  
+
     //handle pledge stuff.
     if (
       !CRM_Utils_Array::value('separate_membership_payment', $form->_params) &&
@@ -1412,7 +1412,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $contactID,
       'email-' . $form->_bltID
     );
-    
+
     //create contribution activity w/ individual and target
     //activity w/ organisation contact id when onbelf, CRM-4027
     $targetContactID = NULL;
@@ -1434,7 +1434,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    * Create the recurring contribution record
    *
    */
-  function processRecurringContribution(&$form, &$params, $contactID, $contributionType, $online = TRUE) {
+  static function processRecurringContribution(&$form, &$params, $contactID, $contributionType, $online = TRUE) {
     // return if this page is not set for recurring
     // or the user has not chosen the recurring option
 
@@ -1522,10 +1522,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       //don't create contact - possibly the form was left blank
       return null;
     }
-    
+
     //assign to template for email receipt
     $honor_block_is_active = $this->get('honor_block_is_active');
-    
+
     $this->assign('honor_block_is_active', $honor_block_is_active);
     $this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
 
index 8564305c76d2d04480372c403d4566f8c75a4951..c470427f837b2ead0d93d8507bf69322d3dac16f 100644 (file)
@@ -1169,7 +1169,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     return empty($errors) ? TRUE : $errors;
   }
 
-  public function computeAmount(&$params, &$form) {
+  public static function computeAmount(&$params, &$form) {
     $amount = NULL;
 
     // first clean up the other amount field if present
index 39afc21a22d18892acbb016c96fea089d3620570..91bc8c0204984d236589d18186684fbe8f33aa58 100644 (file)
@@ -69,7 +69,11 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
         'entity_table' => 'civicrm_contribution_page',
         'entity_id' => $this->_id,
       );
-      $defaults['onbehalf_profile_id'] = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+      $onBehalfIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+      if ($onBehalfIDs) {
+        // get the first one only
+        $defaults['onbehalf_profile_id'] = $onBehalfIDs[0];
+      }
     }
     else {
       CRM_Utils_System::setTitle(ts('Title and Settings'));
@@ -202,7 +206,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
     ) {
       $errors['onbehalf_profile_id'] = ts('Please select a profile to collect organization information on this contribution page.');
     }
-    
+
     //CRM-11494
     $start = CRM_Utils_Date::processDate($values['start_date']);
     $end = CRM_Utils_Date::processDate($values['end_date']);
@@ -211,14 +215,14 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
     }
 
     //dont allow on behalf of save when
-    //pre or post profile consists of membership fields 
+    //pre or post profile consists of membership fields
     if ($contributionPageId && CRM_Utils_Array::value('is_organization', $values)) {
       $ufJoinParams = array(
         'module' => 'CiviContribute',
         'entity_table' => 'civicrm_contribution_page',
         'entity_id' => $contributionPageId,
       );
-      
+
       list($contributionProfiles['custom_pre_id'],
         $contributionProfiles['custom_post_id']
       ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
@@ -234,7 +238,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_
       if ($contributionProfiles['custom_post_id']) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($contributionProfiles['custom_post_id']);
         if ($postProfileType == 'Membership') {
-          $conProfileType  = empty($conProfileType) ? "'Includes Profile (bottom of page)'" : "{$conProfileType} and 'Includes Profile (bottom of page)'";          
+          $conProfileType  = empty($conProfileType) ? "'Includes Profile (bottom of page)'" : "{$conProfileType} and 'Includes Profile (bottom of page)'";
         }
       }
       if (!empty($conProfileType)) {
index 90242ab19c474281f77a4d24742fe38f2761fff4..4bf3f690b6fd217922a83793e25b96ee81b63d4b 100644 (file)
@@ -1178,7 +1178,7 @@ AND civicrm_membership.is_test = %2";
    * @return void
    * @access public
    */
-  public function postProcessMembership($membershipParams, $contactID, &$form, &$premiumParams,
+  public static function postProcessMembership($membershipParams, $contactID, &$form, &$premiumParams,
     $customFieldsFormatted = NULL, $includeFieldTypes = NULL
   ) {
     $tempParams  = $membershipParams;
index ca9984efeac219db4f41e180cae2ac2ee30c3003..02838cbdbe0da273d83715c1d1c494147b9ff2cb 100644 (file)
@@ -226,7 +226,7 @@ WHERE
           $ids = implode(',', $entities);
           $queryString = "SELECT cp.id as id, cp.title as title, cp.start_date as startDate, cp.end_date as endDate,ct.name as type
 FROM      civicrm_contribution_page cp, civicrm_financial_type ct
-WHERE     ct.id = cp.financial_type_id AND 
+WHERE     ct.id = cp.financial_type_id AND
           cp.id IN ($ids) AND
           cp.is_active = 1;";
           $crmDAO = CRM_Core_DAO::executeQuery($queryString);
@@ -677,7 +677,11 @@ WHERE  id = %1";
           }
           CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
           $totalPrice += $lineItem[$optionValueId]['line_total'];
-          if ($component) {
+          if (
+            $component &&
+            isset($lineItem[$optionValueId]['auto_renew']) &&
+            is_numeric($lineItem[$optionValueId]['auto_renew'])
+          ) {
             $autoRenew[$lineItem[$optionValueId]['auto_renew']] += $lineItem[$optionValueId]['line_total'];
           }
           break;
@@ -696,7 +700,11 @@ WHERE  id = %1";
           }
           CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
           $totalPrice += $lineItem[$optionValueId]['line_total'];
-          if ($component) {
+          if (
+            $component &&
+            isset($lineItem[$optionValueId]['auto_renew']) &&
+            is_numeric($lineItem[$optionValueId]['auto_renew'])
+          ) {
             $autoRenew[$lineItem[$optionValueId]['auto_renew']] += $lineItem[$optionValueId]['line_total'];
           }
           break;
@@ -721,7 +729,11 @@ WHERE  id = %1";
           CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
           foreach ($optionIds as $optionId) {
             $totalPrice += $lineItem[$optionId]['line_total'];
-            if ($component) {
+            if (
+              $component &&
+              isset($lineItem[$optionId]['auto_renew']) &&
+              is_numeric($lineItem[$optionId]['auto_renew'])
+            ) {
               $autoRenew[$lineItem[$optionId]['auto_renew']] += $lineItem[$optionId]['line_total'];
             }
           }
@@ -751,7 +763,7 @@ WHERE  id = %1";
     if ($component) {
       foreach ($autoRenew as $dontCare => $eachAmount) {
         if (!$eachAmount) {
-          unset($autoRenew[$dontCare]);  
+          unset($autoRenew[$dontCare]);
         }
       }
       if (count($autoRenew) > 1 ) {
@@ -1124,15 +1136,15 @@ GROUP BY     mt.member_of_contact_id";
   }
 
   /**
-   * Check if price set id provides option for 
+   * Check if price set id provides option for
    * user to select both auto-renew and non-auto-renew memberships
    *
-   * @access public                                                                                                                                                                                     
+   * @access public
    * @static
    *
    */
   public static function checkMembershipPriceSet($id) {
-    $query = 
+    $query =
 "
 SELECT      pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew
 FROM        civicrm_price_field_value pfv
@@ -1150,7 +1162,7 @@ WHERE       ps.id = %1
     //2 membership types can be selected
     //instead of comparing all of them
     while ($dao->fetch()) {
-      //temp fix for #CRM-10370 
+      //temp fix for #CRM-10370
       //if its NULL consider it '0' i.e. 'No auto-renew option'
       $daoAutoRenew = $dao->auto_renew;
       if ($daoAutoRenew === NULL) {