| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
public $_component = NULL;
/**
- * Class constructor
+ * Possibly obsolete variable.
+ *
+ * If you use it please explain why it is set in the create function here.
+ *
+ * @var string
+ */
+ public $trxn_result_code;
+
+ /**
+ * Class constructor.
*
* @return \CRM_Contribute_DAO_Contribution
*/
}
/**
- * Takes an associative array and creates a contribution object
+ * Takes an associative array and creates a contribution object.
*
* the function extract all the params it needs to initialize the create a
* contribution object. the params array could contain additional unused name/value
* @param array $ids
* The array that holds all the db ids.
*
- * @return CRM_Contribute_BAO_Contribution
+ * @return CRM_Contribute_BAO_Contribution|void
*/
public static function add(&$params, $ids = array()) {
if (empty($params)) {
- return;
+ return NULL;
}
//per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
$contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
}
/**
- * Get defaults for new entity
+ * Get defaults for new entity.
* @return array
*/
public static function getDefaults() {
}
/**
- * @param array $params
+ * Calculate net_amount & fee_amount if they are not set.
*
- * @return mixed
+ * Net amount should be total - fee.
+ * This should only be called for new contributions.
+ *
+ * @param array $params
+ * Params for a new contribution before they are saved.
*/
public static function calculateMissingAmountParams(&$params) {
if (!isset($params['fee_amount'])) {
}
/**
- * Takes an associative array and creates a contribution object
+ * Takes an associative array and creates a contribution object.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
$softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp);
$softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp);
$softParams['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'pcp', 'name');
- CRM_Contribute_BAO_ContributionSoft::add($softParams);
+ $contributionSoft = CRM_Contribute_BAO_ContributionSoft::add($softParams);
+ //Send notification to owner for PCP
+ if ($contributionSoft->pcp_id) {
+ CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
+ }
}
if (isset($params['soft_credit'])) {
$softParams = $params['soft_credit'];
}
/**
- * convert associative array names to values
- * and vice-versa.
+ * Convert associative array names to values and vice-versa.
*
* This function is used by both the web form layer and the api. Note that
* the api needs the name => value conversion, also the view layer typically
* requires value => name conversion
+ *
+ * @param array $defaults
+ * @param string $property
+ * @param array $lookup
+ * @param bool $reverse
+ *
+ * @return bool
*/
public static function lookupValue(&$defaults, $property, &$lookup, $reverse) {
$id = $property . '_id';
}
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. We'll tweak this function to be more
- * full featured over a period of time. This is the inverse function of
- * create. It also stores all the retrieved values in the default array
+ * Retrieve DB object based on input parameters.
+ *
+ * It also stores all the retrieved values in the default array.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
}
/**
- * Combine all the importable fields from the lower levels object
+ * Combine all the importable fields from the lower levels object.
*
* The ordering is important, since currently we do not have a weight
* scheme. Adding weight is super important and should be done in the
'title' => ts('Contribution Page'),
'name' => 'contribution_page',
'where' => 'civicrm_contribution_page.title',
- 'data_type' => CRM_Utils_Type::T_STRING
- ));
+ 'data_type' => CRM_Utils_Type::T_STRING,
+ ),
+ );
$contributionNote = array(
- 'contribution_note' =>
- array(
- 'title' => ts('Contribution Note'),
- 'name' => 'contribution_note',
- 'data_type' => CRM_Utils_Type::T_TEXT,
- ),
+ 'contribution_note' => array(
+ 'title' => ts('Contribution Note'),
+ 'name' => 'contribution_note',
+ 'data_type' => CRM_Utils_Type::T_TEXT,
+ ),
);
$contributionRecurId = array(
}
/**
- * Delete the indirect records associated with this contribution first
+ * Delete the indirect records associated with this contribution first.
*
* @param int $id
*
* @return mixed|null
* $results no of deleted Contribution on success, false otherwise
- * @access public
*/
public static function deleteContribution($id) {
CRM_Utils_Hook::pre('delete', 'Contribution', $id, CRM_Core_DAO::$_nullArray);
}
/**
- * Check if there is a contribution with the same trxn_id or invoice_id
+ * Check if there is a contribution with the same trxn_id or invoice_id.
*
* @param array $input
* An assoc array of name/value pairs.
* (reference) store ids of duplicate contribs.
* @param int $id
*
- * @return boolean
+ * @return bool
* true if duplicate, false otherwise
*/
public static function checkDuplicate($input, &$duplicates, $id = NULL) {
}
/**
- * Takes an associative array and creates a contribution_product object
+ * Takes an associative array and creates a contribution_product object.
*
* the function extract all the params it needs to initialize the create a
* contribution_product object. the params array could contain additional unused name/value
}
/**
- * Get list of contribution fields for profile
+ * Get list of contribution fields for profile.
* For now we only allow custom contribution fields to be in
* profile
*
}
/**
- * Add extra fields specific to contribtion
- *
+ * Add extra fields specific to contribution.
*/
public static function getSpecialContributionFields() {
$extraFields = array(
}
/**
- * Get list of contribution In Honor of contact Ids
+ * Get list of contribution In Honor of contact Ids.
*
* @param int $honorId
* In Honor of Contact ID.
}
/**
- * Get the sort name of a contact for a particular contribution
+ * Get the sort name of a contact for a particular contribution.
*
* @param int $id
* Id of the contribution.
}
/**
- * Get the contribution details for component export
+ * Get the contribution details for component export.
*
* @param int $exportMode
* Export mode.
}
/**
- * Delete billing address record related contribution
+ * Delete billing address record related contribution.
*
* @param int $contributionId
* @param int $contactId
/**
* Update contribution as well as related objects.
+ *
+ * @param array $params
+ * @param bool $processContributionObject
+ *
+ * @return array
+ * @throws \Exception
*/
public static function transitionComponents($params, $processContributionObject = FALSE) {
// get minimum required values.
WHERE membership_id=$membership->id
ORDER BY id DESC
LIMIT 1;";
- $dao = new CRM_Core_DAO;
+ $dao = new CRM_Core_DAO();
$dao->query($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
/**
* Returns all contribution related object ids.
+ *
+ * @param $contributionId
+ *
+ * @return array
*/
public static function getComponentDetails($contributionId) {
$componentDetails = $pledgePayment = array();
$query = "
SELECT c.id as contribution_id,
c.contact_id as contact_id,
+ c.contribution_recur_id,
mp.membership_id as membership_id,
m.membership_type_id as membership_type_id,
pp.participant_id as participant_id,
if ($dao->pledge_payment_id) {
$pledgePayment[] = $dao->pledge_payment_id;
}
+ if ($dao->contribution_recur_id) {
+ $componentDetails['contributionRecur'] = $dao->contribution_recur_id;
+ }
}
if ($pledgePayment) {
}
/**
- * Get individual id for onbehalf contribution
+ * Get individual id for onbehalf contribution.
*
* @param int $contributionId
* Contribution id.
}
/**
- * Load objects relations to contribution object
+ * Load objects relations to contribution object.
* Objects are stored in the $_relatedObjects property
* In the first instance we are just moving functionality from BASEIpn -
* @see http://issues.civicrm.org/jira/browse/CRM-9996
$values['financial_type_id'] = $this->financial_type_id;
}
-
$template->assign('trxn_id', $this->trxn_id);
$template->assign('receive_date',
CRM_Utils_Date::mysqlToIso($this->receive_date)
*
* @param bool $isNotCancelled
*
- * @return boolean
+ * @return bool
*/
public static function isCancelSubscriptionSupported($contributionId, $isNotCancelled = TRUE) {
$cacheKeyString = "$contributionId";
}
/**
- * Check whether subscription is already cancelled
+ * Check whether subscription is already cancelled.
*
* @param int $contributionId
* Contribution id.
}
/**
- * Create all financial accounts entry
+ * Create all financial accounts entry.
*
* @param array $params
* Contribution object, line item array and params for trxn.
$params['trxnParams']['trxn_id'] = $params['prevContribution']->trxn_id;
$params['trxnParams']['status_id'] = $params['prevContribution']->contribution_status_id;
-
if (!(($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatuses)
|| $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatuses))
&& $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatuses))
//Update contribution status
$params['trxnParams']['status_id'] = $params['contribution']->contribution_status_id;
+ $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
if (!empty($params['contribution_status_id']) &&
$params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id
) {
}
/**
- * Update all financial accounts entry
+ * Update all financial accounts entry.
*
* @param array $params
* Contribution object, line item array and params for trxn.
}
/**
- * Check status validation on update of a contribution
+ * Check status validation on update of a contribution.
*
* @param array $values
* Previous form values before submit.
}
/**
- * Delete contribution of contact
+ * Delete contribution of contact.
*
* CRM-12155
*
* @see CRM_Core_DAO::buildOptions
*
* @param string $fieldName
- * @param string $context
- * @see CRM_Core_DAO::buildOptionsContext.
- * @param array $props
- * whatever is known about this dao object.
+ * @param string $context see CRM_Core_DAO::buildOptionsContext.
+ * @param array $props whatever is known about this dao object.
*
- * @return Array|bool
+ * @return array|bool
*/
public static function buildOptions($fieldName, $context = NULL, $props = array()) {
$className = __CLASS__;
}
/**
- * Validate financial type
+ * Validate financial type.
*
* CRM-13231
*
/**
- * Function to record additional payment for partial and refund contributions
+ * Function to record additional payment for partial and refund contributions.
*
* @param int $contributionId
* is the invoice contribution id (got created after processing participant payment).
}
/**
- * Get list of payments displayed by Contribute_Page_PaymentInfo
+ * Get list of payments displayed by Contribute_Page_PaymentInfo.
*
* @param int $id
* @param $component
return CRM_Utils_Array::value('financial_account_id', $result);
}
+ /**
+ * Check tax amount.
+ *
+ * @param array $params
+ * @param bool $isLineItem
+ *
+ * @return mixed
+ */
public static function checkTaxAmount($params, $isLineItem = FALSE) {
$taxRates = CRM_Core_PseudoConstant::getTaxRates();
- // Update contribution
+ // Update contribution.
if (!empty($params['id'])) {
$id = $params['id'];
$values = $ids = array();
}
return $params;
}
+
}