Beispiel #1
0
 /**
  * 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;
             }
         }
     }
 }
Beispiel #3
0
 static function addTemplate($module, $object, $template, $object_name = false)
 {
     // Normalize the template name
     if ($template == 'default') {
         $template = 'basic';
     }
     // The ActivityStream has subdirectories but this code doesn't expect it
     // let's fix it up here
     if (strpos($module, '/') !== false) {
         $tmp = explode('/', $module);
         $module = array_pop($tmp);
     }
     // Verify that we should use this template for BWC modules
     if (self::ignoreBWCTemplate($module, $template)) {
         return;
     }
     $templates = array();
     $fields = array();
     if (empty($object_name)) {
         $object_name = $object;
     }
     $_object_name = strtolower($object_name);
     if (!empty($GLOBALS['dictionary'][$object]['table'])) {
         $table_name = $GLOBALS['dictionary'][$object]['table'];
     } else {
         $table_name = strtolower($module);
     }
     if (empty($templates[$template])) {
         foreach (SugarAutoLoader::existingCustom('include/SugarObjects/templates/' . $template . '/vardefs.php', 'include/SugarObjects/implements/' . $template . '/vardefs.php') as $path) {
             require $path;
             $templates[$template] = $vardefs;
         }
     }
     if (!empty($templates[$template])) {
         static $merge_types = array('fields', 'relationships', 'indices', 'name_format_map', 'visibility', 'acls');
         foreach ($merge_types as $merge_type) {
             if (empty($GLOBALS['dictionary'][$object][$merge_type])) {
                 $GLOBALS['dictionary'][$object][$merge_type] = array();
             }
             if (!empty($templates[$template][$merge_type]) && is_array($templates[$template][$merge_type])) {
                 $GLOBALS['dictionary'][$object][$merge_type] = array_merge($templates[$template][$merge_type], $GLOBALS['dictionary'][$object][$merge_type]);
             }
         }
         /* The duplicate_check property is inherited in full unless already defined - merge has no meaning here */
         if (empty($GLOBALS['dictionary'][$object]['duplicate_check']) && !empty($templates[$template]['duplicate_check'])) {
             $GLOBALS['dictionary'][$object]['duplicate_check'] = $templates[$template]['duplicate_check'];
         }
         if (isset($templates[$template]['favorites']) && !isset($GLOBALS['dictionary'][$object]['favorites'])) {
             $GLOBALS['dictionary'][$object]['favorites'] = $templates[$template]['favorites'];
         }
         // maintain a record of this objects inheritance from the SugarObject templates...
         $GLOBALS['dictionary'][$object]['templates'][$template] = $template;
         if (!empty($templates[$template]['uses'])) {
             foreach ($templates[$template]['uses'] as $extraTemplate) {
                 VardefManager::addTemplate($module, $object, $extraTemplate, $object_name);
             }
         }
     }
 }