Sugar Community Edition 5.5 Documentation
Sugar Developer Guide
Chapter 2 Application Framework
Backwards Compatibility with Custom Code
It does however present some backwards compatibility problems. Most notably you will need to update your code if you have custom code that relies on a deprecated entry point such as a custom Quote template that may have called pdf.php which is no longer a stand-alone entry point. In these cases, you will need to change the URL reference as described below:When developing in SugarCRM, we suggest that you turn on Developer Mode (Admin->System Settings->Advanced->Developer Mode) which causes the system to ignore these cached files. This is especially helpful when you are altering templates, metadata or language files directly. When using Module Builder or Studio, the system will automatically refresh the file cache. Turn off the Developer Mode when you have completed your customizations because this mode degrades system performance.Sugar Dashlets use the abstract factory design pattern. Individual Dashlets extend the base abstract class Dashlet.php, ListView Dashlets extend the base abstract classDashletGeneric.php, while chart Dashlets extend the base abstract class DashletGenericChart.php.Typically, Sugar Dashlet developers will want to use the custom/ directory in order to make their Sugar Dashlets upgrade-safe. The standard modules/ directory location is where you'll find Sugar Dashlets offered in base Sugar releases.The file name containing the main Sugar Dashlet code must match the Sugar Dashlet’s class name. For example, the Sugar Dashlet class JotPadDashlet will be found in the file /Home/Dashlets/JotPadDashlet/JotPadDashlet.php. The JotPadDashlet Dashlet is a sample Sugar Dashlet released originally in Sugar 4.5. It serves as a useful example from which to begin your development efforts.
The naming convention for the metadata file is className.meta.php, where className is the name of your Sugar Dashlet, and it must appear in the same directory as the Sugar Dashlet code. For JotPadDashlet the meta file is stored inLanguage files have a similar naming convention: className.locale.lang.php (e.g., /Dashletsmodules/Home/Dashlets/JotPadDashlet/JotpadDashlet.en_us.lang.php )The suggested templating engine for Sugar Dashlets is Smarty, however it is not required.
• Module Views – Generic views of data in modules
• Portal – Sugar Dashlets that allow access to outside data (rss, Web services, etc)
• Charts – Charts of data
• Tools – Various tools like a notepad, calculator, or even a world clock!
• Miscellaneous - Any other Sugar DashletscallMethod is a generic way to call a method in a Dashlet class. Use this function to generically call a method within your Dashlet class (php side). Optionally, you can refresh your Dashlet after a call and also utilize a callback function.Sugar 5.1 uses a type-ahead combo box system we call QuickSearch based around ExtJS. The Sugar QuickSearch (SQS) code resides in the file <sugar_root>/include/javascript/quicksearch.js. The ExtJS library which drives the QuickSearch is located at <sugar_root>/include/javascript/ext-2.0/ext-quicksearch.js. These two files are grouped in <sugar_root>/include/javascript/sugar_grp1.js which is loaded in all the main page of SugarCRM. A custom Ext ComboBox is used to pull data via an AJAX call to http://yourserver/SugarCRM/index.php which then accesses the file <sugar_root>/modules/Home/quicksearchQuery.php.Note: Sugar versions 4.5.1 – 5.0.0 use a system based on wick. Sugar 4.5.0 and prior use <sugar_root>/json_server.php.sqsNoAutofill : add this string to the class of the field to disable the Automatic filling of the field on Blur.
• See the ‘Roles’ feature in the Sugar Application Guide for the list of actions and their possible values.By default, Sugar uses globally unique identification values (GUIDs) for primary keys for all database records. Sugar provides a create_guid() utility function for creating these GUIDs in the following format: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee. The primary key column length is 36 characters.Valid values are 'debug', 'info', 'error', 'fatal', 'security', and 'off'. The logger will log information for the specified and higher logging levels. For example if you set the log level to 'error' then you would see logs for 'error', 'fatal', and 'security'. You also may define your own log levels on the fly. For example if you set the value to 'test' then only values logged to $GLOBALS['log']->test('This is my test log message'); would be logged. You should avoid using the logging level of ‘off’. The default value is 'fatal'.You may concatenate static strings, variables and function calls to set this value. For example if you wish to have monthly logs set this to 'sugarcrm' . date('Y_m') and every day it will generate a new log file. The default value is 'sugarcrm'.The date format for the log file is any value that is acceptable to the PHP strftime() function. The default is '%c'. For a complete list of available date formats, please see the strftime() PHP documentation.Note: If the Sugar config.php variables site_url is wrong, SugarSoap will not work. Be sure to verify this value before continuing.SOAP, a standard Web Services protocol implementation, is a way of exchanging structured information of application functionality. The URL to SOAP is http://localhost/service/v2/soap.php and the URL for WSDL is http://localhost/service/v2/soap.php?wsdl. The WSDL file contains the descriptions for all methods with input/output datatype.See examples/SugarFullTest_Version2.php for more examples on usage.Sugar uses the REST protocol to exchange application information. The URL for REST is http://localhost/service/v2/rest.php. The input/output datatype for REST is JSON/PHP serialize. These datatype files, SugarRestJSON.php and SugarRestSerialize.php, are in service/core/REST directory.You can also define you own datatype. To do this, you need to create a corresponding SugarRestCustomDataType.php file in the service/core/REST directory and override generateResponse() and serve() functions.The Serve function decodes or unserializes the appropriate datatype based on the input type; the generateResponse function encodes or serializes it based on the output type. See service/test.html for more examples on usage. In this file, the getRequestData function, which generates URL with json, is both the input_type and the response_type. That is, the request data from the javascript to the server is json and response data from server is also json. You can mix and match any datatype as input and output. For example, you can have json as the input_type and serialize as the response_type based on your application’s requirements.Sugar also provides an example on how to use REST protocol to retrive data from other Sugar instances. In the example, service/example.html uses the SugarRest.server_url variable to make a request to Rest_Proxy.ph, which redirects this request to the appropriate Sugar instance and sends the response back to service/example.html . This server_url varible is a REST URL to other Sugar instances from which you want to retrieve data.All API classes are located in the Service directory. The URL for the Service directory is http://localhost/service/v2/soap.php. The Service directory contains the following folders:
Now your new REST URL will be http://localhost/service/v2_1/rest.php. Your v2_1 directory is now upgrade safe.Note: it is also possible to create a NuSOAP client as follows without requiring the WSDL:This speeds up processing because downloading the WSDL before invoking the method is time intensive. This type of URL (http://www.example.com/sugar/soap.php) without havin ?wsdl at the end work fine with NUSOAP client. But with clients like .net, java you need to generate all the client side classes for all the complex type data types by giving appropriate WSDL (rpc or document and literal and encoded) and make a service call by coding it to those generated classes.
Copyright 2004-2010 SugarCRM Inc.
Product License
User Contributed Comments
No user comments found.Add a Comment













