Hi everyone.
I would need some expert help to solve this problem:
In a "calendar" table I have a checkbox field named "active".
I have set up a "phone_operator" group that can see all records in the "calendar" table (but cannot edit them).
Now I would like to take a step forward:
Hide from the members of the "phone_operator" group, both in the table view and in the detail and print view, all the records where the "active" checkbox field is NOT checked.
I have no idea how to code!
Thanks for your help!
Fabiano
Hide records for a group if a checbox field is unchecked
Re: Hide records for a group if a checbox field is unchecked
Hi Fabiano,
in order to acheive this you need to edit the _init hook and the _dv hook.
Within the _init hook you can modify the query to select only record that have the the checkbox checked.
Something like
In the _dv hook you need to check if the caller is a member of the group and if the record he is calling has the correct value, otherwise send him back to the tableview.
Somewhat something like:
in order to acheive this you need to edit the _init hook and the _dv hook.
Within the _init hook you can modify the query to select only record that have the the checkbox checked.
Something like
Code: Select all
if ($memberInfo['group'] == "phone_operator") {
$options->QueryWhere .= ($options->QueryWhere ? " AND " : " WHERE ") . "active=1";
}
Somewhat something like:
Code: Select all
if ($memberInfo['group'] == "phone_operator") {
$record=get_joined_record('calendar',$selectedID);
if (empty($record['active'])) {
redirect('calendar_view.php');
exit;
}
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Hide records for a group if a checbox field is unchecked
Hi,
just to correct the last entry.
please try for the _dv hook:
just to correct the last entry.
please try for the _dv hook:
Code: Select all
if ($memberInfo['group'] == "phone_operator" && $selectedID) {
$record=get_joined_record('calendar',$selectedID);
if (empty($record['active'])) {
redirect('calendar_view.php');
exit;
}
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.