currentStep = isset($_REQUEST['current_step']) ? ($_REQUEST['current_step'] + 1) : 1; $this->importModule = isset($_REQUEST['import_module']) ? $_REQUEST['import_module'] : ''; if( isset($_REQUEST['from_admin_wizard']) && $_REQUEST['from_admin_wizard'] ) { $this->importModule = 'Administration'; } } /** * @see SugarView::_getModuleTitleParams() */ protected function _getModuleTitleParams($browserTitle = false) { global $mod_strings, $app_list_strings; $iconPath = $this->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; } /** * @see SugarView::display() */ public function display() { global $mod_strings, $app_strings, $current_user; global $sugar_config; $this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false)); $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"',null,null,'.gif',$app_strings['LNK_DELETE'])); $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline','align="absmiddle" border="0"', null,null,'.gif',$mod_strings['LBL_PUBLISH'])); $this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline','align="absmiddle" border="0"', null,null,'.gif',$mod_strings['LBL_UNPUBLISH'])); $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']); $showModuleSelection = ($this->importModule == 'Administration'); $importableModulesOptions = array(); $importablePersonModules = array(); //If we are coming from the admin link, get the module list. if($showModuleSelection) { $tmpImportable = Importer::getImportableModules(); $importableModulesOptions = get_select_options_with_id($tmpImportable, ''); $importablePersonModules = $this->getImportablePersonModulesJS(); $this->ss->assign("IMPORT_MODULE", key($tmpImportable)); } else { $this->instruction = 'LBL_SELECT_DS_INSTRUCTION'; $this->ss->assign('INSTRUCTION', $this->getInstruction()); } $this->ss->assign("FROM_ADMIN", $showModuleSelection); $this->ss->assign("PERSON_MODULE_LIST", json_encode($importablePersonModules)); $this->ss->assign("showModuleSelection", $showModuleSelection); $this->ss->assign("IMPORTABLE_MODULES_OPTIONS", $importableModulesOptions); $this->ss->assign("EXTERNAL_SOURCES", $this->getAllImportableExternalEAPMs()); $this->ss->assign("EXTERNAL_AUTHENTICATED_SOURCES", json_encode($this->getAuthenticatedImportableExternalEAPMs()) ); $selectExternal = !empty($_REQUEST['application']) ? $_REQUEST['application'] : ''; $this->ss->assign("selectExternalSource", $selectExternal); $content = $this->ss->fetch('modules/Import/tpls/step1.tpl'); $submitContent = "
"; $submitContent .= ""; $submitContent .= "
"; $this->ss->assign("JAVASCRIPT",$this->_getJS() ); $this->ss->assign("CONTENT",$content); $this->ss->display('modules/Import/tpls/wizardWrapper.tpl'); } private function getImportablePersonModulesJS() { global $beanList; $results = array(); foreach ($beanList as $moduleName => $beanName) { if( class_exists($beanName) ) { $tmp = new $beanName(); if( isset($tmp->importable) && $tmp->importable && ($tmp instanceof Person)) $results[$moduleName] = $moduleName; } } return $results; } private function getAllImportableExternalEAPMs() { ExternalAPIFactory::clearCache(); return ExternalAPIFactory::getModuleDropDown('Import', TRUE, FALSE); } private function getAuthenticatedImportableExternalEAPMs() { return ExternalAPIFactory::getModuleDropDown('Import', FALSE, FALSE); } /** * Returns JS used in this view */ private function _getJS($sourceType = false) { global $mod_strings; $EXTERNAL_AUTHENTICATED_SOURCES = json_encode($this->getAuthenticatedImportableExternalEAPMs()); $selectExternalSource = !empty($_REQUEST['application']) ? $_REQUEST['application'] : ''; $showModuleSelection = ($this->importModule == 'Administration'); $importableModulesOptions = array(); $importablePersonModules = array(); //If we are coming from the admin link, get the module list. if($showModuleSelection) { $importablePersonModules = $this->getImportablePersonModulesJS(); } $PERSON_MODULE_LIST = json_encode($importablePersonModules); return <<= 1) { if(selectedExternalSource == '') oButtonGroup.check(0); } } } YAHOO.util.Event.addListener(['ext_source','csv_source'], "click", toggleExternalSource); function isExtSourceAuthenticated(source) { if( typeof(auth_sources[source]) != 'undefined') return true; else return false; } function isExtSourceValid(v) { if(v == '') { document.getElementById('ext_source_sign_in_bttn').style.display = 'none'; return ''; } if( !isExtSourceAuthenticated(v) ) { document.getElementById('ext_source_sign_in_bttn').style.display = ''; document.getElementById('gonext').disabled = true; } else { document.getElementById('ext_source_sign_in_bttn').style.display = 'none'; document.getElementById('gonext').disabled = false; } } function openExtAuthWindow() { var import_module = document.getElementById('importstep1').import_module.value; var url = "index.php?module=EAPM&return_module=Import&action=EditView&application=" + selectedExternalSource + "&return_action=" + import_module; document.location = url; } function setImportModule() { var selectedModuleEl = document.getElementById('admin_import_module'); if(!selectedModuleEl) { return; } //Check if the module selected by the admin is a person type module, if not hide //the external source. var selectedModule = selectedModuleEl.value; document.getElementById('importstep1').import_module.value = selectedModule; } YAHOO.util.Event.addListener('ext_source_sign_in_bttn', "click", openExtAuthWindow); YAHOO.util.Event.addListener('admin_import_module', "change", setImportModule); function initExtSourceSelection() { var el1 = YAHOO.util.Dom.get('ext_source'); if(selectedExternalSource == '') return; el1.checked = true; toggleExternalSource(); isExtSourceValid(selectedExternalSource); } initExtSourceSelection(); setImportModule(); }); var auth_sources = {$EXTERNAL_AUTHENTICATED_SOURCES} var selectedExternalSource = '{$selectExternalSource}'; var personModules = {$PERSON_MODULE_LIST}; EOJAVASCRIPT; } } ?>