minor code tidy ups highlighted by IDE
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 7 May 2014 23:55:42 +0000 (11:55 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 7 May 2014 23:55:42 +0000 (11:55 +1200)
CRM/Contact/Form/Task/PDFLetterCommon.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/ContributionBase.php
CRM/Core/Error.php
CRM/Pledge/BAO/Pledge.php

index f67aa261c1518908bf5a1c13b7de191ac6db0f74..8037b9e24dfbf8662ec0ccf3b2696875ffa58f73 100644 (file)
@@ -257,6 +257,8 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
    *
    * @access protected
    *
+   * @param $form
+   *
    * @return array( $categories, $html_message, $messageToken, $returnProperties )
    */
   static protected function processMessageTemplate(&$form) {
@@ -330,6 +332,8 @@ class CRM_Contact_Form_Task_PDFLetterCommon {
    *
    * @access public
    *
+   * @param $form
+   *
    * @return void
    */
   static function postProcess(&$form) {
index ced16cd19c99f03c39d04cf861589c96d7b45a63..5098e66b7db096ce41e50da76b531eaf2b62259b 100644 (file)
@@ -570,7 +570,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    * @access public
    */
   public function postProcess() {
-    $config = CRM_Core_Config::singleton();
     $contactID = $this->getContactID();
 
     // add a description field at the very beginning
@@ -582,7 +581,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     );
 
     // fix currency ID
-    $this->_params['currencyID'] = $config->defaultCurrency;
+    $this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
 
     $premiumParams = $membershipParams = $tempParams = $params = $this->_params;
 
@@ -889,6 +888,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         foreach ($priceFieldIds as $priceFieldId) {
           if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
             $membershipTypeIds[] = $id;
+            //@todo the value for $term is immediately overwritten. It is unclear from the code whether it was intentional to
+            // do this or a double = was intended (this ambiguity is the reason many IDEs complain about 'assignment in condition'
             $term = 1;
             if ($term = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_num_terms')) {
               $membershipTypeTerms[$id] = ($term > 1) ? $term : 1;
@@ -1120,7 +1121,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     }
     $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $contributionType, $online);
 
-    $config = CRM_Core_Config::singleton();
     // CRM-11885
     // if non_deductible_amount exists i.e. Additional Details fieldset was opened [and staff typed something] -> keep it.
     if (isset($params['non_deductible_amount']) && (!empty($params['non_deductible_amount']))) {
@@ -1171,7 +1171,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     }
 
     //get the contrib page id.
-    $campaignId = $contributionPageId = NULL;
+    $contributionPageId = NULL;
     if ($online) {
       $contributionPageId = $form->_id;
       $campaignId = CRM_Utils_Array::value('campaign_id', $params);
@@ -1468,9 +1468,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       return NULL;
     }
 
-    $recurParams = array();
-    $config = CRM_Core_Config::singleton();
-    $recurParams['contact_id'] = $contactID;
+    $recurParams = array('contact_id' => $contactID);
     $recurParams['amount'] = CRM_Utils_Array::value('amount', $params);
     $recurParams['auto_renew'] = CRM_Utils_Array::value('auto_renew', $params);
     $recurParams['frequency_unit'] = CRM_Utils_Array::value('frequency_unit', $params);
@@ -1553,6 +1551,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    */
   static function processOnBehalfOrganization(&$behalfOrganization, &$contactID, &$values, &$params, $fields = NULL) {
     $isCurrentEmployer = FALSE;
+    $dupeIDs = array();
     $orgID = NULL;
     if (!empty($behalfOrganization['organization_id']) && !empty($behalfOrganization['org_option'])) {
       $orgID = $behalfOrganization['organization_id'];
@@ -1659,23 +1658,23 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
   static function processPcpSoft(&$params, &$contribution) {
     //add soft contribution due to pcp or Submit Credit / Debit Card Contribution by admin.
     if (!empty($params['soft_credit_to'])) {
-      $contribSoftParams = array();
+      $contributionSoftParams = array();
       foreach (array(
         'pcp_display_in_roll', 'pcp_roll_nickname', 'pcp_personal_note', 'amount') as $val) {
         if (!empty($params[$val])) {
-          $contribSoftParams[$val] = $params[$val];
+          $contributionSoftParams[$val] = $params[$val];
         }
       }
 
-      $contribSoftParams['contact_id'] = $params['soft_credit_to'];
+      $contributionSoftParams['contact_id'] = $params['soft_credit_to'];
       // add contribution id
-      $contribSoftParams['contribution_id'] = $contribution->id;
+      $contributionSoftParams['contribution_id'] = $contribution->id;
       // add pcp id
-      $contribSoftParams['pcp_id'] = $params['pcp_made_through_id'];
+      $contributionSoftParams['pcp_id'] = $params['pcp_made_through_id'];
 
-      $contribSoftParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
+      $contributionSoftParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
 
-      $softContribution = CRM_Contribute_BAO_ContributionSoft::add($contribSoftParams);
+      CRM_Contribute_BAO_ContributionSoft::add($contributionSoftParams);
     }
   }
 
index 340e8f5098a5d4a19fd0932e82f4c822200e7888..e9535cae9ac66c69ab463c2ee6ac8aa5c7fc609c 100644 (file)
@@ -195,6 +195,17 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
    */
   public $_honor_block_is_active = FALSE;
 
+  /**
+   * Contribution mode e.g express for payment express, notify for off-site + notification back to CiviCRM
+   * @var string
+   */
+  public $_contributeMode;
+
+  /**
+   * contribution page supports memberships
+   * @var boolean
+   */
+  public $_useForMember;
   /**
    * Function to set variables up before form is built
    *
index ee1f1037261c5c519b4b591976de8068dc9d5e0e..1da9a4fbab28525c101dff8114f5734bba1852ee 100644 (file)
@@ -119,7 +119,12 @@ class CRM_Core_Error extends PEAR_ErrorStack {
     return NULL;
   }
 
-  function displaySessionError(&$error, $separator = '<br />') {
+  /**
+   * Status display function specific to payment processor errors
+   * @param $error
+   * @param string $separator
+   */
+  static function displaySessionError(&$error, $separator = '<br />') {
     $message = self::getMessages($error, $separator);
     if ($message) {
       $status = ts("Payment Processor Error message") . "{$separator} $message";
index e6b8e8d98f9fbd6103d80904c958187ae3d6e6ea..654ca965ac76bbb8876155f66412c28e9e2ae5b0 100644 (file)
@@ -489,7 +489,7 @@ GROUP BY  currency
    *
    * @return void.
    */
-  function sendAcknowledgment(&$form, $params) {
+  static function sendAcknowledgment(&$form, $params) {
     //handle Acknowledgment.
     $allPayments = $payments = array();