* @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @link     http://www.mediboard.org */
$date = CValue::get("date");
$user_id = CValue::get("user_id", null);
$words = html_entity_decode(CValue::get("words"));
$object_ref_id = CValue::get("object_ref_id");
$object_ref_class = CValue::get("object_ref_class");
$fuzzy_search = CValue::get("fuzzy_search", null);
$fuzzy_search = CValue::get("fuzzy_search", null);
$types = CValue::get("types", array());
// Recherche par aggreg pour les logs
if ($date || $user_id) {
    $client_index = new CSearchLog();
    $client_index->createClient();
    $client_index->loadIndex($client_index->loadNameIndex());
    $date = CMbDT::format($date, "%Y/%m/%d");
    $words .= "date:[" . $date . " TO " . "{$date}] user_id:(" . $user_id . ")";
    $agregation = array();
    $tabActive = "";
    if (!$types) {
        $types = $client_index->loadContextes();
    }
} else {
    $client_index = new CSearch();
    $client_index->createClient();
    $client_index->loadIndex();
    $words .= " object_ref_class:" . $object_ref_class . " " . "object_ref_id:" . $object_ref_id;
    $results = $client_index->queryByType($words, null, $types);
    $agregation = $results->getAggregation("ref_type");
    $tabActive = $agregation["buckets"][0]["key"];