当前位置: 首页>>代码示例>>PHP>>正文


PHP ConnectorUtils::cleanMetaDataFile方法代码示例

本文整理汇总了PHP中ConnectorUtils::cleanMetaDataFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectorUtils::cleanMetaDataFile方法的具体用法?PHP ConnectorUtils::cleanMetaDataFile怎么用?PHP ConnectorUtils::cleanMetaDataFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectorUtils的用法示例。


在下文中一共展示了ConnectorUtils::cleanMetaDataFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_SaveModifyDisplay

 function action_SaveModifyDisplay()
 {
     if (empty($_REQUEST['display_sources'])) {
         return;
     }
     require_once 'include/connectors/utils/ConnectorUtils.php';
     require_once 'include/connectors/sources/SourceFactory.php';
     $connectors = ConnectorUtils::getConnectors();
     $connector_keys = array_keys($connectors);
     $modules_sources = ConnectorUtils::getDisplayConfig();
     if (!is_array($modules_sources)) {
         $modules_sources = (array) $modules_sources;
     }
     $sources = array();
     $values = array();
     $new_modules_sources = array();
     if (!empty($_REQUEST['display_values'])) {
         $display_values = explode(',', $_REQUEST['display_values']);
         foreach ($display_values as $value) {
             $entry = explode(':', $value);
             $new_modules_sources[$entry[1]][$entry[0]] = $entry[0];
         }
     }
     //These are the sources that were modified.
     //We only update entries for these sources that have been changed
     $display_sources = explode(',', $_REQUEST['display_sources']);
     foreach ($display_sources as $source) {
         $sources[$source] = $source;
     }
     //foreach
     $removedModules = array();
     //Unset entries that have all sources removed
     foreach ($modules_sources as $module => $source_entries) {
         foreach ($source_entries as $source_id) {
             if (!empty($sources[$source_id]) && empty($new_modules_sources[$module][$source_id])) {
                 unset($modules_sources[$module][$source_id]);
                 $removedModules[$module] = true;
             }
         }
     }
     $removedModules = array_keys($removedModules);
     foreach ($removedModules as $key) {
         if (empty($new_modules_sources[$key])) {
             ConnectorUtils::cleanMetaDataFile($key);
         }
     }
     //Update based on new_modules_sources
     foreach ($new_modules_sources as $module => $enabled_sources) {
         //If the module is not in $modules_sources add it there
         if (empty($modules_sources[$module])) {
             $modules_sources[$module] = $enabled_sources;
         } else {
             foreach ($enabled_sources as $source_id) {
                 if (empty($modules_sources[$module][$source_id])) {
                     $modules_sources[$module][$source_id] = $source_id;
                 }
             }
             //foreach
         }
     }
     //foreach
     //Should we just remove entries where all sources are disabled?
     $unset_modules = array();
     foreach ($modules_sources as $module => $mapping) {
         if (empty($mapping)) {
             $unset_modules[] = $module;
         }
     }
     foreach ($unset_modules as $mod) {
         unset($modules_sources[$mod]);
     }
     if (!write_array_to_file('modules_sources', $modules_sources, CONNECTOR_DISPLAY_CONFIG_FILE)) {
         //Log error and return empty array
         $GLOBALS['log']->fatal("Cannot write \$modules_sources to " . CONNECTOR_DISPLAY_CONFIG_FILE);
     }
     $sources_modules = array();
     foreach ($modules_sources as $module => $source_entries) {
         foreach ($source_entries as $id) {
             $sources_modules[$id][$module] = $module;
         }
     }
     //Now update the searchdefs and field mapping entries accordingly
     require 'modules/Connectors/metadata/searchdefs.php';
     $originalSearchDefs = $searchdefs;
     $connectorSearchDefs = ConnectorUtils::getSearchDefs();
     $searchdefs = array();
     foreach ($sources_modules as $source_id => $modules) {
         foreach ($modules as $module) {
             $searchdefs[$source_id][$module] = !empty($connectorSearchDefs[$source_id][$module]) ? $connectorSearchDefs[$source_id][$module] : (!empty($originalSearchDefs[$source_id][$module]) ? $originalSearchDefs[$source_id][$module] : array());
         }
     }
     //Write the new searchdefs out
     if (!write_array_to_file('searchdefs', $searchdefs, 'custom/modules/Connectors/metadata/searchdefs.php')) {
         $GLOBALS['log']->fatal("Cannot write file custom/modules/Connectors/metadata/searchdefs.php");
     }
     //Unset the $_SESSION['searchDefs'] variable
     if (isset($_SESSION['searchDefs'])) {
         unset($_SESSION['searchDefs']);
     }
     //Clear mapping file if needed (this happens when all modules are removed from a source
//.........这里部分代码省略.........
开发者ID:nartnik,项目名称:sugarcrm_test,代码行数:101,代码来源:controller.php


注:本文中的ConnectorUtils::cleanMetaDataFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。