Leveraging ACL access levels in your code: Part 3 – Field Level ACLs

sugarcrmdevelopers —  October 5, 2012 — 2 Comments

So part 1 and part 2 of this series has focused on the module and record level ACL permissions for records. If you are a user of a commerical edition of Sugar ( Professional, Corporate, Enterprise, or Ultimate ) you have another option here as well with Field level ACLs. This means that for each field in a record, you can have very fine grained permission framework to determine if a record is able to be viewed or edited.

The crux of doing this is thru the ACLField::hasAccess($field, $module, $user_id, $is_owner) method. This method returns back an integer value that corresponds to the ACL level, as shown below…

With this, you can easily determine if a field can be accessed by the given User object.

Now I can imagine there’s lots of developers out there building addons to work on either CE or Pro that would love to leverage this, but don’t want to have to deal with maintaining separate packages. The best way to get around this is to do a bit of feature detection, such as this…

2 responses to Leveraging ACL access levels in your code: Part 3 – Field Level ACLs

  1. 

    Wow. amazing. Thanks for this!

  2. 

    Wow, thanks for this!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s