function commerce_kickstart_install in Commerce Kickstart 7.2
Same name and namespace in other branches
- 7 commerce_kickstart.install \commerce_kickstart_install()
- 3.x commerce_kickstart.install \commerce_kickstart_install()
Implements hook_install().
File
- ./
commerce_kickstart.install, line 525 - Installation code for Commerce Kickstart.
Code
function commerce_kickstart_install() {
// Add text formats.
$filtered_html_format = array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// HTML filter.
'filter_html' => array(
'weight' => 1,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 2,
'status' => 1,
),
// 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' => 1,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 1,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$full_html_format = (object) $full_html_format;
filter_format_save($full_html_format);
// Enable the admin theme.
$admin_theme = 'commerce_kickstart_admin';
theme_enable(array(
$admin_theme,
));
variable_set('admin_theme', $admin_theme);
variable_set('node_admin_theme', '1');
// Insert default pre-defined node types into the database.
$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);
}
// "Basic page" configuration.
variable_set('node_options_page', array(
'status',
));
variable_set('comment_page', COMMENT_NODE_HIDDEN);
variable_set('node_submitted_page', FALSE);
variable_set('pathauto_node_page_pattern', '[node:title]');
// 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',
'access comments',
'access checkout',
'view own commerce_order entities',
'view any commerce_product entity',
$filtered_html_permission,
));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
'access content',
'access comments',
'access checkout',
'view own commerce_order entities',
'view any commerce_product entity',
'post comments',
'skip comment approval',
$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 = 2;
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();
// Set Mimemail.
variable_set('mimemail_format', 'full_html');
// Set checkout progress.
variable_set('commerce_checkout_progress_link', 0);
variable_set('commerce_checkout_progress_list_type', 'ol');
variable_set('commerce_checkout_progress_block_pages', array_keys(commerce_checkout_pages()));
// Configure Chosen.
variable_set('chosen_jquery_selector', '.view-filters .views-exposed-form select');
variable_set('chosen_minimum_single', 'Always Apply');
variable_set('chosen_minimum_multiple', 'Always Apply');
variable_set('chosen_minimum_width', 200);
variable_set('chosen_search_contains', TRUE);
// Create the default Search API server.
$values = array(
'machine_name' => 'frontend',
'name' => 'Frontend',
'description' => '',
'class' => 'search_api_db_service',
'options' => array(
'database' => 'default:default',
'min_chars' => 3,
),
);
search_api_server_insert($values);
// Enable automatic title replacement for node and commerce product bundles.
foreach (array(
'node',
'commerce_product',
) as $entity_type) {
$title_settings = array(
'auto_attach' => array(
'title' => 'title',
),
'hide_label' => array(
'entity' => 'entity',
'page' => 0,
),
);
variable_set('title_' . $entity_type, $title_settings);
}
// Disable migrate autoregistration.
variable_set('migrate_disable_autoregistration', TRUE);
// Creating needed fields
$field_image = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_image',
'foreign keys' => array(
'fid' => array(
'columns' => array(
'fid' => 'fid',
),
'table' => 'file_managed',
),
),
'indexes' => array(
'fid' => array(
0 => 'fid',
),
),
'locked' => 0,
'module' => 'image',
'settings' => array(
'default_image' => 0,
'uri_scheme' => 'public',
),
'translatable' => 1,
'type' => 'image',
);
field_create_field($field_image);
}