Does this work with the Views and Contemplate module?

limbo90 - September 5, 2007 - 17:47
Project:CCK Field Permissions
Version:5.x-1.9
Component:Miscellaneous
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

I have installed this module into a Drupal 5.1 site which is using CCK and the Contemplate module, the resulting node being pushed through the Views module as well.

I have been through the setup process, activating the module, selecthing the appropriate content type, setting the permissions etc. However, the field in question is still being displayed.

Note I am not using groupings with the CCK content type.

Can anyone confirm they have got this module working in this way?

thx,

mark

#1

nobody1225 - September 7, 2007 - 03:31

subscribe. +1 ,thanks.

#2

pbarnett - October 16, 2007 - 17:06

I can confirm that it specifically doesn't work with Views...

#3

Andreas Kohlbecker - November 12, 2007 - 13:12

I implemented a basic views support for CCK Field Permissions module, which at least works with views which are displayed as tables. Sorry, but i had no time for further testing or development. Field access is restricted by unsetting the according field:

<?php


/**
* Implemenation of hook views_pre_view
*/
function cck_field_perms_views_pre_view(&$view, $items){
  foreach(
$view->field as $idx => $field){
   
$field_name = substr($field['field'], 0, ( strlen($field['field']) - strlen('_value')) );
    if(!
cck_field_perms_access(null, $field_name, 'view')){
      unset(
$view->field[$idx]);
      unset(
$view->table_header[$idx]);
    }
  }
}
?>

I know using unset() has caused problems in the past as discussed in http://drupal.org/node/138984, but i decided to use it anyway for this enhancement, at least for now, since i have not discovered any problems with unset and views yet.

The patch (cck_field_perms-views0.1.patch) provided here includes the views functionality and also a little bugfix for another Issue:
The means to set the #access attribute for fields does not work (at least in my developing environment win xp & php5.2.1 and for sure in the case which is mentioned by http://drupal.org/node/183204):

<?php

function cck_field_perms_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
...
/* Line 85 : */  $node->$disallowed_field['#access'] = false;
?>

AttachmentSize
cck_field_perms-views0.1.patch 2.8 KB

#4

Andreas Kohlbecker - November 13, 2007 - 15:45
Category:support request» bug report
Priority:normal» critical
Status:active» needs review

SORRY ! I erroneously posted to the wrong issue here. Since deleting of replies is not possible I replaced it with this message.

 
 

Drupal is a registered trademark of Dries Buytaert.