The patch checks the user's roles against the block's roles.

CommentFileSizeAuthor
homebox.module_blockRoles.patch1.97 KBrocnhorse
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

benlotter’s picture

Could you paste the text of the fix? This looks like what I need but I don't how to read or use the patch files.

rocnhorse’s picture

Find the line ~322
foreach ($page->settings['blocks'] as $key => $block) {

replace:

    if (!isset($info[$block['module']])) {
      $info[$block['module']] = module_invoke($block['module'], 'block', 'list');
    }
    $allowed_blocks[$block['module']][$block['delta']] = $info[$block['module']][$block['delta']];
    if (!empty($block['title'])) {
      $allowed_blocks[$block['module']][$block['delta']]['info'] = $block['title'];
    }

with:

    // Check the block's roles against the user's roles
    $blockRoles = array();
    $result = db_query("SELECT rid FROM {blocks_roles} WHERE module='%s' AND delta='%s'", $block['module'], $block['delta']);
    while ($result && ($row = db_fetch_object($result))) {
       $blockRoles[$row->rid] = $row->rid;
    }
    // If the block has no roles or the user has a matching role show the block
    if(empty($blockRoles) || 0 < count(array_intersect_key($user->roles,$blockRoles))){
        if (!isset($info[$block['module']])) {
          $info[$block['module']] = module_invoke($block['module'], 'block', 'list');
        }
        $allowed_blocks[$block['module']][$block['delta']] = $info[$block['module']][$block['delta']];
        if (!empty($block['title'])) {
          $allowed_blocks[$block['module']][$block['delta']]['info'] = $block['title'];
        }
     }
  }
drumm’s picture

Issue summary: View changes
Status: Needs review » Closed (cannot reproduce)

I believe this has been fixed in the Drupal 7 version.