本文整理汇总了PHP中ConnectorUtils::getSearchDefs方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectorUtils::getSearchDefs方法的具体用法?PHP ConnectorUtils::getSearchDefs怎么用?PHP ConnectorUtils::getSearchDefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectorUtils
的用法示例。
在下文中一共展示了ConnectorUtils::getSearchDefs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* @see SugarView::display()
*/
public function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
$source_id = $_REQUEST['source_id'];
$connector_strings = ConnectorUtils::getConnectorStrings($source_id);
$is_enabled = ConnectorUtils::isSourceEnabled($source_id);
$modules_sources = array();
$sources = ConnectorUtils::getConnectors();
$display_data = array();
if ($is_enabled) {
$searchDefs = ConnectorUtils::getSearchDefs();
$searchDefs = !empty($searchDefs[$_REQUEST['source_id']]) ? $searchDefs[$_REQUEST['source_id']] : array();
$source = SourceFactory::getSource($_REQUEST['source_id']);
$field_defs = $source->getFieldDefs();
//Create the Javascript code to dynamically add the tables
$json = getJSONobj();
foreach ($searchDefs as $module => $fields) {
$disabled = array();
$enabled = array();
$enabled_fields = array_flip($fields);
$field_keys = array_keys($field_defs);
foreach ($field_keys as $index => $key) {
if (!empty($field_defs[$key]['hidden']) || empty($field_defs[$key]['search'])) {
continue;
}
if (!isset($enabled_fields[$key])) {
$disabled[$key] = !empty($connector_strings[$field_defs[$key]['vname']]) ? $connector_strings[$field_defs[$key]['vname']] : $key;
} else {
$enabled[$key] = !empty($connector_strings[$field_defs[$key]['vname']]) ? $connector_strings[$field_defs[$key]['vname']] : $key;
}
}
$modules_sources[$module] = array_merge($enabled, $disabled);
asort($disabled);
$display_data[$module] = array('enabled' => $enabled, 'disabled' => $disabled);
}
}
$this->ss->assign('no_searchdefs_defined', !$is_enabled);
$this->ss->assign('display_data', $display_data);
$this->ss->assign('modules_sources', $modules_sources);
$this->ss->assign('sources', $sources);
$this->ss->assign('mod', $GLOBALS['mod_strings']);
$this->ss->assign('APP', $GLOBALS['app_strings']);
$this->ss->assign('source_id', $_REQUEST['source_id']);
$this->ss->assign('theme', $GLOBALS['theme']);
$this->ss->assign('connector_language', $connector_strings);
echo $this->ss->fetch('modules/Connectors/tpls/search_properties.tpl');
}
示例2: 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
//.........这里部分代码省略.........
示例3: process
/**
* @see SugarView::process()
*/
public function process()
{
//Load Sources Here...
if (!empty($_REQUEST['merge_module'])) {
$this->_merge_module = $_REQUEST['merge_module'];
} else {
//Error
}
$moduleError = false;
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
$modules_sources = ConnectorUtils::getDisplayConfig();
if (empty($modules_sources)) {
$moduleError = true;
} else {
$this->_modules_sources = $modules_sources;
if (empty($this->_modules_sources[$this->_merge_module]) || empty($this->_modules_sources[$this->_merge_module])) {
$moduleError = true;
}
}
if ($moduleError) {
$GLOBALS['log']->error($GLOBALS['mod_strings']['ERROR_NO_CONNECTOR_DISPLAY_CONFIG_FILE']);
echo $GLOBALS['mod_strings']['ERROR_NO_CONNECTOR_DISPLAY_CONFIG_FILE'];
return;
}
$_SESSION['merge_module'] = $this->_merge_module;
$this->seed = BeanFactory::getBean($this->_merge_module, $_REQUEST['record']);
//search form
$searchdefs = ConnectorUtils::getSearchDefs();
$this->_searchDefs = isset($searchdefs) ? $searchdefs : array();
$mapped_fields = array();
unset($_SESSION['searchDefs'][$this->_merge_module][$this->seed->id]);
$sources = $modules_sources[$this->_merge_module];
$source = array_shift($sources);
foreach ($sources as $lsource) {
if (!empty($this->_searchDefs[$lsource][$this->_merge_module])) {
$s = ConnectorFactory::getInstance($lsource);
if ($s->getSource()->isEnabledInWizard()) {
$source_map = $s->getModuleMapping($this->_merge_module);
foreach ($this->_searchDefs[$lsource][$this->_merge_module] as $key) {
$beanKey = $key;
if (!empty($source_map[$key])) {
$beanKey = $source_map[$key];
}
if (!empty($this->seed->{$beanKey})) {
$val = $this->seed->{$beanKey};
if (is_object($val) && get_class($val) == 'SugarEmailAddress') {
$emailaddress = '';
if (!empty($val->addresses)) {
foreach ($val->addresses as $email) {
if (!empty($email['primary_address'])) {
$emailaddress = $email['email_address'];
break;
}
}
}
$val = $emailaddress;
}
} else {
$val = '';
}
$_SESSION['searchDefs'][$this->_merge_module][$this->seed->id][$lsource][$key] = $val;
}
//foreach
}
}
//if
}
//end search form
parent::process();
}
示例4: action_SaveModifySearch
function action_SaveModifySearch()
{
$search_sources = !empty($_REQUEST['search_sources']) ? explode(',', $_REQUEST['search_sources']) : array();
$search_values = !empty($_REQUEST['search_values']) ? explode(',', $_REQUEST['search_values']) : array();
//Build the source->module->fields mapping
$source_modules_fields = array();
foreach ($search_values as $id) {
$parts = explode(':', $id);
$source_modules_fields[$parts[0]][$parts[1]][] = $parts[2];
}
require_once 'include/connectors/utils/ConnectorUtils.php';
$searchdefs = ConnectorUtils::getSearchDefs();
//Now update for each source
foreach ($search_sources as $source) {
$existing_modules = !empty($searchdefs[$source]) ? array_keys($searchdefs[$source]) : array();
unset($searchdefs[$source]);
foreach ($existing_modules as $module) {
if (empty($source_modules_fields[$source][$module])) {
$searchdefs[$source][$module] = array();
}
}
if (!empty($source_modules_fields[$source])) {
foreach ($source_modules_fields[$source] as $module => $def) {
$searchdefs[$source][$module] = $def;
}
}
}
if (!file_exists('custom/modules/Connectors/metadata')) {
mkdir_recursive('custom/modules/Connectors/metadata');
}
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");
return array();
}
if (isset($_SESSION['searchDefs'])) {
unset($_SESSION['searchDefs']);
}
// refresh connector cache
require_once 'include/connectors/ConnectorManager.php';
$cm = new ConnectorManager();
$connectors = $cm->buildConnectorsMeta();
// BEGIN SUGAR INT
if (empty($_REQUEST['from_unit_test'])) {
// END SUGAR INT
header("Location: index.php?action=ConnectorSettings&module=Connectors");
// BEGIN SUGAR INT
}
// END SUGAR INT
}
示例5: uninstallSource
/**
* uninstallSource
*
* @param String $source String value of the id of the connector to un-install
* @return boolean $result boolean value indicating whether or not connector was un-installed
*/
public static function uninstallSource($source)
{
if (empty($source)) {
return false;
}
//Remove the source from the connectors.php file
$connectorsFile = 'custom/modules/Connectors/metadata/connectors.php';
if (file_exists($connectorsFile)) {
require $connectorsFile;
if (isset($connectors[$source])) {
unset($connectors[$source]);
if (!write_array_to_file('connectors', $connectors, $connectorsFile)) {
//Log error and return empty array
$GLOBALS['log']->fatal("Cannot write connectors to file");
return false;
}
}
}
//Update the display_config.php file to remove this source
$modules_sources = array();
require CONNECTOR_DISPLAY_CONFIG_FILE;
foreach ($modules_sources as $module => $mapping) {
foreach ($mapping as $id => $src) {
if ($src == $source) {
unset($modules_sources[$module][$id]);
}
}
}
//Make the directory for the config file
if (!file_exists('custom/modules/Connectors/metadata')) {
mkdir_recursive('custom/modules/Connectors/metadata');
}
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);
return false;
}
//Remove from searchdefs
$searchdefs = ConnectorUtils::getSearchDefs();
if (!empty($searchdefs[$source])) {
unset($searchdefs[$source]);
}
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");
return false;
}
return true;
}