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

Definition of views_handler_filter_node_access.

File

modules/node/views_handler_filter_node_access.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_filter_node_access.
  5. */
  6. /**
  7. * Filter by node_access records.
  8. *
  9. * @ingroup views_filter_handlers
  10. */
  11. class views_handler_filter_node_access extends views_handler_filter {
  12. function admin_summary() { }
  13. function operator_form(&$form, &$form_state) { }
  14. function can_expose() {
  15. return FALSE;
  16. }
  17. /**
  18. * See _node_access_where_sql() for a non-views query based implementation.
  19. */
  20. function query() {
  21. if (!user_access('administer nodes') && module_implements('node_grants')) {
  22. $table = $this->ensure_my_table();
  23. $grants = db_or();
  24. foreach (node_access_grants('view') as $realm => $gids) {
  25. foreach ($gids as $gid) {
  26. $grants->condition(db_and()
  27. ->condition($table . '.gid', $gid)
  28. ->condition($table . '.realm', $realm)
  29. );
  30. }
  31. }
  32. $this->query->add_where('AND', $grants);
  33. $this->query->add_where('AND', $table . '.grant_view', 1, '>=');
  34. }
  35. }
  36. }