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
static function matchContact(string $names, string $email): ?int {
$names = StringOps::split_names($names); // Hopefully just a temporary solution
$firstnames = $names['firstnames'] ?? NULL;
$lastname = $names['lastname'] ?? NULL;
$display_name = $names['display_name'] ?? NULL;
$firstnames = $names['firstnames'];
$lastname = $names['lastname'];
try {
$contact = civicrm_api3('Contact', 'getorcreate', [
'xcm_profile' => Civi::settings()->get('twinglecampaign_xcm_profile'),
'first_name' => $firstnames,
'last_name' => $lastname,
'display_name' => $display_name,
'email' => $email,
]);
return (int) $contact['id'];

View file

@ -1,8 +1,8 @@
<?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 {
}
}

View file

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

View file

@ -40,8 +40,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
$response_copy = $response;
// Create soft credit for contribution
if (array_key_exists('contribution', $response)) {
$contribution = array_shift($response_copy['contribution']);
if (array_key_exists('contribution', $response['values'])) {
$contribution = array_shift($response_copy['values']['contribution']);
if (array_key_exists('campaign_id', $contribution)) {
try {
$twingle_event = civicrm_api3(
@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle',
['id' => $contribution['campaign_id']]
);
$response['soft_credit'] =
$response['values']['soft_credit'] =
self::createSoftCredit($contribution, $twingle_event)['values'];
$event->setResponse($response);
} catch (CiviCRM_API3_Exception $e) {
@ -58,8 +58,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
}
}
// Create soft credit for sepa mandate
elseif (array_key_exists('sepa_mandate', $response)) {
$sepa_mandate = array_pop($response_copy['sepa_mandate']);
elseif (array_key_exists('sepa_mandate', $response['values'])) {
$sepa_mandate = array_pop($response_copy['values']['sepa_mandate']);
try {
$contribution = civicrm_api3(
@ -84,7 +84,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle',
['id' => $contribution['contribution_campaign_id']]
);
$response['soft_credit'] =
$response['values']['soft_credit'] =
self::createSoftCredit($contribution, $twingle_event)['values'];
$event->setResponse($response);
} 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
* contribution which it will create.
*
* @param array $apiRequest
* @param callable $callsame
* @param $apiRequest
* @param $callsame
*
* @return mixed
*/
public static function mapDonation(array $apiRequest, callable $callsame) {
public function mapDonation($apiRequest, $callsame) {
if (array_key_exists(
'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 {
$targetCampaign = civicrm_api3(
'TwingleEvent',
@ -200,9 +204,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'contribution_id' => $contribution['id'],
]
);
throw $e;
}
}
}
}

View file

@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_StringOperations {
$firstnames = implode(" ", $names);
return ['firstnames' => $firstnames, 'lastname' => $lastname];
}
return ['display_name' => $string];
return $string;
}
/**
@ -71,4 +71,4 @@ class CRM_TwingleCampaign_Utils_StringOperations {
public static function startsWith($haystack, $needle): bool {
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
}
}
}

View file

@ -193,8 +193,8 @@ function civicrm_api3_twingle_project_Sync(array $params): array {
foreach ($projects_from_civicrm['values'] as $project_from_civicrm) {
if (
!in_array($project_from_civicrm['project_id'],
array_column($projects_from_twingle, 'id'),
) && $project_from_civicrm['is_active'] == 1) {
array_column($projects_from_twingle, 'id')
)) {
// store campaign id in $id
$id = $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="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2024-06-15</releaseDate>
<version>1.0.8</version>
<releaseDate>2023-02-28</releaseDate>
<version>1.0.5</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.74</ver>
<ver>5.14.0</ver>
</compatibility>
<comments></comments>
<requires>
<ext>de.systopia.xcm</ext>
<ext>de.systopia.campaign</ext>