Compare commits

..

No commits in common. "main" and "1.0.5" have entirely different histories.
main ... 1.0.5

7 changed files with 28 additions and 27 deletions

View file

@ -219,15 +219,13 @@ class CRM_TwingleCampaign_BAO_TwingleEvent extends Campaign {
private private
static function matchContact(string $names, string $email): ?int { static function matchContact(string $names, string $email): ?int {
$names = StringOps::split_names($names); // Hopefully just a temporary solution $names = StringOps::split_names($names); // Hopefully just a temporary solution
$firstnames = $names['firstnames'] ?? NULL; $firstnames = $names['firstnames'];
$lastname = $names['lastname'] ?? NULL; $lastname = $names['lastname'];
$display_name = $names['display_name'] ?? NULL;
try { try {
$contact = civicrm_api3('Contact', 'getorcreate', [ $contact = civicrm_api3('Contact', 'getorcreate', [
'xcm_profile' => Civi::settings()->get('twinglecampaign_xcm_profile'), 'xcm_profile' => Civi::settings()->get('twinglecampaign_xcm_profile'),
'first_name' => $firstnames, 'first_name' => $firstnames,
'last_name' => $lastname, 'last_name' => $lastname,
'display_name' => $display_name,
'email' => $email, 'email' => $email,
]); ]);
return (int) $contact['id']; return (int) $contact['id'];

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* A simple custom exception that indicates a problem within the TwingleCampaign class * A simple custom exception that indicates a problem with the TwingleCampaign class
*/ */
class CRM_TwingleCampaign_Exceptions_TwingleCampaignException extends Exception { class CRM_TwingleCampaign_Exceptions_TwingleCampaignException extends Exception {

View file

@ -96,7 +96,7 @@ class CRM_TwingleCampaign_Upgrader extends CRM_TwingleCampaign_Upgrader_Base {
[1 => $e->getMessage()] [1 => $e->getMessage()]
), ),
E::ts('Scheduled Job'), E::ts('Scheduled Job'),
'error' error
); );
} }

View file

@ -40,8 +40,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
$response_copy = $response; $response_copy = $response;
// Create soft credit for contribution // Create soft credit for contribution
if (array_key_exists('contribution', $response)) { if (array_key_exists('contribution', $response['values'])) {
$contribution = array_shift($response_copy['contribution']); $contribution = array_shift($response_copy['values']['contribution']);
if (array_key_exists('campaign_id', $contribution)) { if (array_key_exists('campaign_id', $contribution)) {
try { try {
$twingle_event = civicrm_api3( $twingle_event = civicrm_api3(
@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle', 'getsingle',
['id' => $contribution['campaign_id']] ['id' => $contribution['campaign_id']]
); );
$response['soft_credit'] = $response['values']['soft_credit'] =
self::createSoftCredit($contribution, $twingle_event)['values']; self::createSoftCredit($contribution, $twingle_event)['values'];
$event->setResponse($response); $event->setResponse($response);
} catch (CiviCRM_API3_Exception $e) { } catch (CiviCRM_API3_Exception $e) {
@ -58,8 +58,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
} }
} }
// Create soft credit for sepa mandate // Create soft credit for sepa mandate
elseif (array_key_exists('sepa_mandate', $response)) { elseif (array_key_exists('sepa_mandate', $response['values'])) {
$sepa_mandate = array_pop($response_copy['sepa_mandate']); $sepa_mandate = array_pop($response_copy['values']['sepa_mandate']);
try { try {
$contribution = civicrm_api3( $contribution = civicrm_api3(
@ -84,7 +84,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle', 'getsingle',
['id' => $contribution['contribution_campaign_id']] ['id' => $contribution['contribution_campaign_id']]
); );
$response['soft_credit'] = $response['values']['soft_credit'] =
self::createSoftCredit($contribution, $twingle_event)['values']; self::createSoftCredit($contribution, $twingle_event)['values'];
$event->setResponse($response); $event->setResponse($response);
} catch (CiviCRM_API3_Exception $e) { } catch (CiviCRM_API3_Exception $e) {
@ -103,12 +103,12 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
* the de.systopia.twingle extension can include the campaign into the * the de.systopia.twingle extension can include the campaign into the
* contribution which it will create. * contribution which it will create.
* *
* @param array $apiRequest * @param $apiRequest
* @param callable $callsame * @param $callsame
* *
* @return mixed * @return mixed
*/ */
public static function mapDonation(array $apiRequest, callable $callsame) { public function mapDonation($apiRequest, $callsame) {
if (array_key_exists( if (array_key_exists(
'campaign_id', 'campaign_id',
@ -129,7 +129,11 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
} }
} }
} }
elseif (!empty($apiRequest['params']['custom_fields']['event'])) { elseif (array_key_exists(
'event',
$apiRequest['params']['custom_fields']) &&
!empty($apiRequest['params']['custom_fields']['event'])
) {
try { try {
$targetCampaign = civicrm_api3( $targetCampaign = civicrm_api3(
'TwingleEvent', 'TwingleEvent',
@ -200,8 +204,6 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'contribution_id' => $contribution['id'], 'contribution_id' => $contribution['id'],
] ]
); );
throw $e;
} }
} }

View file

@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_StringOperations {
$firstnames = implode(" ", $names); $firstnames = implode(" ", $names);
return ['firstnames' => $firstnames, 'lastname' => $lastname]; return ['firstnames' => $firstnames, 'lastname' => $lastname];
} }
return ['display_name' => $string]; return $string;
} }
/** /**

View file

@ -193,8 +193,8 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
foreach ($projects_from_civicrm['values'] as $project_from_civicrm) { foreach ($projects_from_civicrm['values'] as $project_from_civicrm) {
if ( if (
!in_array($project_from_civicrm['project_id'], !in_array($project_from_civicrm['project_id'],
array_column($projects_from_twingle, 'id'), array_column($projects_from_twingle, 'id')
) && $project_from_civicrm['is_active'] == 1) { )) {
// store campaign id in $id // store campaign id in $id
$id = $project_from_civicrm['id']; $id = $project_from_civicrm['id'];
unset($project_from_civicrm['id']); unset($project_from_civicrm['id']);

View file

@ -14,12 +14,13 @@
<url desc="Support">https://lab.civicrm.org/Marc_Michalsky/de-forumzfd-twinglecampaign/-/issues</url> <url desc="Support">https://lab.civicrm.org/Marc_Michalsky/de-forumzfd-twinglecampaign/-/issues</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url> <url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls> </urls>
<releaseDate>2024-06-15</releaseDate> <releaseDate>2023-02-28</releaseDate>
<version>1.0.8</version> <version>1.0.5</version>
<develStage>stable</develStage> <develStage>stable</develStage>
<compatibility> <compatibility>
<ver>5.74</ver> <ver>5.14.0</ver>
</compatibility> </compatibility>
<comments></comments>
<requires> <requires>
<ext>de.systopia.xcm</ext> <ext>de.systopia.xcm</ext>
<ext>de.systopia.campaign</ext> <ext>de.systopia.campaign</ext>