Archive | SecuritySuite RSS feed for this section

Multiple DetailViews for the Same Module

This past September Francesca from the SugarCRM forums asked if there was a way to have a different layout view for each department:

two different Edit Views and two different Detail Views for the SAME module?

The short answer is yes. SugarCRM lets you do just about anything. The question always is – at what cost and/or tradeoff?

To do this for a module (like the Accounts module) copy custom/metadata/Accounts/metadata/detailviewdefs.php and rename for each department. For example, custom/metadata/Accounts/metadata/detailviewdefs_sales.php. Then create a custom view.detail.php and tell SugarCRM to use the appropriate custom layout:

Caveat – you must turn on developerMode. Otherwise, it will just cache the first requested layout and every subsequent request will use that same cache/modules/Accounts/DetailView.tpl. With this code, we need that .tpl rebuilt on every request. Actually, thinking about this more it really does have some annoying limitations:

  • Can’t take advantage of cache.
    Result = performance degradation.
  • Can’t use Studio to edit the custom layouts.
    Result = time consuming code changes.
  • Has to be done for any and every module required and for every department.
    Result = more time consuming work.

I didn’t start writing this post with this intention, but it is clear that if you really want custom layouts just use my SecuritySuite module. Even if you don’t need the teams security portion, the custom layouts feature by itself makes doing this a breeze.

Result = saving time, money, and frustration.

Then again, it may be good enough for a one-time thing.

Update: Angel (check out his awesome blog!) has noted that the cache can also be cleared on demand using:

TemplateHandler::clearCache('Accounts','DetailView.tpl');

This removes the need to turn on developerMode and reduces the lack of caching just to that view in that specific module.

Adding a panel via javascript in SugarCRM

I’m working on a new feature that requires a panel to be inserted on the edit screen in very specific cases. Since this is for SecuritySuite it must work for all modules; both current and future. Because of this, customizing each module’s view.edit.php is out of the question. The end goal is to allow users who are a member of multiple groups to choose which group(s) should be associated with any newly created record. This used to be the “Use Popup Select” feature but due to the new AjaxUI in SugarCRM this no longer works.

Right below the Assigned To panel and above the buttons is where I’d like to insert the panel:
Where the panel should go

Now here is where the problem comes in. Generally, when you need to show/hide a panel based on a field’s value all you do is create the panel in Studio and then either customize the view.edit.php and view.detail.php or detailviewdefs/editviewdefs.php to spit out javascript to hide the panel based on certain conditions AFTER the parent::process(). If it needs to be tightly coupled to a field’s value then you’d just spit out the appropriate javascript to show/hide all of the appropriate panels. In this case, we don’t necessarily know what modules will ever be created in a given install. Since there are thousands of installs using SecuritySuite on SugarCRM CE for the team functionality it needs to be as forgiving as possible.

The place that allows for this flexibility to customize is the main MVC view.edit.php (include/MVC/View/views/edit.php). Thankfully this module already customizes that file to allow for the custom layout for each team feature. This is not upgrade-safe, of course. There are many changes in SecuritySuite that are not upgrade-safe. It is a necessary evil to ensure that everything is secured properly. Any team solution that claims to be upgrade-safe is doing so at the expense of not truely being secure.

In this specific case the panel should only show if this is to be a newly created record and if the current user is a member of 2 or more groups. Otherwise, it just inherits the single group associated to the user (if the “Inherit from Created By User” is chosen).

On to the code. To insert the panel we are going to do so after the template has been rendered. So we will do this in the display function after the echo.

Yes, some of that code sucks. For example, the functions used to get the group count, etc should be static functions but it’s been around for years and would cripple some folks who use the library so now I’m kind of stuck. If you have suggestions, please fire away.

As of 6.5.0 SugarCRM began shipping with jQuery already included. I’m a fan of jQuery due to the ubiquity of it, ease of use, and ease of finding help. In this case I hand build the panel html then do a preg_replace to remove line breaks as javascript’s support for multiline strings is nil. Once the panel is all set some javascript is outputted with which uses jQuery’s append function to add the panel to the panel container.

Here is the finished result:
The finished product. A panel insert into SugarCRM

Have ideas on how to improve this? I’d love to hear them!

Store moved to SugarOutfitters!

Why? Besides being a pain to use for everyone the old store just didn’t provide a good user experience. Moving to SugarOutfitters allows me to provide you with better support and better documentation. This will free me up to continue to support and grow SecuritySuite.

–Sidebar–
I created SugarOutfitters along with Chad Hutchins to make it easy to “Find quality, proven solutions to enhance your SugarCRM© experience.” We feel what is there now is a good first step to a larger vision of improving that experience. You can get more info from the SugarOutfitters blog. I’d love to hear your feedback on it.
–End Sidebar–

A big thank you is owed to all of you who have used and continue to use SecuritySuite. It has become the most popular teams solution for SugarCRM CE. However, I’m not satisfied with that. There is more that can be added to the suite to make it even more useful to you. Field level access and the ability to filter the list view by groups are two that come to mind. Custom group layouts works for most people who need to hide certain layouts but it doesn’t cover 100% of the cases. If you have some ideas that you’d love to see included make sure to add them as Feature Requests.

To continue its growth and to remove the confusion of having 2 different pricing options only a Yearly Subscription will be offered going forward. It is very important to me that you get a great value for the price and I believe the new price point achieves that while balancing the need to put food on my family’s table (not the same as Latrell Sprewell). I want to give you the best price possible while being able to ensure that this module will be around for a long, long time. With how often the SugarCRM code base changes it is quite time consuming to maintain as there are now 431 files in SecuritySuite. This is a necessity to ensure that your data is locked down and secure.

If you have bought a Yearly Subscription from the old store within the past year your purchase will be honored through the end of its term. You can login and go to your account here to view your subscription order and download all new versions that are released.

Thank you!
-Jason Eggers