You are here

function varbase_install in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 7.2

Same name and namespace in other branches
  1. 8.8 varbase.install \varbase_install()
  2. 8.4 varbase.install \varbase_install()
  3. 8.5 varbase.install \varbase_install()
  4. 8.6 varbase.install \varbase_install()
  5. 8.7 varbase.install \varbase_install()
  6. 7.3 varbase.install \varbase_install()
  7. 7 varbase.install \varbase_install()
  8. 9.0.x varbase.install \varbase_install()

Implements hook_install().

Perform actions to set up the site for this profile.

See also

system_install()

File

./varbase.install, line 14
Install, update and uninstall functions for the Vardot Base install profile.

Code

function varbase_install() {

  // Disable user picture support.
  variable_set('user_pictures', '0');

  // Allow visitor account creation with administrative approval.
  variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);

  // Enable default permissions for system roles.
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
    'access content',
  ));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'access content',
  ));

  // Projects to disable.
  $dis_module = array(
    "toolbar",
    "overlay",
  );

  // Disable Projects.
  db_update('system')
    ->fields(array(
    'status' => 0,
  ))
    ->condition('name', $dis_module, 'IN')
    ->execute();

  //themes to enable
  $en_theme = array(
    'ember',
    'bootstrap',
    'vartheme2',
  );
  $dis_theme = array(
    'bartik',
  );
  theme_enable($en_theme);
  theme_disable($dis_theme);

  // Create a default role for site administrators, with all available permissions assigned.
  $admin_role = new stdClass();
  $admin_role->name = 'Super admin';
  $admin_role->weight = 4;
  if ($role = user_role_load_by_name($admin_role->name)) {
    $admin_role = $role;
  }
  else {
    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);

  //Create a other roles for specific site administration tasks.
  $content_role = new stdClass();
  $content_role->name = 'Content admin';
  $content_role->weight = 2;
  if (!($role = user_role_load_by_name($content_role->name))) {
    user_role_save($content_role);
  }
  $site_admin_role = new stdClass();
  $site_admin_role->name = 'Site admin';
  $site_admin_role->weight = 3;
  if (!($role = user_role_load_by_name($site_admin_role->name))) {
    user_role_save($content_role);
  }

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

  //* @todo: investigate further this problem below to the end of the function

  /**
   * For some reason rdf throws a "Base table of view not found" error on installation if made through dependendices[]
   * for some another freaky reason diff always appears as non-existing when trying to install.
   *
   * This is a workaround to enable these module after the batch install is done.
   */
  $modules_to_enable = array(
    'rdf',
    'diff',
  );
  module_enable($modules_to_enable);

  // For some reason the feature varbase_ckeditor keeps getting overriden when enabled. Here's a quick workaround
  if (module_exists('varbase_ckeditor')) {
    features_revert(array(
      'varbase_ckeditor' => array(
        'ckeditor_profile',
      ),
    ));
  }
}