Skip to content

Instantly share code, notes, and snippets.

View esimonetti's full-sized avatar
📃
Open to new opportunities

Enrico Simonetti esimonetti

📃
Open to new opportunities
View GitHub Profile
@esimonetti
esimonetti / afterLoginUsers.php
Last active April 26, 2017 01:00
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.
<?php
// Enrico Simonetti
// enricosimonetti.com
// custom/logichooks/modules/Users/afterLoginUsers.php
class afterLoginUsers
{
public function callAfterLogin($bean, $event, $args)
@esimonetti
esimonetti / afterEntryPoint.php
Last active November 29, 2017 20:02
Disable Activity Stream on Sugar 7 - Application logic hook to disable writes everywhere and example of vardefs to disable module specific UI
<?php
// Enrico Simonetti
// enricosimonetti.com
// custom/logichooks/application/afterEntryPoint.php
class afterEntryPoint
{
public function disableActivityStream($event, $arguments)
@esimonetti
esimonetti / SugarACLLock.php
Last active November 30, 2023 03:52
SugarCRM v7 - Conditional record locking through ACL's customisation - Reach out for SugarCRM consulting: https://www.naonis.tech/services/sugar-crm.html
<?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 / SugarACLReadOnly.php
Last active November 30, 2023 03:49
SugarCRM v7 - Default a module to Read only through ACL's customisation - Reach out for SugarCRM consulting: https://www.naonis.tech/services/sugar-crm.html
<?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 / arduino_temperature_driven_fan.ino
Last active December 14, 2017 06:31
Arduino Temperature Driven Fan - Driving a two speeds fan with an Arduino, based on the environment temperature
#include <EEPROM.h>
#include <EasyButton.h>
#include <LiquidCrystal.h>
#include <dht.h>
// board led
const int board_led = 13;
// eeprom value
byte eeprom_value;
@esimonetti
esimonetti / CustomPersonFilterApi.php
Last active August 29, 2015 14:23
Modify Users REST API to retrieve all Users/Employees. The system normally allows retrieve of records with status or employee_status='Active' and with portal_only='0'
<?php
//
// Enrico Simonetti
//
//
// Description:
// Modify Users REST API to retrieve all Users/Employees
// The system normally allows retrieve of records with status or employee_status='Active' and with portal_only='0'
//
@esimonetti
esimonetti / errors.php
Last active January 30, 2016 02:38
PHP driven error messages in Sugar v7 - Works for sidecar and BWC modules
// Assuming that $b is a valid bean instance...
// Assuming we are editing the record...
// On SugarApiException($app_strings[$error_app_label], null, null, 422, 'my_error_code_sample');
// "my_error_code_sample" is displayed on the output as "error"
// $app_strings[$error_app_label] is displayed on the output as "error_message"
$error_app_label = 'LBL_MY_ERROR_MESSAGE';
if(!empty($b->module_name) && isModuleBWC($b->module_name))
{
@esimonetti
esimonetti / motor-with-mosfet-increasing-speed.ino
Created March 4, 2015 03:56
Control a DC motor speed with Arduino and a MOSFET - Increasing speed
const int motorpin = 5;
int motor_speed = 0;
void setup()
{
Serial.begin(57600);
pinMode(motorpin, OUTPUT);
}
void loop()
@esimonetti
esimonetti / motor-with-mosfet-three-speed.ino
Created March 4, 2015 03:54
Control a DC motor speed with Arduino and a MOSFET - Three speeds
const int motorpin = 5;
const int divider = 3;
int motor_speed = 0;
void setup()
{
Serial.begin(57600);
pinMode(motorpin, OUTPUT);
}
@esimonetti
esimonetti / inboundEmailsLogic.php
Last active June 2, 2016 13:36
SugarCRM - Inbound Email Case Creation - Custom Record Assignment and Case reopening - custom/modules/Emails/inboundEmailsLogic.php
<?php
// Enrico Simonetti
// 11/09/2014
// Tested on SugarCRM 6.5.17
// Create standard Inbound Email to Case functionality, using by default an empty team ($inbound_cases_team) for round robin assignment
// Then define the custom assignment rules
/*
Logic hook entries will look something like this... if entered manually