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

Comments

nobody1225’s picture

subscribe. +1 ,thanks.

pbarnett’s picture

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

Andreas Kohlbecker’s picture

StatusFileSize
new2.8 KB

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:


/**
 * 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):

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

Andreas Kohlbecker’s picture

Category: support » bug
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.