Code style
This commit is contained in:
parent
cf9483ca3e
commit
ac1b08b775
4 changed files with 47 additions and 74 deletions
|
@ -687,7 +687,10 @@ class CRM_Twingle_Profile {
|
||||||
return $default_profile;
|
return $default_profile;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new ProfileException('Could not find default profile', ProfileException::ERROR_CODE_DEFAULT_PROFILE_NOT_FOUND);
|
throw new ProfileException(
|
||||||
|
'Could not find default profile',
|
||||||
|
ProfileException::ERROR_CODE_DEFAULT_PROFILE_NOT_FOUND
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,17 +115,17 @@ class CRM_Twingle_Upgrader extends CRM_Extension_Upgrader_Base {
|
||||||
public function upgrade_5150(): bool {
|
public function upgrade_5150(): bool {
|
||||||
$this->ctx->log->info('Activate mapping of `purpose` and `user_extra_field` to notes in each existing profile.');
|
$this->ctx->log->info('Activate mapping of `purpose` and `user_extra_field` to notes in each existing profile.');
|
||||||
|
|
||||||
$profiles = CRM_Twingle_Profile::getProfiles();
|
foreach (CRM_Twingle_Profile::getProfiles() as $profile) {
|
||||||
if ($profiles) {
|
|
||||||
foreach ($profiles as $profile) {
|
|
||||||
$profile_changed = FALSE;
|
$profile_changed = FALSE;
|
||||||
|
/** @phpstan-var array<string> $contribution_notes */
|
||||||
$contribution_notes = $profile->getAttribute('map_as_contribution_notes', []);
|
$contribution_notes = $profile->getAttribute('map_as_contribution_notes', []);
|
||||||
|
/** @phpstan-var array<string> $contact_notes */
|
||||||
$contact_notes = $profile->getAttribute('map_as_contact_notes', []);
|
$contact_notes = $profile->getAttribute('map_as_contact_notes', []);
|
||||||
if (!in_array('purpose', $contribution_notes)) {
|
if (!in_array('purpose', $contribution_notes, TRUE)) {
|
||||||
$profile->setAttribute('map_as_contribution_notes', array_merge($contribution_notes, ['purpose']));
|
$profile->setAttribute('map_as_contribution_notes', array_merge($contribution_notes, ['purpose']));
|
||||||
$profile_changed = TRUE;
|
$profile_changed = TRUE;
|
||||||
}
|
}
|
||||||
if (!in_array('user_extrafield', $contact_notes)) {
|
if (!in_array('user_extrafield', $contact_notes, TRUE)) {
|
||||||
$profile->setAttribute('map_as_contact_notes', array_merge($contact_notes, ['user_extrafield']));
|
$profile->setAttribute('map_as_contact_notes', array_merge($contact_notes, ['user_extrafield']));
|
||||||
$profile_changed = TRUE;
|
$profile_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,6 @@ class CRM_Twingle_Upgrader extends CRM_Extension_Upgrader_Base {
|
||||||
$profile->saveProfile();
|
$profile->saveProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
use CRM_Twingle_ExtensionUtil as E;
|
use CRM_Twingle_ExtensionUtil as E;
|
||||||
use Civi\Twingle\Exceptions\BaseException;
|
use Civi\Twingle\Exceptions\BaseException;
|
||||||
|
use Civi\Api4\Note;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TwingleDonation.Submit API specification
|
* TwingleDonation.Submit API specification
|
||||||
|
@ -485,20 +486,19 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create contact notes.
|
// Create contact notes.
|
||||||
|
/** @phpstan-var array<string> $contact_note_mappings */
|
||||||
$contact_note_mappings = $profile->getAttribute('map_as_contact_notes', []);
|
$contact_note_mappings = $profile->getAttribute('map_as_contact_notes', []);
|
||||||
foreach (['user_extrafield'] as $target) {
|
foreach (['user_extrafield'] as $target) {
|
||||||
if (
|
if (
|
||||||
isset($params[$target])
|
isset($params[$target])
|
||||||
&& '' !== $params[$target]
|
&& '' !== $params[$target]
|
||||||
&& in_array($target, $contact_note_mappings)
|
&& in_array($target, $contact_note_mappings, TRUE)
|
||||||
) {
|
) {
|
||||||
civicrm_api4('Note', 'create', [
|
Note::create(FALSE)
|
||||||
'values' => [
|
->addValue('entity_table', 'civicrm_contact')
|
||||||
'entity_table' => 'civicrm_contact',
|
->addValue('entity_id', $contact_id)
|
||||||
'entity_id' => $contact_id,
|
->addValue('note', $params[$target])
|
||||||
'note' => $params[$target],
|
->execute();
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,27 +803,26 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result_values['contribution'] = $contribution['values'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add notes to the contribution.
|
// Add notes to the contribution.
|
||||||
$contribution_note_mappings = $profile->getAttribute("map_as_contribution_notes", []);
|
/** @phpstan-var array<string> $contribution_note_mappings */
|
||||||
|
$contribution_note_mappings = $profile->getAttribute('map_as_contribution_notes', []);
|
||||||
foreach (['purpose', 'remarks'] as $target) {
|
foreach (['purpose', 'remarks'] as $target) {
|
||||||
if (
|
if (
|
||||||
in_array($target, $contribution_note_mappings)
|
in_array($target, $contribution_note_mappings, TRUE)
|
||||||
&& isset($params[$target])
|
&& isset($params[$target])
|
||||||
&& '' !== $params[$target]
|
&& '' !== $params[$target]
|
||||||
) {
|
) {
|
||||||
civicrm_api4('Note', 'create', [
|
Note::create(FALSE)
|
||||||
'values' => [
|
->addValue('entity_table', 'civicrm_contribution')
|
||||||
'entity_table' => 'civicrm_contribution',
|
->addValue('entity_id', reset($contribution['values'])['id'])
|
||||||
'entity_id' => CRM_Utils_Array::first($result_values['contribution'])['id'],
|
->addValue('note', reset($params[$target]))
|
||||||
'note' => $params[$target],
|
->execute();
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result_values['contribution'] = $contribution['values'];
|
||||||
|
}
|
||||||
|
|
||||||
// MEMBERSHIP CREATION
|
// MEMBERSHIP CREATION
|
||||||
|
|
||||||
// CHECK whether a membership should be created (based on profile settings and data provided)
|
// CHECK whether a membership should be created (based on profile settings and data provided)
|
||||||
|
|
|
@ -316,21 +316,7 @@
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">
|
<td class="label">
|
||||||
{$form.map_as_contribution_notes.label}
|
{$form.map_as_contribution_notes.label}
|
||||||
<a
|
{help id="id-map_as_contribution_notes" title=$form.map_as_contribution_notes.label}
|
||||||
onclick='
|
|
||||||
CRM.help(
|
|
||||||
"{ts domain="de.systopia.twingle"}Create contribution note for{/ts}",
|
|
||||||
{literal}{
|
|
||||||
"id": "id-map_as_contribution_notes",
|
|
||||||
"file": "CRM\/Twingle\/Form\/Profile"
|
|
||||||
}{/literal}
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
'
|
|
||||||
href="#"
|
|
||||||
title="{ts domain="de.systopia.twingle"}Help{/ts}"
|
|
||||||
class="helpicon"
|
|
||||||
></a>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="content">{$form.map_as_contribution_notes.html}</td>
|
<td class="content">{$form.map_as_contribution_notes.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -338,21 +324,7 @@
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">
|
<td class="label">
|
||||||
{$form.map_as_contact_notes.label}
|
{$form.map_as_contact_notes.label}
|
||||||
<a
|
{help id="id-map_as_contact_notes" title=$form.map_as_contact_notes.label}
|
||||||
onclick='
|
|
||||||
CRM.help(
|
|
||||||
"{ts domain="de.systopia.twingle"}Create contact note for{/ts}",
|
|
||||||
{literal}{
|
|
||||||
"id": "id-map_as_contact_notes",
|
|
||||||
"file": "CRM\/Twingle\/Form\/Profile"
|
|
||||||
}{/literal}
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
'
|
|
||||||
href="#"
|
|
||||||
title="{ts domain="de.systopia.twingle"}Help{/ts}"
|
|
||||||
class="helpicon"
|
|
||||||
></a>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="content">{$form.map_as_contact_notes.html}</td>
|
<td class="content">{$form.map_as_contact_notes.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue