Compare commits
13 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
012f4901e4 | ||
![]() |
7415fac88d | ||
![]() |
91c70c645a | ||
![]() |
de9cd894b7 | ||
![]() |
711ccd7469 | ||
![]() |
beb9d8f170 | ||
![]() |
65c7e668b3 | ||
![]() |
93c1ab649d | ||
![]() |
ee32f19f31 | ||
![]() |
cbb148b22f | ||
![]() |
9118b622d0 | ||
![]() |
db1ab69138 | ||
![]() |
bcd2b448d2 |
7 changed files with 27 additions and 28 deletions
|
@ -219,13 +219,15 @@ 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'];
|
$firstnames = $names['firstnames'] ?? NULL;
|
||||||
$lastname = $names['lastname'];
|
$lastname = $names['lastname'] ?? NULL;
|
||||||
|
$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'];
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A simple custom exception that indicates a problem with the TwingleCampaign class
|
* A simple custom exception that indicates a problem within the TwingleCampaign class
|
||||||
*/
|
*/
|
||||||
class CRM_TwingleCampaign_Exceptions_TwingleCampaignException extends Exception {
|
class CRM_TwingleCampaign_Exceptions_TwingleCampaignException extends Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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['values'])) {
|
if (array_key_exists('contribution', $response)) {
|
||||||
$contribution = array_shift($response_copy['values']['contribution']);
|
$contribution = array_shift($response_copy['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['values']['soft_credit'] =
|
$response['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['values'])) {
|
elseif (array_key_exists('sepa_mandate', $response)) {
|
||||||
$sepa_mandate = array_pop($response_copy['values']['sepa_mandate']);
|
$sepa_mandate = array_pop($response_copy['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['values']['soft_credit'] =
|
$response['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 $apiRequest
|
* @param array $apiRequest
|
||||||
* @param $callsame
|
* @param callable $callsame
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function mapDonation($apiRequest, $callsame) {
|
public static function mapDonation(array $apiRequest, callable $callsame) {
|
||||||
|
|
||||||
if (array_key_exists(
|
if (array_key_exists(
|
||||||
'campaign_id',
|
'campaign_id',
|
||||||
|
@ -129,11 +129,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (array_key_exists(
|
elseif (!empty($apiRequest['params']['custom_fields']['event'])) {
|
||||||
'event',
|
|
||||||
$apiRequest['params']['custom_fields']) &&
|
|
||||||
!empty($apiRequest['params']['custom_fields']['event'])
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
$targetCampaign = civicrm_api3(
|
$targetCampaign = civicrm_api3(
|
||||||
'TwingleEvent',
|
'TwingleEvent',
|
||||||
|
@ -204,7 +200,9 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
|
||||||
'contribution_id' => $contribution['id'],
|
'contribution_id' => $contribution['id'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 $string;
|
return ['display_name' => $string];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,4 +71,4 @@ class CRM_TwingleCampaign_Utils_StringOperations {
|
||||||
public static function startsWith($haystack, $needle): bool {
|
public static function startsWith($haystack, $needle): bool {
|
||||||
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
|
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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']);
|
||||||
|
|
7
info.xml
7
info.xml
|
@ -14,13 +14,12 @@
|
||||||
<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>2023-02-28</releaseDate>
|
<releaseDate>2024-06-15</releaseDate>
|
||||||
<version>1.0.5</version>
|
<version>1.0.8</version>
|
||||||
<develStage>stable</develStage>
|
<develStage>stable</develStage>
|
||||||
<compatibility>
|
<compatibility>
|
||||||
<ver>5.14.0</ver>
|
<ver>5.74</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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue