Skip to content

Instantly share code, notes, and snippets.

View chadhutchins's full-sized avatar

Chad Hutchins chadhutchins

View GitHub Profile
@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 / 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 / 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 / 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: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 / 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');
<?php
/**
* Put this immediately before line 92 in SugarModules/modules/off_Dynamic_Target_List/dynamic_AddJobsHere.php
**/
// check if sugarchimp table exists and the list has a synced mailchimp list id
if (!empty($obj_custom->mailchimp_list_name_c) && $db->getRowCount($db->query("SHOW TABLES LIKE 'sugarchimp'"))==1)
{
// insert 'remove mailchimp subscriber' jobs for each record that is getting removed from the prospect_lists_prospects table
@chadhutchins
chadhutchins / gist:2fe3dd0bce97413b2c5b
Created April 21, 2015 21:04
Classes for creating your own custom queue table to run on Sugar's On-demand Scheduler
<?php
$job_strings[] = 'YourJobQueue';
function YourJobQueue()
{
$queues_to_process = array(
'FirstQueue',
'SecondQueue',
'ThirdQueue',
// assuming jquery and the cookie plugin are already included.
$("html").addClass("js");
$(document).ready(function() {
if ($.cookie('exp_alert_banner_newsletter')!='hide') {
$("p.alert").slideDown("slow");
$("p.alert span.hidealert a").click(function() {
$("p.alert").slideUp("slow");
<?php
// custom array merging
// if something exists in the custom array, it should overwrite the default
// otherwise take the default value
$default = array(
"key1" => "val1",
"key2" => "val2",
"key3" => array(