Skip to content

Instantly share code, notes, and snippets.

Enrico Simonetti esimonetti

Block or report user

Report or block esimonetti

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
@esimonetti
esimonetti / csv_to_sugar_php_dropdown.php
Created Dec 2, 2019
Script to convert a csv file into Sugar php dropdowns
View csv_to_sugar_php_dropdown.php
<?php
// example dropdowns.csv content
// "ddname","key1","value1"
// "ddname","key2","value2"
$fileName = 'dropdowns.csv';
if (file_exists($fileName)) {
$file = fopen($fileName, 'r');
$dd = [];
View newrelic-on-sugardockerized.txt
FROM php:7.3-apache-stretch
.
.
.
RUN apt-get install -y gnupg \
&& echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' >> /etc/apt/sources.list.d/newrelic.list \
&& curl -L https://download.newrelic.com/548C16BF.gpg | apt-key add - \
&& echo 'newrelic.transaction_tracer.detail = 1' >> /usr/local/etc/php/conf.d/newrelic-additional.ini \
&& echo 'newrelic.transaction_tracer.internal_functions_enabled = 1' >> /usr/local/etc/php/conf.d/newrelic-additional.ini \
@esimonetti
esimonetti / cacheOnSugar.php
Last active Nov 13, 2019
With the new PSR-16 compatible caching engine we introduced recently, the new way to get the caching object is with something like this sample code
View cacheOnSugar.php
<?php
// remember to set redis on config_override.php
/*
$sugar_config['external_cache_disabled'] = false;
$sugar_config['external_cache_disabled_redis'] = false;
$sugar_config['external_cache']['redis']['host'] = 'sugar-redis';
*/
// to test the simplest standalone script
@esimonetti
esimonetti / extractMetadata.php
Last active Oct 30, 2019
Utility to extract Sugar's metadata content to be able to compare two different metadatas - USE TOOTHPASTE INSTEAD! https://github.com/esimonetti/toothpaste
View extractMetadata.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-26 on Sugar 9.0.0
//
// Metadata extractor, to compare 2 metadatas with a diff command
// eg: diff -auNw file1.array file2.array)
@esimonetti
esimonetti / createMissingTables.php
Last active Oct 30, 2019
Create missing tables - USE TOOTHPASTE INSTEAD! https://github.com/esimonetti/toothpaste
View createMissingTables.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-24 Sugar 9.0.0
// create missing tables
function usage($error = '') {
if (!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
@esimonetti
esimonetti / with_acl_team_set_id.php
Last active Oct 10, 2019
Find records across all tables with acl_team_set_id not null, and their teams
View with_acl_team_set_id.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-02 on Sugar 8.0.0
//
// CLI script to find records with acl_team_set_id
function usage($error = '') {
@esimonetti
esimonetti / sugar-cli-fus.txt
Last active Nov 14, 2019
Useful sugar file system commands to analyse an instance
View sugar-cli-fus.txt
# Quick way to tell the difference of the modules dir of two instances
# 1 - from within the vanilla system module's dir
cd modules
ls -la | awk '{ print $9 }' | grep -v '\.' | grep -v '\.\.' > ~/core_modules_dir.txt
# 2 - from within the customer system module's dir
cd modules
ls -la | awk '{ print $9 }' | grep -v '\.' | grep -v '\.\.' > ~/customer.txt
# 3 - diff the twos and do some fus to get the actual differences
diff -auNw ~/core_modules_dir.txt ~/customer.txt | grep + | grep -v "@" | cut -c 2- | grep -v "\+\+" | grep -v "\-\-"
@esimonetti
esimonetti / .htaccess
Last active Aug 27, 2019
Change sugar upload dir to another disk/mount
View .htaccess
...
...
# file path will depend on the installation path or where the file should be
# if this needs to be executed everywhere (even from cron), consider setting it on php.ini instead of the .htaccess
php_value auto_prepend_file /var/www/html/sugar/prepend.php
@esimonetti
esimonetti / secretHandling.php
Last active May 13, 2019
Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
View secretHandling.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-05-13
// Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
// secret value to encrypt for storage purposes, and to decrypt real-time
@esimonetti
esimonetti / list.php
Created Jan 9, 2019
Add tags to reports on listviews
View list.php
<?php
//
// Enrico Simonetti
// 2019-01-10
//
// file: custom/Extension/modules/Reports/Ext/clients/base/views/list/list.php
//
// Add tags to reports on listviews
//
You can’t perform that action at this time.