function search_restrict_query_node_access_alter in Search Restrict 7
Implements hook_query_node_access_alter().
File
- ./
search_restrict.module, line 74 - Restrict by role who can search for each content type.
Code
function search_restrict_query_node_access_alter(QueryAlterableInterface $query) {
global $user;
if ($user->uid == 1) {
return;
}
$search = FALSE;
$node = FALSE;
foreach ($query
->getTables() as $alias => $table) {
if ($table['table'] == 'search_index') {
$search = $alias;
}
elseif ($table['table'] == 'node') {
$node = $alias;
}
}
if ($node && $search) {
$excluded_content_types = _search_restrict_excluded_content_types();
if (!empty($excluded_content_types)) {
$query
->condition($node . '.type', array(
$excluded_content_types,
), 'NOT IN');
}
}
}