Skip to content

Instantly share code, notes, and snippets.

Chad Hutchins chadhutchins

Block or report user

Report or block chadhutchins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View token.php
<?php
// given a proper $token and $consumer...
require_once('include/api/RestService.php');
require_once('clients/base/api/OAuth2Api.php');
$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',
};
client.request(settings).then(function(data){console.log(data);});
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
<?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
<?php
// notice the upper-case letter ‘m’
require_once(‘modules/MyModule/MyModule.php’);
@chadhutchins
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
<?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
chadhutchins / proxy.php
Last active Dec 6, 2019
Proxy Script to allow Sugar to Receive MailChimp Webhooks using SugarChimp
View proxy.php
<?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
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
<?php
$job_strings[] = 'YourJobQueue';
function YourJobQueue()
{
$queues_to_process = array(
'FirstQueue',
'SecondQueue',
'ThirdQueue',
View gist:10b62a30ec9e6614dde0
<?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
You can’t perform that action at this time.