Hi all!
A few days ago i started considering how to solve the following UseCase in Drupal:
- Have a node with some information and some downloads
- only participants can view and access the downloads
Thoughts:
- use new node-type module and add all functionality
- use cck for new node-type
- use userreference module for the participants
- use download-module from drupal (and node and file hooks)
- use cck download field and hook_field_access() from cck
I have done:
- Created new ContentType including the UserReference and the FileField
- wrote the following code for fieldaccess_userreference
Problems:
- I cannot access the $nid - is there an other way to access the current node??
- Does the download-link work if a field is inaccessible? (first tests seem so - with dl method set to private)
- How far is the integration (iin the upper mentioned case) inn Drupal7 or how will i solve this in the upcoming version of drupal (might be an option ^^)
/**
* Implementation of hook_field_access().
*
* @see content_access().
*/
function fieldaccess_userreference_field_access($op, $field, $account) {
//TODO: read the configured fields - current version shows/hides all fields
global $user; //current user
global $nid; //current node
$node = node_load($nid);
$access = FALSE; //later: get default access permission