Skip to content

Instantly share code, notes, and snippets.

View mmarum-sugarcrm's full-sized avatar

Matt Marum mmarum-sugarcrm

View GitHub Profile
@mmarum-sugarcrm
mmarum-sugarcrm / AccountsOnSaveHooksTest.php
Last active January 12, 2016 06:39
PHPUnit tests for example AccountsOnSave logic hooks
<?php
/*
* Copyright 2015 SugarCRM Inc.
*/
require_once 'custom/modules/Accounts/AccountsOnSaveHooks.php';
/**
* Example tests for our custom Logic Hook.
*/
@mmarum-sugarcrm
mmarum-sugarcrm / AccountsOnSaveHooks.php
Last active November 13, 2015 23:28
Example Sugar 7 before_save Logic Hook
<?php
/*
* Copyright 2015 SugarCRM Inc.
*/
/**
* Example of a module logic hook that we will unit test
*/
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
@mmarum-sugarcrm
mmarum-sugarcrm / test-template.js
Created September 8, 2015 04:15
Jasmine template for Sugar 7 views
/*
* Basic Jasmine test template for any Sugar 7 view
*/
ddescribe("Jasmine template for Sugar 7 views", function () {
/*
* Some useful constants for our tests.
* We use them to keep track of the module, layout, and view we are testing
*/
var moduleName = 'Accounts'; //TODO CHANGE TO AN APPROPRIATE MODULE
var viewName = "CHANGE_ME"; //TODO CHANGE TO YOUR VIEW NAME
@mmarum-sugarcrm
mmarum-sugarcrm / case-count-by-status.js
Last active September 8, 2015 04:15
Jasmine tests for Case Count by Status dashlet
/*
* Basic Jasmine tests for Case Count by Status dashlet
*/
ddescribe("Case Count by Status", function () {
/*
* Some useful constants for our tests.
* We use them to keep track of the module, layout, and view we are testing
*/
var moduleName = 'Cases';
var viewName = 'case-count-by-status';
@mmarum-sugarcrm
mmarum-sugarcrm / en_us.case-count-by-status.php
Created July 6, 2015 19:32
Case Count by Status English language extension
<?php
// This file will provide English strings for our new labels.
// Additional extensions could be created so that our dashlet supports other languages.
$app_strings['LBL_CASE_COUNT_BY_STATUS'] = 'Case Count By Status';
$app_strings['LBL_CASE_COUNT_BY_STATUS_DESCRIPTION'] = 'Shows the number of Cases on the Cases List view by status.';
$app_strings['LBL_CASE_COUNT_BY_STATUS_TOTAL'] = 'Total Cases:';
@mmarum-sugarcrm
mmarum-sugarcrm / case-count-by-status.hbs
Created July 6, 2015 18:48
Case Count by Status example dashlet Handlebars template
{{!
Case Count by Status example dashlet Handlebars template
We are reusing styling from the Sugar 7 Styleguide for our example dashlet.
Here we are borrowing CSS used in our Forecast Details dashlet which is suitable for display any set of name value pairs.
}}
<div class="forecast-details">
{{#each values}}
<div class="row-fluid">
@mmarum-sugarcrm
mmarum-sugarcrm / case-count-by-status.js
Last active March 3, 2016 04:27
Case Count by Status example dashlet controller
/**
* Case Count by Status example dashlet controller
*
* Controller logic watches the current collection on display and updates the
* dashlet automatically whenever the current collection changes.
*
* This is a simple example of a dashlet for List Views in Sugar 7.x.
*
**/
({
@mmarum-sugarcrm
mmarum-sugarcrm / case-count-by-status.php
Last active August 29, 2015 14:24
Case Count by Status Dashlet Metadata
<?php
/**
* Metadata for the Case Count by Status example dashlet view
*
* This dashlet is only allowed to appear on the Case module's list view
* which is also known as the 'records' layout.
*/
$viewdefs['base']['view']['case-count-by-status'] = array(
'dashlets' => array(
@mmarum-sugarcrm
mmarum-sugarcrm / MobileApiLogicHook.php
Last active August 29, 2015 14:22
Sugar 7 Mobile API Logic Hook example
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Example Mobile API Logic Hooks class
**/
class MobileApiLogicHook
{
/**
@mmarum-sugarcrm
mmarum-sugarcrm / RestrictedOAuth2MobileApi.php
Last active August 29, 2015 14:22
Restricting login to SugarCRM Mobile by Role in Sugar 7
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once 'clients/mobile/api/OAuth2MobileApi.php';
/**
* Example of how to override the core OAuth2MobileApi class in order to alter SugarCRM Mobile authentication behavior
**/
class RestrictedOAuth2MobileApi extends OAuth2MobileApi {