add some shitty temporary logic for name processing

This commit is contained in:
Marc Michalsky forumZFD 2020-11-12 14:03:24 +01:00
parent e4af927a5b
commit 080157754b
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -307,11 +307,20 @@ class TwingleEvent extends Campaign {
if (is_array($names) && count($names) > 1) {
$lastname = array_pop($names);
$test = $names[count($names) - 1];
$nameSuffixes = ['de', 'da', 'von', 'van'];
$lastnamePrefixes = ['da', 'de', 'der', 'van', 'von'];
if (in_array($test, $nameSuffixes)) {
array_pop($names);
$lastname = $test . ' ' . $lastname;
if (in_array($test, $lastnamePrefixes)) {
if ($test == 'der' &&
$names[count($names) - 2] == 'van' ||
$names[count($names) - 2] == 'von'
) {
$lastname = implode(' ', array_splice($names, -2))
. ' ' . $lastname;
}
else {
array_pop($names);
$lastname = $test . ' ' . $lastname;
}
}
$names = implode(" ", $names);
@ -334,19 +343,23 @@ class TwingleEvent extends Campaign {
/**
* Gets the campaign id of the parent TwingleProject campaign.
*
* @return int|null
* @throws CiviCRM_API3_Exception
*/
private function getParentCampaignId() {
$cf_project_id = Cache::getInstance()->getCustomFieldMapping()['twingle_project_id'];
$cf_project_id = Cache::getInstance()
->getCustomFieldMapping()['twingle_project_id'];
$parentCampaign = civicrm_api3('Campaign', 'get', [
'sequential' => 1,
$cf_project_id => $this->values['project_id']
'sequential' => 1,
$cf_project_id => $this->values['project_id'],
]);
if ($parentCampaign['is_error'] == 0) {
return (int) $parentCampaign['id'];
}
else return NULL;
else {
return NULL;
}
}
/**