add value formatting

This commit is contained in:
Marc Michalsky forumZFD 2020-10-13 09:11:09 +02:00
parent 18100e866b
commit 36ff75843a
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -420,15 +420,64 @@ class TwingleProject {
if ($direction == self::IN) {
// Change timestamp into DateTime string
if ($values['last_modified_date']) {
$values['last_modified_date'] =
self::getDateTime($values['last_modified_date']);
}
// empty project_type to 'default
if ($values['type']) {
$values['type'] = $values['type'] == ''
? 'default'
: $values['type'];
}
// format donation rhythm
if (is_array($values['donation_rhythm'])) {
$tmp = [];
foreach ($values['donation_rhythm'] as $key => $value) {
if ($value) {
$tmp[$key] = $key;
}
}
$values['donation_rhythm'] = \CRM_Utils_Array::implodePadded($tmp);
}
// Format project target format
if (key_exists('has_projecttarget_as_money', $values)) {
$values['has_projecttarget_as_money'] =
$values['has_projecttarget_as_money'] ? 'in Euro' : 'percentage';
}
// Format contact fields
if ($values['exclude_contact_fields']) {
$possible_contact_fields =
self::$campaigns['custom_fields']
['twingle_project_exclude_contact_fields']['option_values'];
$exclude_contact_fields = explode(',', $values['exclude_contact_fields']);
foreach ($exclude_contact_fields as $exclude_contact_field) {
unset($possible_contact_fields[$exclude_contact_field]);
}
$values['exclude_contact_fields'] =
\CRM_Utils_Array::implodePadded($possible_contact_fields);
}
// Format languages
if ($values['languages']) {
$values['languages'] =
\CRM_Utils_Array::implodePadded(
explode(
',',
$values['languages']
)
);
}
}
elseif ($direction == self::OUT) {
// Change DateTime string into timestamp