function node_views_analyze in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 6.3 modules/node.views.inc \node_views_analyze()
- 6.2 modules/node.views.inc \node_views_analyze()
- 7.3 modules/node.views.inc \node_views_analyze()
Implements hook_views_analyze().
File
- modules/
node.views.inc, line 712 - Provide views data and handlers for node.module.
Code
function node_views_analyze($view) {
$ret = array();
// Check for something other than the default display:
if ($view->base_table == 'node') {
foreach ($view->displayHandlers as $id => $display) {
if (!$display
->isDefaulted('access') || !$display
->isDefaulted('filters')) {
// check for no access control
$access = $display
->getOption('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(
'rid',
))
->fields('p', array(
'permission',
))
->condition('r.rid', array(
'anonymous',
'authenticated',
), 'IN')
->condition('p.permission', 'access content')
->execute();
foreach ($result as $role) {
$role->safe = TRUE;
$roles[$role->rid] = $role;
}
if (!($roles['anonymous']->safe && $roles['authenticated']->safe)) {
$ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', array(
'%display' => $display['display_title'],
)), 'warning');
}
$filters = $display
->getOption('filters');
foreach ($filters as $filter) {
if ($filter['table'] == 'node' && ($filter['field'] == 'status' || $filter['field'] == 'status_extra')) {
continue 2;
}
}
$ret[] = Analyzer::formatMessage(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 $id => $display) {
if ($display
->getPluginId() == 'page') {
if ($display
->getOption('path') == 'node/%') {
$ret[] = Analyzer::formatMessage(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;
}