Skip to content

Instantly share code, notes, and snippets.

@eggsurplus
eggsurplus / AddSecurityGroup.php
Created October 15, 2015 01:55
Add a default SecurityGroup for any newly created user
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Add a default SecurityGroup for any newly created user
*/
class AddSecurityGroup
{
function add_default_group($bean, $event, $arguments)
{
@eggsurplus
eggsurplus / OpportunitiesByLeadSourceByOutcomeDashlet.php
Created August 20, 2015 21:01
Adding SecuritySuite support to a chart
<?php
//.........
protected function constuctQuery()
{
$query = "SELECT lead_source,sales_stage,sum(amount_usdollar/1000) as total, ".
"count(*) as opp_count FROM opportunities ";
$query .= " WHERE opportunities.deleted=0 ";
if ( count($this->lsbo_ids) > 0 )
$query .= "AND opportunities.assigned_user_id IN ('".implode("','",$this->lsbo_ids)."') ";
if ( count($this->lsbo_lead_sources) > 0 )
@eggsurplus
eggsurplus / header.php
Created September 20, 2014 18:22
header.php for wiki-profileactions
<?php
$viewdefs['base']['layout']['header'] = array(
'components' =>
array(
array(
'layout' => 'module-list',
),
array(
'view' => 'globalsearch',
@eggsurplus
eggsurplus / wiki-profileactions.php
Created September 20, 2014 18:20
wiki-profileactions.php
<?php
require_once('clients/base/views/profileactions/profileactions.php');
$viewdefs['base']['view']['wiki-profileactions'] = $viewdefs['base']['view']['profileactions'];
@eggsurplus
eggsurplus / wiki-profileactions.js
Created September 20, 2014 18:19
wiki-profileactions.js
({
extendsFrom: 'ProfileactionsView',
initialize: function(options) {
this._super('initialize', [options]);
},
setCurrentUserData: function() {
app.view.invokeParent(this, {type: 'view', name: 'profileactions', method: 'setCurrentUserData'});
}
})
@eggsurplus
eggsurplus / moduleadminoption.php
Created July 23, 2014 15:59
Reuse admin panel
<?php
//check for existing installed modules
$mycompany_admin_options_defs = array();
if(!empty($admin_group_header['MyCompany']))
{
$mycompany_admin_options_defs = $admin_group_header['MyCompany'][3];
}
//add this module to it
$mycompany_admin_options_defs['Administration']['thismodule_license']= array('helpInline','LBL_THISMODULE_LICENSE_TITLE','LBL_THISMODULE_LICENSE','./index.php?module=ThisModule&action=license');
@eggsurplus
eggsurplus / WebToLeadCapture.php
Created July 14, 2014 17:44
Partial WebToLeadCapture.php for updating existing lead
if(empty($lead->id)) {
$lead->id = create_guid();
$lead->new_with_id = true;
}
//BEGIN - eggsurplus - update existing leads
if(!empty($_POST['record'])) {
//get the existing bean (returns null if a bad ID is passed so a new Lead will be created still)
$lead = BeanFactory::getBean('Leads',$_POST['record']);
$lead->new_with_id = false;
}
@eggsurplus
eggsurplus / Capture.php
Created July 14, 2014 15:32
Alter lead capture form to allow updating existing leads
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
@eggsurplus
eggsurplus / editviewdefs.php
Created July 14, 2014 15:18
custom/modules/Employees/editviewdefs.php
<?php
$viewdefs ['Employees'] =
array (
'EditView' =>
array (
'templateMeta' =>
array (
'maxColumns' => '2',
'widths' =>
array (
@eggsurplus
eggsurplus / Save.php
Created June 3, 2014 18:15
Employee module doesn't use the MVC framework when saving so custom field types do not save.
<?php
// This file goes in /custom/modules/Employees/Save.php
// For SugarCRM CE 6.5.16 - the relevant code is in the CUSTOM CODE section commented below
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/MySettings/TabController.php');
$tabs_def = urldecode(isset($_REQUEST['display_tabs_def']) ? $_REQUEST['display_tabs_def'] : '');
$DISPLAY_ARR = array();
parse_str($tabs_def,$DISPLAY_ARR);