From d77a0a586a6231def5fb62b352d4ef0301bf8e4b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 14 May 2014 15:59:42 +1200 Subject: [PATCH] more minor tidy-ups & comment fixes --- CRM/Contribute/Form/AdditionalInfo.php | 2 +- CRM/Contribute/Form/Contribution.php | 70 ++++++++++++++++++-------- CRM/Contribute/Form/SoftCredit.php | 2 +- CRM/Core/Form.php | 5 ++ CRM/Core/Payment.php | 2 +- CRM/Utils/Request.php | 12 ++--- 6 files changed, 64 insertions(+), 29 deletions(-) diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index d16051062d..a086cdeb99 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -330,7 +330,7 @@ class CRM_Contribute_Form_AdditionalInfo { * @param bool $ccContribution * @access public. * - * @return void. + * @return array */ static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { $form->assign('receiptType', 'contribution'); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index dcce07bb40..c27932b18d 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -39,7 +39,7 @@ */ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditPayment { /** - * the id of the contribution that we are proceessing + * the id of the contribution that we are processing * * @var int * @public @@ -47,7 +47,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP public $_id; /** - * the id of the premium that we are proceessing + * the id of the premium that we are processing * * @var int * @public @@ -151,11 +151,24 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP * @var array */ public $_fromEmails; + + /** + * ID of from email + * @var integer + */ + public $fromEmailId; /* * Store the line items if price set used. */ public $_lineItems; + /** + * line item + * @todo explain why we use lineItem & lineItems + * @var array + */ + public $_lineItem; + /** * @var array soft credit info */ @@ -189,6 +202,19 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ public $_priceSet; + /** + * form defaults + * @todo can we define this a as protected? can we define higher up the chain + * @var array + */ + public $_defaults; + + /** + * User display name + * + * @var string + */ + public $userDisplayName; /** * Function to set variables up before form is built * @@ -211,8 +237,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP return; } - $config = CRM_Core_Config::singleton(); - $this->_formType = CRM_Utils_Array::value('formType', $_GET); // get price set id. @@ -272,7 +296,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP return; } - if (in_array('CiviPledge', $config->enableComponents) && !$this->_formType) { + if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) { $this->preProcessPledge(); } @@ -339,7 +363,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $defaults['option_type'] = 1; } - $fields = array(); if ($this->_action & CRM_Core_Action::DELETE) { return $defaults; } @@ -655,7 +678,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP TRUE, array('onChange' => "CRM.buildCustomData( 'Contribution', this.value );") ); - + $paymentInstrument = FALSE; if (!$this->_mode) { $paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Paid By'), @@ -973,7 +996,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ public function postProcess() { $session = CRM_Core_Session::singleton(); - $sendReceipt = FALSE; + $sendReceipt = $pId = $contribution = FALSE; + $softParams = $softIDs =array(); + if ($this->_action & CRM_Core_Action::DELETE) { CRM_Contribute_BAO_Contribution::deleteContribution($this->_id); $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', @@ -1056,9 +1081,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { $isQuickConfig = 1; } - //CRM-11529 for quick config backoffice transactions + //CRM-11529 for quick config back office transactions //when financial_type_id is passed in form, update the - //lineitems with the financial type selected in form + //line items with the financial type selected in form if ($isQuickConfig && !empty($submittedValues['financial_type_id']) && CRM_Utils_Array::value($this->_priceSetId, $lineItem) ) { foreach ($lineItem[$this->_priceSetId] as &$values) { @@ -1091,7 +1116,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } else { //build soft credit params - $softParams = $softIDs =array(); foreach ($submittedValues['soft_credit_contact_id'] as $key => $val) { if ($val && $submittedValues['soft_credit_amount'][$key]) { $softParams[$key]['contact_id'] = $val; @@ -1113,7 +1137,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP //Credit Card Contribution. if ($this->_mode) { - $this->processCreditCard($submittedValues, $config, $session, $pId, $lineItem); + $this->processCreditCard($submittedValues, $config, $session, $lineItem); } else { //Offline Contribution. @@ -1200,13 +1224,10 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } // CRM-11956 - // 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']))) { - $params['non_deductible_amount'] = $params['non_deductible_amount']; - } + // if non_deductible_amount exists i.e. Additional Details field set was opened [and staff typed something] - // if non_deductible_amount does NOT exist - then calculate it depending on: // $ContributionType->is_deductible and whether there is a product (premium). - else { + if (!isset($params['non_deductible_amount']) || (!empty($params['non_deductible_amount']))) { $contributionType = new CRM_Financial_DAO_FinancialType(); $contributionType->id = $params['financial_type_id']; if (!$contributionType->find(TRUE)) { @@ -1376,7 +1397,16 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } } - public function processCreditCard($submittedValues, $config, $session, $pId, $lineItem) { + /** + * @param $submittedValues + * @param $config + * @param $session CRM_Core_Session + * @param $lineItem + * + * @throws CRM_Core_Exception + */ + public function processCreditCard($submittedValues, $config, $session, $lineItem) { + $sendReceipt = $contribution = FALSE; $unsetParams = array( 'trxn_id', 'payment_instrument_id', @@ -1422,7 +1452,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $params['email-Primary'] = $this->userEmail; // now set the values for the billing location. - foreach ($this->_fields as $name => $dontCare) { + foreach (array_keys($this->_fields) as $name) { $fields[$name] = 1; } @@ -1544,7 +1574,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } if ($paymentParams['amount'] > 0.0) { - // force a reget of the payment processor in case the form changed it, CRM-7179 + // force a re-get of the payment processor in case the form changed it, CRM-7179 $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this, TRUE); $result = $payment->doDirectPayment($paymentParams); } diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php index 59f893aed0..415fe372f3 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -196,7 +196,7 @@ class CRM_Contribute_Form_SoftCredit { * @param $errors * @param $self * - * @return true if no errors, else array of errors + * @return array of errors * @access public * @static */ diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 1112f75d75..ae09c486bd 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -117,6 +117,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ public $urlPath = array(); + /** + * @var CRM_Core_Controller + */ + public $controller; + /** * constants for attributes for various form elements * attempt to standardize on the number of variations that we diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index d4a96e4d81..2256fbae41 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -87,7 +87,7 @@ abstract class CRM_Core_Payment { * singleton function used to manage this object * * @param string $mode the mode of operation: live or test - * @param object $paymentProcessor the details of the payment processor being invoked + * @param array $paymentProcessor the details of the payment processor being invoked * @param object $paymentForm reference to the form object if available * @param boolean $force should we force a reload of this payment object * diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index 7512777324..eea57653e1 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -57,12 +57,12 @@ class CRM_Utils_Request { /** * Retrieve a value from the request (GET/POST/REQUEST) * - * @param $name string name of the variable to be retrieved - * @param $type string type of the variable (see CRM_Utils_Type for details) - * @param $store session scope where variable is stored - * @param bool|\is $abort is this variable required - * @param $default default value of the variable if not present - * @param string|\where $method where should we look for the variable + * @param string $name name of the variable to be retrieved + * @param string $type type of the variable (see CRM_Utils_Type for details) + * @param stdClass $store session scope where variable is stored + * @param bool $abort is this variable required + * @param mixed $default default value of the variable if not present + * @param string $method where should we look for the variable * * @return mixed the value of the variable * @access public -- 2.25.1