Skip to content

Instantly share code, notes, and snippets.

View chadhutchins's full-sized avatar

Chad Hutchins chadhutchins

View GitHub Profile
@chadhutchins
chadhutchins / gist:15269c14d82b8bd4acca
Created November 14, 2014 14:30
LoveTEFL SugarChimp Webhook Receiver Changes
<?php
echo "SugarChimp Webhook Receiver is setup properly!";
require_once('modules/SugarChimp/includes/classes/SugarChimp/Helper.php');
require_once('modules/SugarChimp/includes/classes/SugarChimp/FieldMap.php');
require_once('modules/SugarChimp/includes/classes/SugarChimp/Activity.php');
@chadhutchins
chadhutchins / gist:bef6020d25ae241217ab
Created November 10, 2014 17:05
Add SugarChimp Activity as a Sugar Subpanel
<?php
$layout_defs['Contacts']['subpanel_setup']['sugarchimpactivity'] = array(
'top_buttons' => array(array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'SugarChimpActivity', 'mode' => 'MultiSelect'),),
'order' => 900,
'sort_by' => 'timestamp',
'sort_order' => 'desc',
'module' => 'SugarChimpActivity',
'refresh_page'=>1,
'subpanel_name' => 'default',
@chadhutchins
chadhutchins / webhook-receiver.php
Created November 6, 2014 21:48
How to send an email with Mandrill using a SugarOutfitters Webhook for a SugarCRM Add-on Sale
<?php
// load up mandrill
require_once('vendor/mandrill/src/Mandrill.php');
define(MANDRILL_APIKEY,'MANDRILL_API_KEY_GOES_HERE');
// get the webhook response
// decode the json data into a php object
$body = @file_get_contents('php://input');
$response = json_decode($body);
@chadhutchins
chadhutchins / gist:a7d14f77a765e2608d39
Created June 4, 2014 23:54
Sample use of app re-sync in Sugar 7 in post_install script
window.parent.SUGAR.App.sync({callback: function(){
window.parent.SUGAR.App.router.navigate('#your_module/layout/license', {trigger:true, replace:true});
}});
@chadhutchins
chadhutchins / gist:95a8832dbef14b5daace
Created June 4, 2014 23:50
In Sugar 7, run a simple sync to reload your module's app data after installing to prevent the "Data not available" error.
window.parent.SUGAR.App.sync()
@chadhutchins
chadhutchins / remove_old_sugarchimp_events.php
Created February 20, 2014 03:12
Remove old SugarChimp events.
<?php
$db_time = date($timedate->get_db_date_format(), strtotime("-20 DAY"));
$query = "DELETE FROM atc_sugarchimpclient WHERE (status = 'Processed' OR status = 'Error') AND date_entered <= '{$db_time}'";
$db->query($query);
@chadhutchins
chadhutchins / test.php
Created September 25, 2013 15:56
Example of issues grabbing the account_id of a contact when using BeanFactory in version 6.5.15.
<?php
// Having issues grabbing the account_id of a contact when using BeanFactory
// in version 6.5.15 to create/load the contact
// To test this out, put this in custom/modules/Contacts/test.php and go
// to http://instance/index.php?module=Contacts&action=test to see the results
// Only "CASE 4" below returns the expected results.
$account_id = "11c5a47e-49a8-c077-4c6a-524304ac91ca";
from __future__ import division
import collections
from texttable import Texttable
by_status = collections.defaultdict(list)
per_page = 100
offset = 0
while True:
@chadhutchins
chadhutchins / script.php
Last active June 29, 2016 05:32
SugarOutfitters Starter Webhook Script
<?php
// get the webhook response
$body = @file_get_contents('php://input');
// decode the json data into a php object
$response = json_decode($body);
// the webhook property tells us exactly which webhook event was fired
// so let's create a case for a few webhooks
@chadhutchins
chadhutchins / script.php
Created July 31, 2013 21:57
PHP starter script... not much to see here.
<?php
echo “Hello, world!”;