Compare commits

...

16 commits
1.0.4 ... main

Author SHA1 Message Date
Marc Michalsky
012f4901e4
🔖 bump version to 1.0.8 2024-07-18 15:38:42 +02:00
Marc Michalsky
7415fac88d
Cover the case where an event creator passes only one name part 2024-07-18 15:37:30 +02:00
Marc Michalsky
91c70c645a
Push only active campaigns to Twingle 2024-07-18 15:35:31 +02:00
Marc Michalsky
de9cd894b7
🔖 bump version to 1.0.7 2024-06-15 12:12:35 +02:00
Marc Michalsky
711ccd7469
Merge branch 'twingle_api_adaptions' 2024-06-15 12:02:47 +02:00
Marc Michalsky
beb9d8f170
take into account the latest changes to the Twingle API 2024-06-15 11:36:12 +02:00
Marc_Michalsky
65c7e668b3 Merge branch 'rethrow-exception' into 'main'
APIWrapper: Rethrow exception

See merge request Marc_Michalsky/de-forumzfd-twinglecampaign!3
2024-06-15 09:26:47 +00:00
Marc_Michalsky
93c1ab649d Merge branch 'avoid-array_key_exists-on-null' into 'main'
Avoid `array_key_exists()` on `NULL`

See merge request Marc_Michalsky/de-forumzfd-twinglecampaign!4
2024-06-15 09:25:59 +00:00
Marc_Michalsky
ee32f19f31 Merge branch 'fix-mapDonation' into 'main'
APIWrapper: Make `mapDonation()` static becauts it's called static

See merge request Marc_Michalsky/de-forumzfd-twinglecampaign!2
2024-06-15 09:22:55 +00:00
Dominic Tubach
cbb148b22f Avoid array_key_exists() on NULL 2024-04-22 10:10:51 +02:00
Dominic Tubach
9118b622d0 APIWrapper: Rethrow exception 2024-04-19 10:29:04 +02:00
Dominic Tubach
db1ab69138 APIWrapper: Make mapDonation() static becauts it's called static 2024-04-19 10:15:55 +02:00
Marc Michalsky
bcd2b448d2
fix udefined constant "error" 2024-04-08 12:19:48 +02:00
Marc Michalsky
571a86ea66
🔖 bump version to 1.0.5 2023-08-14 18:44:36 +02:00
Marc Michalsky
dc723ed8aa
🐛 bug fix: wrong value for option values 2023-08-14 17:52:23 +02:00
Marc Michalsky
e5ab52f24b
🐛 fix bug: double escaping of \n 2023-08-14 17:20:24 +02:00
9 changed files with 29 additions and 30 deletions

View file

@ -243,7 +243,7 @@ class CRM_TwingleCampaign_BAO_CustomField {
[
'id' => $option_value_exists['values'][0]['id'],
'label' => $value,
'value' => $value,
'value' => $key,
]
);
}

View file

@ -219,13 +219,15 @@ 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'];
$lastname = $names['lastname'];
$firstnames = $names['firstnames'] ?? NULL;
$lastname = $names['lastname'] ?? NULL;
$display_name = $names['display_name'] ?? NULL;
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,7 +1,7 @@
<?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 {

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['values'])) {
$contribution = array_shift($response_copy['values']['contribution']);
if (array_key_exists('contribution', $response)) {
$contribution = array_shift($response_copy['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['values']['soft_credit'] =
$response['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['values'])) {
$sepa_mandate = array_pop($response_copy['values']['sepa_mandate']);
elseif (array_key_exists('sepa_mandate', $response)) {
$sepa_mandate = array_pop($response_copy['sepa_mandate']);
try {
$contribution = civicrm_api3(
@ -84,7 +84,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'getsingle',
['id' => $contribution['contribution_campaign_id']]
);
$response['values']['soft_credit'] =
$response['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 $apiRequest
* @param $callsame
* @param array $apiRequest
* @param callable $callsame
*
* @return mixed
*/
public function mapDonation($apiRequest, $callsame) {
public static function mapDonation(array $apiRequest, callable $callsame) {
if (array_key_exists(
'campaign_id',
@ -129,11 +129,7 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
}
}
}
elseif (array_key_exists(
'event',
$apiRequest['params']['custom_fields']) &&
!empty($apiRequest['params']['custom_fields']['event'])
) {
elseif (!empty($apiRequest['params']['custom_fields']['event'])) {
try {
$targetCampaign = civicrm_api3(
'TwingleEvent',
@ -204,6 +200,8 @@ class CRM_TwingleCampaign_Utils_APIWrapper {
'contribution_id' => $contribution['id'],
]
);
throw $e;
}
}

View file

@ -69,7 +69,7 @@ class CRM_TwingleCampaign_Utils_MatomoSnippet {
* The combined code after appending the appendix.
*/
public static function append_code($original, $appendix) {
return $original . '\n' . $appendix;
return $original . $appendix;
}
}

View file

@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_StringOperations {
$firstnames = implode(" ", $names);
return ['firstnames' => $firstnames, 'lastname' => $lastname];
}
return $string;
return ['display_name' => $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) {
if (
!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
$id = $project_from_civicrm['id'];
unset($project_from_civicrm['id']);

View file

@ -14,13 +14,12 @@
<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>2023-02-28</releaseDate>
<version>1.0.4</version>
<releaseDate>2024-06-15</releaseDate>
<version>1.0.8</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.14.0</ver>
<ver>5.74</ver>
</compatibility>
<comments></comments>
<requires>
<ext>de.systopia.xcm</ext>
<ext>de.systopia.campaign</ext>