function node_views_analyze
Implements hook_views_analyze().
File
-
modules/
node.views.inc, line 774
Code
function node_views_analyze($view) {
$ret = array();
// Check for something other than the default display.
if ($view->base_table == 'node') {
foreach ($view->display as $display) {
if (empty($display->handler)) {
continue;
}
if (!$display->handler
->is_defaulted('access') || !$display->handler
->is_defaulted('filters')) {
// Check for no access control.
$access = $display->handler
->get_option('access');
if (empty($access['type']) || $access['type'] == 'none') {
$select = db_select('role', 'r');
$select->innerJoin('role_permission', 'p', 'r.rid = p.rid');
$result = $select->fields('r', array(
'name',
))
->fields('p', array(
'permission',
))
->condition('r.name', array(
'anonymous user',
'authenticated user',
), 'IN')
->condition('p.permission', 'access content')
->execute();
foreach ($result as $role) {
$role->safe = TRUE;
$roles[$role->name] = $role;
}
if (!($roles['anonymous user']->safe && $roles['authenticated user']->safe)) {
$ret[] = views_ui_analysis(t('Some roles lack permission to access content, but display %display has no access control.', array(
'%display' => $display->display_title,
)), 'warning');
}
$filters = $display->handler
->get_option('filters');
foreach ($filters as $filter) {
if ($filter['table'] == 'node' && ($filter['field'] == 'status' || $filter['field'] == 'status_extra')) {
continue 2;
}
}
$ret[] = views_ui_analysis(t('Display %display has no access control but does not contain a filter for published nodes.', array(
'%display' => $display->display_title,
)), 'warning');
}
}
}
}
foreach ($view->display as $display) {
if ($display->display_plugin == 'page') {
if ($display->handler
->get_option('path') == 'node/%') {
$ret[] = views_ui_analysis(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', array(
'%display' => $display->display_title,
)), 'warning');
}
}
}
return $ret;
}