Twitter Feed

Xataface Maillist

Sign up to receive the Xataface news letter with weekly updates and development tips.

 
Found 135 of 135 records in table Wiki
Now Showing 52 of 135

Current Record: viewable_editable_fields

How to make a field editable for some users and only viewable for some other users

[Permalink]

If we want only some users to edit a field and some other users only to view that field, then we need to define a fieldX__permissions() method for that field which gives desired permissions for specific users.

One solution is as below.

permissions.ini

[Field Viewer]
view=1
edit=0
new=0

[Field Editor extends Field Viewer]
new=1
edit=1

TableX.php (Delegate class of TableX)

function fieldX__permissions(&$record) {
    $user=&Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
    
    if($user) {
        if($user->val('usernameField')=="UserX")
            $role='Field Viewer';
        else if($user->val('usernameField')=="UserY")
            $role='Field Editor';                

            return Dataface_PermissionsTool::getRolePermissions($role);
    }
        
    return Dataface_PermissionsTool::NO_ACCESS();
}
blog comments powered by Disqus
Powered by Xataface
(c) 2005-2010 All rights reserved