public function testSaveMappingFileSavesNumberFieldAssociationCorrectly() { $lead = new Lead(); $importSource = new ImportFile($this->testFile, ',', '', false); $importer = new Bug61172TestImporterMock($importSource, $lead); $importer->saveMappingFile(); $mappingFile = new ImportMap(); $mappingFile->retrieve_by_string_fields(array('name' => $_REQUEST['save_map_as'])); $this->assertNotEmpty($mappingFile->content); $contentFields = explode('&', $mappingFile->content); $this->assertContains('1=status', $contentFields, "Field status should be associated with #1"); $mappingFile->mark_deleted($mappingFile->id); }
/** * display the form */ public function display() { global $mod_strings, $app_list_strings, $app_strings, $current_user; global $sugar_config; $this->ss->assign("MODULE_TITLE", get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_1_TITLE'], true)); $this->ss->assign("MOD", $mod_strings); $this->ss->assign("APP", $app_strings); $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"')); $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"')); $this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_UNPUBLISH'] . '" border="0"')); $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']); $this->ss->assign("JAVASCRIPT", $this->_getJS()); // handle publishing and deleting import maps if (isset($_REQUEST['delete_map_id'])) { $import_map = new ImportMap(); $import_map->mark_deleted($_REQUEST['delete_map_id']); } if (isset($_REQUEST['publish'])) { $import_map = new ImportMap(); $result = 0; $import_map = $import_map->retrieve($_REQUEST['import_map_id'], false); if ($_REQUEST['publish'] == 'yes') { $result = $import_map->mark_published($current_user->id, true); if (!$result) { $this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']); } } elseif ($_REQUEST['publish'] == 'no') { // if you don't own this importmap, you do now! // unless you have a map by the same name $result = $import_map->mark_published($current_user->id, false); if (!$result) { $this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']); } } } // load bean $focus = loadImportBean($_REQUEST['import_module']); if (!$focus) { showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], $_REQUEST['import_module']); return; } // trigger showing other software packages $this->ss->assign("show_salesforce", false); $this->ss->assign("show_outlook", false); $this->ss->assign("show_act", false); $this->ss->assign("show_jigsaw", false); switch ($_REQUEST['import_module']) { case "Prospects": break; case "Accounts": $this->ss->assign("show_salesforce", true); $this->ss->assign("show_act", true); $this->ss->assign("show_jigsaw", true); break; case "Contacts": $this->ss->assign("show_salesforce", true); $this->ss->assign("show_outlook", true); $this->ss->assign("show_act", true); break; default: $this->ss->assign("show_salesforce", true); break; } // get user defined import maps $this->ss->assign('is_admin', is_admin($current_user)); $import_map_seed = new ImportMap(); $custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module'])); if (count($custom_imports_arr)) { $custom = array(); foreach ($custom_imports_arr as $import) { $custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id); } $this->ss->assign('custom_imports', $custom); } // get globally defined import maps $published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module'])); if (count($published_imports_arr)) { $published = array(); foreach ($published_imports_arr as $import) { $published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id); } $this->ss->assign('published_imports', $published); } $this->ss->display('modules/Import/tpls/step1.tpl'); }
/** * @see SugarView::display() */ public function display() { global $mod_strings, $app_strings, $current_user; global $sugar_config; $selectedData = $this->_retrieveParams(); $this->ss->assign("MODULE_TITLE", $this->getModuleTitle()); $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"')); $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"')); $this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_UNPUBLISH'] . '" border="0"')); $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']); $this->ss->assign("JAVASCRIPT", $this->_getJS(isset($selectedData->source) ? $selectedData->source : false)); // handle publishing and deleting import maps if (isset($_REQUEST['delete_map_id'])) { $import_map = new ImportMap(); $import_map->mark_deleted($_REQUEST['delete_map_id']); } if (isset($_REQUEST['publish'])) { $import_map = new ImportMap(); $result = 0; $import_map = $import_map->retrieve($_REQUEST['import_map_id'], false); if ($_REQUEST['publish'] == 'yes') { $result = $import_map->mark_published($current_user->id, true); if (!$result) { $this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']); } } elseif ($_REQUEST['publish'] == 'no') { // if you don't own this importmap, you do now! // unless you have a map by the same name $result = $import_map->mark_published($current_user->id, false); if (!$result) { $this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']); } } } // trigger showing other software packages $this->ss->assign("show_salesforce", false); $this->ss->assign("show_outlook", false); $this->ss->assign("show_act", false); switch ($_REQUEST['import_module']) { case "Prospects": break; case "Accounts": $this->ss->assign("show_salesforce", true); $this->ss->assign("show_act", true); break; case "Contacts": $this->ss->assign("show_salesforce", true); $this->ss->assign("show_outlook", true); $this->ss->assign("show_act", true); break; default: $this->ss->assign("show_salesforce", true); break; } // show any custom mappings if (sugar_is_dir('custom/modules/Import') && ($dir = opendir('custom/modules/Import'))) { while (($file = readdir($dir)) !== false) { if (sugar_is_file("custom/modules/Import/{$file}") && strpos($file, ".php") !== false) { require_once "custom/modules/Import/{$file}"; $classname = str_replace('.php', '', $file); $mappingClass = new $classname(); $custom_mappings[] = $mappingClass->name; } } } // get user defined import maps $this->ss->assign('is_admin', is_admin($current_user)); $import_map_seed = new ImportMap(); $custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module'])); if (count($custom_imports_arr)) { $custom = array(); foreach ($custom_imports_arr as $import) { $custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id); } $this->ss->assign('custom_imports', $custom); } // get globally defined import maps $published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module'])); if (count($published_imports_arr)) { $published = array(); foreach ($published_imports_arr as $import) { $published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id); } $this->ss->assign('published_imports', $published); } $this->ss->display('modules/Import/tpls/step1.tpl'); }
function action_mapping() { global $mod_strings, $current_user; $results = array('message' => ''); // handle publishing and deleting import maps if (isset($_REQUEST['delete_map_id'])) { $import_map = new ImportMap(); $import_map->mark_deleted($_REQUEST['delete_map_id']); } if (isset($_REQUEST['publish'])) { $import_map = new ImportMap(); $import_map = $import_map->retrieve($_REQUEST['import_map_id'], false); if ($_REQUEST['publish'] == 'yes') { $result = $import_map->mark_published($current_user->id, true); if (!$result) { $results['message'] = $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']; } } elseif ($_REQUEST['publish'] == 'no') { // if you don't own this importmap, you do now, unless you have a map by the same name $result = $import_map->mark_published($current_user->id, false); if (!$result) { $results['message'] = $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']; } } } echo json_encode($results); sugar_cleanup(TRUE); }
echo "\n<p>\n"; echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_1_TITLE'], true); echo "\n</p>\n"; global $theme; $error_msg = ''; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; require_once $theme_path . 'layout_utils.php'; $GLOBALS['log']->info($mod_strings['LBL_MODULE_NAME'] . "upload step 1"); $tmp_file_name = $sugar_config['import_dir'] . "IMPORT_" . $current_user->id; if (file_exists($tmp_file_name)) { unlink($tmp_file_name); } if (isset($_REQUEST['delete_map_id'])) { $import_map = new ImportMap(); $import_map->mark_deleted($_REQUEST['delete_map_id']); } if (isset($_REQUEST['publish'])) { $import_map = new ImportMap(); $result = 0; $import_map = $import_map->retrieve($_REQUEST['import_map_id'], false); if ($_REQUEST['publish'] == 'yes') { $result = $import_map->mark_published($current_user->id, "yes"); if ($result == -1) { $error_msg = "Unable to publish. There is another published Import Map by the same name."; } } else { if ($_REQUEST['publish'] == 'no') { // if you don't own this importmap, you do now! // unless you have a map by the same name $result = $import_map->mark_published($current_user->id, "no");