getModuleTitleIconPath($this->module); $returnArray = array(); if (!empty($iconPath) && !$browserTitle) { $returnArray[] = "{$app_list_strings["; } else { $returnArray[] = $app_list_strings['moduleList'][$_REQUEST['import_module']]; } $returnArray[] = "".$mod_strings['LBL_MODULE_NAME'].""; $returnArray[] = $mod_strings['LBL_STEP_1_TITLE']; return $returnArray; } private function _retrieveParams() { $selectedData = new stdClass(); foreach ($_POST as $key => &$value) { trim(strip_tags($value)); $selectedData->$key = $value; } if (isset($selectedData->custom_enclosure)) { if ($selectedData->custom_enclosure != '"' and $selectedData->custom_enclosure != ''' and $selectedData->custom_enclosure != '') { $selectedData->custom_other = true; } } $this->ss->assign('selectedData', $selectedData); return $selectedData; } /** * @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'); } /** * Returns JS used in this view */ private function _getJS($sourceType = false) { global $mod_strings; if (!$sourceType) { $sourceType = 'csv'; } $getElementById = "document.getElementById('source_{$sourceType}')"; $sourceType = "defineEnclosureSelectPosition('{$sourceType}', {$getElementById});"; return << EOJAVASCRIPT; } } ?>