/**
  * Determine if a module is FTS enabled.
  *
  * @param $module
  * @return bool
  */
 protected function isModuleFtsEnabled($module)
 {
     return SugarSearchEngineMetadataHelper::isModuleFtsEnabled($module);
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * This function is used to determine the search engine to use
  * @param $api ServiceBase The API class of the request
  * @param $args array The arguments array passed in from the API
  * @param $options array An array of options to pass through to the search engine, they get translated to the $searchOptions array so you can see exactly what gets passed through
  * @return string name of the Search Engine
  */
 protected function determineSugarSearchEngine(ServiceBase $api, array $args, array $options)
 {
     require_once 'include/SugarSearchEngine/SugarSearchEngineMetadataHelper.php';
     /*
         How to determine which Elastic Search
         1 - Not Portal
         2 - All Modules are full_text_search = true
         4 - not order by
     */
     /*
      * If a module isn't FTS switch to spot search.  Global Search should be done with either the enabled modules
      * Using the new ServerInfo endpoint OR passing in a blank module list.
      */
     if (!empty($options['moduleList'])) {
         foreach ($options['moduleList'] as $module) {
             if (!SugarSearchEngineMetadataHelper::isModuleFtsEnabled($module)) {
                 return 'SugarSearchEngine';
             }
         }
     }
     /*
      * Currently we cannot do an order by in FTS.  Thus any ordering must be done using the Spot Search
      */
     if (isset($options['orderBySetByApi']) && $options['orderBySetByApi'] == true) {
         return 'SugarSearchEngine';
     }
     // if the query is empty no reason to pass through FTS they want a normal list view.
     if (empty($args['q'])) {
         return 'SugarSearchEngine';
     }
     $fts = SugarSearchEngineFactory::getFTSEngineNameFromConfig();
     //everything is groovy for FTS, get the FTS Engine Name from the conig
     if (!empty($fts)) {
         return $fts;
     }
     return 'SugarSearchEngine';
 }