You are here

bear.install in Bear 7.2

Same filename and directory in other branches
  1. 8.2 bear.install
  2. 8 bear.install
  3. 7 bear.install

File

bear.install
View source
<?php

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

  // See standard_install().
  // This contains less setup than standard install, but similar.
  // Add text formats.
  $filtered_html_format = array(
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => -10,
    'filters' => array(
      // URL filter.
      'filter_url' => array(
        'weight' => 0,
        'status' => 1,
      ),
      // HTML filter.
      'filter_html' => array(
        'weight' => 1,
        'status' => 1,
        'settings' => array(
          'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br> <table> <tr> <td> <thead> <tbody> <th> <u> <s> <h2> <h3> <h4> <h5>',
          'filter_html_help' => 1,
          'filter_html_nofollow' => 0,
        ),
      ),
      // Media Filter.
      'assets_filter' => array(
        'weight' => 2,
        'status' => 1,
        'settings' => array(),
      ),
      'kill_nbsp' => array(
        'status' => 1,
        'weight' => 1,
        'settings' => array(),
      ),
      // HTML corrector filter.
      'filter_htmlcorrector' => array(
        'weight' => 10,
        'status' => 1,
      ),
    ),
  );
  $filtered_html_format = (object) $filtered_html_format;
  filter_format_save($filtered_html_format);
  $full_html_format = array(
    'format' => 'full_html',
    'name' => 'Full HTML',
    'weight' => -9,
    'filters' => array(
      // URL filter.
      'filter_url' => array(
        'weight' => 0,
        'status' => 1,
      ),
      // Line break filter.
      'filter_autop' => array(
        'weight' => 1,
        'status' => 1,
      ),
      // Assets Filter.
      'assets_filter' => array(
        'weight' => 2,
        'status' => 1,
        'settings' => array(),
      ),
      'kill_nbsp' => array(
        'status' => 1,
        'weight' => 1,
        'settings' => array(),
      ),
      // HTML corrector filter.
      'filter_htmlcorrector' => array(
        'weight' => 10,
        'status' => 1,
      ),
    ),
  );
  $full_html_format = (object) $full_html_format;
  filter_format_save($full_html_format);
  $plain_text_format = array(
    'format' => 'plain_text',
    'name' => 'Plain text',
    'weight' => -8,
    'filters' => array(
      'filter_html_escape' => array(
        'weight' => 0,
        'status' => 1,
        'settings' => array(),
      ),
      'filter_url' => array(
        'weight' => 1,
        'status' => 1,
        'settings' => array(
          'filter_url_length' => 72,
        ),
      ),
      'filter_autop' => array(
        'weight' => 2,
        'status' => 1,
        'settings' => array(),
      ),
    ),
  );
  $plain_text_format = (object) $plain_text_format;
  filter_format_save($plain_text_format);

  // Enable some standard blocks.
  $default_theme = variable_get('theme_default', 'bartik');
  $admin_theme = 'seven';
  $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' => 0,
      'region' => 'help',
      '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,
    ),
  );
  $query = db_insert('block')
    ->fields(array(
    'module',
    'delta',
    'theme',
    'status',
    'weight',
    'region',
    'pages',
    'cache',
  ));
  foreach ($blocks as $block) {
    $query
      ->values($block);
  }
  $query
    ->execute();

  // Insert default pre-defined node types into the database. For a complete
  // list of available node type attributes, refer to the node type API
  // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.
  $types = array(
    array(
      'type' => 'page',
      'name' => st('Basic page'),
      'base' => 'node_content',
      'description' => st("Use <em>basic pages</em> for your static content, such as an 'About us' page."),
      'custom' => 1,
      'modified' => 1,
      'locked' => 0,
    ),
  );
  foreach ($types as $type) {
    $type = node_type_set_defaults($type);
    node_type_save($type);
    node_add_body_field($type);
  }

  // Default "Basic page" settings.
  variable_set('node_options_page', array(
    'status',
    'revision',
  ));
  variable_set('node_preview_page', 0);
  variable_set('node_submitted_page', FALSE);

  // Default pathauto setting to match menu positions.
  variable_set('pathauto_node_pattern', "[node:menu-link:parents:join-path]/[node:title]");

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

  // Enable default permissions for system roles.
  $filtered_html_permission = filter_permission_name($filtered_html_format);
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array(
    'access content',
    $filtered_html_permission,
  ));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'access content',
    $filtered_html_permission,
  ));

  // Create a default role for site administrators, with all available permissions assigned.
  $admin_role = new stdClass();
  $admin_role->name = 'administrator';
  $admin_role->weight = 3;
  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);

  // Add an editor role.
  $editor_role = new stdClass();
  $editor_role->name = 'editor';
  $editor_role->weight = 2;
  user_role_save($editor_role);
  $perms = array(
    'access administration menu',
    'access administration pages',
    'access assets overview',
    'access coffee',
    'access content',
    'access content overview',
    'access user profiles',
    'administer assets',
    'administer asset types',
    'administer menu',
    'administer nodes',
    'administer url aliases',
    'administer users',
    'bypass node access',
    'change own username',
    'create url aliases',
    'create asset with type document',
    'create asset with type image',
    'create asset with type embed',
    'delete asset with type document',
    'delete asset with type image',
    'delete asset with type embed',
    'delete revisions',
    'edit asset with type document',
    'edit asset with type image',
    'edit asset with type embed',
    'revert revisions',
    'use text format filtered_html',
    'use text format full_html',
    'view own unpublished content',
    'view revisions',
    'view style guides',
    'view the administration theme',
    'edit field help text',
  );
  user_role_grant_permissions($editor_role->rid, $perms);

  // Enable seven and bear_skin themes and set defaults.
  theme_enable(array(
    'seven',
    'bear_skin',
  ));
  variable_set('theme_default', 'bear_skin');
  variable_set('admin_theme', 'seven');
  variable_set('node_admin_theme', '1');
}

Functions

Namesort descending Description
bear_install Implement hook_install().