Skip to content

Instantly share code, notes, and snippets.

View sugarknowledge's full-sized avatar

Knowledge Manager sugarknowledge

View GitHub Profile
@sugarknowledge
sugarknowledge / NuSOAP_example.php
Created June 28, 2012 20:54
Example of setting up NuSOAP
<?php
//require NuSOAP
require_once("./lib/nusoap.php");
//retrieve WSDL
$client = new nusoap_client("http://{site_url}/service/v4/soap.php?wsdl", 'wsdl');
@sugarknowledge
sugarknowledge / REST_PHP_set_entries.php
Created July 3, 2012 19:57
PHP Example using cURL with the v4 REST API to create multiple contacts using set_entries
<?php
$url = "http://{site_url}/service/v4/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
@sugarknowledge
sugarknowledge / SOAP_PHP_get_entries_example.php
Created July 3, 2012 21:19
PHP Example using NuSOAP with the v4 SOAP API to retrieve account records with get_entries
<?php
$url = "http://{site_url}/service/v4/soap.php?wsdl";
$username = "admin";
$password = "password";
//require NuSOAP
require_once("./nusoap/lib/nusoap.php");
//retrieve WSDL
@sugarknowledge
sugarknowledge / accounts_save.php
Created July 6, 2012 21:22
Example Manifest for installing a logic hook
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class Accounts_Save
{
function updateAccountName(&$bean, $event, $arguments)
{
$bean->name = "My New Account Name (" . time() . ")";
}
@sugarknowledge
sugarknowledge / SOAP_PHP_get_relationships_example.php
Created July 27, 2012 14:18
PHP Example using NuSOAP with the v4 SOAP API to retrieve leads related to a specific target list with get_relationships
<?php
$url = "http://{site_url}/service/v4/soap.php?wsdl";
$username = "admin";
$password = "password";
//require NuSOAP
require_once("./nusoap/lib/nusoap.php");
//retrieve WSDL
@sugarknowledge
sugarknowledge / CustomFileCheck.php
Created August 2, 2012 16:50
Module Loader Restriction Workarounds
<?php
//require utils
require_once("include/utils.php");
$check_path = "modules/Accounts/logic_hooks.php";
//if the $check_path exists in custom, $path will be returned as "custom/{$check_path}", otherwise $check_path will be returned
$path = get_custom_file_if_exists("modules/Accounts/logic_hooks.php");
@sugarknowledge
sugarknowledge / en_us.lang.php
Created August 3, 2012 13:50
Creating an Installable Package that Creates New Fields
<?php
$mod_strings['LBL_TEXT_FIELD_EXAMPLE'] = 'Text Field Example';
$mod_strings['LBL_DROPDOWN_FIELD_EXAMPLE'] = 'DropDown Field Example';
$mod_strings['LBL_CHECKBOX_FIELD_EXAMPLE'] = 'Checkbox Field Example';
$mod_strings['LBL_MULTISELECT_FIELD_EXAMPLE'] = 'Multi-Select Field Example';
$mod_strings['LBL_DATE_FIELD_EXAMPLE'] = 'Date Field Example';
$mod_strings['LBL_DATETIME_FIELD_EXAMPLE'] = 'DateTime Field Example';
$mod_strings['LBL_ENCRYPT_FIELD_EXAMPLE'] = 'Encrypt Field Example';
@sugarknowledge
sugarknowledge / tinyButtonConfig.php
Created August 20, 2012 16:20
How to Modify the TinyMCE Editor
<?php
//create email template
$buttonConfigs['default'] = array(
'buttonConfig' => "code,help,separator,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,
justifyfull,separator,forecolor,backcolor,separator,styleselect,formatselect,fontselect,fontsizeselect,",
'buttonConfig2' => "cut,copy,paste,pastetext,pasteword,selectall,separator,search,replace,separator,bullist,numlist,separator,outdent,
indent,separator,ltr,rtl,separator,undo,redo,separator, link,unlink,anchor,image,separator,sub,sup,separator,charmap,
visualaid",
'buttonConfig3' => "tablecontrols,separator,advhr,hr,removeformat,separator,insertdate,inserttime,separator,preview"
@sugarknowledge
sugarknowledge / editor_plugin.js
Created August 28, 2012 03:56
Setting a default font and font-size in TinyMCE
(function() {
tinymce.create('tinymce.plugins.CustomSetFontPlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
@sugarknowledge
sugarknowledge / pmcqueen_Sugar_Logic_example_concat_textfields
Created September 7, 2012 18:36
pmcqueen - Sugar Logic Example : Concatenating TextFields
concat($first_name, " ", $last_name)