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 / afterEntryPoint.php
Created Jan 31, 2018
Disable network card's mac address query on guid/uuid generation
View afterEntryPoint.php
<?php
// Enrico Simonetti
// enricosimonetti.com
// 2018-01-31 on 7.9.3.0
// custom/logichooks/application/afterEntryPoint.php
class afterEntryPoint
@esimonetti
esimonetti / afterSaveCases.php
Last active Aug 20, 2018
Set Case's Teams to the private team of the created by user and of the assigned user. This logic will work only if all users have as default team, their own private team only
View afterSaveCases.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-19 on Sugar 7.9.2.0
//
// Set Case's Teams to the private team of the created by user and of the assigned user. This logic will work only if all users have as default team, their own private team only
// file: custom/logichooks/modules/Cases/afterSaveCases.php
@esimonetti
esimonetti / ProcessQueueCommand.php
Last active Jan 21, 2019
Sugar CLI command to run index processing without waiting for the scheduler - SUPERSEDED, LOOK INTO ./bin/sugarcrm search:silent_reindex and ./bin/sugarcrm search:silent_reindex_mp
View ProcessQueueCommand.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-15 on Sugar 7.9.2.0
// Sugar CLI command to run index processing without waiting for the scheduler
//
// Trigger reindex with: ./bin/sugarcrm search:reindex
// Process records by running either as a background process or with a cron: ./bin/sugarcrm elastic:process_records
@esimonetti
esimonetti / clean_activities_stream.php
Last active Oct 23, 2018
The latests up to date project is located here: https://github.com/esimonetti/SugarActivityStreamPurger. CLI script to clean activity streams to keep only the last N months, and keep only activities of records that are still valid. A more aggressive and faster version of this script can be found here: https://gist.github.com/esimonetti/39f65396f…
View clean_activities_stream.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-13 on Sugar 7.9.2.0
//
// CLI script to clean activity streams to keep only the last N months, and keep only activities of records that are still valid
//
// TEST, TEST, TEST AND USE AT YOUR OWN RISK!
@esimonetti
esimonetti / delete_orphans.php
Last active Jun 29, 2018
CLI script to find and delete orphan records on the custom tables of Sugar modules - Tested up to 35M records in one script run, at about 5,200 records deleted per second
View delete_orphans.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-13 on Sugar 7.9.2.0
//
// CLI script to find and delete orphan records on the custom tables of Sugar modules
function usage($error = '') {
@esimonetti
esimonetti / CustomNotesFilterApi.php
Last active Dec 8, 2017
Sample customised filter api to help find Notes that are related to multiple Contacts at the same time, with a custom many to many relationship
View CustomNotesFilterApi.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-08 tested on Sugar 7.9.2.0
// Sample customised filter api to help find Notes that are related to multiple Contacts at the same time, with a custom many to many relationship
// eg: {{url}}/rest/v10/Notes?contact_id[]=<first id>&contact_id[]=<second id> will only return Notes that are related to both contacts at the same time
//
// file: custom/modules/Notes/clients/base/api/CustomNotesFilterApi.php
@esimonetti
esimonetti / notifications.js
Last active Nov 24, 2017
Sample customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
View notifications.js
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-24 tested on Sugar 7.9.2.0
// Sample customised notifications view to increase Notifications polling and separate delays for Notifications from Meetings and Calls reminders
//
// IMPORTANT: Lowering the delay values through the configuration options will increase the frequency of the amount of requests completed to the server, for every user's open browser tab. You need to consider the server load implications and sizing requirements.
//
// file: custom/clients/base/views/notifications/notifications.js
@esimonetti
esimonetti / repair.php
Last active Jun 27, 2019
Sugar CLI Repair - Instance as script argument
View repair.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-01 on Sugar 7.9.2.0
function usage($error = '') {
if (!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
print(' php ' . __FILE__ . ' --instance /full/path' . PHP_EOL);
View autoload_custom_redis_cache.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-11-01 tested on Sugar 7.9.1.0
// Forcing custom Sugar Cache to autoload: https://gist.github.com/esimonetti/78999f4dfbac22fd26bab8453a0ed149
//
// file: custom/Extension/application/Ext/Include/autoload_custom_redis_cache.php
SugarAutoloader::addDirectory('custom/include/SugarCache/');
@esimonetti
esimonetti / CustomAccountsRelateApi.php
Last active Aug 25, 2017
Sugar 7.9.1.0 example of how to extend the RelateApi to display on the Account's Notes subpanel all its Notes and all its first level members Accounts Notes
View CustomAccountsRelateApi.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-08-25 on Sugar 7.9.1.0
// filename: custom/modules/Accounts/clients/base/api/CustomAccountsRelateApi.php
//
// Display on the Account's Notes subpanel all its Notes and all its first level members Accounts Notes
You can’t perform that action at this time.