Hide records for a group if a checbox field is unchecked

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Hide records for a group if a checbox field is unchecked

Post by fgazza » 2021-12-27 23:40

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Hide records for a group if a checbox field is unchecked

Post by pbottcher » 2021-12-28 10:37

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

Code: Select all

		if ($memberInfo['group'] == "phone_operator") {
			$options->QueryWhere .= ($options->QueryWhere ? " AND " : " WHERE ") . "active=1";
		}
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:

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.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Hide records for a group if a checbox field is unchecked

Post by pbottcher » 2021-12-28 14:45

Hi,

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.

Post Reply