Skip to content

Instantly share code, notes, and snippets.

View dmulvi's full-sized avatar

Danny Mulvihill dmulvi

View GitHub Profile
@dmulvi
dmulvi / PreventAccessHook.php
Created September 21, 2017 16:32
Prevent Access to module via Logic Hooks
<?php
class PreventAccessHook
{
public function preventAccess($bean, $event, $args) {
global $db, $current_user, $log;
// allow admins to view records
if ($current_user->is_admin && $event !== 'before_delete') {
return;
@dmulvi
dmulvi / tricks.md
Last active April 27, 2017 16:58
sublime-tricks

Find Non-ASCII characters Just use regex search with string:

[^\x00-\x7F]
@dmulvi
dmulvi / git-commands.sh
Last active May 23, 2017 17:28
Git Commands
# compare two branches (master and temp)
git log --graph --decorate --pretty=oneline --abbrev-commit master origin/master temp
# pull an old file and overwrite current
git checkout 'master@{7 days ago}' -- path/to/file.txt
# log changes before a date
git log --stat --before="2017-05-09"
@dmulvi
dmulvi / SugarCRM.sublime-syntax
Last active March 27, 2017 14:37
SugarCRM Log Syntax Highlighter
%YAML 1.2
---
name: SugarCRM Log
scope: source.sugarcrmlog
contexts:
main:
- match: \w{3}\s?\w{3}\s?\d{2}\s?\d{2}:\d{2}:\d{2}\s?\d{4}
scope: text.sugar_log_date_string
<?php
// this allows adding a new custom field to the core module table
<?php
$dictionary['Account']['fields']['new_field'] = array(
'name' => 'new_field',
'vname' => 'LBL_NEW_FIELD',
'type' => 'varchar',
'len' => '255',
@dmulvi
dmulvi / new.menu.php
Created April 29, 2016 00:43
Sugar 6 - Add Module Nav Item
<?php
// add this file to /custom/Extension/modules/Contacts/Ext/Menus/ and QRR
global $module_menu;
$module_menu[] = array('index.php?module=Contacts&action=Integrated_Search', 'Integrated Search', '');
@dmulvi
dmulvi / view.js
Last active February 20, 2016 17:30
SugarCRM - easily create a custom handlebars helper
/* just throw this in the initialize method of your custom view */
window.Handlebars.registerHelper('trimString', function(module) {
var moduleShort = module.substring(0,2);
return new Handlebars.SafeString(moduleShort);
});
// force extra lines
@dmulvi
dmulvi / fullname.js
Last active February 9, 2017 22:20
SugarCRM 7 - add fields to Full Name headerpane display (middle name, nick name, preferred name etc)
/*
* I only wanted to apply this change to the Contacts modules so I put this file in:
* custom/modules/Contacts/clients/base/fields/fullname/
*/
({
extendsFrom: 'FullnameField',
formatMap: {
'f': 'first_name',
'l': 'last_name',
@dmulvi
dmulvi / ExampleNonAuthApi.php
Last active February 9, 2016 13:08
SugarCRM 7 example of a noLoginRequired endpoint with simple client_id/access_key Authorization
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class ExampleNonAuthApi extends SugarApi
{
public function registerApiRest() {
return array(
'SampleEndpoint' => array(
'reqType' => 'POST',
@dmulvi
dmulvi / SugarWidgetSubPanelDeleteButton.php
Last active December 30, 2015 20:19
SugarCRM 6.x - Replace remove action with a delete action on subpanel
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*
* For this file start by copying the file located in /include/generic/SugarWidgets/SugarWidgetSubPanelRemoveButton.php
* into this new file and place it in /custom/include/generic/SugarWidgets/ (create the directories if needed)
*
* Then make the below updates to the file to enable actually deleting the record that the
* subpanel links to instead of only deleting the relationship and retaining the record.
*/