search_api_stats.module in Search API Stats 7
File
search_api_stats.module
View source
<?php
function search_api_stats_permission() {
return array(
'access search api stats' => array(
'title' => t('access search api stats'),
'description' => t('access search api stats.'),
),
);
}
function search_api_stats_search_api_query_alter(SearchApiQueryInterface $query) {
global $user, $language;
$index = $query
->getIndex();
if (!empty($index)) {
$server = $index
->server();
}
if (empty($index) || empty($server)) {
return;
}
$keywords = trim(drupal_strtolower($query
->getOriginalKeys()));
if (!empty($keywords)) {
db_insert('search_api_stats')
->fields(array(
's_name' => $server->machine_name,
'i_name' => $index->machine_name,
'timestamp' => REQUEST_TIME,
'uid' => $user->uid,
'sid' => session_id(),
'keywords' => $keywords,
'filters' => '',
'sort' => '',
'language' => $language->language,
))
->execute();
}
}
function search_api_stats_views_api() {
return array(
'api' => 3.0,
'path' => drupal_get_path('module', 'search_api_stats') . '/includes/views',
);
}