You are here

function _panopoly_install_help_block in Panopoly 7

Helper function: add Help block to default/admin theme Help region.

2 calls to _panopoly_install_help_block()
panopoly_install in ./panopoly.install
Implements hook_install().
panopoly_update_7102 in ./panopoly.install
Enable the core Block module and place the Help block.

File

./panopoly.install, line 42
Install, update and uninstall hooks.

Code

function _panopoly_install_help_block() {
  $default_theme = variable_get('theme_default', 'responsive_bartik');
  $admin_theme = variable_get('admin_theme', $default_theme);

  // Add the help block to the main theme help region.
  $blocks = array(
    array(
      'module' => 'system',
      'delta' => 'help',
      'theme' => $default_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'help',
      'pages' => '',
      'cache' => -1,
    ),
  );

  // If the admin theme is different than default theme, add the help
  // block to the admin them help region.
  if ($admin_theme != $default_theme) {
    $blocks[] = array(
      'module' => 'system',
      'delta' => 'help',
      'theme' => $admin_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'help',
      'pages' => '',
      'cache' => -1,
    );
  }

  // Add the blocks if they aren't already placed.
  foreach ($blocks as $block) {
    $region = db_select('block', 'b')
      ->fields('b', array(
      'region',
    ))
      ->condition('theme', $block['theme'])
      ->condition('module', $block['module'])
      ->condition('delta', $block['delta'])
      ->execute()
      ->fetchField();
    if (empty($region) || $region == -1) {
      db_merge('block')
        ->key(array(
        'theme' => $block['theme'],
        'module' => $block['module'],
        'delta' => $block['delta'],
      ))
        ->fields($block)
        ->execute();
    }
  }

  // Update the menu router information.
  menu_rebuild();
}