[update to previous post]
I must have something out of whack here. I've reviewed the docs on __field__permissions and fieldname__permissions in the effort to hide certain fields/columns in my XF application based on the user's level; my records each have group IDs and numeric level numbers; and I'm aiming to show the user his/her own records and in those records to hide certain columns (depending on the user's level). For myself and my admin users, I'm providing full access to all records.
I've been able to preselect the group's records based on log-in ID using the delegate class approach; but I'm not having luck with hiding fields using field__permissions.
In my tablename.php delegate file, I've got this for example:
- Code: Select all
function init(&$users){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
if ( !$user ) return Dataface_PermissionsTool::NO_ACCESS();
$role = $user->val('Role');
switch ($role){
case 'ADMIN':
return Dataface_PermissionsTool::ALL();
case 'STAFF':
return Dataface_PermissionsTool::ALL();
default:
$users->setSecurityFilter(array('Level'=>$user->val('Level'))); // limit display to records with matching level;
$level = $user->val('Level');
if ( $level == '2' ) // for users with level 2, hide the field called "Level" by turning off view, edit, & list perms;
function Level__permissions(&$record) {
return array('view'=>0,'edit'=>0,'list'=>0);
}
}
}
Alas, though this successfully differentiates users by role (admin vs. me vs. the default; this leaves the 'Level' field right where it sat, fully accessible to users with level 2!
I think I'm close here, but longing for the trip up the Wonkavator....