You are here

multipurpose_corporate_profile.install in Multipurpose Corporate Profile 7

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

Installing file.

Install, update and uninstall functions for the multipurpose_corporate_profile.

File

multipurpose_corporate_profile.install
View source
<?php

/**
 * @file
 * Installing file.
 *
 * Install, update and uninstall functions
 * for the multipurpose_corporate_profile.
 */

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

  // Enable some multipurpose corporate_profile blocks.
  $default_theme = 'multipurpose_corporate_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' => 'user',
      'delta' => 'login',
      'theme' => $default_theme,
      'status' => 1,
      'weight' => 0,
      'region' => 'sidebar_first',
      '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,
    ),
  );

  // Create a default role for site administrators,
  // with all available permissions assigned.
  shortcut_set_save($shortcut_set);
  $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_names = array(
    'features_general_content',
    'feature_adci_contact_info',
    'features_test_content',
  );
  foreach ($features_names 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