[#5] Re-format results output to return membership and contact information
This commit is contained in:
parent
9ffbd5b070
commit
2413b09f3b
1 changed files with 19 additions and 2 deletions
|
@ -258,6 +258,9 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
// Copy submitted parameters.
|
// Copy submitted parameters.
|
||||||
$original_params = $params;
|
$original_params = $params;
|
||||||
|
|
||||||
|
// Prepare results array.
|
||||||
|
$result_values = array();
|
||||||
|
|
||||||
// Get the profile defined for the given form ID, or the default profile
|
// Get the profile defined for the given form ID, or the default profile
|
||||||
// if none matches.
|
// if none matches.
|
||||||
$profile = CRM_Twingle_Profile::getProfileForProject($params['project_id']);
|
$profile = CRM_Twingle_Profile::getProfileForProject($params['project_id']);
|
||||||
|
@ -417,6 +420,11 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result_values['contact'] = $contact_id;
|
||||||
|
if (isset($organisation_id)) {
|
||||||
|
$result_values['organization'] = $organisation_id;
|
||||||
|
}
|
||||||
|
|
||||||
// If requested, add contact to newsletter groups defined in the profile.
|
// If requested, add contact to newsletter groups defined in the profile.
|
||||||
if (!empty($params['newsletter']) && !empty($groups = $profile->getAttribute('newsletter_groups'))) {
|
if (!empty($params['newsletter']) && !empty($groups = $profile->getAttribute('newsletter_groups'))) {
|
||||||
foreach ($groups as $group_id) {
|
foreach ($groups as $group_id) {
|
||||||
|
@ -424,6 +432,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'contact_id' => $contact_id,
|
'contact_id' => $contact_id,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$result_values['newsletter'][] = $group_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +444,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'contact_id' => $contact_id,
|
'contact_id' => $contact_id,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$result_values['postinfo'][] = $group_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,6 +457,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'contact_id' => $contact_id,
|
'contact_id' => $contact_id,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$result_values['donation_receipt'][] = $group_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +543,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
// Create the mandate.
|
// Create the mandate.
|
||||||
$mandate = civicrm_api3('SepaMandate', 'createfull', $mandate_data);
|
$mandate = civicrm_api3('SepaMandate', 'createfull', $mandate_data);
|
||||||
|
|
||||||
$result_values = $mandate['values'];
|
$result_values['sepa_mandate'] = $mandate['values'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Create (recurring) contribution.
|
// Create (recurring) contribution.
|
||||||
|
@ -570,7 +584,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result_values = $contribution['values'];
|
$result_values['contribution'] = $contribution['values'];
|
||||||
|
}
|
||||||
|
|
||||||
// Create membership if a membership type is configured within the profile.
|
// Create membership if a membership type is configured within the profile.
|
||||||
if (!empty($membership_type_id = $profile->getAttribute('membership_type_id'))) {
|
if (!empty($membership_type_id = $profile->getAttribute('membership_type_id'))) {
|
||||||
|
@ -578,6 +593,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
'contact_id' => $contact_id,
|
'contact_id' => $contact_id,
|
||||||
'membership_type_id' => $membership_type_id,
|
'membership_type_id' => $membership_type_id,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$result_values['membership'] = $membership;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = civicrm_api3_create_success($result_values);
|
$result = civicrm_api3_create_success($result_values);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue