/** * The collector method for modules. Gets metadata for all of the module specific data * * @param $moduleName The name of the module to collect metadata about. * @param MetaDataContextInterface|null $context Metadata context * @return array An array of hashes containing the metadata. Empty arrays are * returned in the case of no metadata. */ public function getModuleData($moduleName, MetaDataContextInterface $context = null) { require_once 'include/SugarSearchEngine/SugarSearchEngineMetadataHelper.php'; $vardefs = $this->getVarDef($moduleName); if (!empty($vardefs['fields']) && is_array($vardefs['fields'])) { require_once 'include/MassUpdate.php'; $vardefs['fields'] = MassUpdate::setMassUpdateFielddefs($vardefs['fields'], $moduleName); } $data['fields'] = isset($vardefs['fields']) ? $vardefs['fields'] : array(); // Add the _hash for the fields array $data['fields']['_hash'] = md5(serialize($data['fields'])); $data['nameFormat'] = isset($vardefs['name_format_map']) ? $vardefs['name_format_map'] : null; $data['views'] = $this->getModuleViews($moduleName, $context); $data['datas'] = $this->getModuleDatas($moduleName); $data['layouts'] = $this->getModuleLayouts($moduleName); $data['fieldTemplates'] = $this->getModuleFields($moduleName); $data['menu'] = $this->getModuleMenu($moduleName); $data['config'] = $this->getModuleConfig($moduleName); $data['filters'] = $this->getModuleFilters($moduleName); // Indicate whether Module Has duplicate checking enabled --- Rules must exist and Enabled flag must be set $data['dupCheckEnabled'] = isset($vardefs['duplicate_check']) && isset($vardefs['duplicate_check']['enabled']) && $vardefs['duplicate_check']['enabled'] === true; // Indicate whether a Module has activity stream enabled $data['activityStreamEnabled'] = ActivityQueueManager::isEnabledForModule($moduleName); $data['ftsEnabled'] = SugarSearchEngineMetadataHelper::isModuleFtsEnabled($moduleName); // TODO we need to have this kind of information on the module itself not hacked around on globals $data['isBwcEnabled'] = in_array($moduleName, $GLOBALS['bwcModules']); $seed = BeanFactory::newBean($moduleName); $data['globalSearchEnabled'] = $this->getGlobalSearchEnabled($seed, $vardefs, $this->platforms[0]); if (!empty($seed)) { $favoritesEnabled = $seed->isFavoritesEnabled() !== false ? true : false; $data['favoritesEnabled'] = $favoritesEnabled; } // Currently no way to disable following // But this flag is here in case we add that feature in the future $data['followingEnabled'] = true; $data["_hash"] = $this->hashChunk($data); return $data; }