/** * Constructor for the bean, it performs following tasks: * * 1. Initalized a database connections * 2. Load the vardefs for the module implemeting the class. cache the entries * if needed * 3. Setup row-level security preference * All implementing classes must call this constructor using the parent::SugarBean() class. * * @param array $arr row of data fetched from the database. * @return nothing */ function SugarBean() { global $dictionary, $current_user; static $loaded_defs = array(); $this->db = DBManagerFactory::getInstance(); $this->dbManager =& DBManagerFactory::getInstance(); if (false == $this->disable_vardefs && empty($loaded_defs[$this->object_name]) || !empty($GLOBALS['reload_vardefs'])) { VardefManager::loadVardef($this->module_dir, $this->object_name); // build $this->column_fields from the field_defs if they exist if (!empty($dictionary[$this->object_name]['fields'])) { foreach ($dictionary[$this->object_name]['fields'] as $key => $value_array) { $column_fields[] = $key; } $this->column_fields = $column_fields; } //setup custom fields if (!isset($this->custom_fields) && empty($this->disable_custom_fields)) { $this->setupCustomFields($this->module_dir); } //load up field_arrays from CacheHandler; if (empty($this->list_fields)) { $this->list_fields = LoadCachedArray($this->module_dir, $this->object_name, 'list_fields'); } if (empty($this->column_fields)) { $this->column_fields = LoadCachedArray($this->module_dir, $this->object_name, 'column_fields'); } if (empty($this->required_fields)) { $this->required_fields = LoadCachedArray($this->module_dir, $this->object_name, 'required_fields'); } if (isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) { $this->field_name_map = $dictionary[$this->object_name]['fields']; $this->field_defs = $dictionary[$this->object_name]['fields']; if (!empty($dictionary[$this->object_name]['optimistic_locking'])) { $this->optimistic_lock = true; } } $loaded_defs[$this->object_name]['column_fields'] =& $this->column_fields; $loaded_defs[$this->object_name]['list_fields'] =& $this->list_fields; $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; } else { $this->column_fields =& $loaded_defs[$this->object_name]['column_fields']; $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; $this->required_fields =& $loaded_defs[$this->object_name]['required_fields']; $this->field_name_map =& $loaded_defs[$this->object_name]['field_name_map']; $this->field_defs =& $loaded_defs[$this->object_name]['field_defs']; $this->added_custom_field_defs = true; if (!isset($this->custom_fields)) { $this->setupCustomFields($this->module_dir, false); } if (!empty($dictionary[$this->object_name]['optimistic_locking'])) { $this->optimistic_lock = true; } } if ($this->bean_implements('ACL') && !empty($GLOBALS['current_user'])) { $this->acl_fields = isset($dictionary[$this->object_name]['acl_fields']) && $dictionary[$this->object_name]['acl_fields'] === false ? false : true; } $this->populateDefaultValues(); }
function SugarBean() { global $dictionary, $current_user; static $loaded_defs = array(); $this->db =& PearDatabase::getInstance(); $this->dbManager =& DBManagerFactory::getInstance(); if (empty($loaded_defs[$this->object_name])) { if (isset($this->module_dir) && isset($this->object_name) && !isset($dictionary[$this->object_name])) { if (file_exists('modules/' . $this->module_dir . '/vardefs.php')) { include_once 'modules/' . $this->module_dir . '/vardefs.php'; } if (file_exists('custom/modules/' . $this->module_dir . '/Ext/Vardefs/vardefs.ext.php')) { include_once 'custom/modules/' . $this->module_dir . '/Ext/Vardefs/vardefs.ext.php'; } } //load up field_arrays from CacheHandler; if (empty($this->list_fields)) { $this->list_fields = LoadCachedArray($this->module_dir, $this->object_name, 'list_fields'); } if (empty($this->column_fields)) { $this->column_fields = LoadCachedArray($this->module_dir, $this->object_name, 'column_fields'); } if (empty($this->required_fields)) { $this->required_fields = LoadCachedArray($this->module_dir, $this->object_name, 'required_fields'); } if (isset($dictionary[$this->object_name])) { $this->field_name_map = $dictionary[$this->object_name]['fields']; $this->field_defs = $dictionary[$this->object_name]['fields']; if (isset($dictionary[$this->object_name]['optimistic_locking']) && $dictionary[$this->object_name]['optimistic_locking']) { $this->optimistic_lock = true; } } //setup custom fields if (!isset($this->custom_fields) && empty($this->disable_custom_fields)) { $this->setupCustomFields($this->module_dir); } $loaded_defs[$this->object_name]['column_fields'] =& $this->column_fields; $loaded_defs[$this->object_name]['list_fields'] =& $this->list_fields; $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; } else { $this->column_fields =& $loaded_defs[$this->object_name]['column_fields']; $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; $this->required_fields =& $loaded_defs[$this->object_name]['required_fields']; $this->field_name_map =& $loaded_defs[$this->object_name]['field_name_map']; $this->field_defs =& $loaded_defs[$this->object_name]['field_defs']; $this->bean->added_custom_field_defs = true; if (!isset($this->custom_fields)) { $this->setupCustomFields($this->module_dir, false); } if (!empty($dictionary[$this->object_name]['optimistic_locking'])) { $this->optimistic_lock = true; } } }