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

[Acknowledgements] Fix for selecting all roles #9209

Merged
Merged
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions modules/acknowledgements/php/acknowledgements.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,28 @@ class Acknowledgements extends \NDB_Menu_Filter_Form
if ($values['addPresent'] === 'Yes') {
$values['addEndDate'] = null;
}
$affiliations = is_array($values['addAffiliations']) ?
$affils = is_array($values['addAffiliations']) ?
implode(', ', $values['addAffiliations']) :
$values['addAffiliations'];
$degrees = is_array($values['addDegrees']) ?
$degs = is_array($values['addDegrees']) ?
implode(', ', $values['addDegrees']) :
$values['addDegrees'];
$roles = is_array($values['addRoles']) ?
$roles = is_array($values['addRoles']) ?
implode(', ', $values['addRoles']) :
$values['addRoles'];
$results = [
$results = [
'ordering' => $values['addOrdering'],
'full_name' => $values['addFullName'],
'citation_name' => $values['addCitationName'],
'affiliations' => $affiliations,
'degrees' => $degrees,
'roles' => $roles,
'affiliations' => implode(',', array_filter(explode(',', $affils))),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not do the array_filter before the implode on line 96/99/102?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since the fields are strings and not arrays, it skips lines 96, 99, and 102. I didn't want to get rid of that part though as I don't know if there was some other reason for it. By doing it later it makes sure to do it for all cases without duplicating the codes on 96 and 97, 99 and 100, and 102 and 103
image

'degrees' => implode(',', array_filter(explode(',', $degs))),
'roles' => implode(',', array_filter(explode(',', $roles))),
'start_date' => $values['addStartDate'],
'end_date' => $values['addEndDate'],
'present' => $values['addPresent'],
];

$DB->insert('acknowledgements', $results);
$DB->insertIgnore('acknowledgements', $results);
unset($values);

header("Location: {$baseurl}/acknowledgements/", true, 303);
Expand Down
Loading