You are here

function block_access_set_allowable_regions_config in Block Access 7

Attempts to set the allowable regions for each theme (config) - if none, all are assumed

Parameters

type $module:

type $delta:

type $form:

1 call to block_access_set_allowable_regions_config()
block_access_check_config_form in ./block_access.module

File

./block_access.module, line 262

Code

function block_access_set_allowable_regions_config($module, $delta, &$form) {
  global $theme;
  if (user_access(BLOCK_ACCESS_ALL_CONFIG_REGION)) {
    return TRUE;
  }

  // Loop over each region listed in the options panel
  $default_value = NULL;
  foreach ($form['regions'] as $heading => $hval) {

    //    if ((is_array($heading)) && (isset($heading['#options']))) {
    if (is_array($hval) && isset($hval['#options'])) {

      // The current theme
      $default_value = NULL;
      foreach ($form['regions'][$heading]['#options'] as $name => $des) {
        if (block_access_user_access($module, $delta, "dreg_{$name}")) {
          if ($form['regions'][$heading]['#default_value'] == $name) {

            //$form['regions'][$heading]['#default_value'] = NULL;
            $form['regions'][$heading]['#access'] = FALSE;
          }
          unset($form['regions'][$heading]['#options'][$name]);
        }
        else {
          $default_value = $name;
        }
      }
    }
  }
}