Skip to content

Instantly share code, notes, and snippets.


Chad Hutchins chadhutchins

View GitHub Profile
View token.php
// given a proper $token and $consumer...
$service = new RestService();
$api = new OAuth2Api();
View app.js
client = ZAFClient.init();
var settings = {
url: '{{setting.sugarUrl}}',
headers: {'oauth-token': '{{setting.sugarOauthAccessToken}}'},
secure: true,
type: 'GET',
dataType: 'json',
contentType: 'application/json',
View queries2.sql
-- works in MySQL, fails in MSSQL
SELECT * FROM contacts WHERE IFNULL(title,’’)=’CEO’;
-- works in MSSQL
SELECT * FROM contacts WHERE ISNULL(title,’’)=’CEO’;
View queries1.sql
-- works in MySQL, fails in MSSQL
SELECT * FROM contacts WHERE title=’CEO’ && title=’CTO’;
-- works in both MySQL and MSSQL
SELECT * FROM contacts WHERE title=’CEO’ AND title=’CTO’;
View database.php
global $db;
echo $db->dbType;
if ($db->dbType == ‘mysql’) echoMySQL is being used”;
if ($db->dbType == ‘mssql’) echoMSSQL is being used”;
View MyModule.php
// notice the upper-case letter ‘m’
chadhutchins / mailchimp-v3-batch-updates.php
Created Dec 4, 2015
This script shows how to use the MailChimp v3 API to re-subscribe a large group of mistakingly unsubscribed email addresses in a MailChimp List. There are a couple examples commented out that can be used. The first shows how to look up the status of a batch API call sent to MailChimp. And the second shows how to make a batch API call to re-subsc…
View mailchimp-v3-batch-updates.php
// replace this with your mailchimp api key
$mailchimp_apikey = "mailchimp-api-key-goes-here";
// create mailchimp api object that is used later to make api calls
$mcapi = new MailChimp_API($mailchimp_apikey);
// Use the following code if you want to look up the status of a batch call
chadhutchins / proxy.php
Last active Dec 6, 2019
Proxy Script to allow Sugar to Receive MailChimp Webhooks using SugarChimp
View proxy.php
If you want to keep your SugarCRM server non-accessible from the outside web
But you still want to receive MailChimp updates with SugarChimp, this script will help you do so
You need to make this script accessible from the outside web and it will allow MailChimp to connect to Sugar through the SuagrChimpWebhook entrypoint
All other Sugar requests will get ignored
Be sure to change the $sugar_url variable to the path of your index.php script inside your Sugar folder
chadhutchins / gist:2fe3dd0bce97413b2c5b
Created Apr 21, 2015
Classes for creating your own custom queue table to run on Sugar's On-demand Scheduler
View gist:2fe3dd0bce97413b2c5b
$job_strings[] = 'YourJobQueue';
function YourJobQueue()
$queues_to_process = array(
View gist:10b62a30ec9e6614dde0
* 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
You can’t perform that action at this time.