You are here

brainstorm_profile.install in Brainstorm profile 7

Same filename and directory in other branches
  1. 8 brainstorm_profile.install

Install profiles and site configuration for a standard site installation.

File

brainstorm_profile.install
View source
<?php

/**
 * @file
 * Install profiles and site configuration for a standard site installation.
 */

/**
 * Implements hook_install().
 *
 * Perform actions to set up the site for this profile.
 */
function brainstorm_profile_install() {

  // Enable some brainstorm blocks.
  $default_theme = 'brainstorm_theme';
  $admin_theme = 'seven';

  // Disable all themes.
  db_update('system')
    ->fields(array(
    'status' => 0,
  ))
    ->condition('type', 'theme')
    ->execute();

  // Enable $default_theme.
  db_update('system')
    ->fields(array(
    'status' => 1,
  ))
    ->condition('type', 'theme')
    ->condition('name', $default_theme)
    ->execute();

  // Enable $admin_theme.
  db_update('system')
    ->fields(array(
    'status' => 1,
  ))
    ->condition('type', 'theme')
    ->condition('name', $admin_theme)
    ->execute();
  variable_set('theme_default', $default_theme);
  variable_set('admin_theme', $admin_theme);

  // Activate admin theme when editing a node.
  variable_set('node_admin_theme', '1');
  $blocks = array(
    array(
      'module' => 'system',
      'delta' => 'main',
      'theme' => $default_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'content',
      'pages' => '',
      'cache' => -1,
    ),
    array(
      'module' => 'system',
      'delta' => 'help',
      'theme' => $default_theme,
      'status' => 1,
      'weight' => -10,
      'region' => 'content',
      'pages' => '',
      'cache' => -1,
    ),
    array(
      'module' => 'system',
      'delta' => 'main',
      'theme' => $admin_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'content',
      'pages' => '',
      'cache' => -1,
    ),
    array(
      'module' => 'system',
      'delta' => 'help',
      'theme' => $admin_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'help',
      'pages' => '',
      'cache' => -1,
    ),
  );

  // Drop system / user blocks to ensure correct building.
  db_delete('block')
    ->condition('module', 'system')
    ->execute();
  db_delete('block')
    ->condition('module', 'user')
    ->execute();

  // Add in our blocks defined above.
  $query = db_insert('block')
    ->fields(array(
    'module',
    'delta',
    'theme',
    'status',
    'weight',
    'region',
    'pages',
    'cache',
  ));
  foreach ($blocks as $block) {
    $query
      ->values($block);
  }
  $query
    ->execute();

  // From shortcut.install, add shortcuts to the default set on install.
  $shortcut_set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME);
  $shortcut_set->links = NULL;
  $shortcut_set->links = array(
    array(
      'link_path' => 'admin/appearance/settings',
      'link_title' => st('Theme'),
      'weight' => -17,
    ),
  );
  shortcut_set_save($shortcut_set);

  // Create a default role for site administrators, with permissions assigned.
  $admin_role = new stdClass();
  $admin_role->name = 'administrator';
  $admin_role->weight = 10;
  user_role_save($admin_role);
  user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));

  // Set this as the administrator role.
  variable_set('user_admin_role', $admin_role->rid);

  // Assign user 1 the "administrator" role.
  db_insert('users_roles')
    ->fields(array(
    'uid' => 1,
    'rid' => $admin_role->rid,
  ))
    ->execute();

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

  // Revert features to ensure they are all installed.
  $features = array(
    'feature_general_content',
    'feature_views',
  );
  foreach ($features as $feature_name) {
    $feature = features_get_features($feature_name);
    if ($feature) {
      $components = array_keys($feature->info['features']);
      features_revert(array(
        $feature_name => $components,
      ));
    }
  }

  // Ignore any rebuild messages.
  node_access_needs_rebuild(FALSE);

  // Ignore any other install messages.
  drupal_get_messages();
}

Functions

Namesort descending Description
brainstorm_profile_install Implements hook_install().