Skip to content

Commit

Permalink
correctly recalculate multivalue email attributes for both visible an…
Browse files Browse the repository at this point in the history
…d hidden form fields
  • Loading branch information
ioigoume committed Jan 5, 2024
1 parent 6170b4d commit ec160eb
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions app/View/CoPetitions/petition-attributes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,28 @@

$hfieldName = $ea['model'] . '.' . $ea['field'];
$fieldName = $hfieldName . "-disabled";
$default_val = null;

if(strpos($hfieldName, 'EnrolleeCoPerson.EmailAddress') !== false
|| strpos($hfieldName, 'EnrolleeOrgIdentity.EmailAddress') !== false) {
$email_list = $ea['default'];
if(!empty($email_list) && !empty($vv_envsource_delimiter)) {
$delimiter = "";
if($vv_envsource_delimiter == AuthProviderEnum::Shibboleth) {
$delimiter = ";";
} elseif($vv_envsource_delimiter == AuthProviderEnum::Simplesamlphp) {
$delimiter =",";
}

$emails = explode($delimiter, $email_list);
if(is_array($emails) && count($emails) > 1) {
// XXX We are only keeping the first email
$default_val = $emails[0];
}
}
}

print $this->Form->hidden($hfieldName, array('default' => $ea['default'])) . PHP_EOL;
print $this->Form->hidden($hfieldName, array('default' => ($default_val ?? $ea['default']) )) . PHP_EOL;
}

// XXX need to retrieve current values for edit and view
Expand Down Expand Up @@ -566,7 +586,7 @@
array(
// We don't support two sponsors, but if we did this id would break
'id' => 'EnrolleeCoPersonRoleSponsorCoPersonId',
'default' => (isset($ea['default']) ? $ea['default'] : null)
'default' => ($ea['default'] ?? null)
))
. '</div>
<div class="field-desc">
Expand Down Expand Up @@ -630,7 +650,7 @@
array(
// We don't support two managers, but if we did this id would break
'id' => 'EnrolleeCoPersonRoleManagerCoPersonId',
'default' => (isset($ea['default']) ? $ea['default'] : null)
'default' => ($ea['default'] ?? null)
))
. '</div>
<div class="field-desc">
Expand All @@ -650,7 +670,8 @@
$args['value'] = generateCn($vv_default_sponsor['PrimaryName']);
} elseif($fieldName == 'EnrolleeCoPersonRole.manager_co_person_id-disabled') {
$args['value'] = generateCn($vv_default_manager['PrimaryName']);
} elseif(strpos($fieldName, 'EnrolleeCoPerson.EmailAddress') !== false) {
} elseif(strpos($fieldName, 'EnrolleeCoPerson.EmailAddress') !== false
|| strpos($fieldName, 'EnrolleeOrgIdentity.EmailAddress') !== false) {
$email_list = $args['default'];
if(!empty($email_list) && !empty($vv_envsource_delimiter)) {
$delimiter = "";
Expand Down

0 comments on commit ec160eb

Please sign in to comment.