Leveraging ACL access levels in your code: Part 1 – Admin/Developer access

bsoremsugar —  October 3, 2012 — 5 Comments

UPDATED 10/4/2012 – Added that the Module Level Admin and Developer access are only are specific to the commercial editions of Sugar.

One of the big things Sugar brings to the table is a strong ACL layer, which allows you to control the level of access users have to portions of the application.

For the second case of checking to see if the user is an administrator for the selected module ( which is only available as functionality in the commercial editions of Sugar ), there is a simple call to the User object method isAdminForModule($module). Note the different syntax in the comments for pre-SugarCRM 6.2.1 usage…

You can also check to see if a User has Developer level ACL access for a module instead ( again only an option for the commercial editions of Sugar ). Remember that an System Administrator automatically inherits the Developer privilege, but a module level Adminstrator has to specifically be given Developer Access as well. To check for Developer level ACL access, you can use the isDeveloperForModule($module) User object call. Note the different syntax in the comments for pre-SugarCRM 6.2.1 usage…

These calls can be leveraged anywhere in the code base ( including Smarty templates! ), and you can substitute the usage above of $GLOBALS[‘current_user’] with a different User object to check to see if that User is an administrator instead.

Come back tomorrow where we will leverage the more fine grained ACL permission of seeing if users have access to view and change records.

5 responses to Leveraging ACL access levels in your code: Part 1 – Admin/Developer access

  1. 

    Pah! more time wasted reading an article for ProEnt version. Why so difficult to prefix the article with which version it applies to?

  2. 

    John, if this article is for CE then why cant I see ‘Access Type’ in my Roles definition?

  3. 

    John,

    You say, “These calls can be leveraged anywhere in the code base ( including Smarty templates! )”, which is great, because leveraging this in a Smarty template is exactly what I want to do – the problem is “how”? I’ve got plenty of PHP experience – but I’m not familiar with Smarty. I know how to call PHP code inside a Smarty but not how to pass the result back to Smarty, and from what I’ve read calling PHP in Smarty is considered poor practice.

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