Read only permissions on field in edit view...

A place for users and developers of the Xataface to discuss and receive support.

Read only permissions on field in edit view...

Postby ururk » Thu Jan 13, 2011 12:40 am

I'm trying to display a column as read-only in a users profile. In the table delegate class, I set their role to 'MYPROFILE' which extends OWNER:

Code: Select all
function getPermissions(&$record){
      $auth =& Dataface_AuthenticationTool::getInstance();
      $user =& $auth->getLoggedInUser();

      if ($record && $user->val('ID') == $record->val('ID')) {
         return Dataface_PermissionsTool::getRolePermissions('MYPROFILE');
      } else {
         $role = $user->val('Role');
         return Dataface_PermissionsTool::getRolePermissions($role);
      }
   }


That part works, and it works on related records as well.

I now need to show a field in the profile, but disable editing. I'm able to set permissions for ADMIN only:

Code: Select all
function My_Date__permissions(&$record){
return $this->adminonly();
}


Their permissions are rendered properly - the field does not appear, and only shows up for 'ADMIN' accounts.

When I try setting this to READ_ONLY on a specific field (so users can see the field, but not edit):

Code: Select all
function My_Status__permissions(&$record){
return Dataface_PermissionsTool::READ_ONLY();   
}


When the record is edited... Status is editable.

I'm trying to figure out where I'm doing wrong.

Thanks!
ururk
 
Posts: 18
Joined: Mon Nov 01, 2010 12:31 pm

Re: Read only permissions on field in edit view...

Postby shannah » Fri Jan 14, 2011 12:55 pm

This is a little tricky and it deals with the way Xataface merges permissions on fields. When specifying field permissions whatever permissions array you return is then merged with the record permissions. NO_ACCESS actually explicityly specifies a 0 for every permission available. READ ONLY specifies a '1' for only those permissions allowed for reading but doesn't say anything about the other permissions. So when merged with the record permissions the omitted permissions take on the value specified for the record.

For fields you should usually start with a base of NO ACCESS and then add only those permissions that you want to grant.

e.g.
Code: Select all
$perms = Dataface_PermissionsTool::NO_ACCESS();
$perms['view']=1;
return $perms;
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Read only permissions on field in edit view...

Postby ururk » Fri Jan 14, 2011 4:24 pm

That works - thanks!
ururk
 
Posts: 18
Joined: Mon Nov 01, 2010 12:31 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 23 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved