custom_search.install in Custom Search 7
Same filename and directory in other branches
Install, update, and uninstall functions for the custom search module.
File
custom_search.installView source
<?php
/**
* @file
* Install, update, and uninstall functions for the custom search module.
*/
/**
* Implements hook_install().
*/
function custom_search_install() {
db_update('system')
->fields(array(
'weight' => 100,
))
->condition('name', 'custom_search')
->execute();
}
/**
* Implements hook_uninstall().
*/
function custom_search_uninstall() {
db_delete('variable')
->condition('name', 'custom_search_%', 'LIKE')
->execute();
}
/**
* Implements hook_enable().
*/
function custom_search_enable() {
drupal_set_message(t('Custom Search enabled. Don\'t forget to <a href="@link">set permissions</a>.', array(
'@link' => url('admin/people/permissions', array(
'fragment' => 'module-custom_search',
)),
)));
}
/**
* Increases the module weight.
*/
function custom_search_update_7100() {
db_update('system')
->fields(array(
'weight' => 100,
))
->condition('name', 'custom_search')
->execute();
return t("Module's weight increased.");
}
/**
* New sub-modules notice.
*/
function custom_search_update_7101() {
return t('Custom Search has been divided in multiple modules. Please re-enable the sub-modules you need.');
}
/**
* Custom search paths upgrade.
*/
function custom_search_update_7102() {
if (variable_get('custom_search_path', '') != '') {
variable_set('custom_search_paths', variable_get('custom_search_path', '') . '|Custom path');
}
variable_del('custom_search_path');
return t('Custom search paths upgraded.');
}
/**
* Changes in the advanced search form settings.
*/
function custom_search_update_7103() {
if (variable_get('custom_search_results_advanced_override', FALSE)) {
variable_set('custom_search_advanced_or_display', variable_get('custom_search_criteria_or_display', FALSE));
variable_set('custom_search_advanced_phrase_display', variable_get('custom_search_criteria_phrase_display', FALSE));
variable_set('custom_search_advanced_negative_display', variable_get('custom_search_criteria_negative_display', FALSE));
$types = array_keys(array_filter(variable_get('custom_search_node_types', array())));
if (count($types)) {
$names = array_keys(node_type_get_names());
foreach ($names as $name) {
if (!in_array($name, $types)) {
variable_set('custom_search_advanced_type_' . $name . '_display', FALSE);
}
}
}
if (module_exists('taxonomy')) {
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $voc) {
if (variable_get('custom_search_voc' . $voc->vid . '_selector', 'disabled') == 'disabled') {
variable_set('custom_search_advanced_voc' . $voc->vid . '_display', FALSE);
}
}
}
}
variable_del('custom_search_results_advanced_override');
return t('Advanced search form settings changed.');
}
/**
* Store vids - machine names association.
*/
function custom_search_update_7104() {
if (module_exists('taxonomy')) {
$vocabularies = taxonomy_get_vocabularies();
$machine_names = array();
foreach ($vocabularies as $voc) {
$machine_names[$voc->machine_name] = $voc->vid;
}
// This will be needed for those upgrading to Drupal 8 or Backdrop.
variable_set('custom_search_taxonomy_machine_names', $machine_names);
}
}
Functions
Name | Description |
---|---|
custom_search_enable | Implements hook_enable(). |
custom_search_install | Implements hook_install(). |
custom_search_uninstall | Implements hook_uninstall(). |
custom_search_update_7100 | Increases the module weight. |
custom_search_update_7101 | New sub-modules notice. |
custom_search_update_7102 | Custom search paths upgrade. |
custom_search_update_7103 | Changes in the advanced search form settings. |
custom_search_update_7104 | Store vids - machine names association. |