/** * this method is called within a vardefs.php file which extends from a SugarObject. * It is meant to load the vardefs from the SugarObject. */ function createVardef($module, $object, $templates = array('default'), $object_name = false) { global $dictionary; //reverse the sort order so priority goes highest to lowest; $templates = array_reverse($templates); foreach ($templates as $template) { VardefManager::addTemplate($module, $object, $template, $object_name); } LanguageManager::createLanguageFile($module, $templates); $vardef_paths = array('custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php'); //search a predefined set of locations for the vardef files foreach ($vardef_paths as $path) { if (file_exists($path)) { require $path; } } }
/** * this method is called within a vardefs.php file which extends from a SugarObject. * It is meant to load the vardefs from the SugarObject. * * @param string $module * @param string $object * @param array $templates * @param bool $object_name */ static function createVardef($module, $object, $templates = ['default'], $object_name = false) { global $dictionary; include_once 'modules/TableDictionary.php'; //reverse the sort order so priority goes highest to lowest; $templates = array_reverse($templates); foreach ($templates as $template) { VardefManager::addTemplate($module, $object, $template, $object_name); } LanguageManager::createLanguageFile($module, $templates); if (isset(VardefManager::$custom_disabled_modules[$module])) { $vardef_paths = ['custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php']; //search a predefined set of locations for the vardef files foreach ($vardef_paths as $path) { if (file_exists($path)) { require $path; } } } }
/** * this method is called within a vardefs.php file which extends from a SugarObject. * It is meant to load the vardefs from the SugarObject. */ static function createVardef($module, $object, $templates = array('default'), $object_name = false) { global $dictionary; include_once 'modules/TableDictionary.php'; if (isset($GLOBALS['dictionary'][$object]['uses'])) { // Load in the vardef 'uses' first $templates = array_merge($GLOBALS['dictionary'][$object]['uses'], $templates); unset($GLOBALS['dictionary'][$object]['uses']); // createVardef auto-adds the 'default' template, so to avoid using it twice // among avoiding using other templates twice let's make sure the templates // are unique $templates = array_unique($templates); } // Load up fields if there is a need for that. Introduced with the taggable // template if (isset($GLOBALS['dictionary'][$object]['load_fields'])) { $lf = $GLOBALS['dictionary'][$object]['load_fields']; // Make sure we actually have a fields array to work with if (empty($GLOBALS['dictionary'][$object]['fields'])) { $GLOBALS['dictionary'][$object]['fields'] = array(); } if (is_string($lf) && function_exists($lf)) { // Merge fields from the function onto the known fields $GLOBALS['dictionary'][$object]['fields'] = array_merge($GLOBALS['dictionary'][$object]['fields'], $lf()); } elseif (is_array($lf) && isset($lf['class']) && isset($lf['method'])) { $class = $lf['class']; $method = $lf['method']; // Merge fields from the method call onto the known fields $GLOBALS['dictionary'][$object]['fields'] = array_merge($GLOBALS['dictionary'][$object]['fields'], $class::$method()); } } //reverse the sort order so priority goes highest to lowest; $templates = array_reverse($templates); foreach ($templates as $template) { VardefManager::addTemplate($module, $object, $template, $object_name); } // Some of the templates might have loaded templates if (isset($GLOBALS['dictionary'][$object]['templates'])) { $templates = $GLOBALS['dictionary'][$object]['templates']; } LanguageManager::createLanguageFile($module, $templates); if (isset(VardefManager::$custom_disabled_modules[$module])) { $vardef_paths = array(SugarAutoLoader::loadExtension("vardefs", $module), 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php'); //search a predefined set of locations for the vardef files foreach ($vardef_paths as $path) { // file_exists here is only for custom/Extension since loadExtension already checks // the file map and will return false if something's wrong if (!empty($path) && file_exists($path)) { require $path; } } } // Handle unsetting of fields as per the defs. Do this last to make sure // all extension fields have loaded if (isset($GLOBALS['dictionary'][$object]['unset_fields'])) { $uf = $GLOBALS['dictionary'][$object]['unset_fields']; if (is_string($uf)) { unset($GLOBALS['dictionary'][$object]['fields'][$uf]); } elseif (is_array($uf)) { foreach ($uf as $f) { unset($GLOBALS['dictionary'][$object]['fields'][$f]); } } } }