Sugar Developer Blog

Adding/Modifying the Shortcuts Menu

29 Jun, 2009
Posted By: kaz

Adding/Modifying the Shortcuts Menu

Suppose you want to modify the Opportunities Shortcuts menu to add a shortcut to create a new Lead (not tied to the existing opportunity).

Create a custom file called:

/custom/Extension/modules/Opportunities/Ext/Menus/CustomMenu.php

The filename is not very important.  Add the following contents:
<?php

if(ACLController::checkAccess(’Leads’, ‘edit’, true))$module_menu[]=Array(”index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’);

?>

Lets’s look at this code to see what it does.
if(ACLController::checkAccess(’Leads’, ‘edit’, true))

This line of code checks to see if the user has access to the Leads module.  If they do then the system will all another shortcut menu.  This is not strictly required, but good coding practice so users don’t see menu items for modules they can’t create or edit.

The variable $module_menu contains the items the information used to create the menus.  The format is

$module_menu[]=Array($url,$menu_title,$image_icon,$module)

$url – this is where you want to go.  You can look at <install dir>/<ModuleName>/Menu.php to see the shortcuts for the existing modules

$menu_title – In this example, I hard coded the name to “New from Canvass Form”.  If you want the application to be multi-lingual and conform to Sugar standards, you should add a custom string and use something like $mod_strings['LNK_NEW_FROM_CANVASS_FORM']

$image_icon – The images are found in themes/default/images.  If you want to add a new icon, put it there.

$module – The name of the module

You must do a Quick Repair and Rebuild for this to take effect.

If you want to not show the out of the box shortcut menu items, you can just redeclare the array.  Putting the following code in your cusotm file:

<?php

$module_menu= array();

if(ACLController::checkAccess(’Leads’, ‘edit’, true))$module_menu[]=Array(”index.php?module=Leads&action=EditView&return_module=Opportunities&return_action=ListView”, “New From Canvass Form”,”CreateNotes”, ‘Leads’);

?>

will have only 1 shortcut item.

IIS FastCGI support in Sugar 5.5

11 Jun, 2009
Posted By: John Mertic

One of the most exciting features for those deploying Sugar on Windows stacks is the offical support for the new IIS/FastCGI support of PHP. This promises to bring great performance and stability boosts as compared to using the previous ISAPI method of using PHP.

What is FastCGI?

There has for sometime been two popular ways of using PHP with Microsoft’s IIS ( Internet Information Server ); either you could use the ISAPI hook which runs PHP in the same process as IIS, or CGI support which runs it in a seperate process. Both approaches had thier drawbacks; running PHP in ISAPI mode required thread-safety, which although PHP was reasonably good at, the many libraries PHP uses aren’t. So using CGI was the natural choice to help your web server avoid crashing, but it had the flaw of being very slow since each PHP request would have to spawn off a whole new PHP process. This made deploying on Windows something nobody would do for anything but the smallest web applications.

Microsoft fixed this issue by adding a FastCGI mode to IIS 7 ( and backwards to IIS 6 and 5.1 via an add-on ). The FastCGI appoach is similar to the CGI approach where PHP handles the requests externally from the IIS process. But instead of launching a new process each time, IIS instead pools them, saving the overhead costs of launching and destroying processes on every request. This results in a significant improvement in speed compared to CGI ( around 4x-8x on average ) and little to no stability issues unlike with ISAPI. Both PHP and Microsoft are putting lots of effort into improving stability on FastCGI as well, making deploying production web applications on a pure Windows stack a reality.

This sounds great! Now, what do I need to do?

Microsoft has dedicated instuctions for setting up PHP to work with IIS 6 and IIS 7, and the new Microsoft Web Platform Installer 2.0 Beta will also configure PHP correctly. In addtion, the PHP Windows Installer will configure PHP correctly with IIS 5.1,6, and 7; be sure to use the NTS ( Non thread safe ) binaries, as they will yield better performance than the standard thread safe ones since we don’t need thread-safety when using FastCGI.

We recommend changing a few of the default setting for FastCGI and PHP when using the IIS/FastCGI support. First, with FastCGI ( which can be changed in the fcgiext.ini file for IIS 5.1/6 and in the FastCGI panel in IIS 7 when you have installed the IIS Admin Pack ):

ActivityTimeout - change to 3600, which is the maximum value

RequestTimeout - change to 3600, also the maximum value

Those settings will allow IIS/FastCGI to not interfere with the PHP max_execution_time/request_timeout settings.

On the PHP side, be sure the following settings are set:

fastcgi.logging=0

fastcgi.impersonate=1

These help prevent wierd FastCGI errors and improve security for your Sugar instance.

If you are on IIS 7, you will need to install the URL Rewrite extension, which provide .htaccess like directory security for your Sugar install.

Once that is done, you should be ready to go. If you run into any issues with using IIS/FastCGI, just let us know.

SugarForge 2.0?

08 Jun, 2009
Posted By: Matt Heitzenroder

I’ve been thinking a lot lately on how you (the developer community) and SugarCRM can work closer together.  We’ve come up with a few ideas that we’re working on here at Sugar.

For starters, I want to revamp SugarForge.  There are some features that I want and they do not currently exist.  My inspiration has come from sites I have been using lately - GitHub, BitBucket, and LaunchPad. I have also been playing with Trac a lot.  What all of these have in common is excellent source control and wikis. I also particularly like the project management & issue tracking available from Trac.

I don’t think its possible (or even wise) to replace SugarForge with any of the above mentioned developer collaboration services.  However, I do think we have some options.  These are the few that I have identified:

Is there any software collaboration suites that you think would be perfect for SugarForge 2.0?  Right now I’m leaning towards gForge because it’s PHP and SugarForge is already gForge based.  It looks like they’ve done some major updates since we initially started SugarForge.

If you have any other ideas that will help SugarCRM collaborate with you better PLEASE let me know. You can often find me hanging out in the IRC #sugarcrm channel (nick: roder).  That’s irc.freenode.net in channel #sugarcrm.

Sugar 5.5 Beta is here

28 May, 2009
Posted By: Matt Heitzenroder

Note: Upgrade files from Sugar 5.5 Beta to any later release will not be provided. Therefore, we recommend that you upgrade a copy of your production Sugar system for testing purposes only.

There are some great new features for developers in 5.5.  I think that there are two big key features for developers are the

  • REST API
  • Themes framework

I haven’t had a chance to hack on the REST api, but I gave it a quick review.  Since we’re just introducing it, right now is the perfect time to help influence it’s developement, submit fixes, etc.  Please, let use know what you think.

To take a look at, look in the ./services/ directory and you’ll see some tests and also an example.  The tests are specific to a specific to some specific records that SugarCRM’s engineering team,  so you’ll have to modify them to suit your database records.

John Mertic is the rockstar behind the new Themes Framework.  I’m really excited to see what innovation come from it.  However, perhaps the best innovation is the possibility of a high performance theme.  A lot of that will come when companies finally decide to ditch IE6 and adopt a more modern browser.  Did you know that IE’s javascript still does not have support for manipulating an array with “foreach”?

Our goal for this Beta release and the upcoming RC release is to receive valuable feedback that will help us achieve a high level of quality in the Sugar 5.5 GA release.  Please share your comments and questions with us within the Sugar 5.5 Beta forum thread. You can also find additional information about the Sugar 5.5 release within the Sugar 5.5 forums.

We look forward to hearing from you about your experiences with the Sugar 5.5 Beta release!

Sugar’s Open Cloud - What Does It Mean?

20 May, 2009
Posted By: Matt Heitzenroder

were-open-imageIn short, the SugarCRM Open Cloud is the evolution of Sugar’s commitment to empower their customers with choice and flexibility.

Matt Asay recently posted commentary on Tim O’Reilly’s poignant thoughts on Cloud Computing that goes a little something like this:

Don’t be fooled, cloud computing is a way to keep things proprietary.

The open source community made so much progress in the past decade getting software with open source licenses into business’s products and IT solutions.  But just when you thought your software was becoming open and standards compliant, someone found a way to market vendor lock-in again.

So the “Cloud” and (perhaps more apropos) Software as a Service models are easy and attractive solutions because there is “No Software” to mess with.  This is all fine and dandy, until there’s a bug you need to be fixed or feature you need to be added.  Then your business is stuck because you don’t have access to source code. So it’s back to the old proprietary model that our open source licenses seek to fix.

What’s even worse, is that with your application in the Cloud, you’ve relinquished complete control of the application entirely to your vendor.  What happens if a switch or a router burns out and performance for the next couple days is terrible and it’s accessibility spotty at best?  In the cloud, all of your data and your business’s mission critical application is at the mercy of the vendor.

Please don’t mistake what I am saying, there IS a very tangible value created by cloud computing.  This isn’t a FUD blog post.  Do you have the technical and financial resources to scale X, Y, or Z product?  What about rolling out the software in a few minutes?  Unlikely, even for the largest enterprises.  That’s why the cloud IS important, it’s because it removes the technology barriers that keeps businesses from successful implementations. However, we need to bring the values of open source to computing in the cloud.

In my opinion, bringing openness to the Cloud does not mean we need to apply licenses that close the ASP loophole to the code that we write. Restrictions on how to use or distribute software that exist in said licenses just create hurdles that prevent massive adoption.  Instead we need to encourage truly free (as in libre, not gratis) software in the cloud.  This is where SugarCRM’s Open Cloud shines.

The SugarCRM Open Cloud creates choice and flexibility for the customer by focusing on openness. This removes the proprietary nature from SaaS and the Cloud. Now you can purchase SugarCRM and can be up and running with “no software” in short order.  However, because of Sugar’s commitment to open standards, if you want, you can migrate your CRM to any host with PHP.  There are no restrictions, your SugarCRM instance is free (as in libre) in the Cloud.

I propose a new marketing slogan of “No Software, No Choice” for our competitor, but I suspect that won’t go over well in the market.

SugarCRM 5.2.0 patch D Released

24 Apr, 2009
Posted By: Matt Heitzenroder

I just wanted to bring to your attention that SugarCRM has released 5.2.0d.  Here’s what you need to know:

New Features, Enhancements, and Behavior Changes

A new Repair option named “Repair Non-Lowercased Fields” allows you to use mixed-case field names when searching for records

Fixed Bugs in 5.2d

Bug 20619 - The get_relationships function fails for custom modules.

Bug 20728 - Fields referencing a custom drop-down list that was not created through the Module Builder do not load properly in Module Builder when exported and loaded on another system, and hence cannot be edited in the new system.

Bug 22836 - The Group User name does not display in the record’s Detail View.

Bug 25151 - When you click an email address in the Employees List View to compose an email, the “To” field does not display.

Bug 25485 - When using a SQL Server database, when you sort a paginated Accounts List View by a custom field, the system displays an “incorrect syntax” error if you click the Next button to navigate to the next page.

Bug 25598 - The value Amount of an opportunity is not converted correctly from EUR to USD for a contract with a default currency of EUR.

Bug 25718 - You are unable to import data for custom multi-select fields with default value.

Bug 26666 - You cannot use mixed-case field names in Search forms.

Bug 27476 - When installing Sugar 5.2.0 with MS SQL database, an error prompts Sugar to create a new MSSQL user.

Bug 27490 - Account links in the Contacts dashlet are incorrect.

Bug 27491 - Related record links in the Meetings dashlet are incorrect.

Bug 27564 - When composing an email, personal and group email addresses are not differentiated in the “From” drop-down list.

Bug 27674 - If you do not have the latest Sugar version, the Configure Sugar Updates page displays strange characters.

Bug 27693 - When you click an email address from the Leads List View, the To field does not display the email address of the lead.

Bug 27877 - Roles created for a custom module are deleted if you re-deploy the module.

Bug 28159 - The Campaign Log label incorrectly displays as “Campaigns”.

Bug 28411 - The My Pipeline By Sales Stage dashlet displays wrong total sum value if the user’s default currency is different from the system default currency.

Bug 28412 - Bar charts do not work if the user’s default currency is different from the system default currency.

Bug 28461 - When importing multi-byte data into Sugar, the length is calculated in bytes instead of characters.

Bug 28586 - When you run a cron job from the Suger User Interface or cron.php from the command line, the tracker table is populated when Tracker Actions is the only box selected on the Tracker Settings page.

Bug 29037 - When importing emails, any email with the word “java” in the message ID is imported multiple times.

A full listing of all bugs fixed in this patch including further details on the bugs listed above can be found in the Bug Tracker.

Compatibility Matrix is available here

Known Limitations

Some entry points were changed in Sugar 5.1. Hence, a custom file created in 5.0, unless you manually updated it with the new entry point in 5.1, may fail in 5.2 with the error message “Not a valid entry point”.

For example, if you have customized vCard, navigate to custom\modules\
<modulename>\metadata\detailviewdefs.php
and replace:

<name=”vcard” action=”vCard.php”>

with the following:

<name=”vcard” action=”index.php”>

<input type=”hidden” name=”entryPoint” value=”vCard”>

SugarCRM’s Resource Limits

22 Apr, 2009
Posted By: Matt Heitzenroder

This post is for SugarCRM system administrators developers.

System Administrators  -  If you’re running a SugarCRM system, keep some of these tips in mind.

Developers - These are just good things to know.

Sometimes “user initiated processes” turn into runaway processes on the server.  For example, someone may create a tool that iterates through a result set from the database query, only to do additional queries based on the result. The tool may work well for the developer on their dev environment, but it may not scale well.  These kind of actions turn into runaway processes.

Many different platforms impose quotas/limits.  SugarCRM is no different.  In the 5.1 release we created database query limits.  As a developer, you should be aware of these so that you can develop code accordingly.

In config.php you’ll find a section of the $sugar_config array that looks like and is controlled like this:

'resource_management' =>
array (
'special_query_limit' => 50000,
'special_query_modules' =>
array (
0 =>'Reports',
1 => 'Export',
2 => 'Import',
3 => 'Administration',
4 => 'Sync',
),
'default_limit' => 1000,
),

This is the “out of the box” configuration - of course you can change this (c’mon this is SugarCRM, you can modify anything!).

Some intentionally resource intensive features such as Reports, Exports, Import, Offline Client, and anything in the Admin section are allowed to have 50,000 queries.  Otherwise, the default is 1000 queries.  You can modify this to fit your needs.

The best way to modify this is in config_override.php using $sugar_config['resource_management']

Another feature that allows you to manage access to some key administrative areas of your Sugar system is the following setting:


$sugar_config['admin_access_control'] = true;

Some of the actions that this setting will disable are features in the admin panel:

  1. Backups
  2. Upgrade Wizard
  3. Module Builder

The full list is detailed in files_access_control_map.php and is easily expanded in custom/include/MVC/Controller/file_access_control_map.php.

A final security control allows you to restrict Module Loader to read modules from only a specific directory on the server and disables the ability to upload new modules into the Module Loader.


$sugar_config['use_common_ml_dir'] = true ; // to enable or disable the feature.

$sugar_config['common_ml_dir'] = '/path/to/your/directory'; // modules will be loaded from this directory.

Remove a Tab, keep the Subpanel

21 Apr, 2009
Posted By: Matt Heitzenroder

I was speaking with one of Sugar’s stellar Customer Support Engineers today when we came up with this little tid bit…

The problem:

The customer wanted to remove the Opportunities tab, but keep it as a subpanel in a detailview - oh and make it upgrade safe.

The solution:

The modules that are displayed or hidden are (for the most part) by include/modules.php

If you view include/modules.php, you’ll notice that there are multiple arrays.  Most importantly, there is a way (at the very end) to override this file:


if (file_exists('include/modules_override.php'))

{

include('include/modules_override.php');

}

if (file_exists('custom/application/Ext/Include/modules.ext.php'))

{

include('custom/application/Ext/Include/modules.ext.php');

}

I prefer to keep all customizations in the “custom” directory - so let’s use .custom/application/Ext/Include/modules.ext.php

After creating the file, this is the code we added:


&lt;?php

$modulekey = array_keys($moduleList, 'Opportunities');

foreach($modulekey as $key =&gt; $value){

unset($moduleList[$modulekey[$value]]);

}

$modules_exempt_from_availability_check['Opportunities'] = 'Opportunities';

$modInvisList[] = 'Opportunities';

?&gt;

The critical array here is “$modules_exempt_from_availability_check”.  This array adds the subpanel back into the view.

Also, it’s worth noting the gymnastics we used to unset the array.  That’s because you need to unset it by the array’s index….  Because it’s possible that we someone else could put “Opportunities” in the moduleList array multiple times, we loop through it.

Finally, to date (the 5.2.0c), modules.ext.php would get over-written by Module Builder if you deploy a module.  That means, if you make a module, this custom code would get destroyed.  The simple solution, is to put it in the other place -> include/modules_override.php.  While that’s safe, it’s keeping custom code out of the custom directory.  A bug has been filed and we’ll see a fix in future releases.

If you can think of ways that will help create better hooks for customizations in the custom directory, please let us know!  We’re always looking for ways to make Sugar even more upgrade safe with customizations.

Sugar 5.5 and Internet Explorer 6 support

17 Apr, 2009
Posted By: John Mertic

IE 6 LogoAs a part of the upcoming Sugar 5.5 release, we are doing a major overhaul on our Theme framework. Not only will these make it easier to build new themes and customize the out-of-the-box themes, but we’ll also be optimizing our CSS and Javascript code to decrease payload and load times, providing a much better user experience. But we have one potential roadblock to that:

Internet Explorer 6.

Released in the fall of 2001 ( that’s nearly 8 years ago now! ) it is woefully out of date in terms in CSS and Web standards compliance, especially in comparision to “modern” browsers such as Mozilla Firefox, Apple’s Safari, and it’s successor Internet Explorer 7. The blogosphere has been aflutter with the news of dropping IE6 after Microsoft’s announcement of the automatic updates to IE8. We are considering removing IE6 support as well, since doing so will allow us to simplify our testing/support matrix, and remove lots of IE 6 customizations from our code.

We are looking for feedback from the community on the impact of this potential change. Please leave any thoughts you have about this ( good or bad ) in the comments below or in the forum.

PHP & Windows Server 2008

13 Apr, 2009
Posted By: Matt Heitzenroder

I just ran across Microsoft’s new website for PHP and Windows Server 2008 and I there are several reasons why I wanted to bring it to your attention.

  1. Sweet! Easy to install PHP w/ IIS & SQL Server environments
  2. Humility
  3. The power of Open Source
  4. The website looks like Super Mario Bros.

I have been installing PHP on a wide variety of environments for the past 5+ years. I am (oddly I suppose) out of my comfort zone with playing with IIS & SQL Server.  It’s nice to see that Microsoft has gone out of their way to make this easy.

Which brings me to my second point, did you catch the humility on the site?  This is the first sentence on the website:

We know PHP hasn’t always run smoothly on the Windows platform, so we’ve now optimised Windows Server 2008 to support your applications through a new component, FastCGI.

That is quite an admission on part of Microsoft and it’s nice to see them take that tack.  This brings me to my third point: PHP has made an incredible grassroots impact on those involved in the internet industry.   I would have never guessed  5 years ago that Microsoft would be supporting PHP so much.  Cool!

I suspect since Microsoft is heavily invested in Facebook, which runs primarily on the PHP platform that we will continue to see Microsoft become increasingly involved in the development of PHP. Now that Facebook user-base has surpassed 200-million, Microsoft would like to see Facebook using Microsoft servers.  To do so, I think they will have continue to find ways to make PHP ultra high performance on Windows.

Finally, what’s up w/ the 8-bit Super Mario Bros. webpage?  I like that it panders to my nostalgic geekiness, but I can’t draw the connection.  Anyone want to take a guess why the Super Mario Bros. theme?

Have feedback for us? Drop us a line.
Terms & Conditions | Privacy | Trademark Info | Contact Info | FAQs | SugarCRM Inc.© 2004 - 2009 All rights reserved.