function search_by_page_update_6000 in Search by Page 7
Same name and namespace in other branches
- 6 search_by_page.install \search_by_page_update_6000()
Add language, environment, and uid fields to sbp_path table.
File
- ./
search_by_page.install, line 165 - Install hooks for search_by_page module
Code
function search_by_page_update_6000() {
db_add_field('sbp_path', 'language', array(
'description' => 'Language for this path',
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'default' => '',
));
db_add_field('sbp_path', 'environment', array(
'description' => 'Environment ID',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
db_add_index('sbp_path', 'envi', array(
'environment',
));
db_add_field('sbp_path', 'uid', array(
'description' => 'User ID used to index this path',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
// Set up environment based on previous settings, if no environment exists
$stuff = variable_get('search_by_page_settings', array());
if (!count($stuff)) {
$envid = 1;
search_by_page_setting_set('environment_name', $envid, t('default'));
search_by_page_setting_set('block_title', $envid, t('Search'));
search_by_page_setting_set('page_title', $envid, t('Search'));
search_by_page_setting_set('page_path', $envid, 'search_pages');
variable_set('search_by_page_default_environment', $envid);
// Note: Do the sub-module settings here too, because they should all be
// done in one update.
$fields = array(
'field_label' => 'search_by_page_field_label',
'button_label' => 'search_by_page_button_label',
'sbp_users_roles_indexed' => 'sbp_users_roles_indexed',
'sbp_nodes_types_indexed' => 'sbp_nodes_types_indexed',
'sbp_nodes_display_type' => 'sbp_nodes_display_type',
'sbp_attach_only_listed' => 'sbp_attach_only_listed',
'sbp_attach_node_types' => 'sbp_attach_node_types',
'sbp_attach_field_types' => 'sbp_attach_field_types',
'sbp_attach_only_listed' => 'sbp_attach_only_listed',
'sbp_attach_prepend_node_titles' => 'sbp_attach_prepend_node_titles',
'sbp_attach_title_sep' => 'sbp_attach_title_sep',
'sbp_attach_use_description' => 'sbp_attach_use_description',
);
foreach ($fields as $field => $oldfield) {
if ($value = variable_get($oldfield, 0)) {
search_by_page_setting_set($field, $envid, $value);
variable_del($oldfield);
}
}
}
// Set default environment and language
$lang = language_default('language');
db_update('sbp_path')
->fields(array(
'language' => $lang,
'environment' => 1,
))
->execute();
}