Try modifying your getPermissions() method as follows:
- Code: Select all
function getPermissions(&$record){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
if ( !$user ) return Dataface_PermissionsTool::NO_ACCESS();
if ( $user->val('Role') == 'ADMIN' ) return Dataface_PermissionsTool::ALL();
else if ($record and $user and $record->val('UserID') == $user->val('UserID') ){
return Dataface_PermissionsTool::ALL();
}
else {
$perms = Dataface_PermissionsTool::READ_ONLY();
$perms['new'] = 1;
return $perms;
}
return Dataface_PermissionsTool::READ_ONLY();
}
English iterpretation:
1. Admins can do everything.
2. Record owners can do everything to the records that they own.
3. Regular users get read only access plus they can add new records.
Your previous getPermissions method worked as follows:
1. Admins can do everything that does NOT pertain to a particular record.
2. Regular users can do everything if the current action is 'new' (which is not the case when adding new records through the grid).
3. Regular users get READ ONLY access in contexts that do NOT pertain to a particular record.
4. Record owners get all permissions to record that they own.
5. Otherwise users get read only access.
This previous rules were kind of convoluted and make it hard to predict how the system would act.
-Steve