false, 'show_title' => false, 'show_subpanels' => false, 'show_search' => true, 'show_footer' => false, 'show_javascript' => false, 'view_print' => false,); public function init($bean, $view_object_map) { $this->seed = $bean; } public function display(){ if ( isset($_REQUEST['name_basic']) ) { $file_search = trim($_REQUEST['name_basic']); } else { $file_search = ''; } if ( !isset($_REQUEST['apiName']) ) { $apiName = 'LotusLive'; } else { $tmpApi = ExternalAPIFactory::loadAPI($_REQUEST['apiName'],true); if ( $tmpApi === false ) { $GLOBALS['log']->error('The user attempted to access an invalid external API ('.$_REQUEST['apiName'].')'); return; } $apiName = $_REQUEST['apiName']; } // See if we are running as a popup window if ( isset($_REQUEST['isPopup']) && $_REQUEST['isPopup'] == 1 && !empty($_REQUEST['elemBaseName']) ) { $isPopup = true; } else { $isPopup = false; } // Need to manually attempt to fetch the EAPM record, we don't want to give them the signup screen when they just have a deactivated account. if ( !$eapmBean = EAPM::getLoginInfo($apiName,true) ) { $smarty = new Sugar_Smarty(); echo $smarty->fetch('include/externalAPI/'.$apiName.'/'.$apiName.'Signup.'.$GLOBALS['current_language'].'.tpl'); return; } $api = ExternalAPIFactory::loadAPI($apiName,true); $api->loadEAPM($eapmBean); $quickCheck = $api->quickCheckLogin(); if ( ! $quickCheck['success'] ) { $errorMessage = string_format(translate('LBL_ERR_FAILED_QUICKCHECK','EAPM'), array($apiName)); $errorMessage .= '
'; $errorMessage .= ''; $errorMessage .= ''; $errorMessage .= ''; $errorMessage .= ''; $errorMessage .= ''; $errorMessage .= ''; $errorMessage .= '
 '; $errorMessage .= ''; $errorMessage .= '
'; echo $errorMessage; return; } $searchDataLower = $api->searchDoc($file_search,true); // In order to emulate the list views for the SugarFields, I need to uppercase all of the key names. $searchData = array(); if ( is_array($searchDataLower) ) { foreach ( $searchDataLower as $row ) { $newRow = array(); foreach ( $row as $key => $value ) { $newRow[strtoupper($key)] = $value; } if ( $isPopup ) { // We are running as a popup window, we need to replace the direct url with some javascript $newRow['DOC_URL'] = "javascript:window.opener.SUGAR.field.file.populateFromPopup('".addslashes($_REQUEST['elemBaseName'])."','".addslashes($newRow['ID'])."','".addslashes($newRow['NAME'])."','".addslashes($newRow['URL'])."','".addslashes($newRow['URL'])."'); window.close();"; }else{ $newRow['DOC_URL'] = $newRow['URL']; } $searchData[] = $newRow; } } $displayColumns = array( 'NAME' => array( 'label' => 'LBL_LIST_EXT_DOCUMENT_NAME', 'type' => 'varchar', 'link' => true, ), 'DATE_MODIFIED' => array( 'label' => 'LBL_DATE', 'type' => 'date', ), ); $ss = new Sugar_Smarty(); $ss->assign('searchFieldLabel',translate('LBL_SEARCH_EXTERNAL_DOCUMENT','Documents')); $ss->assign('displayedNote',translate('LBL_EXTERNAL_DOCUMENT_NOTE','Documents')); $ss->assign('APP',$GLOBALS['app_strings']); $ss->assign('MOD',$GLOBALS['mod_strings']); $ss->assign('data', $searchData); $ss->assign('displayColumns',$displayColumns); $ss->assign('imgPath',SugarThemeRegistry::current()->getImageURL($apiName.'_image_inline.png')); if ( $isPopup ) { $ss->assign('linkTarget',''); $ss->assign('isPopup',1); $ss->assign('elemBaseName',$_REQUEST['elemBaseName']); } else { $ss->assign('linkTarget','_new'); $ss->assign('isPopup',0); $ss->assign('elemBaseName',''); } $ss->assign('apiName',$apiName); $ss->assign('DCSEARCH',$file_search); if ( $isPopup ) { // Need the popup header... I feel so dirty. ob_start(); echo('
'); insert_popup_header($GLOBALS['theme'], false); $output_html = ob_get_contents(); ob_end_clean(); $output_html .= get_form_header(translate('LBL_SEARCH_FORM_TITLE','Documents'), '', false); echo($output_html); } $ss->display('modules/Documents/tpls/view.extdoc.tpl'); if ( $isPopup ) { // Close the dccontent div echo('
'); } } }