Skip to content

Instantly share code, notes, and snippets.

View hatimalam's full-sized avatar

Hatim Alam hatimalam

View GitHub Profile
@hatimalam
hatimalam / enable_acl_vardef.php
Created June 25, 2019 05:08
Enable ACL vardef for Product Catalog
<?php
/**
* Overriding PC bean to enable ACL
* custom/Extension/modules/ProductTemplates/Ext/Vardefs/enable_acl_vardef.php
*/
$dictionary['ProductTemplate']['acls'] = array('SugarACLLockedFields' => true, 'SugarACLStatic' => true);
@hatimalam
hatimalam / custom_pc_bean_registry.php
Created June 25, 2019 04:47
Product Catalog custom bean registry
<?php
/**
* Overriding PC bean to enable ACL
* custom/Extension/application/Ext/Include/custom_pc_bean_registry.php
*/
$objectList['ProductTemplates'] = 'ProductTemplate';
$beanList['ProductTemplates'] = 'CustomProductTemplate';
$beanFiles['CustomProductTemplate'] = 'custom/modules/ProductTemplates/ProductTemplate.php';
$moduleList[] = 'ProductTemplates';
@hatimalam
hatimalam / ProductTemplate.php
Created June 25, 2019 04:46
Custom Product Catalog Bean File
<?php
/**
* Overriding PC bean to enable ACL
* custom/modules/ProductTemplates/ProductTemplate.php
*/
require_once("modules/ProductTemplates/ProductTemplate.php");
class CustomProductTemplate extends ProductTemplate
{
public function __construct()
{
@hatimalam
hatimalam / default.php
Created November 14, 2017 15:00
Adding new field to list view search - SugarCRM 7.x
<?php
/** custom filter file to add new field to module list view search **/
//push your new field to quicksearch_field array
$viewdefs['Accounts']['base']['filter']['default']['quicksearch_field'][] = 'account_number_c';
//give priority > 0
$viewdefs['Accounts']['base']['filter']['default']['quicksearch_priority'] = 2;
?>
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class CheckOppDiscount {
function check_opp_discount($bean, $event, $arguments) {
//check if discount percentage is >25%
if($bean->opp_discount_c > 25) {
//get assigned user bean
$assigned_user_bean = BeanFactory::getBean("Users", $bean->assigned_user_id);
//fetch assigned user's manager
<?php
$hook_version = 1;
$hook_array = array();
$hook_array['before_save'] = array();
$hook_array['before_save'][] = array(
1,
'Check discount percentage on opp save',
'custom/modules/Opportunities/customLogicHooks.php',
'CheckOppDiscount',
'check_opp_discount'
@hatimalam
hatimalam / TestContactApi.php
Created March 2, 2016 19:19
Test API endpoint to showcase Sugar Notification
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class TestContactAPi extends SugarApi
{
public function registerApiRest()
{
return array(
'testContactUpdate' => array(
//request type
@hatimalam
hatimalam / customLogicHooks.php
Last active February 22, 2016 19:53
Logic hook action method to create new Sugar Notificaiton on post or comment in Activity Stream.
<?php
/**
* Desc: Before save logic hook to create Sugar Notification if new post or comment in Activity Stream
* Written by: Hatim Alam
* Dated: 21st Feb 2016
*/
class SugarNotifyUser {
function notify_user_on_post_comment($bean, $event, $arguments) {
@hatimalam
hatimalam / create_notification_save.php
Created February 22, 2016 04:27
before save logic hook
<?php
$hook_version = 1;
$hook_array = array();
$hook_array['before_save'] = array();
$hook_array['before_save'][] = array(
1,
'Create Sugar Notification on any new post or comment',
'custom/modules/ActivityStream/Activities/customLogicHook.php',
'SugarNotifyUser',
'notify_user_on_post_comment'