Newer
Older
Dries Buytaert
committed
<?php
Dries Buytaert
committed
/**
* Implement hook_profile_tasks().
Dries Buytaert
committed
function default_profile_tasks() {
$tasks = array(
'default_profile_site_setup' => array(),
);
return $tasks;
}
/**
* Installation task; perform actions to set up the site for this profile.
*
* This task does not return any output, meaning that control will be passed
* along to the next task without ending the page request.
*
* @param $install_state
* An array of information about the current installation state.
*/
function default_profile_site_setup(&$install_state) {
Dries Buytaert
committed
// Enable some standard blocks.
Dries Buytaert
committed
$values = array(
Dries Buytaert
committed
array(
'module' => 'system',
'delta' => 'main',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
Dries Buytaert
committed
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'left',
'pages' => '',
Dries Buytaert
committed
'cache' => -1,
Dries Buytaert
committed
),
array(
'module' => 'system',
'delta' => 'navigation',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'left',
'pages' => '',
Dries Buytaert
committed
'cache' => -1,
Dries Buytaert
committed
),
array(
'module' => 'system',
'delta' => 'management',
'theme' => 'garland',
'status' => 1,
'weight' => 1,
'region' => 'left',
'pages' => '',
Dries Buytaert
committed
'cache' => -1,
Dries Buytaert
committed
),
array(
'module' => 'system',
'delta' => 'powered-by',
'theme' => 'garland',
'status' => 1,
'weight' => 10,
'region' => 'footer',
'pages' => '',
Dries Buytaert
committed
'cache' => -1,
Dries Buytaert
committed
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
Dries Buytaert
committed
'cache' => -1,
Dries Buytaert
committed
),
Dries Buytaert
committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
array(
'module' => 'system',
'delta' => 'main',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'seven',
'status' => 1,
'weight' => 10,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
Dries Buytaert
committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
array(
'module' => 'system',
'delta' => 'main',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'seven',
'status' => 1,
'weight' => 10,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
Dries Buytaert
committed
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
$query->values($record);
}
$query->execute();
Dries Buytaert
committed
// Insert default user-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',
Steven Wittens
committed
'name' => st('Page'),
'base' => 'node_content',
Dries Buytaert
committed
'description' => st("Use <em>pages</em> for your static content, such as an 'About us' page."),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
array(
Dries Buytaert
committed
'type' => 'article',
'name' => st('Article'),
'base' => 'node_content',
Dries Buytaert
committed
'description' => st('Use <em>articles</em> for time-specific content like news, press releases or blog posts.'),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
);
foreach ($types as $type) {
$type = node_type_set_defaults($type);
node_type_save($type);
}
// Default page to not be promoted and have comments disabled.
variable_set('node_options_page', array('status'));
Dries Buytaert
committed
variable_set('comment_page', COMMENT_NODE_HIDDEN);
// Don't display date and author information for page nodes by default.
Angie Byron
committed
variable_set('node_submitted_page', FALSE);
// Create an image style.
$style = array('name' => 'thumbnail');
$style = image_style_save($style);
$effect = array(
'isid' => $style['isid'],
'name' => 'image_scale_and_crop',
'data' => array('width' => '85', 'height' => '85'),
);
image_effect_save($effect);
// Enable user picture support and set the default to a square thumbnail option.
variable_set('user_pictures', '1');
variable_set('user_picture_dimensions', '1024x1024');
variable_set('user_picture_file_size', '800');
variable_set('user_picture_style', 'thumbnail');
$theme_settings = theme_get_settings();
$theme_settings['toggle_node_user_picture'] = '1';
$theme_settings['toggle_comment_user_picture'] = '1';
variable_set('theme_settings', $theme_settings);
Dries Buytaert
committed
// Create a default vocabulary named "Tags", enabled for the 'article' content type.
$description = st('Use tags to group articles on similar topics into categories.');
$help = st('Enter a comma-separated list of words to describe your content.');
Dries Buytaert
committed
$vid = db_insert('taxonomy_vocabulary')->fields(array(
Dries Buytaert
committed
'name' => 'Tags',
'description' => $description,
Dries Buytaert
committed
'machine_name' => 'tags',
Dries Buytaert
committed
'help' => $help,
'relations' => 0,
'hierarchy' => 0,
'multiple' => 0,
'required' => 0,
'tags' => 1,
'module' => 'taxonomy',
'weight' => 0,
))->execute();
Dries Buytaert
committed
db_insert('taxonomy_vocabulary_node_type')->fields(array('vid' => $vid, 'type' => 'article'))->execute();
Dries Buytaert
committed
// Create a default role for site administrators.
$rid = db_insert('role')->fields(array('name' => 'administrator'))->execute();
// Set this as the administrator role.
variable_set('user_admin_role', $rid);
// Assign all available permissions to this role.
foreach (module_invoke_all('permission') as $key => $value) {
db_insert('role_permission')
->fields(array(
'rid' => $rid,
'permission' => $key,
))->execute();
Dries Buytaert
committed
}
// Update the menu router information.
menu_rebuild();
Dries Buytaert
committed
// Save some default links.
Dries Buytaert
committed
$link = array('link_path' => 'admin/structure/menu-customize/main-menu/add', 'link_title' => 'Add a main menu link', 'menu_name' => 'main-menu');
Dries Buytaert
committed
menu_link_save($link);
Dries Buytaert
committed
// Enable the admin theme.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', 'seven')
->execute();
variable_set('admin_theme', 'seven');
variable_set('node_admin_theme', '1');
Gábor Hojtsy
committed
/**
Dries Buytaert
committed
* Implement hook_form_alter().
Gábor Hojtsy
committed
*
* Allows the profile to alter the site-configuration form. This is
* called through custom invocation, so $form_state is not populated.
*/
function default_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'install_configure') {
// Set default for site name field.
Gábor Hojtsy
committed
$form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];