I would love it if Node-Level Blocks supported Domain Access. Specifically in conjunction with NodeBlocks. The problem is I have a number of domains (sub-sites) that have a similar structure and therefore I have a number of NodeBlocks that have the same Title. When I'm logged into one domain and edit a node, the Node-Level Blocks fieldset has NodeBlocks for all of the domains not jus the domains that I have access to :s

Comments

GregSmith104’s picture

I was able to cobble something together that seems to work and is somewhat elegant based on the fact that Domain Access uses node_access() to determine what content is available on a given domain.

I created a function to check if the current user has access to the given block if it's a nodeblock...otherwise it just returns TRUE.

function nlb_check_domain_access($block) {
  if($block['module']['#value'] == 'nodeblock') {
    return node_access('view', node_load($block['delta']['#value']));
  } else {
    return TRUE;
  }
}

I added a call to this function inside of an if check in function template_preprocess_node_level_blocks_fieldset around line 286

...
// Only take form elements that are blocks.
    if (isset($block['info']) && nlb_check_domain_access($block)) {
...

Seems to work, but it would be nice to have someone else verify this.

Johnny vd Laar’s picture

Access checks in the template layer isn't a good practice. Node level blocks also isn't responsible for hiding nodeblocks. Nodeblock module should take care of this I think.

As I'm the maintainer of both modules I will look into a good solution.

GregSmith104’s picture

Thanks Johnny :D Everything works perfectly on the front-end with no mods, but de-cluttering the Node-Level blocks admin based on Domain Access rules would be AWESOME!

Johnny vd Laar’s picture

Status: Active » Closed (works as designed)