Skip to content

Instantly share code, notes, and snippets.

@eggsurplus
eggsurplus / custom_dropdown_vardef.php
Created October 2, 2012 05:11
A custom dropdown field utilizing a function
//custom/Extension/modules/Project/Ext/Vardefs/from_template_c.php
$dictionary['Project']['fields']['from_template_c'] = array (
'name' => 'from_template_c',
'vname' => 'LBL_FROM_TEMPLATE',
'function' => 'getProjectTemplates',
'type' => 'enum',
'len' => '100',
'comment' => 'The template that the project was created from.',
);
@eggsurplus
eggsurplus / custom_util_function.php
Created October 2, 2012 05:14
A custom util function
//custom/Extension/application/Ext/Utils/getProjectTemplates.php
function getProjectTemplates(){
static $projectTemplates = null;
if(!$projectTemplates){
global $db;
$query = "SELECT id, name FROM project where deleted = 0 and is_template = 1 order by name asc ";
$result = $db->query($query, false);
@eggsurplus
eggsurplus / SOCustomCase.php
Created October 18, 2012 02:22
Safely Customizing a Core Bean in SugarCRM - Part 1. SOCustomCase
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
//custom/modules/Cases/SOCustomCase.php
require_once("modules/Cases/Case.php");
class SOCustomCase extends aCase {
function get_list_view_data(){
$temp_array = parent::get_list_view_data(); //let it work as it does by default
@eggsurplus
eggsurplus / controller.php
Created October 18, 2012 02:31
Safely Customizing a Core Bean in SugarCRM - Part 1. CustomCasesController
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
//custom/modules/Cases/controller.php
require_once('include/MVC/Controller/SugarController.php');
require_once('custom/modules/Cases/SOCustomCase.php');
class CustomCasesController extends SugarController {
function action_listview() {
$this->bean = new SOCustomCase();
@eggsurplus
eggsurplus / contract_products_utils.php
Created November 8, 2012 16:46
Manifest Utils Directive in a SugarCRM Module - Function
// /extensions/application/utils/contract_products_utils.php
function getProducts(){
static $products = null;
if(!$products){
global $db;
$query = "SELECT id, name FROM products where deleted = 0 order by name asc ";
$result = $db->query($query, false);
@eggsurplus
eggsurplus / product_dropdown_vardefs.php
Created November 8, 2012 16:46
Manifest Utils Directive in a SugarCRM Module - Vardefs
// /extensions/modules/Contracts/vardefs/product_dropdown_vardefs.php
$dictionary['Contract']['fields']['product_c'] = array (
'name' => 'product_c',
'vname' => 'LBL_PRODUCT',
'function' => 'getProducts',
'type' => 'enum',
'len' => '100',
);
@eggsurplus
eggsurplus / manifest.php
Created November 8, 2012 16:47
Manifest Utils Directive in a SugarCRM Module - Manifest
//manifest.php
//...............
'vardefs' =>
array (
//copies to custom/Extension/modules/Contracts/Ext/Vardefs
array (
'from' => '<basepath>/extensions/modules/Contracts/vardefs/product_dropdown_vardefs.php',
'to_module' => 'Contracts',
),
),
@eggsurplus
eggsurplus / config.html
Created November 15, 2012 16:47
Saving Admin Options For A Custom SugarCRM Module - config screen
<form name="ConfigureSettings" id="EditView" method="POST" >
<input type="hidden" name="module" value="abc_Module">
<input type="hidden" name="action" value=”SaveConfig”>
API URL: <input type=”text” name=”api_url” value=”” size=”35”/><br/>
<input type='submit' value='Save Configuration' />
</form>
@eggsurplus
eggsurplus / SaveConfig.php
Created November 15, 2012 16:48
Saving Admin Options For A Custom SugarCRM Module - SaveConfig
require_once('modules/Administration/Administration.php');
$administration = new Administration();
//do data validation, etc here
//....
//save the setting to the config table
$administration->saveSetting("abc_Module", "api_url", $_REQUEST['api_url']);
@eggsurplus
eggsurplus / config.php
Created November 15, 2012 16:49
Saving Admin Options For A Custom SugarCRM Module - config
require_once('modules/Administration/Administration.php');
$administration = new Administration();
$administration->retrieveSettings();
$api_url = $administration->settings['abc_Module_api_url'];