File: /home/nexper/public_html/crm/custom/modules/EmailTemplates/EmailTemplate.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once("modules/EmailTemplates/EmailTemplate.php");
// EmailTemplate is used to store email email_template information.
class CustomEmailTemplate extends EmailTemplate {
function generateFieldDefsJS2() {
global $current_user;
$contact = new Contact();
$account = new Account();
$lead = new Lead();
$prospect = new Prospect();
$event = new FP_events();
$loopControl = array(
'Contacts' => array(
'Contacts' => $contact,
'Leads' => $lead,
'Prospects' => $prospect,
),
'Accounts' => array(
'Accounts' => $account,
),
'Users' => array(
'Users' => $current_user,
),
'Events' => array(
'Events' => $event,
),
);
$prefixes = array(
'Contacts' => 'contact_',
'Accounts' => 'account_',
'Users' => 'contact_user_',
'Events' => 'event_',
);
$collection = array();
foreach($loopControl as $collectionKey => $beans) {
$collection[$collectionKey] = array();
foreach($beans as $beankey => $bean) {
foreach($bean->field_defs as $key => $field_def) {
if( ($field_def['type'] == 'relate' && empty($field_def['custom_type'])) ||
($field_def['type'] == 'assigned_user_name' || $field_def['type'] =='link') ||
($field_def['type'] == 'bool') ||
(in_array($field_def['name'], $this->badFields)) ) {
continue;
}
if(!isset($field_def['vname'])) {
//echo $key;
}
// valid def found, process
$optionKey = strtolower("{$prefixes[$collectionKey]}{$key}");
$optionLabel = preg_replace('/:$/', "", translate($field_def['vname'], $beankey));
$dup=1;
foreach ($collection[$collectionKey] as $value){
if($value['name']==$optionKey){
$dup=0;
break;
}
}
if($dup)
$collection[$collectionKey][] = array("name" => $optionKey, "value" => $optionLabel);
}
}
}
$json = getJSONobj();
$ret = "var field_defs = ";
$ret .= $json->encode($collection, false);
$ret .= ";";
return $ret;
}
}