diff --git a/modules/node/views_handler_filter_node_access.inc b/modules/node/views_handler_filter_node_access.inc index a29b13f..6e98b28 100644 --- a/modules/node/views_handler_filter_node_access.inc +++ b/modules/node/views_handler_filter_node_access.inc @@ -17,14 +17,32 @@ class views_handler_filter_node_access extends views_handler_filter { return FALSE; } + function options_form(&$form, &$form_state) { + $form['value'] = array( + '#type' => 'select', + '#title' => t('Node access'), + '#description' => t('Level of access to a node'), + '#options' => array( + 'view' => t('View'), + 'update' => t('Edit'), + 'delete' => t('Delete'), + ), + '#default_value' => $this->value ? $views->value : 'view', + ); + $form['caution'] = array( + '#markup' => t('Note: for Edit and Delete access, only node access grants are checked. Modules can override node access grants to allow or deny actions, so this check does not necessarily reflect whether the user can actually perform the Edit or Delete action.'), + ); + } + + /** * See _node_access_where_sql() for a non-views query based implementation. */ function query() { if (!user_access('administer nodes') && module_implements('node_grants')) { + $access = !empty($this->value) ? $this->value : 'view'; $table = $this->ensure_my_table(); $grants = db_or(); - foreach (node_access_grants('view') as $realm => $gids) { + foreach (node_access_grants($access) as $realm => $gids) { foreach ($gids as $gid) { $grants->condition(db_and() ->condition($table . '.gid', $gid) @@ -34,7 +52,7 @@ class views_handler_filter_node_access extends views_handler_filter { } $this->query->add_where('AND', $grants); - $this->query->add_where('AND', $table . '.grant_view', 1, '>='); + $this->query->add_where('AND', $table . '.grant_'. $access, 1, '>='); } } }