At SugarCRM, we have been accelerating the rate at which we share technology with the Sugar Developer community. Back in June at UnCon, we shared more open source code examples and tools than ever before. In April, we announced Sucrose Charts and the Sugar REST Harness. I am pleased to announce that we have open sourced three more projects under the Apache-2 license!

Continue Reading…

Here is a guest post from Sugar Developer Francesca Shiekh who works for our customer Wolfram Research. She also happens to be one of the most active developers in the Sugar Developer Community! In this post, Francesca and Wolfram Research Systems Administrator Trey Mitchell share how you can customize Sugar to use an alternative PDF generator for the creation of PDF documents in Sugar.

Creating better PDFs with CSS

Screen Shot 2016-08-05 at 2.41.58 PM

We wanted a custom Contracts module that allowed specific styling to be applied to all Contract PDFs.  We determined that we could use CSS to apply a consistent style to any and all PDF documents associated with this new custom Contracts module. But we could not achieve this with SugarPDF due to the complexity of our CSS. Also overriding sugarpdf.pfdmanager.php was not an option as it is an extension of TCPDF and TCPDF has limited CSS support.

It was therefore necessary for use to look at alternatives that could better handle CSS.  We found a promising open source tool called wkhtmltopdf that uses WebKit.  WebKit should be familiar because it is the same layout engine used in Safari and Google Chrome, and is therefore very accurate in rendering CSS.

We still wanted to leverage the PDF Manager module to create and maintain our PDFs. We planned to develop our Contract templates in HTML with our own custom CSS and then copy them into the HTML editor that was already available in PDF Manager.

Read more below to find out how we made it work.

Continue Reading…

Alex Vlasov is an experienced Sugar Developer and contractor that works on the SugarCRM Engineering platform team. In this post, Alex shares advice to Sugar Developers for preparing their Sugar customizations for PHP 5.6 and PHP 7.

The Sugar team has been preparing core Sugar code for PHP 5.6 and PHP 7 support with an eye on deprecating support for older PHP versions. This means there are some actions that the Sugar Developer community needs to take in order to prepare their code for latest versions of PHP.

Summary of core Sugar app changes

In order to support newer versions of PHP, we made some changes to internal core classes that Sugar Developers need to know about. Many of these changes were made in Sugar 7.7.1 when we added PHP 5.6 support. Other changes outlined below are in upcoming Sugar releases.

PHP 7 deprecated features removed from core Sugar code

  1. Removed static calls to non-static methods
  2. Removed PHP4-style constructors

Read the full list of features deprecated in PHP7.

Additional changes to address core Sugar code hygiene and to adopt new PHP 7 features

  1. Fixed incompatible child class methods signatures
  2. Updated 3rd party libraries to support latest versions of PHP
  3. Changes to support PHP 7.0 new uniform variable syntax
  4. Adopted PHP 7’s CSPRNG API but added random_compat library to support older PHP versions

Actions for Sugar Developers

In order to properly upgrade custom code, two main tasks need to be performed:

Make your code compatible with PHP 5.6 and PHP 7.0

To make your code compatible with PHP 5.6 and 7.0, use the following checklist.

  1. Remove static calls to non-static methods within your PHP code
  2. Remove any use of PHP4-style constructors within your PHP code
  3. Remove other deprecated PHP functionality in your PHP code (PHP 5.6 deprecated features, PHP 7 deprecated features)

For example,

class Foo {

	public function __construct() { // Yes.
		// ...
	}

	public function Foo() { // No.
		// ...
	}

    public static function aStaticMethod() {
        // ...
    }

    public function aNormalMethod() {
    	// ...
    }
}

Foo::aStaticMethod(); // Yes.
Foo::aNormalMethod(); // No.

For additional detail, refer to PHP migration guides for PHP 5.6 and PHP 7.0.

Make your code compatible with changes to Sugar PHP APIs

To make custom code compatible with updated Sugar PHP APIs, use the following checklist.

  1. (7.7.1) Do not use old PHP4 constructors in Sugar PHP classes, they are removed as part of PHP 7.0 support.
  2. (7.7.1) If there is code that extends Sugar PHP classes, make sure child methods signatures are correct
  3. (7.7.1) 3rd party libraries were moved:
    1. parsecsv library was moved to the vendor directory
  4. (future) 3rd party libraries updates:
    1. Elastica library will be upgraded, so make sure you do not use deprecated Elastica APIs.
    2. Removal of mcrypt support and Crypt_Blowfish library, so make sure you are not calling these libraries directly.
  5. (future) Significant changes to be made to the following Sugar PHP APIs:
    1. ActivitiesApi::getQueryObject() will become protected and function arguments are changed
    2. RelationshipHandler class will stop extending Relationship class
    3. SearchForm class will not extend EditView class anymore
    4. Quarter*TimePeriod::buildLeaves() methods will have function arguments changed
    5. PMSEEngineFilterApi::addFieldFilter() method will be renamed

 

Three UnCon General Sessions recorded and now available!

The recordings for the UnCon general sessions are now available in the UnCon space of the Sugar Community. Visit the UnCon Archive to get access to the below videos as well as slides, pictures, and links to code examples for these general sessions as well as our breakout sessions.

Continue Reading…

Sugar and older versions of PHP

The latest version of PHP that Sugar 6.5 supported was PHP 5.3 which was released back in 2009. That is a long time ago folks. A sizable portion of the Sugar Developer community was in grade school back when PHP 5.3 was cool.

While we like to keep Sugar on the cutting edge, we have not been able to keep up to date with the latest PHP release. We have needed to maintain an upgrade path in each new Sugar release for customers still on Sugar 6.5. That is, up until now.

PHP Support matrix

As of Sugar 7.7.1 release:

Sugar version  Supported PHP versions
 6.5.x   5.2   5.3
 7.6.x   5.3   5.4
 7.7.0   5.3   5.4   5.5
 7.7.1   5.3   5.4   5.5   5.6

We do not plan on supporting 4 different versions of PHP forever, so you can expect to see support for older versions of PHP, such as PHP 5.3, to be dropped in upcoming Sugar releases.

For the complete and up-to-date reference of supported PHP versions, please view our Supported Platforms documentation.

Read on to learn more about why you should upgrade.

Continue Reading…

backbone

Upgrading our Backbone

Have you done some Sidecar programming lately? Then you have been using Backbone. Backbone is the err… backbone of Sidecar. It provides all the base MVC classes which are extended by Sidecar to create the Sugar 7 UI. For example, all Sidecar controllers (Views, Layouts, Fields) extend from the Backbone View class.

Ultimately, a solid background in Backbone programming will turn you into a Sidecar wizard in no time.

Screen Shot 2016-07-11 at 11.12.50 AM

All Sidecar controllers, such as the Record View controller,  extends from the Backbone View class

But if you are a Backbone aficionado then you might have noticed that Sugar 7.7 and earlier versions uses an old version of Backbone (specifically Backbone 0.9.10). We have been missing out on bug fixes and miscellaneous feature improvements. So for Sugar 7.8 we will be moving to Backbone 1.2.3.  Since Backbone.js has a hard dependency on Underscore.js, we will also upgrade the Underscore library from 1.4.4 to 1.8.3.

All Sugar Developers should check out the Backbone changelog and the Underscore changelog to see if their code customizations could be impacted by this long overdue library upgrade.

Read on to learn more about some adjustments you need to make to your Sugar code.

Continue Reading…

As promised, slides and code from UnCon are now available.  Video editing is still being worked on but videos of UnCon general sessions will be posted as soon as they are available. My Suga colleagues really outdid themselves this year!

UnCon 2016 Slides

All the slides from each of the general and breakout sessions have been posted in the UnCon community.

This is a great opportunity to refresh your memory or review any of the presentations that you happened to have missed this year. There are 28 presentations to go through.

Use these presentations as an aide to help you present what you learned at UnCon to your own colleagues!

UnCon 2016 Code

All example code shown at UnCon is available in the UnCon Github repository in the 2016 branch.  All the example code in this repository is licensed under Apache 2.0 unless otherwise noted.

There are a ton of code examples to learn and try out for yourselves. We presented and shared at least 2X more code than last year!

SLOC for UnCon 2016 Branch (as of June 28th)

Language files blank comment code
PHP 69 455 747 2,806
JavaScript 25 283 377 1,709
CSS 1 294 25 1,019
XML 7 0 0 347
Handlebars 16 5 63 204
JSON 3 4 0 73
LESS 1 0 3 2
SUM: 122 1,041 1,215 6,160

We also showed open source projects that exist in other Github repositories such as Sucrose.io and Sidecar Debugger Tool.