Data displayed by User only
Permalink Browser Info Environment
I am trying to setup a system where the User can enter data by a form and then view and edit only their own data/records that they have entered. All other users data is hidden from them. Is that possible and simple to set up? Of course Admins can see all data/records too.
Type: | Discussion |
---|---|
Status: | New |
I know this was posted almost a year ago but I would like to know how to do this as well. Owners can only view their records but administrators can view all records. Possible?
This is how I accomplished this:
First, edit the data display block so that the check box that says "Limit to records owned by user?" is checked.
Then in the block controller for data display I changed this:
to this:
So now, only record owners can view their records but the above addition to the block controller adds an exception for users that are in the "Administrators" group.
First, edit the data display block so that the check box that says "Limit to records owned by user?" is checked.
Then in the block controller for data display I changed this:
if($this->showOwnedRecords) { $asl->requireOwnership(); $fullasl->requireOwnership(); }
to this:
if($this->showOwnedRecords) { $u = new User(); //gets current user object $g = Group::getByName("Administrators"); if($u->inGroup($g)) { } else { $asl->requireOwnership(); $fullasl->requireOwnership(); } }
So now, only record owners can view their records but the above addition to the block controller adds an exception for users that are in the "Administrators" group.