You are here

protected function context_reaction_block::is_editable_region in Context 7.3

Determine whether inline editing requirements are met and that the current user may edit.

3 calls to context_reaction_block::is_editable_region()
context_reaction_block::block_get_blocks_by_region in plugins/context_reaction_block.inc
Get a renderable array of a region containing all enabled blocks.
context_reaction_block::block_list in plugins/context_reaction_block.inc
An alternative version of block_list() that provides any context enabled blocks.
context_reaction_block::editable_region in plugins/context_reaction_block.inc
Add markup for making a region editable.

File

plugins/context_reaction_block.inc, line 272

Class

context_reaction_block
Expose blocks as context reactions.

Code

protected function is_editable_region($region, $reset = FALSE) {

  // Check requirements.
  // Generally speaking, it does not make sense to allow anonymous users to
  // edit a context inline. Though it may be possible to save (and restore)
  // an edited context to an anonymous user's cookie or session, it's an
  // edge case and probably not something we want to encourage anyway.
  static $requirements;
  if (!isset($requirements) || $reset) {
    global $user;
    if ($user->uid && user_access('administer contexts') && variable_get('context_ui_dialog_enabled', FALSE)) {
      $requirements = TRUE;
      drupal_add_library('system', 'ui.droppable');
      drupal_add_library('system', 'ui.sortable');
      drupal_add_js(drupal_get_path('module', 'context') . '/plugins/context_reaction_block.js');
      drupal_add_css(drupal_get_path('module', 'context') . '/plugins/context_reaction_block.css');
    }
    else {
      $requirements = FALSE;
    }
  }

  // Check that this region is not locked by the theme.
  global $theme;
  $info = system_get_info('theme', $theme);
  if ($info && isset($info['regions_locked']) && in_array($region, $info['regions_locked'])) {
    return FALSE;
  }

  // Check that this region is not hidden
  $visible = $this
    ->system_region_list($theme, REGIONS_VISIBLE);
  return $requirements && $this
    ->is_enabled_region($region) && isset($visible[$region]);
}