/** * @see SugarView::display() */ public function display() { require_once 'include/connectors/utils/ConnectorUtils.php'; $source = $_REQUEST['source_id']; $sources = ConnectorUtils::getConnectors(); $modules_sources = ConnectorUtils::getDisplayConfig(); //$json = getJSONobj(); $enabled_modules = array(); $disabled_modules = array(); //Find all modules this source has been enabled for foreach ($modules_sources as $module => $mapping) { foreach ($modules_sources[$module] as $entry) { if ($entry == $source) { $enabled_modules[$module] = $module; } } } global $moduleList, $beanList; //Do filtering here? $count = 0; global $current_user; $access = $current_user->getDeveloperModules(); $d = dir('modules'); while ($e = $d->read()) { if (substr($e, 0, 1) == '.' || !is_dir('modules/' . $e)) { continue; } if (empty($enabled_modules[$e]) && file_exists('modules/' . $e . '/metadata/studio.php') && file_exists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) { $disabled_modules[$e] = $e; } } $s = SourceFactory::getSource($source); // Not all sources can be connected to all modules $enabled_modules = $s->filterAllowedModules($enabled_modules); $disabled_modules = $s->filterAllowedModules($disabled_modules); asort($enabled_modules); asort($disabled_modules); //$enabled = $json->encode($enabled_modules); //$disabled = $json->encode($disabled_modules); //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n"; //$this->ss->assign('new_modules_sources', $modules_sources); //$this->ss->assign('dynamic_script', $script); $this->ss->assign('enabled_modules', $enabled_modules); $this->ss->assign('disabled_modules', $disabled_modules); $this->ss->assign('source_id', $source); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('APP', $GLOBALS['app_strings']); $this->ss->assign('theme', $GLOBALS['theme']); $this->ss->assign('external', !empty($sources[$source]['eapm'])); $this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only'])); // We don't want to tell the user to set the properties of the connector if there aren't any $fields = $s->getRequiredConfigFields(); $this->ss->assign('externalHasProperties', !empty($fields)); $this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : ""); echo $this->ss->fetch('modules/Connectors/tpls/display_properties.tpl'); }
/** * @see SugarView::display() */ public function display() { require_once 'include/connectors/utils/ConnectorUtils.php'; $source = $_REQUEST['source_id']; $sources = ConnectorUtils::getConnectors(); $modules_sources = ConnectorUtils::getDisplayConfig(); $enabled_modules = array(); $disabled_modules = array(); //Find all modules this source has been enabled for foreach ($modules_sources as $module => $mapping) { foreach ($modules_sources[$module] as $entry) { if ($entry == $source) { $enabled_modules[$module] = isset($GLOBALS['app_list_strings']['moduleList'][$module]) ? $GLOBALS['app_list_strings']['moduleList'][$module] : $module; } } } global $moduleList, $beanList; //Do filtering here? $count = 0; global $current_user; $access = $current_user->getDeveloperModules(); foreach (SugarAutoLoader::getDirFiles("modules", true) as $e) { //Strip the 'modules/' portion out from beginning of $e $e = substr($e, 8); if (empty($enabled_modules[$e]) && SugarAutoLoader::existingCustomOne("modules/{$e}/metadata/studio.php") && SugarAutoLoader::fileExists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) { $disabled_modules[$e] = isset($GLOBALS['app_list_strings']['moduleList'][$e]) ? $GLOBALS['app_list_strings']['moduleList'][$e] : $e; } } $s = SourceFactory::getSource($source); // Not all sources can be connected to all modules $enabled_modules = $s->filterAllowedModules($enabled_modules); $disabled_modules = $s->filterAllowedModules($disabled_modules); asort($enabled_modules); asort($disabled_modules); //$enabled = $json->encode($enabled_modules); //$disabled = $json->encode($disabled_modules); //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n"; //$this->ss->assign('new_modules_sources', $modules_sources); //$this->ss->assign('dynamic_script', $script); $this->ss->assign('enabled_modules', $enabled_modules); $this->ss->assign('disabled_modules', $disabled_modules); $this->ss->assign('source_id', $source); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('APP', $GLOBALS['app_strings']); $this->ss->assign('theme', $GLOBALS['theme']); $this->ss->assign('external', !empty($sources[$source]['eapm'])); $this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only'])); // We don't want to tell the user to set the properties of the connector if there aren't any $fields = $s->getRequiredConfigFields(); $this->ss->assign('externalHasProperties', !empty($fields)); $this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : ""); echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/display_properties.tpl')); }
/** * @see SugarView::display() */ public function display() { require_once 'include/connectors/utils/ConnectorUtils.php'; $source = $_REQUEST['source_id']; $sources = ConnectorUtils::getConnectors(); $modules_sources = ConnectorUtils::getDisplayConfig(); //$json = getJSONobj(); $enabled_modules = array(); $disabled_modules = array(); //Find all modules this source has been enabled for foreach ($modules_sources as $module => $mapping) { foreach ($modules_sources[$module] as $entry) { if ($entry == $source) { $enabled_modules[$module] = $module; } } } global $moduleList, $beanList; //Do filtering here? $count = 0; global $current_user; $access = get_admin_modules_for_user($current_user); $d = dir('modules'); while ($e = $d->read()) { if (substr($e, 0, 1) == '.' || !is_dir('modules/' . $e)) { continue; } if (empty($enabled_modules[$e]) && file_exists('modules/' . $e . '/metadata/studio.php') && file_exists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) { $disabled_modules[$e] = $e; } } asort($enabled_modules); asort($disabled_modules); //$enabled = $json->encode($enabled_modules); //$disabled = $json->encode($disabled_modules); //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n"; //$this->ss->assign('new_modules_sources', $modules_sources); //$this->ss->assign('dynamic_script', $script); $this->ss->assign('enabled_modules', $enabled_modules); $this->ss->assign('disabled_modules', $disabled_modules); $this->ss->assign('source_id', $source); $this->ss->assign('mod', $GLOBALS['mod_strings']); $this->ss->assign('APP', $GLOBALS['app_strings']); $this->ss->assign('theme', $GLOBALS['theme']); echo $this->ss->fetch('modules/Connectors/tpls/display_properties.tpl'); }
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 foreach ($sources as $id) { if (empty($sources_modules[$source])) { //Now write the new mapping entry to the custom folder $dir = $connectors[$id]['directory']; if (!preg_match('/^custom\\//', $dir)) { $dir = 'custom/' . $dir; } if (!file_exists("{$dir}")) { mkdir_recursive("{$dir}"); } $fakeMapping = array('beans' => array()); if (!write_array_to_file('mapping', $fakeMapping, "{$dir}/mapping.php")) { $GLOBALS['log']->fatal("Cannot write file {$dir}/mapping.php"); } $s = SourceFactory::getSource($id); $s->saveMappingHook($fakeMapping); } //if } //foreach //Now update the field mapping entries foreach ($sources_modules as $id => $modules) { $source = SourceFactory::getSource($id); $mapping = $source->getMapping(); $mapped_modules = array_keys($mapping['beans']); foreach ($mapped_modules as $module) { if (empty($sources_modules[$id][$module])) { unset($mapping['beans'][$module]); } } //Remove modules from the mapping entries foreach ($modules as $module) { if (empty($mapping['beans'][$module])) { $originalMapping = $source->getOriginalMapping(); if (empty($originalMapping['beans'][$module])) { $defs = $source->getFieldDefs(); $keys = array_keys($defs); $new_mapping_entry = array(); foreach ($keys as $key) { $new_mapping_entry[$key] = ''; } $mapping['beans'][$module] = $new_mapping_entry; } else { $mapping['beans'][$module] = $originalMapping['beans'][$module]; } } //if } //foreach //Now write the new mapping entry to the custom folder $dir = $connectors[$id]['directory']; if (!preg_match('/^custom\\//', $dir)) { $dir = 'custom/' . $dir; } if (!file_exists("{$dir}")) { mkdir_recursive("{$dir}"); } if (!write_array_to_file('mapping', $mapping, "{$dir}/mapping.php")) { $GLOBALS['log']->fatal("Cannot write file {$dir}/mapping.php"); } $source->saveMappingHook($mapping); } //foreach // save eapm configs foreach ($connectors as $connector_name => $data) { if (isset($sources[$connector_name]) && !empty($data["eapm"])) { // if we touched it AND it has EAPM data $connectors[$connector_name]["eapm"]["enabled"] = !empty($_REQUEST[$connector_name . "_external"]); } } ConnectorUtils::saveConnectors($connectors); ConnectorUtils::updateMetaDataFiles(); // 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 }
/** * smarty_function_sugar_button * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_button($params, $smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $js_form = empty($params['form_id']) ? "var _form = (this.form) ? this.form : document.forms[0];" : "var _form = document.getElementById('{$params['form_id']}');"; $type = $params['id']; $location = empty($params['location']) ? "" : "_" . $params['location']; if (isset($GLOBALS['sugar_config']['enable_action_menu']) && $GLOBALS['sugar_config']['enable_action_menu'] === false) { $enable_action_menu = false; } else { $enable_action_menu = true; } if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "SEARCH": $output = '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" onclick="SUGAR.savedViews.setChooser();" class="button" type="submit" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; break; case "CANCEL": $cancelButton = '{capture name="cancelReturnUrl" assign="cancelReturnUrl"}'; $cancelButton .= '{if !empty($smarty.request.return_action) && $smarty.request.return_action == "DetailView" && !empty($fields.id.value) && empty($smarty.request.return_id)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$fields.id.value|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{elseif !empty($smarty.request.return_module) || !empty($smarty.request.return_action) || !empty($smarty.request.return_id)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$smarty.request.return_id|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{else}'; $cancelButton .= "parent.SUGAR.App.router.buildRoute('{$module}')"; $cancelButton .= '{/if}'; $cancelButton .= '{/capture}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.bwc.revertAttributes();parent.SUGAR.App.router.navigate({$cancelReturnUrl}, {literal}{trigger: true}{/literal}); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $output = $cancelButton; break; case "DELETE": $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} '; break; case "DUPLICATE": $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\'' . $view . '\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; break; case "EDIT": $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; break; case "FIND_DUPLICATES": $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} '; break; case "SUBPANELSAVE": if ($view == 'QuickCreate' || isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate') { $view = "form_SubpanelQuickCreate_{$module}"; } $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "SUBPANELCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "SUBPANELFULLFORM": $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $output .= '<input type="hidden" name="full_form" value="full_form">'; break; case "DCMENUCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "DCMENUSAVE": if ($view == 'QuickCreate') { $view = "form_DCQuickCreate_{$module}"; } else { if ($view == 'EditView') { $view = "form_DCEditView_{$module}"; } } $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return DCMenu.save(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "DCMENUFULLFORM": $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\'' . $params['module'] . '\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $output .= '<input type="hidden" name="full_form" value="full_form">'; $output .= '<input type="hidden" name="is_admin" value="">'; break; case "POPUPSAVE": $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view; $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="' . $js_form . ' _form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "POPUPCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; $output = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; break; //Button for the Connector intergration wizard //Button for the Connector intergration wizard case "CONNECTOR": require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $modules_sources = ConnectorUtils::getDisplayConfig(); if (!is_null($modules_sources) && !empty($modules_sources)) { foreach ($modules_sources as $mod => $entry) { if ($mod == $module && !empty($entry)) { foreach ($entry as $source_id) { $source = SourceFactory::getSource($source_id); if ($source->isEnabledInWizard()) { $output = '<input title="{$APP.LBL_MERGE_CONNECTORS}" type="button" class="button" onClick="document.location=\'index.php?module=Connectors&action=Step1&record={$fields.id.value}&merge_module={$module}\'" name="merge_connector" value="{$APP.LBL_MERGE_CONNECTORS}">'; if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } } } } } return ''; case "PDFVIEW": $output = '{sugar_button module="$module" id="REALPDFVIEW" view="$view" form_id="formDetailView" record=$fields.id.value}'; break; case "REALPDFVIEW": if (empty($params['record'])) { $smarty->trigger_error("sugar_button: missing required param (record)"); } $record = $params['record']; require_once 'modules/PdfManager/PdfManagerHelper.php'; $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module); //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); } $output = ''; if (!empty($pdfManagerList) || !empty($tplLayouts)) { if (SugarThemeRegistry::current()->name != "Classic") { if ($enable_action_menu) { $output = ' <input id="pdfview_button" value="' . translate('LBL_PDF_VIEW') . '" type="button" class="button" />'; } $pdfItems = array(); if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'name' => $pdfTemplate->name); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id); $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfview" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array()); } } } //quote legacy templates if ($module == "Quotes") { foreach ($tplLayouts as $sugarpdf => $path) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '', 'name' => $path); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => ''); $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array()); } } } sort($pdfItems); if (!$enable_action_menu) { if (!empty($urlParams)) { $output .= '<ul class="clickMenu fancymenu">'; $output .= '<li class="sugar_action_button">'; $output .= '<a>' . translate('LBL_PDF_VIEW') . '</a>'; $output .= '<ul class="subnav" style="display: none;">'; foreach ($urlParams as $tplButton) { if (isset($tplButton['pdf_template_id'])) { $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>'; } else { // legacy templates $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>'; } } $output .= '</ul><span class="ab"></span></li></ul>'; } } else { require_once 'include/SugarSmarty/plugins/function.sugar_menu.php'; $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty); } } else { $output = ' <script type="text/javascript"> function display_pdf_list(el) { var menu = \''; if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>'; } } //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); foreach ($tplLayouts as $sugarpdf => $path) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => ''); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $path . '</a>'; } } $output .= '\'; SUGAR.util.showHelpTips(el,menu); } </script> <a onclick="display_pdf_list(this);" />' . translate('LBL_PDF_VIEW') . '</a> '; } } break; case "PDFEMAIL": $output = '{sugar_button module="$module" id="REALPDFEMAIL" view="$view" form_id="formDetailView" record=$fields.id.value}'; break; case "REALPDFEMAIL": $output = ''; global $current_user, $sugar_config; $userPref = $current_user->getPreference('email_link_type'); $defaultPref = $sugar_config['email_default_client']; if ($userPref != '') { $client = $userPref; } else { $client = $defaultPref; } if ($client == 'sugar') { if (empty($params['record'])) { $smarty->trigger_error("sugar_button: missing required param (record)"); } $record = $params['record']; require_once 'modules/PdfManager/PdfManagerHelper.php'; $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module); //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); } if (!empty($pdfManagerList) || !empty($tplLayouts)) { if (SugarThemeRegistry::current()->name != "Classic") { if ($enable_action_menu) { $output = ' <input id="pdfemail_button" value="' . translate('LBL_PDF_EMAIL') . '" type="button" class="button" />'; } $pdfItems = array(); if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1", 'name' => $pdfTemplate->name); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1"); $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfemail" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array()); } } } //quote legacy templates if ($module == "Quotes") { foreach ($tplLayouts as $sugarpdf => $path) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout', 'name' => $path); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout'); $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array()); } } } sort($pdfItems); if (!$enable_action_menu) { if (!empty($urlParams)) { $output .= '<ul class="clickMenu fancymenu">'; $output .= '<li class="sugar_action_button">'; $output .= '<a>' . translate('LBL_PDF_EMAIL') . '</a>'; $output .= '<ul class="subnav" style="display: none;">'; foreach ($urlParams as $tplButton) { if (isset($tplButton['pdf_template_id'])) { $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id'] . '&to_email=' . $tplButton['to_email']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>'; } else { // legacy templates $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>'; } } $output .= '</ul><span class="ab"></span></li></ul>'; } } else { require_once 'include/SugarSmarty/plugins/function.sugar_menu.php'; $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty); } } else { $output = ' <script language="javascript"> function display_pdf_email_list(el) { var menu = \''; if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1"); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>'; } } //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); foreach ($tplLayouts as $sugarpdf => $path) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout'); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $sugarpdf . '</a>'; } } $output .= '\'; SUGAR.util.showHelpTips(el,menu); } </script> <a onclick="display_pdf_email_list(this);" />' . translate('LBL_PDF_EMAIL') . '</a> '; } } } break; case 'SHARE': // TODO we shouldn't rely on the name field only, but we don't // have this information anywhere and this is BWC code... $shareButton = <<<ENDB <form> <input type="hidden" id="share_button_name" value="{\$fields.name.value}"> <input title="{\$APP.LBL_SHARE_BUTTON_TITLE}" accessKey="{\$APP.LBL_SHARE_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.bwc.shareRecord('{$params['module']}', '{\$fields.id.value}', this.form.share_button_name.value)" type="button" name="button" value="{\$APP.LBL_SHARE_BUTTON_LABEL}"> </form> ENDB; $output = $shareButton; break; } //switch if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } else { if (is_array($type) && isset($type['sugar_html'])) { require_once 'include/SugarHtml/SugarHtml.php'; $dom_tree = SugarHtml::parseSugarHtml($type['sugar_html']); replaceFormClick($dom_tree, $js_form); $output = SugarHtml::createHtml($dom_tree); if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } else { if (is_array($type) && isset($type['customCode'])) { require_once 'include/SugarHtml/SugarHtml.php'; $dom_tree = SugarHtml::parseHtmlTag($type['customCode']); $hidden_exists = false; replaceFormClick($dom_tree, $js_form, $hidden_exists); if ($hidden_exists) { //If the customCode contains hidden fields, the extracted hidden fields need to append in the original form $form = $smarty->get_template_vars('form'); $hidden_fields = $dom_tree; extractHiddenInputs($hidden_fields); if (!isset($form)) { $form = array(); } if (!isset($form['hidden'])) { $form['hidden'] = array(); } $form['hidden'][] = SugarHtml::createHtml($hidden_fields); $smarty->assign('form', $form); } $output = SugarHtml::createHtml($dom_tree); if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } } } }
/** * @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(); }
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(); $sources = array(); $values = array(); $new_modules_sources = array(); if (!empty($_REQUEST['display_values'])) { $display_values = split(',', $_REQUEST['display_values']); foreach ($display_values as $value) { $entry = split(':', $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 = split(',', $_REQUEST['display_sources']); foreach ($display_sources as $source) { $sources[$source] = $source; } //foreach //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]); } } } //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; } } //Clear mapping file if needed (this happens when all modules are removed from a source foreach ($sources as $id) { if (empty($sources_modules[$source])) { //Now write the new mapping entry to the custom folder $dir = $connectors[$id]['directory']; if (!preg_match('/^custom\\//', $dir)) { $dir = 'custom/' . $dir; } if (!file_exists("{$dir}")) { mkdir_recursive("{$dir}"); } if (!write_array_to_file('mapping', array('beans' => array()), "{$dir}/mapping.php")) { $GLOBALS['log']->fatal("Cannot write file {$dir}/mapping.php"); } } //if } //foreach //Now update the field mapping entries foreach ($sources_modules as $id => $modules) { $source = SourceFactory::getSource($id); $mapping = $source->getMapping(); $mapped_modules = array_keys($mapping['beans']); foreach ($mapped_modules as $module) { if (empty($sources_modules[$id][$module])) { unset($mapping['beans'][$module]); } } //Remove modules from the mapping entries foreach ($modules as $module) { if (empty($mapping['beans'][$module])) { $originalMapping = $source->getOriginalMapping(); if (empty($originalMapping['beans'][$module])) { $defs = $source->getFieldDefs(); $keys = array_keys($defs); $new_mapping_entry = array(); foreach ($keys as $key) { $new_mapping_entry[$key] = ''; } $mapping['beans'][$module] = $new_mapping_entry; } else { $mapping['beans'][$module] = $originalMapping['beans'][$module]; } } //if } //foreach //Now write the new mapping entry to the custom folder $dir = $connectors[$id]['directory']; if (!preg_match('/^custom\\//', $dir)) { $dir = 'custom/' . $dir; } if (!file_exists("{$dir}")) { mkdir_recursive("{$dir}"); } if (!write_array_to_file('mapping', $mapping, "{$dir}/mapping.php")) { $GLOBALS['log']->fatal("Cannot write file {$dir}/mapping.php"); } } //foreach ConnectorUtils::updateMetaDataFiles(); // 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 }
public function getFieldsWithParams($param_name, $param_value) { $modules_sources = ConnectorUtils::getDisplayConfig(); $cache_file = 'cache/include/twilio/phone_field_map.php'; //Make the directory for the config file if (!file_exists('cache/include/twilio')) { mkdir_recursive('cache/include/twilio'); } $module_phone_field_list = array(); if (!is_file($cache_file)) { // build_phone_field_map($cache_file); $module_phone_field_list = get_phone_field_map(); } else { include $cache_file; } foreach ($module_phone_field_list as $module_name => $phone_fields) { if (!isset($modules_sources[$module_name]) || !isset($modules_sources[$module_name]['ext_rest_twilio'])) { unset($module_phone_field_list[$module_name]); } } $return_phone_list = array(); foreach ($module_phone_field_list as $module_name => $fields_list) { foreach ($fields_list as $field_name) { $return_phone_list[$field_name] = ''; } } // if(empty($this->_field_defs)){ // $this->loadVardefs(); // } // $fields_with_param = array(); // foreach($this->_field_defs as $key => $def){ // if(!empty($def[$param_name]) && ($def[$param_name] == $param_value)){ // $fields_with_param[$key] = $def; // } // } // return $return_phone_list; }
/** * smarty_function_sugar_actions_link * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_actions_link($params, &$smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $type = $params['id']; $location = empty($params['location']) ? "" : "_" . $params['location']; if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "SEARCH": // TODO review these SUGAR.ajaxUI.* methods return '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" accessKey="{$APP.LBL_SEARCH_BUTTON_KEY}" onclick="SUGAR.savedViews.setChooser(); SUGAR.ajaxUI.submitForm(this.form);" class="button" type="button" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; break; case "CANCEL": $cancelButton = '{capture name="cancelReturnUrl" assign="cancelReturnUrl"}'; $cancelButton .= '{if !empty($smarty.request.return_action) && $smarty.request.return_action == "DetailView" && !empty($fields.id.value)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$fields.id.value|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{elseif !empty($smarty.request.return_module) || !empty($smarty.request.return_action) || !empty($smarty.request.return_id)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$smarty.request.return_id|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{else}'; $cancelButton .= "parent.SUGAR.App.router.buildRoute('{$module}')"; $cancelButton .= '{/if}'; $cancelButton .= '{/capture}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.router.navigate({$cancelReturnUrl}, {literal}{trigger: true}{/literal}); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; return $cancelButton; break; case "DELETE": return '{if $bean->aclAccess("delete")}<a title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'ListView\'; $(\'#form\')[0].action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')){literal}{$(\'#form\').submit()}{/literal};" name="Delete" id="delete_button">{$APP.LBL_DELETE_BUTTON_LABEL}</a>{/if} '; break; case "DUPLICATE": return '{if $bean->aclAccess("edit")}<a title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].isDuplicate.value=true; $(\'#form\')[0].action.value=\'' . $view . '\'; $(\'#form\')[0].return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Duplicate" id="duplicate_button">{$APP.LBL_DUPLICATE_BUTTON_LABEL}</a>{/if} '; break; case "EDIT": return '{if $bean->aclAccess("edit")}<a title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].return_id.value=\'{$id}\'; $(\'#form\')[0].action.value=\'EditView\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Edit" id="edit_button">{$APP.LBL_EDIT_BUTTON_LABEL}</a>{/if} '; break; case "EDIT2": return '{if $bean->aclAccess("edit")}<a title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].return_id.value=\'{$id}\'; $(\'#form\')[0].action.value=\'EditView\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Edit">{$APP.LBL_EDIT_BUTTON_LABEL}</a>{/if} '; break; case "FIND_DUPLICATES": return '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<a title="{$APP.LBL_DUP_MERGE}" accessKey="M" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].return_id.value=\'{$id}\'; $(\'#form\')[0].action.value=\'Step1\'; $(\'#form\')[0].module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Merge" id="merge_duplicate_button">{$APP.LBL_DUP_MERGE}</a>{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="{if $isDuplicate}this.form.return_id.value=\'\'; {/if}this.form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(this.form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} '; break; case "SUBPANELSAVE": if ($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action'])) == 'quickcreate') { $view = "form_SubpanelQuickCreate_{$module}"; } return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="this.form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(this.form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "SUBPANELCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "SUBPANELFULLFORM": $html = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="this.form.return_action.value=\'DetailView\'; this.form.action.value=\'EditView\'; if(typeof(this.form.to_pdf)!=\'undefined\') this.form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $html .= '<input type="hidden" name="full_form" value="full_form">'; return $html; case "POPUPSAVE": $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view; return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="this.form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "POPUPCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<a id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\'>{$APP.LNK_VIEW_CHANGE_LOG}</a>'; $view = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; return $view; //Button for the Connector intergration wizard //Button for the Connector intergration wizard case "CONNECTOR": require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $modules_sources = ConnectorUtils::getDisplayConfig(); if (!is_null($modules_sources) && !empty($modules_sources)) { foreach ($modules_sources as $mod => $entry) { if ($mod == $module && !empty($entry)) { foreach ($entry as $source_id) { $source = SourceFactory::getSource($source_id); if ($source->isEnabledInWizard()) { return '<a title="{$APP.LBL_MERGE_CONNECTORS}" accessKey="{$APP.LBL_MERGE_CONNECTORS_BUTTON_KEY}" onClick="document.location=\'index.php?module=Connectors&action=Step1&record={$fields.id.value}&merge_module={$module}\'" name="merge_connector">{$APP.LBL_MERGE_CONNECTORS}</a>'; } } } } } return ''; } //switch } else { if (is_array($type) && isset($type['customCode'])) { return $type['customCode']; } } }