/** * @see SugarView::display() */ public function display() { global $mod_strings, $app_strings; require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $this->ss->assign('mod', $mod_strings); $this->ss->assign('APP', $app_strings); $connectors = ConnectorUtils::getConnectors(true); $required_fields = array(); //Get required fields for first connector only $connectorsToShow = $connectors; foreach ($connectors as $id => $entry) { $s = SourceFactory::getSource($id); $connector_strings = ConnectorUtils::getConnectorStrings($id); $fields = $s->getRequiredConfigFields(); if (!$s->isEnabledInAdminProperties() || empty($fields)) { unset($connectorsToShow[$id]); } else { if (empty($required_fields)) { foreach ($fields as $field_id) { $label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id; $required_fields[$id][$field_id] = $label; } } } } $this->ss->assign('SOURCES', $connectorsToShow); $this->ss->assign('REQUIRED_FIELDS', $required_fields); // Handle active tab selection $active_tab = isset($_REQUEST['active_tab']) ? $_REQUEST['active_tab'] : null; $this->ss->assign('ACTIVE_TAB', $active_tab); echo $this->getModuleTitle(false); $this->ss->display($this->getCustomFilePathIfExists('modules/Connectors/tpls/modify_properties.tpl')); }
public function display() { global $sugar_config; require_once 'include/connectors/sources/SourceFactory.php'; require_once 'include/connectors/utils/ConnectorUtils.php'; $source_id = $_REQUEST['source_id']; $connector_language = ConnectorUtils::getConnectorStrings($source_id); $source = SourceFactory::getSource($source_id); $properties = $source->getProperties(); $required_fields = array(); $config_fields = $source->getRequiredConfigFields(); $fields = $source->getRequiredConfigFields(); foreach ($fields as $field_id) { $label = isset($connector_language[$field_id]) ? $connector_language[$field_id] : $field_id; $required_fields[$field_id] = $label; } // treat string as a template (the string resource plugin is unavailable in the current Smarty version) if (isset($connector_language['LBL_LICENSING_INFO'])) { $siteUrl = rtrim($sugar_config['site_url'], '/'); $connector_language['LBL_LICENSING_INFO'] = str_replace('{$SITE_URL}', $siteUrl, $connector_language['LBL_LICENSING_INFO']); } $this->ss->assign('required_properties', $required_fields); $this->ss->assign('source_id', $source_id); $this->ss->assign('properties', $properties); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('app', $GLOBALS['app_strings']); $this->ss->assign('connector_language', $connector_language); $this->ss->assign('hasTestingEnabled', $source->hasTestingEnabled()); echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/source_properties.tpl')); }
/** * @see SugarView::display() */ public function display() { global $mod_strings, $app_strings; require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $this->ss->assign('mod', $mod_strings); $this->ss->assign('APP', $app_strings); $connectors = ConnectorUtils::getConnectors(true); $required_fields = array(); //Get required fields for first connector only $connectorsToShow = $connectors; foreach ($connectors as $id => $entry) { $s = SourceFactory::getSource($id); $connector_strings = ConnectorUtils::getConnectorStrings($id); $fields = $s->getRequiredConfigFields(); if (empty($fields)) { unset($connectorsToShow[$id]); } else { if (empty($required_fields)) { foreach ($fields as $field_id) { $label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id; $required_fields[$id][$field_id] = $label; } } } } $this->ss->assign('SOURCES', $connectorsToShow); $this->ss->assign('REQUIRED_FIELDS', $required_fields); echo $this->getModuleTitle(); $this->ss->display('modules/Connectors/tpls/modify_properties.tpl'); }
function display() { global $mod_strings, $app_strings; require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $sugar_smarty = new Sugar_Smarty(); $sugar_smarty->assign('mod', $mod_strings); $sugar_smarty->assign('APP', $app_strings); $connectors = ConnectorUtils::getConnectors(true); $required_fields = array(); //Get required fields for first connector only foreach ($connectors as $id => $entry) { $s = SourceFactory::getSource($id); $connector_strings = ConnectorUtils::getConnectorStrings($id); $fields = $s->getRequiredConfigFields(); foreach ($fields as $field_id) { $label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id; $required_fields[$id][$field_id] = $label; } break; } $sugar_smarty->assign('SOURCES', $connectors); $sugar_smarty->assign('REQUIRED_FIELDS', $required_fields); echo get_module_title('Connectors', $mod_strings['LBL_MODIFY_PROPERTIES_PAGE_TITLE'], true); $sugar_smarty->display('modules/Connectors/tpls/modify_properties.tpl'); }
/** * @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'); }
function display() { require_once 'include/connectors/sources/SourceFactory.php'; require_once 'include/connectors/utils/ConnectorUtils.php'; $source_id = $_REQUEST['source_id']; $connector_language = ConnectorUtils::getConnectorStrings($source_id); $source = SourceFactory::getSource($source_id); $properties = $source->getProperties(); $required_fields = array(); $config_fields = $source->getRequiredConfigFields(); $fields = $source->getRequiredConfigFields(); foreach ($fields as $field_id) { $label = isset($connector_language[$field_id]) ? $connector_language[$field_id] : $field_id; $required_fields[$field_id] = $label; } $this->ss->assign('required_properties', $required_fields); $this->ss->assign('source_id', $source_id); $this->ss->assign('properties', $properties); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('app', $GLOBALS['app_strings']); $this->ss->assign('connector_language', $connector_language); $this->ss->assign('hasTestingEnabled', $source->hasTestingEnabled()); echo $this->ss->fetch('modules/Connectors/tpls/source_properties.tpl'); }
function action_GetSearchForm() { $this->view = 'ajax'; if (!empty($_REQUEST['source_id'])) { //get the search fields and return the search form $ss = new Sugar_Smarty(); require_once 'include/connectors/utils/ConnectorUtils.php'; $searchdefs = ConnectorUtils::getSearchDefs(); $merge_module = $_REQUEST['merge_module']; $seed = loadBean($merge_module); $_searchDefs = isset($searchdefs) ? $searchdefs : array(); $_trueFields = array(); $source = $_REQUEST['source_id']; $searchLabels = ConnectorUtils::getConnectorStrings($source); $record = $_REQUEST['record']; $sourceObj = SourceFactory::getSource($source); $field_defs = $sourceObj->getFieldDefs(); if (!empty($_searchDefs[$source][$merge_module])) { foreach ($_searchDefs[$source][$merge_module] as $key) { if (!empty($_SESSION['searchDefs'][$merge_module][$record][$source][$key])) { $_trueFields[$key]['value'] = $_SESSION['searchDefs'][$merge_module][$record][$source][$key]; } else { $_trueFields[$key]['value'] = ''; } if (!empty($field_defs[$key]) && isset($searchLabels[$field_defs[$key]['vname']])) { $_trueFields[$key]['label'] = $searchLabels[$field_defs[$key]['vname']]; } else { $_trueFields[$key]['label'] = $key; } } //foreach } //fi $ss->assign('mod', $GLOBALS['mod_strings']); $ss->assign('search_fields', $_trueFields); $ss->assign('source_id', $source); $ss->assign('fields', $seed->field_defs); $ss->assign('module', $merge_module); $ss->assign('RECORD', $record); $ss->assign('APP', $GLOBALS['app_strings']); $ss->assign('MOD', $GLOBALS['mod_strings']); echo $ss->fetch('modules/Connectors/tpls/search_form.tpl'); } }
public function showFrame($event, $args) { if ($GLOBALS['app']->controller->action != 'DetailView') { return; } require_once 'include/connectors/utils/ConnectorUtils.php'; $bean = $GLOBALS['app']->controller->bean; // Build the base arguments static $userFieldMap = array('crm_user_id' => 'id', 'crm_user_fn' => 'first_name', 'crm_user_ln' => 'last_name', 'crm_user_email' => 'email1'); if ($GLOBALS['current_user']->id != '1') { $extraUrl = $this->handleFieldMap($GLOBALS['current_user'], $userFieldMap); } else { // Need some extra code here for the '1' admin user $myUserFieldMap = $userFieldMap; unset($myUserFieldMap['crm_user_id']); $extraUrl = 'crm_user_id=' . urlencode($GLOBALS['sugar_config']['unique_key']) . '&' . $this->handleFieldMap($GLOBALS['current_user'], $myUserFieldMap); } $extraUrl .= '&crm_org_id=' . urlencode($GLOBALS['sugar_config']['unique_key']) . '&crm_org_name=' . (!empty($GLOBALS['system_config']->settings['system_name']) ? urlencode($GLOBALS['system_config']->settings['system_name']) : '') . '&crm_server_url=' . urlencode($GLOBALS['sugar_config']['site_url']) . '&crm_session_id=&crm_version=v62&crm_deploy_id=3&crm_size=400&is_embed_version=true'; // Use the per-module functions to build the frame if (is_a($bean, 'Account')) { $url = $this->getAccountFrameUrl($bean, $extraUrl); } else { if (is_a($bean, 'Contact')) { $url = $this->getContactFrameUrl($bean, $extraUrl); } else { if (is_a($bean, 'Lead')) { $url = $this->getLeadFrameUrl($bean, $extraUrl); } else { if (is_a($bean, 'Opportunity')) { $url = $this->getOpportunityFrameUrl($bean, $extraUrl); } else { $url = ''; } } } } if ($url != '') { // Check if the user should be shown the frame or not $smarty = new Sugar_Smarty(); $tplName = 'modules/Connectors/connectors/sources/ext/rest/insideview/tpls/InsideView.tpl'; require_once 'include/connectors/utils/ConnectorUtils.php'; $connector_language = ConnectorUtils::getConnectorStrings('ext_rest_insideview'); $smarty->assign('connector_language', $connector_language); $smarty->assign('logo', getWebPath('modules/Connectors/connectors/sources/ext/rest/insideview/images/insideview.png')); $smarty->assign('video', getWebPath('modules/Connectors/connectors/sources/ext/rest/insideview/images/video.png')); $smarty->assign('close', getWebPath('modules/Connectors/connectors/sources/ext/rest/insideview/images/close.png')); $smarty->assign('logo_expanded', getWebPath('modules/Connectors/connectors/sources/ext/rest/insideview/images/insideview_expanded.png')); $smarty->assign('logo_collapsed', getWebPath('modules/Connectors/connectors/sources/ext/rest/insideview/images/insideview_collapsed.png')); $smarty->assign('AJAX_URL', $url); $smarty->assign('APP', $GLOBALS['app_strings']); if ($GLOBALS['current_user']->getPreference('allowInsideView', 'Connectors') != 1) { $smarty->assign('showInsideView', false); } else { $smarty->assign('showInsideView', true); $smarty->assign('URL', $url); //echo "<div id='insideViewDiv' style='width:100%;height:400px;overflow:hidden'><iframe id='insideViewFrame' src='$url' style='border:0px; width:100%;height:480px;overflow:hidden'></iframe></div>"; } echo $smarty->fetch($tplName); } }
/** * @see SugarView::display() */ public function display() { require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $connector_strings = ConnectorUtils::getConnectorStrings($_REQUEST['source_id']); $sources = ConnectorUtils::getConnectors(); $source_id = $_REQUEST['source_id']; $source = SourceFactory::getSource($source_id); $is_enabled = ConnectorUtils::isSourceEnabled($source_id); $script = ''; $display_data = array(); if ($is_enabled) { $mapping = $source->getMapping(); $source_defs = $source->getFieldDefs(); //Create the Javascript code to dynamically add the tables $json = getJSONobj(); foreach ($mapping['beans'] as $module => $field_mapping) { $mod_strings = return_module_language($GLOBALS['current_language'], $module); $bean = loadBean($module); if (!is_object($bean)) { continue; } $field_defs = $bean->getFieldDefinitions(); $available_fields = array(); $labels = array(); $duplicate_labels = array(); foreach ($field_defs as $id => $def) { //We are filtering out some fields here if ($def['type'] == 'relate' || $def['type'] == 'link' || isset($def['dbType']) && $def['dbType'] == 'id') { continue; } if (isset($def['vname'])) { $available_fields[$id] = !empty($mod_strings[$def['vname']]) ? $mod_strings[$def['vname']] : $id; } else { $available_fields[$id] = $id; } //Remove the ':' character in some labels if (preg_match('/\\:$/', $available_fields[$id])) { $available_fields[$id] = substr($available_fields[$id], 0, strlen($available_fields[$id]) - 1); } if (isset($labels[$available_fields[$id]])) { $duplicate_labels[$labels[$available_fields[$id]]] = $labels[$available_fields[$id]]; $duplicate_labels[$id] = $id; } else { $labels[$available_fields[$id]] = $id; } } foreach ($duplicate_labels as $id) { $available_fields[$id] = $available_fields[$id] . " ({$id})"; } asort($available_fields); $field_keys = array(); $field_values = array(); $source_fields = array(); foreach ($field_mapping as $id => $field) { if (!empty($source_defs[$id])) { $source_fields[$id] = $source_defs[$id]; } } $source_fields = array_merge($source_fields, $source_defs); foreach ($source_fields as $id => $def) { if (empty($def['hidden'])) { $field_keys[strtolower($id)] = !empty($connector_strings[$source_fields[$id]['vname']]) ? $connector_strings[$source_fields[$id]['vname']] : $id; $field_values[] = !empty($field_mapping[strtolower($id)]) ? $field_mapping[strtolower($id)] : ''; } } $display_data[$module] = array('field_keys' => $field_keys, 'field_values' => $field_values, 'available_fields' => $available_fields, 'field_mapping' => $field_mapping); } } $this->ss->assign('display_data', $display_data); $this->ss->assign('empty_mapping', empty($display_data) ? true : false); $this->ss->assign('dynamic_script', $script); $this->ss->assign('sources', $sources); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('APP', $GLOBALS['app_strings']); $this->ss->assign('source_id', $source_id); $this->ss->assign('source_name', $sources[$source_id]['name']); $this->ss->assign('theme', $GLOBALS['theme']); echo $this->ss->fetch('modules/Connectors/tpls/mapping_properties.tpl'); }
/** * @see SugarView::display() */ public function display() { $this->ss->assign('RECORD', $_REQUEST['record']); $this->ss->assign('module', $this->_merge_module); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('search_fields', $this->_trueFields); $this->ss->assign('fields', $this->seed->field_defs); $this->_tabs = array(); $first_source = ''; $source_instance = null; $source_list = array(); foreach ($this->_modules_sources[$_SESSION['merge_module']] as $source) { $s = SourceFactory::getSource($source); if ($s->isEnabledInWizard()) { $config = $s->getConfig(); $this->_tabs[] = array('title' => $config['name'], 'link' => $source, 'key' => $source); if (empty($first_source)) { $first_source = $source; $source_instance = ConnectorFactory::getInstance($source); } $source_list[] = $source; } } $this->ss->assign('SOURCES', $source_list); $this->ss->assign('source_id', $first_source); $this->_trueFields = array(); $field_defs = $source_instance->getFieldDefs(); $sMap = $source_instance->getModuleMapping($this->_merge_module); $searchLabels = ConnectorUtils::getConnectorStrings($first_source); if (!empty($this->_searchDefs[$first_source][$this->_merge_module])) { foreach ($this->_searchDefs[$first_source][$this->_merge_module] as $key) { $beanKey = $key; if (!empty($sMap[$key])) { $beanKey = $sMap[$key]; } if (!empty($this->seed->{$beanKey})) { $this->_trueFields[$key]['value'] = $this->seed->{$beanKey}; } else { $this->_trueFields[$key]['value'] = ''; } if (!empty($field_defs[$key]) && isset($searchLabels[$field_defs[$key]['vname']])) { $this->_trueFields[$key]['label'] = $searchLabels[$field_defs[$key]['vname']]; } else { $this->_trueFields[$key]['label'] = $key; } //$_trueFields[$key]['label'] = isset($searchLabels[$field_defs[$key]['vname']]) ? $searchLabels[$field_defs[$key]['vname']] : $key; $_SESSION['searchDefs'][$this->_merge_module][$this->seed->id][$first_source][$key] = $this->_trueFields[$key]['value']; } //foreach } //fi $this->ss->assign('search_fields', $this->_trueFields); $tab_panel = new ConnectorWidgetTabs($this->_tabs, $first_source, 'SourceTabs.loadTab', 'subpanelTablist'); $this->ss->assign('TABS', $tab_panel->display()); echo $this->getModuleTitle(false); echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/step1.tpl')); //display bean detail view $GLOBALS['module'] = $this->_merge_module; //end display bean detail view }
/** * getDisplayColumns * This is a private method to return a PHP array of display columns used for the list view. * It will first check in the Connector's custom directories for a listviewdefs.php file. * Then it will check the modules/Connector's directory to see if a listviewdefs.php file was * defined there. If not, it will generate the array based on the fields mapped. * * @param source_instance The Connector source instance to retrieve the display columns for * @param beans The PHP array of filled SugarBean results * @return displayColumns A PHP array of display columns */ private function getDisplayColumns($source_instance, $beans) { $source_id = $_REQUEST['source_id']; require_once 'include/connectors/utils/ConnectorUtils.php'; $connector_strings = ConnectorUtils::getConnectorStrings($source_id); $dir = str_replace('_', '/', $source_id); $file = SugarAutoLoader::existingCustomOne("modules/Connectors/connectors/sources/{$dir}/listviewdefs.php"); if ($file) { require $file; } $displayColumns = array(); $output_list = $source_instance->getModuleMapping($_SESSION['merge_module']); $output_list = !empty($output_list) ? $output_list : $beans[0]->get_list_view_array(); $sugar_bean_field_defs = $beans[0]->getFieldDefinitions(); $connector_field_defs = $source_instance->getFieldDefs(); //There was a listviewdefs.php file specified, now we have to figure out the mapping based on //the Connector fields specified. In the listviewdefs.php files, the key is the Connector's //vardef entry key. We are allowing this to be case-insensitive. //Use listviewdefs.php file if there is one if (isset($listViewDefs[$source_id])) { foreach ($listViewDefs[$source_id] as $key => $listDef) { $check_key = strtolower($key); if (isset($output_list[$check_key])) { $width = isset($listDef['width']) ? $listDef['width'] : round(95 / count($listViewDefs), 1); //Use the Connector's field label, but fall back on the bean's label if we need to $label = isset($connector_field_defs[$key]['vname']) ? $connector_strings[$connector_field_defs[$key]['vname']] : $sugar_bean_field_defs[$output_list[$check_key]]['vname']; $displayColumns[$output_list[$check_key]] = array('width' => $width, 'label' => $label); } } } else { $width = round(95 / count($output_list), 1); foreach ($output_list as $key => $value) { if (isset($connector_field_defs[$key]['vname'])) { $label = $connector_strings[$connector_field_defs[$key]['vname']]; } else { if (isset($sugar_bean_field_defs[$value]['vname'])) { $label = $sugar_bean_field_defs[$value]['vname']; } else { $label = $value; } } $displayColumns[$value] = array('width' => $width, 'label' => $label); } } return $displayColumns; }