Hi
I wanted to use the Flexinode module to create unique nodes, but I also wanted to be able to restrict viewing or accessing a flexinode by role. I've found a simple way to do this in changing the flexinode_perm and flexinode_access functions:
function flexinode_perm() {
$perms = array('administer content types');
foreach (flexinode_content_types() as $ctype) {
$perms[] = 'view '. $ctype->name .' content';
$perms[] = 'create '. $ctype->name .' content';
$perms[] = 'edit own '. $ctype->name .' content';
$perms[] = 'edit any '. $ctype->name .' content';
}
return $perms;
}
function flexinode_access($op, $node) {
global $user;
if (!is_object($node)) {
$type = $node;
$node = new StdClass();
$node->type = $type;
}
if ($op == 'view') {
return user_access('view '. node_get_name($node) .' content');
}
if ($op == 'create') {
return user_access('create '. node_get_name($node) .' content');
}
if ($op == 'update') {
foreach ($node as $fieldname => $field) {
if (preg_match('!flexinode_[0-9]+_format!', $fieldname) && !filter_access($field)) {
return FALSE;
}
}
}
if ($op == 'update' || $op == 'delete') {
if (user_access('edit any '. node_get_name($node) .' content')) {
return TRUE;
}
elseif (user_access('edit own '. node_get_name($node) .' content') && ($user->uid == $node->uid)) {