Commit d0cb2dbe authored by KarenS's avatar KarenS

#63240 Implement new views access callback feature and add install file with...

#63240 Implement new views access callback feature and add install file with warning that permissions need to be set, patch by Moshe Weitzman.
parent 833886f8
......@@ -102,6 +102,9 @@ function content_views_field_views_data($field) {
'additional fields' => $columns,
'content_field_name' => $field['field_name'],
'allow_empty' => TRUE,
// Access control modules should implement content_views_access_callback().
'access callback' => 'content_views_access_callback',
'access arguments' => array($field),
),
'argument' => array(
'field' => $columns[0],
......@@ -260,21 +263,6 @@ class views_handler_field_content extends views_handler_field_node {
$this->content_field = content_fields($this->definition['content_field_name']);
}
/**
* This provides a method of controlling field-level access in Views.
*/
function access() {
// Avoid FALSE returns for non-existant hooks by using module_implements()
// to check only modules that implement the hook.
$modules = module_implements('content_views_access');
foreach ($modules as $module) {
if (module_invoke($module, 'content_views_access', $this->definition['content_field_name']) === FALSE) {
return FALSE;
}
}
return parent::access();
}
function options(&$options) {
parent::options($options);
$field = $this->content_field;
......
<?php
// $Id$
/**
* Implementation of hook_install().
*/
function content_permissions_install() {
drupal_set_message(t('Please <a href="!url">configure your field permissions</a> immediately. All fields are inaccessible by default.', array('!url' => url('admin/user/access', array('fragment' => 'content_permissions')))));
}
\ No newline at end of file
<?php
/**
* TODO:
* Views access implementation
* Fieldgroups
*/
// $Id$
/**
* Implementation of hook_perm().
*/
......@@ -19,7 +12,7 @@ function content_permissions_perm() {
}
/**
* Implementation of hook_form_alter().
* Implementation of hook_form_alter(). Remove inaccessible fields from node display.
*/
function content_permissions_form_alter(&$form, $form_state, $form_id) {
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
......@@ -33,7 +26,7 @@ function content_permissions_form_alter(&$form, $form_state, $form_id) {
}
/**
* Implementation of hook_nodeapi().
* Implementation of hook_nodeapi(). Remove inaccessible fields from node display.
*/
function content_permissions_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'view') {
......@@ -47,8 +40,10 @@ function content_permissions_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
}
/**
* Implementation of hook_content_views_access().
* The default field access callback. Remove inaccessible fields from Views.
*
* @see content_views_field_views_data().
*/
function content_permissions_content_views_access($field_name) {
return user_access('view '. $field_name);
function content_views_access_callback($field) {
return user_access('view '. $field['field_name']);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment