1) ? $ids[$offset-1] : ''; $menu['CURRENT'] = $ids[$offset]; $menu['NEXT'] = !empty($ids[$offset+1]) ? $ids[$offset+1] : ''; } return $menu; } function menu($module, $offset, $isAuditEnabled, $saveAndContinue = false ){ $html_text = ""; if ($offset < 0) { $offset = 0; } //this check if require in cases when you visit the edit view before visiting that modules list view. //you can do this easily either from home, activities or sitemap. $stored_vcr_query = SugarVCR::retrieve($module); // bug 15893 - only show VCR if called as an element in a set of records if (!empty($_REQUEST['record']) and !empty($stored_vcr_query) and isset($_REQUEST['offset']) and (empty($_REQUEST['isDuplicate']) or $_REQUEST['isDuplicate'] == 'false')) { //syncing with display offset; $offset ++; $action = (!empty($_REQUEST['action']) ? $_REQUEST['action'] : 'EditView'); $menu = SugarVCR::play($module, $offset); $list_link = ''; if ($saveAndContinue && !empty($menu['NEXT'])) { $list_link = ajaxLink('index.php?action=' . $action . '&module=' . $module . '&record=' . $menu['NEXT'] . '&offset=' . ($offset + 1)); } $previous_link = ""; if (!empty($menu['PREV'])) { $previous_link = ajaxLink('index.php?module=' . $module . '&action=' . $action . '&offset=' . ($offset - 1) . '&record=' . $menu['PREV']); } $next_link = ""; if (!empty($menu['NEXT'])) { $next_link = ajaxLink('index.php?module=' . $module . '&action=' . $action . '&offset=' . ($offset + 1) . '&record=' . $menu['NEXT']); } $ss = new Sugar_Smarty(); $ss->assign('app_strings', $GLOBALS['app_strings']); $ss->assign('module', $module); $ss->assign('action', $action); $ss->assign('menu', $menu); $ss->assign('list_link', $list_link); $ss->assign('previous_link', $previous_link); $ss->assign('next_link', $next_link); $ss->assign('offset', $offset); $ss->assign('total', ''); $ss->assign('plus', ''); if (!empty($_SESSION[$module . 'total'])) { $ss->assign('total', $_SESSION[$module . 'total']); if ( !empty($GLOBALS['sugar_config']['disable_count_query']) && (($_SESSION[$module. 'total']-1) % $GLOBALS['sugar_config']['list_max_entries_per_page'] == 0) ) { $ss->assign('plus', '+'); } } if (is_file('custom/include/EditView/SugarVCR.tpl')) { $html_text .= $ss->fetch('custom/include/EditView/SugarVCR.tpl'); } else { $html_text .= $ss->fetch('include/EditView/SugarVCR.tpl'); } } return $html_text; } function record($module, $offset){ $GLOBALS['log']->debug('SUGARVCR is recording more records'); $start = max(0, $offset - VCRSTART); $index = $start; $db = DBManagerFactory::getInstance(); $result = $db->limitQuery(SugarVCR::retrieve($module),$start,($offset+VCREND),false); $index++; $ids = array(); while(($row = $db->fetchByAssoc($result)) != null){ $ids[$index] = $row['id']; $index++; } //now that we have the array of ids, store this in the session $_SESSION[$module.'QUERY_ARRAY'] = $ids; return $ids; } function recordIDs($module, $rids, $offset, $totalCount){ $index = $offset; $index++; $ids = array(); foreach($rids as $id){ $ids[$index] = $id; $index++; } //now that we have the array of ids, store this in the session $_SESSION[$module.'QUERY_ARRAY'] = $ids; $_SESSION[$module.'total'] = $totalCount; } function erase($module){ unset($_SESSION[$module. 'QUERY_ARRAY']); } } ?>