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 / SugarACLReadOnly.php
Last active May 30, 2017
SugarCRM v7 - Default a module to Read only through ACL's customisation
View SugarACLReadOnly.php
<?php
//
// Enrico Simonetti
// enricosimonetti.com
//
// 2015-09-10 on Sugar 7.6.0.0
// filename: custom/data/acl/SugarACLReadOnly.php
//
// Read only ACL except for Admin users and specific user ids
@esimonetti
esimonetti / SugarACLLock.php
Last active Apr 22, 2019
SugarCRM v7 - Conditional record locking through ACL's customisation
View SugarACLLock.php
<?php
//
// Enrico Simonetti
// enricosimonetti.com
//
// 2016-05-08 on Sugar 7.7.0.0
// file: custom/data/acl/SugarACLLock.php
//
// ACL to lock record in certain conditions. Always allow admin users and specific user ids
@esimonetti
esimonetti / afterEntryPoint.php
Last active Nov 29, 2017
Disable Activity Stream on Sugar 7 - Application logic hook to disable writes everywhere and example of vardefs to disable module specific UI
View afterEntryPoint.php
<?php
// Enrico Simonetti
// enricosimonetti.com
// custom/logichooks/application/afterEntryPoint.php
class afterEntryPoint
{
public function disableActivityStream($event, $arguments)
@esimonetti
esimonetti / afterLoginUsers.php
Last active Apr 26, 2017
The code implements an after_login logic hook that invalidates the login for any standard user without at least a Role. The sample code purposely does not apply to Administrators as Roles do not apply to them in any case. The code below works on the current version 7.7.2.0.
View afterLoginUsers.php
<?php
// Enrico Simonetti
// enricosimonetti.com
// custom/logichooks/modules/Users/afterLoginUsers.php
class afterLoginUsers
{
public function callAfterLogin($bean, $event, $args)
@esimonetti
esimonetti / SugarScript.php
Last active Feb 6, 2018
Quick Sugar multi purpose script
View SugarScript.php
<?php
// Enrico Simonetti
// enricosimonetti.com
function usage($error = '') {
if (!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
print(' php ' . __FILE__ . ' --instance /full/path' . PHP_EOL);
exit(1);
}
@esimonetti
esimonetti / CustomSugarCacheRedis.php
Last active Dec 13, 2018
Custom implementation of Sugar redis cache, using authentication and persistent connection
View CustomSugarCacheRedis.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-23 tested on Sugar 7.9.2.0 on PHP 7.1 with the addition of: https://gist.github.com/esimonetti/a99ea05b68cd2586949944c1b24b2921
// Custom implementation of Sugar redis cache, using authentication if configured and using persistent connections if configured
//
// file: custom/include/SugarCache/CustomSugarCacheRedis.php
@esimonetti
esimonetti / SugarCronFilteredJobs.php
Created May 2, 2017 — forked from jhoffmann/SugarCronFilteredJobs.php
Both files go into custom/include/SugarQueue, then run a Repair to regenerate cache/file_map.php and you're good to go.
View SugarCronFilteredJobs.php
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
require_once 'include/SugarQueue/SugarCronJobs.php';
require_once 'custom/include/SugarQueue/SugarJobFilteredQueue.php';
// Sample configuration:
//
@esimonetti
esimonetti / sugarpdf.pdfmanager.php
Created Jun 19, 2017
This is just an example of how to print all pdf templates of a module (Contacts) landscape instead of portrait.
View sugarpdf.pdfmanager.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-06-19 on Sugar 7.9.0.0
// filename: custom/modules/Contacts/sugarpdf/sugarpdf.pdfmanager.php
//
// This is just an example of how to print all pdf templates of a module (Contacts) landscape instead of portrait.
// After this customisation is installed, and the system is repaired, all PDF templates for Contacts will be printed landscape instead of portrait
@esimonetti
esimonetti / detail.hbs
Last active Jun 20, 2017
This is an example of how to have templates on sidecar modules, printable on either portrait or landscape based on user's choice. It excludes Reports, Quotes and Project as they do have a custom pdf generation
View detail.hbs
{{!--
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-06-20 on Sugar 7.9.0.0
// filename: custom/clients/base/fields/pdfaction/detail.hbs
//
// Allow for landscape pdf template printing for all modules aside Quotes, Reports and Projects
@esimonetti
esimonetti / TidewaysProf.php
Last active Feb 20, 2019
POC of Tideways profiling extension for Sugar 7.9.1.0 on PHP 7.1
View TidewaysProf.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// Original work: https://gist.github.com/lblockken/78a59273f2460b36eb127a7c2ee510a1
//
// 2017-07-31 on Sugar 7.9.1.0 with PHP 7.1
// filename: custom/include/SugarXHprof/TidewaysProf.php
You can’t perform that action at this time.