grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026".translate("LBL_USE_AOD_SEARCH", "AOD_Index")."";
}
require_once('modules/Home/UnifiedSearchAdvanced.php');
global $mod_strings, $modListHeader, $app_strings, $beanList, $beanFiles;
$usa = new UnifiedSearchAdvanced();
$usa->search();
return;
}
require_once('include/utils.php');
echo "".translate("LBL_USE_VANILLA_SEARCH", "AOD_Index")."";
$index = BeanFactory::getBean("AOD_Index")->getIndex();
$hits = array();
$start = 0;
$amount = 20;
$total = 0;
if (!empty($_REQUEST['start'])) {
$start = $_REQUEST['start'];
}
if (!empty($_REQUEST['total'])) {
$total = $_REQUEST['total'];
}
if (array_key_exists('listViewStartButton', $_REQUEST)) {
$start = 0;
} elseif (array_key_exists('listViewPrevButton', $_REQUEST)) {
$start = max($start - $amount, 0);
} elseif (array_key_exists('listViewNextButton', $_REQUEST)) {
$start = min($start + $amount, $total);
} elseif (array_key_exists('listViewEndButton', $_REQUEST)) {
$start = floor($total / $amount) * $amount;
}
if ($queryString) {
$res = doSearch($index, $queryString, $start, $amount);
$total = $res['total'];
$hits = $res['hits'];
}
?>
|
|
|
|
|
|
|
"
."".$hit->label." | "
."".$hit->name." | "
."".$hit->summary." | "
."".$hit->date_entered." | "
."".$hit->date_modified." | "
."".getScoreDisplay($hit)." | "
."";
}
?>
".translate("LBL_SEARCH_RESULT_EMPTY","AOD_Index")."";
}
?>
module_dir])) {
if (file_exists('custom/modules/'.$bean->module_dir.'/metadata/listviewdefs.php')) {
require('custom/modules/'.$bean->module_dir.'/metadata/listviewdefs.php');
} else {
if (file_exists('modules/'.$bean->module_dir.'/metadata/listviewdefs.php')) {
require('modules/'.$bean->module_dir.'/metadata/listviewdefs.php');
}
}
}
if (!isset($listViewDefs) || !isset($listViewDefs[$bean->module_dir])) {
return $bean->get_summary_text();
}
$summary = array();
;
foreach ($listViewDefs[$bean->module_dir] as $key => $entry) {
if (!$entry['default']) {
continue;
}
$key = strtolower($key);
if (in_array($key, array('date_entered','date_modified','name'))) {
continue;
}
$summary[] = $bean->$key;
}
$summary = array_filter($summary);
return implode(' || ', $summary);
}
function getScoreDisplay($hit)
{
return number_format(100*$hit->score, 2);
}
function unCamelCase($input, $sep = " ")
{
$output = preg_replace(array('/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/'), $sep.'$0', $input);
return ucwords($output);
}
function getModuleLabel($module)
{
return translate('LBL_MODULE_NAME', $module);
}
function cacheQuery($queryString, $resArray)
{
$file = create_cache_directory('modules/AOD_Index/QueryCache/' . md5($queryString));
$out = serialize($resArray);
sugar_file_put_contents_atomic($file, $out);
}
function getCorrectMTime($filePath)
{
$time = filemtime($filePath);
$isDST = (date('I', $time) == 1);
$systemDST = (date('I') == 1);
$adjustment = 0;
if ($isDST == false && $systemDST == true) {
$adjustment = 3600;
} elseif ($isDST == true && $systemDST == false) {
$adjustment = -3600;
} else {
$adjustment = 0;
}
return ($time + $adjustment);
}
function doSearch($index, $queryString, $start = 0, $amount = 20)
{
global $current_user;
$cachePath = 'cache/modules/AOD_Index/QueryCache/' . md5($queryString);
if (is_file($cachePath)) {
$mTime = getCorrectMTime($cachePath);
if ($mTime > (time() - 5*60)) {
$hits = unserialize(sugar_file_get_contents($cachePath));
}
}
if (!isset($hits)) {
$tmphits = $index->find($queryString);
$hits = array();
foreach ($tmphits as $hit) {
$bean = BeanFactory::getBean($hit->record_module, $hit->record_id);
if (empty($bean)) {
continue;
}
if ($bean->bean_implements('ACL') && !is_admin($current_user)) {
//Annoyingly can't use the following as it always passes true for is_owner checks on list
//$bean->ACLAccess('list');
$in_group = SecurityGroup::groupHasAccess($bean->module_dir, $bean->id, 'list');
$is_owner = $bean->isOwner($current_user->id);
$access = ACLController::checkAccess($bean->module_dir, 'list', $is_owner, 'module', $in_group);
if (!$access) {
continue;
}
}
$newHit = new stdClass;
$newHit->record_module = $hit->record_module;
$newHit->record_id = $hit->record_id;
$newHit->score = $hit->score;
$newHit->label = getModuleLabel($bean->module_name);
$newHit->name = $bean->get_summary_text();
$newHit->summary = getRecordSummary($bean);
$newHit->date_entered = $bean->date_entered;
$newHit->date_modified = $bean->date_modified;
$hits[] = $newHit;
}
//Cache results so pagination is nice and snappy.
cacheQuery($queryString, $hits);
}
$total = count($hits);
$hits = array_slice($hits, $start, $amount);
$res = array('total'=>$total,'hits' => $hits);
return $res;
}
function getPaginateHTML($queryString, $start, $amount, $total)
{
$first = !$start;
$last = ($start + $amount) > $total;
if ($first) {
$startImage = SugarThemeRegistry::current()->getImageURL('start_off.gif');
$prevImage = SugarThemeRegistry::current()->getImageURL('previous_off.gif');
} else {
$startImage = SugarThemeRegistry::current()->getImageURL('start.gif');
$prevImage = SugarThemeRegistry::current()->getImageURL('previous.gif');
}
if ($last) {
$endImage = SugarThemeRegistry::current()->getImageURL('end_off.gif');
$nextImage = SugarThemeRegistry::current()->getImageURL('next_off.gif');
} else {
$endImage = SugarThemeRegistry::current()->getImageURL('end.gif');
$nextImage = SugarThemeRegistry::current()->getImageURL('next.gif');
} ?>