id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
6769d7b65ab0-10
./include/MVC/View/views/view.<view>.config.php Implementation The format of these files is as follows: $view_config = array( 'actions' => array( 'popup' => array( 'show_header' => false, 'show_subpanels' => false, 'show_search' => false, 'show_footer' => false, 'show_JavaScript' => true, ), ), 'req_params' => array( 'to_pdf' => array( 'param_value' => true, 'config' => array( 'show_all' => false ), ), ), );
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
6769d7b65ab0-11
'show_all' => false ), ), ), ); To illustrate this process, let us take a look at how the 'popup' action is processed. In this case, the system will go to the actions entry within the view_config and determine the proper configuration. If the request contains the parameter to_pdf, and is set to be true, then it will automatically cause the show_all configuration parameter to be set false, which means none of the options will be displayed. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Legacy_MVC/View/index.html
02aa8e261b20-0
Dashlets Overview Dashlets are special view-component plugins that render data from a context and make use of the Dashlet plugin. They are typically made up of a controller JavaScript file (.js) and at least one Handlebars template (.hbs). Hierarchy Diagram Sugar loads the dashlet view components in the following manner: Note: The Sugar application's client type is "base". For more information on the various client types, please refer to the User Interface page. Dashlet Views The are three views when working with dashlets: Preview, Dashlet View, and Configuration View. The following sections discuss the differences between views. Preview The preview view is used when selecting dashlets to add to your homepage. Preview variables in the metadata will be assigned to the custom model variables. 'preview' => array( 'key1' => 'value1', ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-1
'key1' => 'value1', ), The values in the preview metadata can be retrieved using: this.model.get("key1"); Dashlet View The dashlet view will render the content for the dashlet. It will also contain the settings for editing, removing, and refreshing the dashlet. Configuration View The configuration view is displayed when a user clicks the 'edit' option on the dashlet frame's drop-down menu. Config variables in the metadata will be assigned to the custom model variables 'config' => array( //key value pairs of attributes 'key1' => 'value1', ), The values in the config metadata can be retrieved using: this.model.get("key1"); Dashlet Example
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-2
this.model.get("key1"); Dashlet Example The RSS feed dashlet, located in ./clients/base/views/rssfeed/, handles the display of RSS feeds to the user. The sections below outline the various files that render this dashlet. Metadata The Dashlet view contains the 'dashlets' metadata: Parameters Type Required Description label String yes The name of the dashlet description String no A description of the dashlet config Object yes Pre-populated variables in the configuration viewNote: Config variables in the metadata are assigned to the custom model variables. preview Object yes  Pre-populated variables in the preview filter Object no Filter for display The RSS feed dashlets metadata is located in:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-3
Filter for display The RSS feed dashlets metadata is located in: ./clients/base/views/rssfeed/rssfeed.php <?php /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ $viewdefs['base']['view']['rssfeed'] = array( 'dashlets' => array( array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-4
'dashlets' => array( array( 'label' => 'LBL_RSS_FEED_DASHLET', 'description' => 'LBL_RSS_FEED_DASHLET_DESCRIPTION', 'config' => array( 'limit' => 5, 'auto_refresh' => 0, ), 'preview' => array( 'limit' => 5, 'auto_refresh' => 0, 'feed_url' => 'http://blog.sugarcrm.com/feed/', ), ), ), 'panels' => array( array( 'name' => 'panel_body', 'columns' => 2, 'labelsOnTop' => true, 'placeholders' => true,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-5
'labelsOnTop' => true, 'placeholders' => true, 'fields' => array( array( 'name' => 'feed_url', 'label' => 'LBL_RSS_FEED_URL', 'type' => 'text', 'span' => 12, 'required' => true, ), array( 'name' => 'limit', 'label' => 'LBL_RSS_FEED_ENTRIES_COUNT', 'type' => 'enum', 'options' => 'tasks_limit_options', ), array( 'name' => 'auto_refresh', 'label' => 'LBL_DASHLET_REFRESH_LABEL', 'type' => 'enum',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-6
'type' => 'enum', 'options' => 'sugar7_dashlet_reports_auto_refresh_options', ), ), ), ), ); Controller The rssfeed.js controller file, shown below, contains the JavaScript to render the news articles on the dashlet. The Dashlet view must include 'Dashlet' plugin and can override initDashlet to add additional custom process while it is initializing. ./clients/base/views/rssfeed/rssfeed.js /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-7
* authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ /** * RSS Feed dashlet consumes an RSS Feed URL and displays it's content as a list * of entries. * * The following items are configurable. * * - {number} limit Limit imposed to the number of records pulled. * - {number} refresh How often (minutes) should refresh the data collection. * * @class View.Views.Base.RssfeedView * @alias SUGAR.App.view.views.BaseRssfeedView * @extends View.View */ ({ plugins: ['Dashlet'], /** * Default options used when none are supplied through metadata. *
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-8
/** * Default options used when none are supplied through metadata. * * Supported options: * - timer: How often (minutes) should refresh the data collection. * - limit: Limit imposed to the number of records pulled. * * @property {Object} * @protected */ _defaultOptions: { limit: 5, auto_refresh: 0 }, /** * @inheritdoc */ initialize: function(options) { options.meta = options.meta || {}; this._super('initialize', [options]); this.loadData(options.meta); }, /** * Init dashlet settings */ initDashlet: function() {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-9
* Init dashlet settings */ initDashlet: function() { // We only need to handle this if we are NOT in the configure screen if (!this.meta.config) { var options = {}; var self = this; var refreshRate; // Get and set values for limits and refresh options.limit = this.settings.get('limit') || this._defaultOptions.limit; this.settings.set('limit', options.limit); options.auto_refresh = this.settings.get('auto_refresh') || this._defaultOptions.auto_refresh; this.settings.set('auto_refresh', options.auto_refresh); // There is no default for this so there's no pointing in setting from it
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-10
// There is no default for this so there's no pointing in setting from it options.feed_url = this.settings.get('feed_url'); // Set the refresh rate for setInterval so it can be checked ahead // of time. 60000 is 1000 miliseconds times 60 seconds in a minute. refreshRate = options.auto_refresh * 60000; // Only set up the interval handler if there is a refreshRate higher // than 0 if (refreshRate > 0) { if (this.timerId) { clearInterval(this.timerId); } this.timerId = setInterval(_.bind(function() { if (self.context) { self.context.resetLoadFlag(); self.loadData(options); } }, this), refreshRate);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-11
self.loadData(options); } }, this), refreshRate); } } // Validation handling for individual fields on the config this.layout.before('dashletconfig:save', function() { // Fields on the metadata var fields = _.flatten(_.pluck(this.meta.panels, 'fields')); // Grab all non-valid fields from the model var notValid = _.filter(fields, function(field) { return field.required && !this.dashModel.get(field.name); }, this); // If there no invalid fields we are good to go if (notValid.length === 0) { return true; } // Otherwise handle notification of invalidation _.each(notValid, function(field) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-12
_.each(notValid, function(field) { var fieldOnView = _.find(this.fields, function(comp, cid) { return comp.name === field.name; }); fieldOnView.model.trigger('error:validation:' + field.name, {required: true}); }, this); // False return tells the drawer that it shouldn't close return false; }, this); }, /** * Handles the response of the feed consumption request and sets data from * the result * * @param {Object} data Response from the rssfeed API call */ handleFeed: function (data) { if (this.disposed) { return; } // Load up the template
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-13
return; } // Load up the template _.extend(this, data); this.render(); }, /** * Loads an RSS feed from the RSS Feed endpoint. * * @param {Object} options The metadata that drives this request */ loadData: function(options) { if (options && options.feed_url) { var callbacks = {success: _.bind(this.handleFeed, this), error: _.bind(this.handleFeed, this)}, limit = options.limit || this._defaultOptions.limit, params = {feed_url: options.feed_url, limit: limit}, apiUrl = app.api.buildURL('rssfeed', 'read', '', params);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-14
app.api.call('read', apiUrl, {}, callbacks); } }, /** * @inheritdoc * * New model related properties are injected into each model: * * - {Boolean} overdue True if record is prior to now. */ _renderHtml: function() { if (this.meta.config) { this._super('_renderHtml'); return; } this._super('_renderHtml'); } }) Workflow When triggered, the following procedure will render the view area: Retrieving Data Use the following commands to retrieve the corresponding data: Data Location Element Command Main pane Record View this.model Record View this.context.parent.get("model") List View
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-15
Record View this.context.parent.get("model") List View this.context.parent.get("collection") Metadata   this.dashletConfig['metadata_key'] Module vardefs   app.metadata.getModule("ModuleName") Remote data Bean new app.data.createBean("Module")new app.data.createBeanCollection("Module") RestAPI  app.api.call(method, url, data, callbacks, options) Ajax Call  $.ajax() User inputs   this.settings.get("custom_key") Handlebar Template The rssfeed.hbs template file defines the content of the view. This view is used for rendering the markup rendering in the dashlet content. ./clients/base/views/rssfeed/rssfeed.hbs
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-16
./clients/base/views/rssfeed/rssfeed.hbs {{!-- /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ --}} {{#if feed}} <div class="rss-feed"> <h4> {{#if feed.link}}<a href="{{feed.link}}">{{/if}} {{feed.title}}
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-17
{{feed.title}} {{#if feed.link}}</a>{{/if}} </h4> <ul> {{#each feed.entries}} <li class="news-article"> <a href="{{link}}">Dashlets</a> {{#if author}} - {{str "LBL_RSS_FEED_AUTHOR"}} {{author}}{{/if}} </li> {{/each}} </ul> </div> {{else}} <div class="block-footer"> {{#if errorThrown}} {{str "LBL_NO_DATA_AVAILABLE"}} {{else}} {{loading 'LBL_ALERT_TITLE_LOADING'}} {{/if}} </div>
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
02aa8e261b20-18
{{/if}} </div> {{/if}} Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Dashlets/index.html
7db2415891fc-0
Alerts Overview The alert view widget, located in ./clients/base/views/alert/, displays helpful information such as loading messages, notices, and confirmation messages to the user. Methods app.alert.show(id, options) The app.alert.show(id, options) method displays an alert message to the user with the options provided. Parameters Name Description id The id of the alert message. Used for dismissing specific messages. options.level The alert level options.title The alert's title, which corresponds to the alert's level options.messages The message that the user sees Note: Process alerts do not display messages. options.autoClose Whether or not to auto-close the alert popup options.onClose Callback handler for closing confirmation alerts options.onCancel Callback handler for canceling confirmation alerts options.onLinkClick
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Alerts/index.html
7db2415891fc-1
options.onCancel Callback handler for canceling confirmation alerts options.onLinkClick Callback handler for click actions on a link inside of the alert Default Alert Values Alert Level Alert Appearance Alert Title info blue "Notice" success green "Success" warning yellow "Warning!" error red "Error" process loading message "Loading..." confirmation confirmation dialog "Warning" Alert Examples Standard Alert app.alert.show('message-id', { level: 'success', messages: 'Task completed!', autoClose: true }); Confirmation Alert app.alert.show('message-id', { level: 'confirmation', messages: 'Confirm?', autoClose: false, onConfirm: function(){ alert("Confirmed!"); },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Alerts/index.html
7db2415891fc-2
onConfirm: function(){ alert("Confirmed!"); }, onCancel: function(){ alert("Cancelled!"); } }); Process Alert app.alert.show('message-id', { level: 'process', title: 'In Process...' //change title to modify display from 'Loading...' }); app.alert.dismiss(id) The app.alert.dismiss(id) method dismisses an alert message from view based on the message id. Parameters Name Description id The id of the alert message to dismiss. Example app.alert.dismiss('message-id'); app.alert.dismissAll The app.alert.dismissAll dismisses all alert messages from view. Example app.alert.dismissAll(); Testing in Console
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Alerts/index.html
7db2415891fc-3
Example app.alert.dismissAll(); Testing in Console To test alerts, you can trigger them in your browser's developer tools by using the global App variable as shown below: App.alert.show('message-id', { level: 'success', messages: 'Successful!', autoClose: false }); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Alerts/index.html
f3d567988d24-0
Layouts Overview Layouts are component plugins that define the overall layout and positioning of the page. Layouts replace the previous concept of MVC views and are used system-wide to generate rows, columns, bootstrap fluid layouts, and pop-ups by wrapping and placing multiple views or nested layouts on a page. Layout components are typically made up of a controller JavaScript file (.js) and a PHP file (.php), however, layout types vary and are not dependent on having both files. Hierarchy Diagram The layout components are loaded in the following manner: Note: The Sugar application client type is "base". For more information on the various client types, please refer to the User Interface page. Sidecar Layout Routing Sidecar uses routing to determine where to direct the user. To route the user to a specific page in Sugar, refer to the following default URL formats: Behavior URL Format
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/index.html
f3d567988d24-1
Behavior URL Format Route the user to the list layout for a module http://{site url}/#<module>/ Route the user to the record layout for a specific record http://{site url}/#<module>/f82d09cb-48cd-a1fb-beae-521cf39247b5 Route the user to a custom layout for the module http://{site url}/#<module>/layout/<layout> Layout Example The list layout, located in ./clients/base/layouts/list/, handles the layout for the list view. The sections below outline the various files that render this view. JavaScript The file list.js, shown below, contains the JavaScript used to place the layout content. ./clients/base/layouts/list/list.js /** * Layout that places components using bootstrap fluid layout divs
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/index.html
f3d567988d24-2
/** * Layout that places components using bootstrap fluid layout divs * @class View.Layouts.ListLayout * @extends View.FluidLayout */ ({ /** * Places a view's element on the page. * @param {View.View} comp * @protected * @method */ _placeComponent: function(comp, def) { var size = def.size || 12; // Helper to create boiler plate layout containers function createLayoutContainers(self) { // Only creates the containers once if (!self.$el.children()[0]) { comp.$el.addClass('list'); } } createLayoutContainers(this); // All components of this layout will be placed within the // innermost container div.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/index.html
f3d567988d24-3
// innermost container div. this.$el.append(comp.el); } }) Layout Definition The layout definition is contained as an array in list.php. This layout definition contains four views: massupdate massaddtolist recordlist list-bottom ./clients/base/layouts/list/list.php <?php $viewdefs['base']['layout']['list'] = array( 'components' => array( array( 'view' => 'massupdate', ), array( 'view' => 'massaddtolist', ), array( 'view' => 'recordlist', 'primary' => true, ), array( 'view' => 'list-bottom', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/index.html
f3d567988d24-4
'view' => 'list-bottom', ), ), 'type' => 'simple', 'name' => 'list', 'span' => 12, ); Application For information on working with layouts, please refer to the Creating Layouts and Overriding Layouts pages for practical examples. TopicsCreating LayoutsThis example explains how to create a custom layout to define the various components that load on a page.Overriding LayoutsThis page explains how to override a stock layout component. For this example, we will extend the stock record view and create a custom view named "my-record" that will be used in our record layout's override. This example involves two steps: Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/index.html
0348a29a414a-0
Creating Layouts Overview This example explains how to create a custom layout to define the various components that load on a page.  Creating the Layout This example creates a component named "my-layout", which will render a custom view named "my-view". ./custom/clients/base/layouts/my-layout/my-layout.php <?php $viewdefs['base']['layout']['my-layout'] = array( 'type' => 'simple', 'components' => array( array( 'view' => 'my-view', ), ), ); Creating a View The view component will render the actual content we want to see on the page. The view below will display a clickable cube icon that will spin when clicked by the user.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Creating_Layouts/index.html
0348a29a414a-1
./custom/clients/base/views/my-view/my-view.js ({ className: 'my-view tcenter', cubeOptions: { spin: false }, events: { 'click .sugar-cube': 'spinCube' }, spinCube: function() { this.cubeOptions.spin = !this.cubeOptions.spin; this.render(); } }) ./custom/clients/base/views/my-view/my-view.hbs <style> div.my-view { padding-top: 5%; } div.my-view .sugar-cube { fill:#bbbbbb; height:200px; width:200px; display: inline; }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Creating_Layouts/index.html
0348a29a414a-2
width:200px; display: inline; } </style> <h1>My View</h1> {{{subFieldTemplate 'sugar-cube' 'detail' cubeOptions}}} <p>Click to spin the cube!</p> Once the files are in place, navigate to Admin > Repair and perform a Quick Repair and Rebuild. Navigating to the Layout To see this new layout and view, navigate to http://{site url}/#<module>/layout/my-layout. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Creating_Layouts/index.html
cceea0a619a7-0
Overriding Layouts Overview This page explains how to override a stock layout component. For this example, we will extend the stock record view and create a custom view named "my-record" that will be used in our record layout's override. This example involves two steps: Override the Layout Extend the View These steps are explained in the following sections. Overriding the Layout First, copy ./clients/base/layouts/record/record.php to ./custom/clients/base/layouts/record/record.php. Once copied, modify the following line from: 'view' => 'record', To: 'view' => 'my-record',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-1
To: 'view' => 'my-record', That line will change the record layout from using the base record.js view, ./clients/base/views/record/record.js, to instead use a custom view that we will create in ./custom/clients/base/views/my-record/my-record.js. At this point, the custom layout override should be very similar to the example below: ./custom/clients/base/layouts/record/record.php <?php $viewdefs['base']['layout']['record'] = array( 'components' => array( array( 'layout' => array( 'type' => 'default', 'name' => 'sidebar', 'components' => array( array( 'layout' => array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-2
array( 'layout' => array( 'type' => 'base', 'name' => 'main-pane', 'css_class' => 'main-pane span8', 'components' => array( array( 'view' => 'my-record', 'primary' => true, ), array( 'layout' => 'extra-info', ), array( 'layout' => array( 'type' => 'filterpanel', 'last_state' => array( 'id' => 'record-filterpanel', 'defaults' => array( 'toggle-view' => 'subpanels', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-3
), ), 'refresh_button' => true, 'availableToggles' => array( array( 'name' => 'subpanels', 'icon' => 'fa-table', 'label' => 'LBL_DATA_VIEW', ), array( 'name' => 'list', 'icon' => 'fa-table', 'label' => 'LBL_LISTVIEW', ), array( 'name' => 'activitystream', 'icon' => 'fa-clock-o', 'label' => 'LBL_ACTIVITY_STREAM', ), ),
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-4
), ), 'components' => array( array( 'layout' => 'filter', 'xmeta' => array( 'layoutType' => '', ), 'loadModule' => 'Filters', ), array( 'view' => 'filter-rows', ), array( 'view' => 'filter-actions', ), array( 'layout' => 'activitystream', 'context' => array( 'module' => 'Activities', ), ), array(
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-5
), ), array( 'layout' => 'subpanels', ), ), ), ), ), ), ), array( 'layout' => array( 'type' => 'base', 'name' => 'dashboard-pane', 'css_class' => 'dashboard-pane', 'components' => array( array( 'layout' => array( 'type' => 'dashboard', 'last_state' => array( 'id' => 'last-visit', ) ), 'context' => array( 'forceNew' => true,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-6
'context' => array( 'forceNew' => true, 'module' => 'Home', ), 'loadModule' => 'Dashboards', ), ), ), ), array( 'layout' => array( 'type' => 'base', 'name' => 'preview-pane', 'css_class' => 'preview-pane', 'components' => array( array( 'layout' => 'preview', ), ), ), ), ), ), ), ), ); Extending the View
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
cceea0a619a7-7
), ), ), ), ); Extending the View For this example, we will extend the stock record view and create a custom view named my-record that will be used in our record layouts override. ./custom/clients/base/views/my-record/my-record.js ({ extendsFrom: 'RecordView', initialize: function (options) { this._super("initialize", [options]); //log this point console.log("**** Override called"); } }) Once the files are in place, navigate to Admin > Repair > Quick Repair and Rebuild. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/User_Interface/Layouts/Overriding_Layouts/index.html
9b020ddfed1e-0
Architecture Overview This section of Sugar's Developer Guide begins with a high-level overview of the Sugar platform's architecture and contains documentation on granular concepts in Sugar such as logic hooks, caching, logging, extensions, job queue, and more. Please continue to the bottom of this page or use the navigation on the left to explore the related content. Platform Sugar® is built on open standards and technology such as HTML5, PHP, and JavaScript, and runs on a variety of free and open-source technology like Linux, MySQL, and Elasticsearch. The Sugar platform also supports common proprietary databases such as Oracle, IBM DB2, and Microsoft SQL Server. All of Sugar's customers and partners have access to source code that they can choose to deploy on-premise or utilize Sugar's cloud service for a SaaS deployment.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-1
Out of the box, Sugar uses a consistent platform across all clients and devices (e.g. mobile, web, plug-ins, etc.). Front-End Framework Our clients are based on a front-end framework called Sidecar. Sidecar is built on open source technology: Backbone.js, jQuery, Handlebars.js, and Bootstrap. The Sidecar framework provides a responsive UI (to support a variety of form factors) and uses modern, single-page client architecture. Sugar clients connect to Sugar server application via our client REST API. The REST API is implemented in PHP and drives server-side business logic and interacts with a database. If it can be accomplished via one of our clients, then its equivalent functionality can be accomplished using our REST API.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-2
The Sugar platform uses modules. Modules are a vertically integrated application component that is traditionally organized around a single feature or record type (or underlying database table). For example, contact records are managed via a Contacts module that contains all the business logic, front-end interface definitions, REST APIs, data schema, and relationships with other modules. Custom modules can be created and deployed as needed in order to add new features to a Sugar application instance.  Metadata Sugar's modules are defined primarily using Metadata. There are two types of metadata definitions within Sugar: Vardefs, which define the data model for Sugar modules; and Viewdefs, which define the user interface components that are used with a module. Sugar Metadata is implemented as PHP files that can be modified directly by a Sugar Developer making filesystem changes, or indirectly through the use of Sugar Studio and Module Builder by a Sugar Administrator.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-3
Metadata allows you to configure solutions instead of having to write countless lines of custom code in order to implement common customizations such as adding custom fields, calculated values, and changing user interface layouts. Extensions Beyond metadata, Sugar is highly customizable and includes an extensive Extensions Framework that provides Sugar Developers the capability to contribute to pre-defined extension points within the application in a way that is upgrade-safe and will not conflict with other customizations that exist in the system.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-4
TopicsAutoloaderThe autoloader is an API that allows the unified handling of customizations and customizable metadata while reducing the number of filesystem accesses and improving performance.CachingMuch of Sugar's user interface is built dynamically using a combination of templates, metadata and language files. A file caching mechanism improves the performance of the system by reducing the number of static metadata and language files that need to be resolved at runtime. This cache directory stores the compiled files for JavaScript files, Handlebars templates, and language files.UploadsThe upload directory is used to store files uploaded for imports, attachments, documents, and module loadable packages.EmailOutlines the relationships between emails, email addresses, and bean records.Email AddressesRecommended approaches when working with email addresses in Sugar.LoggingThere are two logging systems implemented in the Sugar application: SugarLogger and PSR-3. PSR-3 is Sugar's preferred logger solution and should be used going forward.Logic
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-5
PSR-3 is Sugar's preferred logger solution and should be used going forward.Logic HooksThe Logic Hook framework allows you to append actions to system events such as when creating, editing, and deleting records.LanguagesSugar as an application platform is internationalized and localizable. Data is stored and presented in the UTF-8 codepage, allowing for all character sets to be used. Sugar provides a language-pack framework that allows developers to build support for any language in the display of user interface labels. Each language pack has its own set of display strings which is the basis of language localization. You can add or modify languages using the information in this guide.ExtensionsThe extension framework, defined in ./ModuleInstall/extensions.php, provides the capability to modify Sugar metadata such as vardefs and layouts in a safe way that supports installing, uninstalling, enabling, and disabling without interfering with other customizations.FiltersFilters are a way to
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-6
enabling, and disabling without interfering with other customizations.FiltersFilters are a way to predefine searches on views that render a list of records such as list views, pop-up searches, and lookups. This page explains how to implement the various types of filters for record list views.Duplicate CheckThe duplicate-check framework provides the capability to alter how the system searches for duplicate records in the database when creating records. For information on duplicate checking during imports, please refer to the index documentation.Elastic SearchThe focus of this document is to guide developers on how Sugar integrates with Elastic Search.Global SearchHow to customize the global search results.Sugar LogicSugar Logic, a feature in all Sugar products, enables custom business logic that is easy to create, manage, and reuse on both the server and client.AdministrationThe Administration class is used to manage settings stored in the database config table.ConfiguratorThe Configurator class, located in
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-7
manage settings stored in the database config table.ConfiguratorThe Configurator class, located in ./modules/Configurator/Configurator.php, handles the config settings found in ./config.php and ./config_override.php.Module LoaderModule Loader is used when installing customizations, plugins,language packs, and hotfixes, and other customizations into a Sugar instance in the form of a Module Loadable Package. This documentation covers the basics and best practices for creating module loadable packages for a Sugar installation.Module BuilderThe Module Builder tool allows programmers to create custom modules without writing code and to create relationships between new and existing CRM modules. To illustrate how to use Module Builder, this article will show how to create and deploy a custom module.QuotesAs of Sugar 7.9.0.0, the quotes module has been moved out of Backward Compatibility mode into Sidecar. Customizations to the Quotes interface will need to be rewritten for
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-8
Compatibility mode into Sidecar. Customizations to the Quotes interface will need to be rewritten for the new Sidecar framework as an automated migration of these customizations is not possible. This document will outline common customizations and implementation methods.SugarBPMSugarBPM™ automation suite is the next-generation workflow management tool for Sugar. Introduced in 7.6, SugarBPM is loosely based on BPMN process notation standards and provides a simple drag-and-drop user interface along with an intelligent flow designer to allow for the creation of easy yet powerful process definitions.Entry PointsEntry points, defined in ./include/MVC/Controller/entry_point_registry.php, were used to ensure that proper security and authentication steps are applied consistently across the entire application. While they are still used in some areas of Sugar, any developers using custom entry points should adjust their customizations to use the latest REST API endpoints instead.Job QueueThe Job Queue
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-9
their customizations to use the latest REST API endpoints instead.Job QueueThe Job Queue executes automated tasks in Sugar through a scheduler, which integrates with external UNIX systems and Windows systems to run jobs that are scheduled through those systems. Jobs are the individual runs of the specified function from a scheduler.Access Control ListsAccess Control Lists (ACLs) are used to control access to the modules, data, and actions available to users in Sugar. By default, Sugar comes with a default ACL Strategy that is configurable by an Admin through the Roles module via Admin > Role Management. Sugar also comes with other ACL strategies that are located in the ./data/acl/ folder, and are used in other parts of the system such as the Administration module, Emails module, Locked Fields functionality, and many others. They can also be leveraged by customizations and custom ACL strategies can be implemented to control your own customizations.TeamsTeams provide the ability to limit access
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-10
can be implemented to control your own customizations.TeamsTeams provide the ability to limit access at the record level, allowing sharing flexibility across functional groups. Developers can manipulate teams programmatically provided they understand Sugar's visibility framework.TagsThe tagging feature allows a user to apply as many "tags" as they choose on any record they want to categorize. This allows the user to effectively group records together from any source within the application and relate them together. Please note that the tag field and Tags module do not support customization at this time.TinyMCEThis section contains information about working with the TinyMCE editor in Sugar.SugarPDFThis section contains information on generating PDFs and configuring PDF settings and fonts in Sugar.DateTimeThe SugarDateTime class, located in, ./include/SugarDateTime.php, extends PHP's built in DateTime class and can be used to perform common operations on date and time values.ShortcutsShortcuts is a framework to
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-11
be used to perform common operations on date and time values.ShortcutsShortcuts is a framework to add shortcut keys to the application. When shortcut keys are registered, they are registered to a particular shortcut session. Shortcut sessions group shortcut keys, and they can be activated, deactivated, saved, and restored. Global shortcut keys can be registered, but they are not tied to a particular shortcut session. They are rather applied everywhere in the application and can only be applied once.ThemesHow to customize the Sugar theme.Web AccessibilityLearn about the Sugar Accessibility Plugin for Sidecar.Validation ConstraintsThis article will cover how to add validation constraints to your custom code.CLISugar on-premise deployments include a command line interface tool built using the Symfony Console Framework. Sugar's CLI is intended to be an administrator or developer level power tool to execute PHP code in the context of Sugar's code base. These commands are version specific and can be executed on a
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-12
in the context of Sugar's code base. These commands are version specific and can be executed on a preinstalled Sugar instance or on an installed Sugar instance. Sugar's CLI is not intended to be used as a tool to interact remotely with an instance nor is it designed to interact with multiple instances.Performance TuningThe Performance Tuning section contains information that will help maximize system performance for your Sugar instance.Backward CompatibilityAs of Sugar® 7, modules are built using the Sidecar framework. Any modules that still use the MVC architecture and have not yet migrated to the Sidecar framework are set in what Sugar refers to as "backward compatibility" (BWC) mode.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
9b020ddfed1e-13
Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/index.html
5938e806bca8-0
Autoloader Overview The autoloader is an API that allows the unified handling of customizations and customizable metadata while reducing the number of filesystem accesses and improving performance. SugarAutoLoader The SugarAutoLoader class, located in ./include/utils/autoloader.php, keeps a map of files within the Sugar directory that may be loaded. Included File Extensions The autoloader will only map files with the following extensions: bmp css gif hbs html ico jpg js less override php png tif tpl xml *All other file extensions are excluded from the mapping. Class Loading Directories The autoloader will scan and autoload classes in the following directories: ./clients/base/api/ ./data/duplicatecheck/ ./data/Relationships/ ./data/visibility/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/index.html
5938e806bca8-1
./data/Relationships/ ./data/visibility/ ./include/ ./include/api/ ./include/CalendarEvents/ ./include/SugarSearchEngine/ ./modules/Calendar/ ./modules/Mailer/ Ignored Directories The following directories in Sugar are ignored by the autoloader mapping: ./.idea/ ./cache/ ./custom/backup/ ./custom/blowfish/ ./custom/Extension/ ./custom/history/ ./custom/modulebuilder/ ./docs/ ./examples/ ./portal/ ./tests/ ./upload/ ./vendor/bin/ ./vendor/HTMLPurifier/ ./vendor/log4php/ ./vendor/nusoap/ ./vendor/pclzip/ ./vendor/reCaptcha/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/index.html
5938e806bca8-2
./vendor/pclzip/ ./vendor/reCaptcha/ ./vendor/ytree/   TopicsConfiguration APIMethods to configure loading paths for the AutoLoader API.File Check APIFile check methods for use with the AutoLoader API.File Map Modification APIMethods to modify files in the AutoLoader API. All the functions below return true on success and false on failure.Metadata APIMethods to load metadata for the AutoLoader API. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/index.html
c342515d343e-0
Configuration API Overview Methods to configure loading paths for the AutoLoader API. addDirectory($dir) Adds a directory to the directory map for loading classes. Directories added should include a trailing "/". SugarAutoloader::addDirectory('relative/file/path/'); addPrefixDirectory($prefix, $dir) Adds a prefix and directory to the $prefixMap for loading classes by prefix. SugarAutoloader::addPrefixDirectory('myPrefix', 'relative/file/path/'); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Configuration_API/index.html
1dfdc157e9b0-0
Metadata API Overview Methods to load metadata for the AutoLoader API. Metadata Loading For the specific sets of metadata, such as detailviewdefs, editviewefs, listviewdefs, searchdefs, popupdefs, and searchfields, a special process is used to load the correct metadata file. You should note that the variable name for the defs, e.g. "detailviewdefs", is usually the same as variable name, except in the case of "searchfields" where it is "SearchFields". The process is described below: If ./custom/modules/{$module}/metadata/{$varname}.php exists, it is used as the data file.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Metadata_API/index.html
1dfdc157e9b0-1
If ./modules/{$module}/metadata/metafiles.php or ./custom/modules/{$module}/metadata/metafiles.php exists, it is loaded with the custom file being preferred. If the variable name exists in the data specified by the metafile, the corresponding filename is assumed to be the defs file name. If the defs file name or its custom/ override exists, it is used as the data file (custom one is preferred). If no file has been found yet, ./modules/{$module}/metadata/{$varname}.php is checked and if existing, it is used as the data file. Otherwise, no metadata file is used. loadWithMetafiles($module, $varname)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Metadata_API/index.html
1dfdc157e9b0-2
loadWithMetafiles($module, $varname) Returns the specified metadata file for a specific module. You should note that due to the scope nature of include(), this function does not load the actual metadata file but will return the file name that should be loaded by the caller. $metadataPath = SugarAutoloader::loadWithMetafiles('Accounts', 'editviewdefs'); loadPopupMeta($module, $metadata = null) Loads popup metadata for either specified $metadata variable or "popupdefs" variable via loadWithMetafiles() and returns it. If no metadata found returns empty array. $popupMetadata = SugarAutoloader::loadPopupMeta('Accounts'); loadExtension($extname, $module = "application")
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Metadata_API/index.html
1dfdc157e9b0-3
loadExtension($extname, $module = "application") Returns the extension path given the extension name and module. For global extensions, the module should be "application" and may be omitted. If the extension has its own module, such as schedulers, it will be used instead of the $module parameter. You should note that due to the scope nature of include(), this function does not load the actual metadata file but return the file name that should be loaded by the caller. If no extension file exists it will return false. //The list of extensions can be found in ./ModuleInstall/extensions.php $extensionPath = SugarAutoloader::loadExtension('logichooks'); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/Metadata_API/index.html
ce60ba26ed5f-0
File Map Modification API Overview Methods to modify files in the AutoLoader API. All the functions below return true on success and false on failure. addToMap($filename, $save = true) Adds an existing file to the file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. This method does not create the file on the filesystem. SugarAutoloader::addToMap('custom/myFile.php'); delFromMap($filename, $save = true) Removes a file from the file map. If $filename points to a directory, this directory and all files under it are removed from the map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. This method does not delete the file from the filesystem.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Map_Modification_API/index.html
ce60ba26ed5f-1
SugarAutoloader::delFromMap('custom/myFile.php'); put($filename, $data, $save = false) Saves data to a file on the filesystem and adds it to the file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. $file = 'custom/myFile.php'; SugarAutoloader::touch($file, true); SugarAutoloader::put($file, '<?php /*file content*/ ?>', true); touch($filename, $save = false) Creates the specified file on the filesystem and adds it to the file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Map_Modification_API/index.html
ce60ba26ed5f-2
SugarAutoloader::touch('custom/myFile.php', true); unlink($filename, $save = false) Removes the specified file from the filesystem and from the current file map. If $save is true, the new map will be saved to the disk file map, otherwise, it will persist only until the end of the request. SugarAutoloader::unlink('custom/myFile.php', true); Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Map_Modification_API/index.html
702953938d05-0
File Check API Overview File check methods for use with the AutoLoader API. existing(...) Returns an array of filenames that exist in the file map. Accepts any number of arguments of which can be filename or array of filenames. If no files exist, empty array is returned. $files = SugarAutoloader::existing('include/utils.php', 'include/TimeDate.php'); existingCustom(...) This method accepts any number of arguments, each of which can be filename or array of filenames. It will return an array of filenames that exist in the file map, adding also files that exist when custom/ is prepended to them. If the original
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
702953938d05-1
filename already had custom/ prefix, it is not prepended again. custom/ files are added to the list after the root directory files so that if included in order, they will override the data of the root file. If no files exist, empty array is returned. $files = SugarAutoloader::existingCustom('include/utils.php', 'include/TimeDate.php'); existingCustomOne(...) Returns the last file of the result returned by existingCustom(), or null if none exist. Accepts any number of arguments of which can be filename or array of filenames. Since customized files are placed after the root files, it will return customized file if exists, otherwise root file. $files = SugarAutoloader::existingCustomOne('include/utils.php'); You should note that the existingCustomOne() method can be used for loading inline PHP files. An example is shown below:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
702953938d05-2
foreach(SugarAutoLoader::existingCustomOne('custom/myFile.php') as $file) { include $file; } Alternative to including inline PHP files, loading class files should be done using requireWithCustom() . fileExists($filename) Checks if a file exists in the file map. You should note that ".." is not supported by this function and any paths including ".." will return false. The path components should be separated by /. You should also note that multiple slashes are compressed and treated as single slash. $file = 'include/utils.php'; if (SugarAutoloader::fileExists($file)) { require_once($file); } getDirFiles($dir, $get_dirs = false, $extension = null)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
702953938d05-3
Retrieves the list of files existing in the file map under the specified directory. If no files are found, the method will return an empty array. By default, the method will return file paths, however, If $get_dirs is set to true, the method will return only directories. If $extension is set, it would return only files having that specific extension. $files = SugarAutoloader::getDirFiles('include'); getFilesCustom($dir, $get_dirs = false, $extension = null) Retrieves the list of files existing in the file map under the specified directory and under it's custom/ path. If no files are found it will return empty array. By default, the method will return file paths, however, If $get_dirs is set to true,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
702953938d05-4
the method will return only directories. If $extension is set, it would return only files having that specific extension. $files = SugarAutoloader::getFilesCustom('include'); lookupFile($paths, $file) Looks up a file in the list of given paths, including with and without custom/ prefix, and return the first match found. The custom/ directory is checked before root files. If no file is found, the method will return false. $paths = array( 'include', 'modules', ); $files = SugarAutoloader::lookupFile($paths, 'utils.php'); requireWithCustom($file, $both = false)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
702953938d05-5
requireWithCustom($file, $both = false) If a custom/ override of the file or the file exist, require_once it and return true, otherwise return false. If $both is set to true, both files are required with the root file being first and custom/ file being second. Unlike other functions, this function will actually include the file. $file = SugarAutoloader::requireWithCustom('include/utils.php'); You should note that the requireWithCustom() method should be used for loading class files and not inline PHP files. Inline PHP files should be loaded using the existingCustomOne() method. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Autoloader/File_Check_API/index.html
af4fcb952433-0
Teams Overview Teams provide the ability to limit access at the record level, allowing sharing flexibility across functional groups. Developers can manipulate teams programmatically provided they understand Sugar's visibility framework. For more information on teams, please refer to the Team Management documentation. Database Tables Table Description teams Each record in this table represents a team in the system. team_sets Each record in this table represents a unique team combination. For example, each user's private team will have a corresponding team set entry in this table. A team set may also be comprised of one or more teams. team_sets_teams The team_sets_teams table maintains the relationships to determine which teams belong to a team set. Each table that previously used the team_id column to maintain team security now uses the team_set_id column's value to associate the record to team(s).
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/index.html
af4fcb952433-1
team_sets_modules This table is used to manage team sets and keep track of which modules have records that are or were associated to a particular team set. Never modify these tables without going through the PHP object methods. Manipuating the team sets with direct SQL may cause undesired side effects in the system due to how the validations and security methods work. Module Team Fields In addition to the team tables, each module table also contains a team_id and team_set_id column. The team_set_id contains the id of a record in the team_sets table that contains the unique combination of teams associated with the record. The team_id will contain the id of the primary team designated for a record. Team Sets (team_set_id)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/index.html
af4fcb952433-2
Team Sets (team_set_id) As mentioned above, Sugar implemented this feature not as a many-to-many relationship but as a one-to-many relationship. On each table that had a team_id field we added a 'team_set_id' field. We have also added a team_sets table, which maintains the team_set_id, and a team_sets_teams table, which relates a team set to the teams. When performing a team based query we use the 'team_set_id' field on the module table to join to team_sets_teams.team_set_id and then join all of the teams associated with that set. Given the list of teams from team_memberships we can then decide if the user has access to the record. Primary Team (team_id)
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/index.html
af4fcb952433-3
Primary Team (team_id) The team_id is still being used, not only to support backwards compatibility with workflow and reports, but also to provide some additional features. When displaying a list, we use the team set to determine whether the user has access to the record. When displaying the data, we show the team from team id in the list. When the user performs a mouseover on that team, Sugar performs an Ajax call to display all of the teams associated with the record. This team_id field is designated as the Primary Team because it is the first team shown in the list, and for sales territory management purposes, can designate the team that actually owns the record and can report on it. Team Security The team_sets_teams table allows the system to check for permissions on multiple teams. The following diagram illustrates table relationships in SugarBean's add_team_security_where_clause method.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/index.html
af4fcb952433-4
Using the team_sets_teams table the system will determine which teams are associated with the team_set_id and then look in the team_memberships table for users that belong to the team(s). TeamSetLink Typically, any relationship in a class is handled by the data/Link2.php class. As a part of dynamic teams, we introduced the ability to provide your own custom Link class to handle some of the functionality related to managing relationships. The team_security parent vardefs in the Sugar objects contain the following in the 'teams' field definition: 'link_class' => 'TeamSetLink', 'link_file' => 'modules/Teams/TeamSetLink.php',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/index.html
af4fcb952433-5
'link_file' => 'modules/Teams/TeamSetLink.php', The link_class entry defines the class name we are using, and the link_file tells us where that class file is located. This class extends the legacy Link.php and overrides some of the methods used to handle relationships such as 'add' and 'delete'. TopicsManipulating Teams ProgrammaticallyHow to manipulate team relationships.Visibility FrameworkThe visibility framework provides the capability to alter the queries Sugar uses to retrieve records from the database. This framework can allow for additional restrictions or specific logic to meet business requirements of hiding or showing only specific records. Visibility classes only apply to certain aspects of Sugar record retrieval, e.g. List Views, Dashlets, and Filter Lookups. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/index.html
d53c4a6d6030-0
Visibility Framework Overview The visibility framework provides the capability to alter the queries Sugar uses to retrieve records from the database. This framework can allow for additional restrictions or specific logic to meet business requirements of hiding or showing only specific records. Visibility classes only apply to certain aspects of Sugar record retrieval, e.g. List Views, Dashlets, and Filter Lookups. Custom Row Visibility Custom visibility class files are stored under ./custom/data/visibility/. The files in this directory can be enabled or disabled by modifying a module's visibility property located in ./custom/Extension/modules/<module>/Ext/Vardefs/. Every enabled visibility class is merged into the module's definition, allowing multiple layers of logic to be added to a module. Visibility Class
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-1
Visibility Class To add custom row visibility, you must create a visibility class that will extend the core SugarVisibility class ./data/SugarVisibility.php . The visibility class has the ability to override the following methods: Name Description addVisibilityQuery Add visibility clauses to a SugarQuery object. addVisibilityFrom [Deprecated] Add visibility clauses to the FROM part of the query. This method should still be implemented, as not all objects have been switched over to use addVisibilityQuery() method. addVisibilityFromQuery [Deprecated] Add visibility clauses to the FROM part of SugarQuery. This method should still be implemented, as not all objects have been switched over to use addVisibilityQuery() method. addVisibilityWhere
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-2
addVisibilityWhere [Deprecated] Add visibility clauses to the WHERE part of the query. This method should still be implemented, as not all objects have been switched over to use addVisibilityQuery() method. addVisibilityWhereQuery [Deprecated] Add visibility clauses to the WHERE part of SugarQuery. This method should still be implemented, as not all objects have been switched over to use addVisibilityQuery() method. The visibility class should also implement Sugarcrm\Sugarcrm\Elasticsearch\Provider\Visibility\StrategyInterface so that the visibility rules are also applied to the global search.  StrategyInterface has the following functions that should be implemented: Name Description elasticBuildAnalysis Build Elasticsearch analysis settings.  This function can be empty if you do not need any special analyzers.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-3
elasticBuildMapping Build Elasticsearch mapping.  This function should contain a mapping of fields that should be analyzed. elasticProcessDocumentPreIndex Process document before it's being indexed. This function should perform any actions to the document that needs to be completed before it is indexed.  elasticGetBeanIndexFields Bean index fields to be indexed.  This function should return an array of the fields that need to be indexed as part of your custom visibility. elasticAddFilters Add visibility filters.  This function should apply the Elastic filters. Example The following example creates a custom visibility filter that determines whether Opportunity records should be displayed based on their Sales Stage.  Opportunity records with Sales Stage set to Closed Won or Closed Lost will not be displayed in the Opportunities module or global search for users with the Demo Visibility role. Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-4
/custom/data/visibility/FilterOpportunities.php: <?php use Sugarcrm\Sugarcrm\Elasticsearch\Provider\Visibility\StrategyInterface as ElasticStrategyInterface; use Sugarcrm\Sugarcrm\Elasticsearch\Provider\Visibility\Visibility; use Sugarcrm\Sugarcrm\Elasticsearch\Analysis\AnalysisBuilder; use Sugarcrm\Sugarcrm\Elasticsearch\Mapping\Mapping; use Sugarcrm\Sugarcrm\Elasticsearch\Adapter\Document; /** * * Custom visibility class for Opportunities module: * * This demo allows to restrict access to opportunity records based on the * user's role and configured filtered sales stages. * * The following $sugar_config parameters are available: *
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-5
* * The following $sugar_config parameters are available: * * $sugar_config['custom']['visibility']['opportunities']['target_role'] * This parameter takes a string containing the role name for which * the filtering should apply. * * $sugar_config['custom']['visibility']['opportunities']['filter_sales_stages'] * This parameters takes an array of filtered sales stages. If current user is * member of the above configured role, then the opportunities with the sale * stages as configured in this array will be inaccessible. * * * Example configuration given that 'Demo Visibility' role exists (config_override.php): *
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-6
* * $sugar_config['custom']['visibility']['opportunities']['target_role'] = 'Demo Visibility'; * $sugar_config['custom']['visibility']['opportunities']['filter_sales_stages'] = array('Closed Won', 'Closed Lost'); * */ class FilterOpportunities extends SugarVisibility implements ElasticStrategyInterface { /** * The target role name * @var string */ protected $targetRole = ''; /** * Filtered sales stages * @var array */ protected $filterSalesStages = array(); /** * {@inheritdoc} */ public function __construct(SugarBean $bean, $params = null) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-7
{ parent::__construct($bean, $params); $config = SugarConfig::getInstance(); $this->targetRole = $config->get( 'custom.visibility.opportunities.target_role', $this->targetRole ); $this->filterSalesStages = $config->get( 'custom.visibility.opportunities.filter_sales_stages', $this->filterSalesStages ); } /** * {@inheritdoc} */ public function addVisibilityWhere(&$query) { if (!$this->isSecurityApplicable()) { return $query; } $whereClause = sprintf( "%s.sales_stage NOT IN (%s)",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-8
"%s.sales_stage NOT IN (%s)", $this->getTableAlias(), implode(',', array_map(array($this->bean->db, 'quoted'), $this->filterSalesStages)) ); if (!empty($query)) { $query .= " AND $whereClause "; } else { $query = $whereClause; } return $query; } /** * {@inheritdoc} */ public function addVisibilityWhereQuery(SugarQuery $sugarQuery, $options = array()) { $where = null; $this->addVisibilityWhere($where, $options); if (!empty($where)) { $sugarQuery->where()->addRaw($where); }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-9
$sugarQuery->where()->addRaw($where); } return $sugarQuery; } /** * Check if we can apply our security model * @param User $user * @return false|User */ protected function isSecurityApplicable(User $user = null) { $user = $user ?: $this->getCurrentUser(); if (!$user) { return false; } if (empty($this->targetRole) || empty($this->filterSalesStages)) { return false; } if (!is_string($this->targetRole) || !is_array($this->filterSalesStages)) { return false; } if (!$this->isUserMemberOfRole($this->targetRole, $user)) {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-10
return false; } if ($user->isAdminForModule("Opportunities")) { return false; } return $user; } /** * Get current user * @return false|User */ protected function getCurrentUser() { return empty($GLOBALS['current_user']) ? false : $GLOBALS['current_user']; } /** * Check if given user has a given role assigned * @param string $targetRole Name of the role * @param User $user * @return boolean */ protected function isUserMemberOfRole($targetRole, User $user) { $roles = ACLRole::getUserRoleNames($user->id);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-11
$roles = ACLRole::getUserRoleNames($user->id); return in_array($targetRole, $roles) ? true : false; } /** * Get table alias * @return string */ protected function getTableAlias() { $tableAlias = $this->getOption('table_alias'); if (empty($tableAlias)) { $tableAlias = $this->bean->table_name; } return $tableAlias; } /** * {@inheritdoc} */ public function elasticBuildAnalysis(AnalysisBuilder $analysisBuilder, Visibility $provider) { // no special analyzers needed } /** * {@inheritdoc} */
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-12
} /** * {@inheritdoc} */ public function elasticBuildMapping(Mapping $mapping, Visibility $provider) { $mapping->addNotAnalyzedField('visibility_sales_stage'); } /** * {@inheritdoc} */ public function elasticProcessDocumentPreIndex(Document $document, \SugarBean $bean, Visibility $provider) { // populate the sales_stage into our explicit filter field $sales_stage = isset($bean->sales_stage) ? $bean->sales_stage : ''; $document->setDataField('visibility_sales_stage', $sales_stage); } /** * {@inheritdoc} */
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-13
} /** * {@inheritdoc} */ public function elasticGetBeanIndexFields($module, Visibility $provider) { // make sure to pull sales_stage regardless of search return array('sales_stage'); } /** * {@inheritdoc} */ public function elasticAddFilters(User $user, Elastica\Query\BoolQuery $filter, Sugarcrm\Sugarcrm\Elasticsearch\Provider\Visibility\Visibility $provider) { if (!$this->isSecurityApplicable($user)) { return; } // apply elastic filter to exclude the given sales stages $filter->addMustNot($provider->createFilter( 'OpportunitySalesStages',
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-14
'OpportunitySalesStages', array( 'filter_sales_stages' => $this->filterSalesStages, ) )); } } ./custom/Extension/modules/Opportunities/Ext/Vardefs/opp_visibility.php <?php if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } $dictionary['Opportunity']['visibility']['FilterOpportunities'] = true; ./custom/src/Elasticsearch/Provider/Visibility/Filter/OpportunitySalesStagesFilter.php <?php namespace Sugarcrm\Sugarcrm\custom\Elasticsearch\Provider\Visibility\Filter;
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-15
use Sugarcrm\Sugarcrm\Elasticsearch\Provider\Visibility\Filter\FilterInterface; use Sugarcrm\Sugarcrm\Elasticsearch\Provider\Visibility\Visibility; /** * * Custom opportunity filter by sales_stage * * This logic can exist directly in the FilterOpportunities visibility class. * However by abstracting the (custom) filters makes it possible to re-use * them in other places as well. */ class OpportunitySalesStagesFilter implements FilterInterface { /** * @var Visibility */ protected $provider; /** * {@inheritdoc} */ public function setProvider(Visibility $provider) { $this->provider = $provider; } /** * {@inheritdoc}
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-16
} /** * {@inheritdoc} */ public function buildFilter(array $options = array()) { return new \Elastica\Query\Terms( 'visibility_sales_stage', $options['filter_sales_stages'] ); } } After creating the above files, log in to your Sugar instance as an administrator and navigate to Administration > Repair > Quick Repair and Rebuild.   Next, perform a full reindex by navigating to Administration > Search and selecting the "delete existing data" option.  Execute a cron to process all of the queued records into Elasticsearch by doing the following:  Open a command line client and navigate to your Sugar directory.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-17
Open a command line client and navigate to your Sugar directory. Execute chmod +x bin/sugarcrm to ensure bin/sugarcrm is executable. Execute php cron.php to consume the queue. Execute bin/sugarcrm elastic:queue to see if the queue has finished. Repeat steps 3 and 4 until the queue has 0 records. This example requires the Sales Stage field to be part of the Opportunities module.  Navigate to Administration > Opportunities and ensure the Opportunities radio button is selected.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-18
Create a new role named "Demo Visibility" and assign a user to this role.  Note: if you are using the sample data, do NOT use Jim as he has admin permission on the Opportunities module and will be able to view all records. We recommend using Max. Configure your instance to filter opportunities for a given sales stages for this role by adding the following to ./config_override.php: <?php $sugar_config['custom']['visibility']['opportunities']['target_role'] = 'Demo Visibility'; $sugar_config['custom']['visibility']['opportunities']['filter_sales_stages'] = array('Closed Won', 'Closed Lost');
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
d53c4a6d6030-19
Log in as the user to whom you assigned the Demo Visibility role. Observe that opportunity records in the sales stages "Closed Won" and "Closed Lost" are no longer accessible. You can download a module loadable package of this example here. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Custom_Record_Visibility/index.html
b76e20c37238-0
Manipulating Teams Programmatically Overview How to manipulate team relationships. Fetching Teams To fetch teams related to a bean, you will need to retrieve an instance of a TeamSet object and use the getTeams() method to retrieve the teams using the team_set_id. An example is shown below: //Create a TeamSet bean - no BeanFactory require_once 'modules/Teams/TeamSet.php'; $teamSetBean = new TeamSet(); //Retrieve the bean $bean = BeanFactory::getBean($module, $record_id); //Retrieve the teams from the team_set_id $teams = $teamSetBean->getTeams($bean->team_set_id); Adding Teams
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html
b76e20c37238-1
Adding Teams To add a team to a bean, you will need to load the team's relationship and use the add() method. This method accepts an array of team ids to add. An example is shown below: //Retrieve the bean $bean = BeanFactory::getBean($module, $record_id); //Load the team relationship $bean->load_relationship('teams'); //Add the teams $bean->teams->add( array( $team_id_1, $team_id_2 ) ); Considerations If adding teams in a logic hook, the recommended approach is to use an after_save hook rather than a before_save hook as the $_REQUEST may reset any changes you make. Removing Teams
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Architecture/Teams/Manipulating_Teams_Programmatically/index.html