Commit b7c12cc1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix display of view access rows after error on submission (bug #894592)



When you submit the view access page and there's an error in the form
submission (due to bad start/stopdates, etc.), sometimes an item is
removed from the array of access records by unsetting the array key.
Messing with the ordering of the array keys causes a javascript error
which stops the access list from being displayed.

Change-Id: Iaa686c8adecc322a6b779ee3247b28c945031854
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent c391286e
......@@ -62,8 +62,9 @@ function pieform_element_viewacl(Pieform $form, $element) {
$presets[] = 'friends';
}
$accesslist = array();
if ($value) {
foreach ($value as $key => &$item) {
foreach ($value as $item) {
if (is_array($item)) {
if ($item['accesstype'] == 'public') {
$item['publicallowed'] = (int)$public;
......@@ -79,13 +80,10 @@ function pieform_element_viewacl(Pieform $form, $element) {
$item['shortname'] = str_shorten_text($item['name'], 30, true);
}
// only show access that is still current. Expired access will be deleted if the form is saved
if($item['stopdate'] && (time() > strtotime($item['stopdate']))) {
unset($value[$key]);
if (empty($item['stopdate']) || (time() <= strtotime($item['stopdate']))) {
$accesslist[] = $item;
}
}
else {
unset($value[$key]);
}
}
}
......@@ -156,7 +154,7 @@ function pieform_element_viewacl(Pieform $form, $element) {
$smarty->assign('viewtype', $element['viewtype']);
$smarty->assign('potentialpresets', json_encode($potentialpresets));
$smarty->assign('loggedinindex', $loggedinindex);
$smarty->assign('accesslist', json_encode($value));
$smarty->assign('accesslist', json_encode($accesslist));
$smarty->assign('viewid', $form->get_property('viewid'));
$smarty->assign('formname', $form->get_property('name'));
$smarty->assign('myinstitutions', json_encode($myinstitutions));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment