views_handler_filter_node_access.inc

  1. 3.x modules/node/views_handler_filter_node_access.inc
  2. 2.x modules/node/views_handler_filter_node_access.inc

File

modules/node/views_handler_filter_node_access.inc
View source
  1. <?php
  2. /**
  3. * Filter by node_access records.
  4. */
  5. class views_handler_filter_node_access extends views_handler_filter {
  6. function admin_summary() { }
  7. function operator_form() { }
  8. function can_expose() {
  9. return FALSE;
  10. }
  11. /**
  12. * See _node_access_where_sql() for a non-views query based implementation.
  13. */
  14. function query() {
  15. if (!user_access('administer nodes')) {
  16. $table = $this->ensure_my_table();
  17. $grants = array();
  18. foreach (node_access_grants('view') as $realm => $gids) {
  19. foreach ($gids as $gid) {
  20. $grants[] = "($table.gid = $gid AND $table.realm = '$realm')";
  21. }
  22. }
  23. $grants_sql = '';
  24. if (count($grants)) {
  25. $grants_sql = implode(' OR ', $grants);
  26. }
  27. $this->query->add_where('AND', $grants_sql);
  28. $this->query->add_where('AND', "$table.grant_view >= 1");
  29. }
  30. }
  31. }