X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fnode%2Fnode.views_execution.inc;fp=web%2Fcore%2Fmodules%2Fnode%2Fnode.views_execution.inc;h=4d834a11e3556ba5e1628458faebd8a0fba2226d;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/node/node.views_execution.inc b/web/core/modules/node/node.views_execution.inc new file mode 100644 index 000000000..4d834a11e --- /dev/null +++ b/web/core/modules/node/node.views_execution.inc @@ -0,0 +1,63 @@ + intval($account->hasPermission('administer nodes')), + '***VIEW_OWN_UNPUBLISHED_NODES***' => intval($account->hasPermission('view own unpublished content')), + '***BYPASS_NODE_ACCESS***' => intval($account->hasPermission('bypass node access')), + ]; +} + +/** + * Implements hook_views_analyze(). + */ +function node_views_analyze(ViewExecutable $view) { + $ret = []; + // Check for something other than the default display: + if ($view->storage->get('base_table') == 'node') { + foreach ($view->displayHandlers as $display) { + if (!$display->isDefaulted('access') || !$display->isDefaulted('filters')) { + // check for no access control + $access = $display->getOption('access'); + if (empty($access['type']) || $access['type'] == 'none') { + $anonymous_role = Role::load(RoleInterface::ANONYMOUS_ID); + $anonymous_has_access = $anonymous_role && $anonymous_role->hasPermission('access content'); + $authenticated_role = Role::load(RoleInterface::AUTHENTICATED_ID); + $authenticated_has_access = $authenticated_role && $authenticated_role->hasPermission('access content'); + if (!$anonymous_has_access || !$authenticated_has_access) { + $ret[] = Analyzer::formatMessage(t('Some roles lack permission to access content, but display %display has no access control.', ['%display' => $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.', ['%display' => $display->display['display_title']]), 'warning'); + } + } + } + } + foreach ($view->displayHandlers as $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.', ['%display' => $display->display['display_title']]), 'warning'); + } + } + } + + return $ret; +}