You are here

function block_access_set_allowable_regions in Block Access 7

Attempts to set the allowable regions - if none, all are assumed

Parameters

type $module:

type $delta:

type $form:

1 call to block_access_set_allowable_regions()
block_access_check_perms in ./block_access.module

File

./block_access.module, line 231

Code

function block_access_set_allowable_regions($module, $delta, $key, &$form) {

  // Loop over each region listed in the options panel
  $default_value = NULL;
  $return = TRUE;
  if (user_access(BLOCK_ACCESS_ALL_CONFIG_REGION)) {
    return TRUE;
  }
  foreach ($form['blocks'][$key]['region']['#options'] as $name => $des) {
    if (block_access_user_access($module, $delta, "dreg_{$name}")) {
      if ($form['blocks'][$key]['region']['#default_value'] == $name) {

        // Do not allow them to change if in a region they do not have access to
        $form['blocks'][$key]['region']['#access'] = FALSE;
      }
      unset($form['blocks'][$key]['region']['#options'][$name]);
    }
    else {
      $default_value = $name;
    }
  }
  return $return;
}