Skip to content

Commit

Permalink
Handling metadata-base per-group permission conditions (with new ID s…
Browse files Browse the repository at this point in the history
…torage system)
  • Loading branch information
jegelstaff committed Nov 5, 2024
1 parent a5cf928 commit 94dc4bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions modules/formulize/class/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -1255,11 +1255,11 @@ function getPerGroupFilterWhereClause($fid, $formAlias="", $groupids=false) {
$filterOOM = array();
for($i=0;$i<count((array) $filterSettings[3]);$i++) {
// ensure filterSettings[0] is an array of element handles! (will be stored as IDs but we need the handles for lower code to work)
if($elementObject = $element_handler->get($filterSettings[0][$i])) {
if(!isMetaDataField($filterSettings[0][$i]) AND $elementObject = $element_handler->get($filterSettings[0][$i])) {
$filterSettings[0][$i] = $elementObject->getVar('ele_handle');
} else {
print "Formulize Error: a per-group permission filter on form $fid is referencing an element that does not exist. Was it renamed or deleted?<br>";
return "";
exit(); // can't invoke intended per-group permissions, must fail out rather than risk showing data user should not have access to :(
}
if($filterSettings[3][$i] == "all") {
$filterAll[] = $i;
Expand Down
30 changes: 16 additions & 14 deletions modules/formulize/include/elementdisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,21 +459,23 @@ function buildEvaluationCondition($match,$indexes,$filterElements,$filterOps,$fi
$element_handler = xoops_getmodulehandler('elements', 'formulize');

foreach ($filterElements as $key => $element) {
// make sure that the filterElements array is using handles, as originally designed and required by code below
if($filterElementObject = $element_handler->get($element)) {
$filterElements[$key] = $filterElementObject->getVar('ele_handle');
} else {
print "Formulize Error: a display or disabled condition for a form element, is referencing a non existent element in another form. Probably the element was deleted?<br>";
return false;
}
$element_metadata = formulize_getElementMetaData($element, !is_numeric($element));
if($element_metadata['ele_uitextshow'] AND isset($element_metadata['ele_uitext'])) {
$filterTerms[$key] = formulize_swapUIText($filterTerms[$key], unserialize($element_metadata['ele_uitext']));
if(!isMetaDataField($element)) {
// make sure that the filterElements array is using handles, as originally designed and required by code below
if($filterElementObject = $element_handler->get($element)) {
$filterElements[$key] = $filterElementObject->getVar('ele_handle');
} else {
print "Formulize Error: a display or disabled condition for a form element, is referencing a non existent element in another form. Probably the element was deleted?<br>";
return false;
}
$element_metadata = formulize_getElementMetaData($element, !is_numeric($element));
if($element_metadata['ele_uitextshow'] AND isset($element_metadata['ele_uitext'])) {
$filterTerms[$key] = formulize_swapUIText($filterTerms[$key], unserialize($element_metadata['ele_uitext']));
}
if($element_metadata['ele_type'] == 'yn' AND ($filterTerms[$key] == 'Yes' OR $filterTerms[$key] == 'No') AND $xoopsConfig['language'] == 'french') {
$filterTerms[$key] = $filterTerms[$key] == 'Yes' ? 'Oui' : $filterTerms[$key];
$filterTerms[$key] = $filterTerms[$key] == 'No' ? 'Non' : $filterTerms[$key];
}
}
if($element_metadata['ele_type'] == 'yn' AND ($filterTerms[$key] == 'Yes' OR $filterTerms[$key] == 'No') AND $xoopsConfig['language'] == 'french') {
$filterTerms[$key] = $filterTerms[$key] == 'Yes' ? 'Oui' : $filterTerms[$key];
$filterTerms[$key] = $filterTerms[$key] == 'No' ? 'Non' : $filterTerms[$key];
}
}


Expand Down

0 comments on commit 94dc4bd

Please sign in to comment.