home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (views_handler_filter_node_access.inc)

This example Drupal source code file (views_handler_filter_node_access.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

as, can_expose, condition, extends, foreach, form, function, gid, gids, grants, nodes, php, realm, table

The views_handler_filter_node_access.inc Drupal example source code

// $Id: views_handler_filter_node_access.inc,v 2010/08/26 09:41:55 dereine Exp $
 * Filter by node_access records.
class views_handler_filter_node_access extends views_handler_filter {
  function admin_summary() { }
  function operator_form(&$form, &$form_state) { }
  function can_expose() {
    return FALSE;

   * See _node_access_where_sql() for a non-views query based implementation.
  function query() {
    if (!user_access('administer nodes')) {
      $table = $this->ensure_my_table();
      $grants = db_or();
      foreach (node_access_grants('view') as $realm => $gids) {
        foreach ($gids as $gid) {
            ->condition($table . '.gid', $gid)
            ->condition($table . '.realm', $realm)

      $this->query->add_where('AND', $grants);
      $this->query->add_where('AND', $table . '.grant_view', 1, '>=');

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_filter_node_access.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.