/** * Takes a bunch of params that are needed to match certain criteria and * retrieves the relevant objects. Typically the valid params are only * contact_id. 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 * * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the flattened values * * @return object CRM_Contribute_BAO_ContributionSoft object * @access public * @static */ static function retrieve(&$params, &$defaults) { $contributionSoft = new CRM_Contribute_DAO_ContributionSoft(); $contributionSoft->copyValues($params); if ($contributionSoft->find(TRUE)) { CRM_Core_DAO::storeValues($contributionSoft, $defaults); return $contributionSoft; } return NULL; }
/** * Function to retrieve soft contributon for contribution record. * @param array $params an associated array * * @return soft contribution id * @static */ static function getSoftContribution($params, $all = false) { require_once 'CRM/Contribute/DAO/ContributionSoft.php'; $cs = new CRM_Contribute_DAO_ContributionSoft(); $cs->copyValues($params); $softContribution = array(); if ($cs->find(true)) { if ($all) { foreach (array('pcp_id', 'pcp_display_in_roll', 'pcp_roll_nickname', 'pcp_personal_note') as $key => $val) { $softContribution[$val] = $cs->{$val}; } } $softContribution['soft_credit_to'] = $cs->contact_id; $softContribution['soft_credit_id'] = $cs->id; } return $softContribution; }
/** * Function to create soft contributon with contribution record. * @param array $params an associated array * * @return soft contribution id * @static */ static function addSoftContribution($params) { require_once 'CRM/Contribute/DAO/ContributionSoft.php'; $softContribution = new CRM_Contribute_DAO_ContributionSoft(); $softContribution->copyValues($params); return $softContribution->save(); }