Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CO-2743_Update_attribute_Form_email_hidden_field_with_the_first_email_value_if_the_attributes_has_multiple_values #571

Open
wants to merge 1 commit into
base: hotfix-4.3.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions app/View/CoPetitions/petition-attributes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
}
}

$co_person_id = $co_person_id ?? $userInfo['co_person_id'] ?? null;

// Sort attributes by model for printing
$coea_model = array();
$misc_attr = array();
Expand Down Expand Up @@ -345,8 +347,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 +588,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 +652,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 +672,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