<?php
/**
 * @file
 * Groups footer install script.
 */

/**
 * Implements hook_install().
 */
function groups_footer_install() {
  cache_clear_all('*', 'cache_block', TRUE);
  $theme = variable_get('theme_default', 'openstack_bootstrap');
 // Place site blocks in the footer region.
  $footer_block = array(
    'module' => 'groups_footer',
    'delta' => 'groups_footer',
    'theme' => $theme,
    'visibility' => 0,
    'region' => 'footer',
    'status' => 0,
    'pages' => '0',
    'cache' => DRUPAL_CACHE_GLOBAL,
    'title' => '<none>',
  );
  drupal_write_record('block', $footer_block);

  // need to update the block because region and status is missing
  db_update('block')
    ->fields(array(
      'cache' => DRUPAL_CACHE_GLOBAL,
      'region' => 'footer',
      'status' => 1,
      'title' => '<none>',
    ))
    ->condition('delta', 'groups_footer')
    ->condition('module', 'groups_footer')
    ->condition('theme', $theme)
    ->execute();
}

/**
 * Implements hook_uninstall()
 *
 * Remove footer block
 */

function groups_footer_uninstall() {
  db_delete('block')
    ->condition('delta', 'groups_footer')
    ->condition('module', 'groups_footer')
    ->condition('theme', 'openstack')
    ->execute();
}
