pre-filter depending on user
Posted: 2020-10-21 13:40
Here is the challenge I need to address, if anybody can help.
Scenario: Users all belong to one permissions group or another, based on their country - Thailand, UK etc. Records in a table include field 'Country' - Thailand, UK etc.
Users from Thailand can access all the table records, as can User from England. When User from User group 'Thailand' arrives, she wants the pre-filtered configured so she only sees records where country field = Thailand. (She can click View all if she wants to see the rest.) When UK guy arrives, he wants the pre-filter to only show where country = UK. That's it - not to much to ask!
But I can't figure out how to reference the current User in order to say - 'ah, she's in the Thai group, we need to filter by country="Thailand".
I have seen the partial solution at: https://bigprof.com/appgini/tips-and-tu ... ult-filter.
But after the usual time consuming non-result, this is my best effort to later it to reflect my needs. My solution doesn't work - any thoughts much appreciated. Thanks
function meetings_init(&$options, $memberInfo, &$args){
/* Apply a default filter only if no filter is already applied by the user */
if(!$_POST['FilterField'][1] && !$_GET['FilterField'][1]){
/*
In the call below, we want to display records of the meetings
table where the value of the 1st field is equal to '(the Group name of thge current user'.
*/
$group = $_REQUEST[Group'];
addFilter(1, 'and', 1, 'equal-to', '$group');
}
return TRUE;
}
Scenario: Users all belong to one permissions group or another, based on their country - Thailand, UK etc. Records in a table include field 'Country' - Thailand, UK etc.
Users from Thailand can access all the table records, as can User from England. When User from User group 'Thailand' arrives, she wants the pre-filtered configured so she only sees records where country field = Thailand. (She can click View all if she wants to see the rest.) When UK guy arrives, he wants the pre-filter to only show where country = UK. That's it - not to much to ask!
But I can't figure out how to reference the current User in order to say - 'ah, she's in the Thai group, we need to filter by country="Thailand".
I have seen the partial solution at: https://bigprof.com/appgini/tips-and-tu ... ult-filter.
But after the usual time consuming non-result, this is my best effort to later it to reflect my needs. My solution doesn't work - any thoughts much appreciated. Thanks
function meetings_init(&$options, $memberInfo, &$args){
/* Apply a default filter only if no filter is already applied by the user */
if(!$_POST['FilterField'][1] && !$_GET['FilterField'][1]){
/*
In the call below, we want to display records of the meetings
table where the value of the 1st field is equal to '(the Group name of thge current user'.
*/
$group = $_REQUEST[Group'];
addFilter(1, 'and', 1, 'equal-to', '$group');
}
return TRUE;
}