Compare commits
23 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
012f4901e4 | ||
![]() |
7415fac88d | ||
![]() |
91c70c645a | ||
![]() |
de9cd894b7 | ||
![]() |
711ccd7469 | ||
![]() |
beb9d8f170 | ||
![]() |
65c7e668b3 | ||
![]() |
93c1ab649d | ||
![]() |
ee32f19f31 | ||
![]() |
cbb148b22f | ||
![]() |
9118b622d0 | ||
![]() |
db1ab69138 | ||
![]() |
bcd2b448d2 | ||
![]() |
571a86ea66 | ||
![]() |
dc723ed8aa | ||
![]() |
e5ab52f24b | ||
![]() |
8863bbeed0 | ||
![]() |
c45f275fc3 | ||
![]() |
de19c3991c | ||
![]() |
82b4632d63 | ||
![]() |
2949ab0168 | ||
![]() |
54adee32a9 | ||
![]() |
bfa3ae7e32 |
16 changed files with 229 additions and 179 deletions
|
@ -7,7 +7,8 @@ class CRM_TwingleCampaign_BAO_Configuration {
|
|||
'twingle_api_key',
|
||||
'twinglecampaign_xcm_profile',
|
||||
'twinglecampaign_default_case',
|
||||
'twinglecampaign_soft_credits'
|
||||
'twinglecampaign_soft_credits',
|
||||
'twinglecampaign_matomo_integration'
|
||||
];
|
||||
|
||||
|
||||
|
@ -27,6 +28,12 @@ class CRM_TwingleCampaign_BAO_Configuration {
|
|||
Civi::settings()->set('twinglecampaign_soft_credits', 0);
|
||||
}
|
||||
|
||||
// Set twinglecampaign_matomo_integration to '0' if checkbox is unchecked
|
||||
if (!array_key_exists('twinglecampaign_matomo_integration', $settings)) {
|
||||
Civi::settings()->set('twinglecampaign_matomo_integration', 0);
|
||||
}
|
||||
|
||||
|
||||
Civi::settings()->add($settings);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,11 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
|||
* @param bool $upgrade
|
||||
* If true: Does not show UF message if custom field already exists
|
||||
*
|
||||
* @returns array Result of custom field creation api call
|
||||
* @returns array|False Result of custom field creation api call. False if
|
||||
* field already existed und wasn't upgraded.
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
public function create(bool $upgrade = FALSE): ?array {
|
||||
public function create(bool $upgrade = FALSE) {
|
||||
|
||||
// Check if the field already exists
|
||||
$field = civicrm_api3(
|
||||
|
@ -129,52 +130,74 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
|||
return NULL;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
$this->id = $field['values'][0]['id'];
|
||||
$this->custom_group_id = $field['values'][0]['custom_group_id'];
|
||||
return $this->upgrade($field['values'][0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing custom field
|
||||
* Upgrade an existing custom field
|
||||
*
|
||||
* @returns array Result of custom field creation api call
|
||||
* @param $attributes
|
||||
* Custom Field data
|
||||
* @returns array|False Result of custom field creation api call, False if
|
||||
* field was not upgraded
|
||||
*/
|
||||
public function update(): array {
|
||||
private function upgrade($attributes) {
|
||||
$upgrade_necessary = False;
|
||||
|
||||
try {
|
||||
$this->result = civicrm_api3(
|
||||
'CustomField',
|
||||
'create',
|
||||
$this->getSetAttributes());
|
||||
if (key_exists('option_group_id', $attributes)) {
|
||||
$this->addOptions($attributes);
|
||||
}
|
||||
|
||||
// Log field creation
|
||||
if ($this->result['is_error'] == 0) {
|
||||
Civi::log()->info("$this->extensionName has updated a custom field.
|
||||
foreach ($this as $var => $value) {
|
||||
// put array items into attributes
|
||||
if (array_key_exists($var, $attributes) && $attributes[$var] != $value) {
|
||||
$this->$var = $attributes[$var];
|
||||
$upgrade_necessary = True;
|
||||
}
|
||||
}
|
||||
|
||||
if ($upgrade_necessary) {
|
||||
try {
|
||||
$this->result = civicrm_api3(
|
||||
'CustomField',
|
||||
'create',
|
||||
$this->getSetAttributes());
|
||||
|
||||
// Log field creation
|
||||
if ($this->result['is_error'] == 0) {
|
||||
Civi::log()->info("$this->extensionName has updated a custom field.
|
||||
label: $this->label
|
||||
name: $this->name
|
||||
id: $this->id
|
||||
group: $this->custom_group_id"
|
||||
);
|
||||
);
|
||||
return $this->result;
|
||||
}
|
||||
else {
|
||||
throw new CiviCRM_API3_Exception($this->result['error_message']);
|
||||
}
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// If the field could not get created: log error
|
||||
$errorMessage = $e->getMessage();
|
||||
if ($this->name && $this->custom_group_id) {
|
||||
Civi::log()
|
||||
->error("$this->extensionName could not create new custom field \"$this->name\" for group \"$this->custom_group_id\": $errorMessage");
|
||||
CRM_Utils_System::setUFMessage(E::ts('Creation of custom field \'%1\' failed. Find more information in the logs.', [1 => $this->name]));
|
||||
}
|
||||
// If there is not enough information: log simple error message
|
||||
else {
|
||||
Civi::log()
|
||||
->error("$this->extensionName could not create new custom field: $errorMessage");
|
||||
CRM_Utils_System::setUFMessage(E::ts("Creation of custom field failed. Find more information in the logs."));
|
||||
}
|
||||
return $this->result;
|
||||
}
|
||||
else {
|
||||
throw new CiviCRM_API3_Exception($this->result['error_message']);
|
||||
}
|
||||
} catch (CiviCRM_API3_Exception $e) {
|
||||
// If the field could not get created: log error
|
||||
$errorMessage = $e->getMessage();
|
||||
if ($this->name && $this->custom_group_id) {
|
||||
Civi::log()
|
||||
->error("$this->extensionName could not create new custom field \"$this->name\" for group \"$this->custom_group_id\": $errorMessage");
|
||||
CRM_Utils_System::setUFMessage(E::ts('Creation of custom field \'%1\' failed. Find more information in the logs.', [1 => $this->name]));
|
||||
}
|
||||
// If there is not enough information: log simple error message
|
||||
else {
|
||||
Civi::log()
|
||||
->error("$this->extensionName could not create new custom field: $errorMessage");
|
||||
CRM_Utils_System::setUFMessage(E::ts("Creation of custom field failed. Find more information in the logs."));
|
||||
}
|
||||
return $this->result;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,30 +211,14 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
|||
$result = [];
|
||||
|
||||
try {
|
||||
$option_group_id = civicrm_api3(
|
||||
'CustomField',
|
||||
'getsingle',
|
||||
['id' => $this->id]
|
||||
)['option_group_id'];
|
||||
} catch (CiviCRM_API3_Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
Civi::log()
|
||||
->error("$this->extensionName could not get get option group id for custom field \"$this->name\": $errorMessage");
|
||||
CRM_Utils_System::setUFMessage(
|
||||
E::ts('%1 could not get option group id for custom field \'%2\'. Find more information in the logs.',
|
||||
[1 => $this->extensionName, 2 => $this->name])
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
foreach ($options as $key => $value) {
|
||||
foreach ($this->option_values as $key => $value) {
|
||||
|
||||
$option_value_exists = civicrm_api3(
|
||||
'OptionValue',
|
||||
'get',
|
||||
[
|
||||
'sequential' => 1,
|
||||
'option_group_id' => $option_group_id,
|
||||
'option_group_id' => $options['option_group_id'],
|
||||
'value' => $key,
|
||||
]
|
||||
);
|
||||
|
@ -222,7 +229,7 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
|||
'OptionValue',
|
||||
'create',
|
||||
[
|
||||
'option_group_id' => $option_group_id,
|
||||
'option_group_id' => $options['option_group_id'],
|
||||
'value' => $key,
|
||||
'label' => $value,
|
||||
]
|
||||
|
@ -236,6 +243,7 @@ class CRM_TwingleCampaign_BAO_CustomField {
|
|||
[
|
||||
'id' => $option_value_exists['values'][0]['id'],
|
||||
'label' => $value,
|
||||
'value' => $key,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -181,15 +181,8 @@ class CRM_TwingleCampaign_BAO_TwingleProject extends Campaign {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
$result = parent::create($no_hook);
|
||||
return parent::create($no_hook);
|
||||
|
||||
// Check if campaign was created successfully
|
||||
if ($result['is_error'] == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
throw new Exception($result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -46,6 +46,13 @@ class CRM_TwingleCampaign_Form_Settings extends CRM_Core_Form {
|
|||
FALSE
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'twinglecampaign_matomo_integration',
|
||||
E::ts('Use Matomo to track user interaction with Twingle forms'),
|
||||
FALSE
|
||||
);
|
||||
|
||||
$this->addButtons([
|
||||
[
|
||||
'type' => 'submit',
|
||||
|
|
|
@ -20,7 +20,7 @@ class CRM_TwingleCampaign_Upgrader extends CRM_TwingleCampaign_Upgrader_Base {
|
|||
* changed campaigns will get pulled from Twingle.
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
public function upgrade_02(): bool {
|
||||
public function upgrade_03(): bool {
|
||||
|
||||
$campaign_info = require E::path() .
|
||||
'/CRM/TwingleCampaign/resources/campaigns.php';
|
||||
|
@ -96,7 +96,7 @@ class CRM_TwingleCampaign_Upgrader extends CRM_TwingleCampaign_Upgrader_Base {
|
|||
[1 => $e->getMessage()]
|
||||
),
|
||||
E::ts('Scheduled Job'),
|
||||
error
|
||||
'error'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -294,83 +294,4 @@ class CRM_TwingleCampaign_Upgrader extends CRM_TwingleCampaign_Upgrader_Base {
|
|||
Civi::settings()->revert('twingle_api_key');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Example: Run a couple simple queries.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws Exception
|
||||
*
|
||||
* public function upgrade_4200() {
|
||||
* $this->ctx->log->info('Applying update 4200');
|
||||
* CRM_Core_DAO::executeQuery('UPDATE foo SET bar = "whiz"');
|
||||
* CRM_Core_DAO::executeQuery('DELETE FROM bang WHERE willy = wonka(2)');
|
||||
* return TRUE;
|
||||
* } // */
|
||||
|
||||
|
||||
/**
|
||||
* Example: Run an external SQL script.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws Exception
|
||||
* public function upgrade_4201() {
|
||||
* $this->ctx->log->info('Applying update 4201');
|
||||
* // this path is relative to the extension base dir
|
||||
* $this->executeSqlFile('sql/upgrade_4201.sql');
|
||||
* return TRUE;
|
||||
* } // */
|
||||
|
||||
|
||||
/**
|
||||
* Example: Run a slow upgrade process by breaking it up into smaller chunk.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws Exception
|
||||
* public function upgrade_4202() {
|
||||
* $this->ctx->log->info('Planning update 4202'); // PEAR Log interface
|
||||
*
|
||||
* $this->addTask(E::ts('Process first step'), 'processPart1', $arg1, $arg2);
|
||||
* $this->addTask(E::ts('Process second step'), 'processPart2', $arg3, $arg4);
|
||||
* $this->addTask(E::ts('Process second step'), 'processPart3', $arg5);
|
||||
* return TRUE;
|
||||
* }
|
||||
* public function processPart1($arg1, $arg2) { sleep(10); return TRUE; }
|
||||
* public function processPart2($arg3, $arg4) { sleep(10); return TRUE; }
|
||||
* public function processPart3($arg5) { sleep(10); return TRUE; }
|
||||
* // */
|
||||
|
||||
|
||||
/**
|
||||
* Example: Run an upgrade with a query that touches many (potentially
|
||||
* millions) of records by breaking it up into smaller chunks.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws Exception
|
||||
* public function upgrade_4203() {
|
||||
* $this->ctx->log->info('Planning update 4203'); // PEAR Log interface
|
||||
*
|
||||
* $minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM
|
||||
* civicrm_contribution');
|
||||
* $maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM
|
||||
* civicrm_contribution'); for ($startId = $minId; $startId <= $maxId;
|
||||
* $startId += self::BATCH_SIZE) {
|
||||
* $endId = $startId + self::BATCH_SIZE - 1;
|
||||
* $title = E::ts('Upgrade Batch (%1 => %2)', array(
|
||||
* 1 => $startId,
|
||||
* 2 => $endId,
|
||||
* ));
|
||||
* $sql = '
|
||||
* UPDATE civicrm_contribution SET foobar = whiz(wonky()+wanker)
|
||||
* WHERE id BETWEEN %1 and %2
|
||||
* ';
|
||||
* $params = array(
|
||||
* 1 => array($startId, 'Integer'),
|
||||
* 2 => array($endId, 'Integer'),
|
||||
* );
|
||||
* $this->addTask($title, 'executeSql', $sql, $params);
|
||||
* }
|
||||
* return TRUE;
|
||||
* } // */
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ use CRM_TwingleCampaign_ExtensionUtil as E;
|
|||
* @return array
|
||||
*/
|
||||
function getCaseTypes(): array {
|
||||
$caseTypes = [NULL => E::ts('none')];
|
||||
try {
|
||||
$result = civicrm_api3('CaseType', 'get', [
|
||||
'sequential' => 1,
|
||||
|
|
75
CRM/TwingleCampaign/Utils/MatomoSnippet.php
Normal file
75
CRM/TwingleCampaign/Utils/MatomoSnippet.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* A simple class which helps to generate JavaScript snippets which can be
|
||||
* embedded in a website to track user interaction with Twingle forms via
|
||||
* Matomo.
|
||||
*/
|
||||
class CRM_TwingleCampaign_Utils_MatomoSnippet {
|
||||
|
||||
private static function embed_in_base_function($code) {
|
||||
return implode("\n",[
|
||||
"<!-- matomo -->",
|
||||
"<script>",
|
||||
"window.addEventListener('message', function(event){",
|
||||
"if(event && event.data && event.data.type === 'donationFinished') {",
|
||||
$code,
|
||||
"}",
|
||||
"} , false);",
|
||||
"</script>",
|
||||
"<!-- matomo -->",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns JavaScript snippet to track events in Matomo.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_event_tracker() {
|
||||
$code = "_paq.push(['trackEvent', 'twingle', 'donation', event.data.value.recurringRythm, event.data.value.amount]);";
|
||||
return self::embed_in_base_function($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns JavaScript snippet to track Matomo goals.
|
||||
*
|
||||
* @param $goal_id
|
||||
* The ID of your Matomo goal.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_goal_tracker($goal_id) {
|
||||
$code = "_paq.push(['trackGoal', $goal_id]);";
|
||||
return self::embed_in_base_function($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns JavaScript snippet to track ecommerce activity in Matomo.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_ecommerce_tracker() {
|
||||
$code = implode("\n", [
|
||||
"_paq.push(['addEcommerceItem', event.data.value.rythm, '', event.data.value.target, event.data.value.amount]);",
|
||||
"_paq.push(['trackEcommerceOrder', 'anonymizedData', event.data.value.amount]);",
|
||||
]);
|
||||
return self::embed_in_base_function($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the given code to the original code.
|
||||
*
|
||||
* @param $original
|
||||
* The original code.
|
||||
* @param $appendix
|
||||
* The code you want to append to the original code.
|
||||
*
|
||||
* @return string
|
||||
* The combined code after appending the appendix.
|
||||
*/
|
||||
public static function append_code($original, $appendix) {
|
||||
return $original . $appendix;
|
||||
}
|
||||
|
||||
}
|
|
@ -49,7 +49,7 @@ class CRM_TwingleCampaign_Utils_StringOperations {
|
|||
$firstnames = implode(" ", $names);
|
||||
return ['firstnames' => $firstnames, 'lastname' => $lastname];
|
||||
}
|
||||
return $string;
|
||||
return ['display_name' => $string];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -113,7 +113,9 @@ return [
|
|||
"option_values" => [
|
||||
"default" => E::ts("Default"),
|
||||
"event" => E::ts("Events"),
|
||||
"membership" => E::ts("Membership")
|
||||
"membership" => E::ts("Membership"),
|
||||
"shop" => E::ts("Shop"),
|
||||
"giftshop" => E::ts("Gift Shop")
|
||||
],
|
||||
"text_length" => 32,
|
||||
"is_active" => 1,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use CRM_TwingleCampaign_ExtensionUtil as E;
|
||||
use CRM_TwingleCampaign_Utils_ExtensionCache as Cache;
|
||||
use CRM_TwingleCampaign_Utils_MatomoSnippet as MatomoSnippet;
|
||||
|
||||
/**
|
||||
* TwingleForm.Get API specification (optional)
|
||||
|
@ -110,16 +111,49 @@ function civicrm_api3_twingle_form_Get(array $params): array {
|
|||
'project_type' => $value[$custom_field_mapping['twingle_project_type']],
|
||||
'counter' => $value[$custom_field_mapping['twingle_project_counter']]
|
||||
];
|
||||
$matomo_integration_enabled = Civi::settings()->get('twinglecampaign_matomo_integration', False);
|
||||
switch ($value[$custom_field_mapping['twingle_project_type']]) {
|
||||
case 'event':
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
$value[$custom_field_mapping['twingle_project_eventall']];
|
||||
if ($matomo_integration_enabled) {
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
MatomoSnippet::append_code(
|
||||
$value[$custom_field_mapping['twingle_project_eventall']],
|
||||
MatomoSnippet::get_event_tracker()
|
||||
);
|
||||
}
|
||||
else {
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
$value[$custom_field_mapping['twingle_project_eventall']];
|
||||
}
|
||||
break;
|
||||
case 'shop':
|
||||
if ($matomo_integration_enabled) {
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
MatomoSnippet::append_code(
|
||||
$value[$custom_field_mapping['twingle_project_widget']],
|
||||
MatomoSnippet::get_ecommerce_tracker()
|
||||
);
|
||||
}
|
||||
else {
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
$value[$custom_field_mapping['twingle_project_widget']];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
$value[$custom_field_mapping['twingle_project_widget']];
|
||||
if ($matomo_integration_enabled) {
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
MatomoSnippet::append_code(
|
||||
$value[$custom_field_mapping['twingle_project_widget']],
|
||||
MatomoSnippet::get_event_tracker()
|
||||
);
|
||||
}
|
||||
else {
|
||||
$returnValues[$value['id']]['embed_code'] =
|
||||
$value[$custom_field_mapping['twingle_project_widget']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return civicrm_api3_create_success($returnValues, $query, 'TwingleForm', 'Get');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -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']);
|
||||
|
|
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="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
|
||||
</urls>
|
||||
<releaseDate>2023-02-28</releaseDate>
|
||||
<version>1.0.3</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>
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
<div class="content">{$form.twinglecampaign_soft_credits.html}</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="crm-section">
|
||||
<div class="label">{$form.twinglecampaign_matomo_integration.label}</div>
|
||||
<div class="content">{$form.twinglecampaign_matomo_integration.html}</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue