3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00
farmOS/farm.install

122 lines
3.1 KiB
Text
Raw Normal View History

<?php
/**
* @file
* farmOS install file.
*/
/**
* Implements hook_install().
*/
function farm_install() {
// Enable farm theme and set as default.
theme_enable(array('farm_theme'));
variable_set('theme_default', 'farm_theme');
// Disable the default Bartik theme
theme_disable(array('bartik'));
// Set the front page to the farm dashboard (provided by the farm_admin).
variable_set('site_frontpage', 'farm');
2015-08-08 15:31:54 +02:00
// Use the farm menu for primary links (provided by farm_admin).
variable_set('menu_main_links_source', 'farm');
// Allow login via email (via logintoboggan).
variable_set('logintoboggan_login_with_email', TRUE);
// Display the login form on access denied pages (via logintoboggan).
variable_set('site_403', 'toboggan/denied');
}
/**
* Implements hook_update_dependencies().
*/
function farm_update_dependencies() {
// farm_livestock_7000() and farm_equipment_update_7000 both depend on
// farm_update_7000() because they use the new field_bases provided by
// farm_fields.
$farm_7000 = array(
'farm' => 7000,
);
$dependencies['farm_equipment'][7000] = $farm_7000;
$dependencies['farm_livestock'][7000] = $farm_7000;
return $dependencies;
}
/**
* Enable the Farm Fields module.
*/
function farm_update_7000(&$sandbox) {
// Install the farm_fields module and revert the field_base component on it,
// so that they are available to update hooks in other modules.
//
// Between farmOS 7.x-1.0-beta2 and 7.x-1.0-beta3, we upgraded from
// Features 1.x to 2.x. This replaced the 'field' component with
// 'field_base' and 'field_instance'. At the same time, a new module was
// introduced, to serve as a place to put common field_bases: farm_fields.
if (!module_exists('farm_fields')) {
// Enable the farm_fields module.
module_enable(array('farm_fields'));
// Reset the "default_hook" static cache for field_base Features components.
module_load_include('inc', 'features', 'features.export');
features_get_default_hooks('field_base', TRUE);
// Load the farm_fields field_base Features include file, otherwise
// feature_get_default() will not see it, and the revert will fail.
module_load_include('inc', 'farm_fields', 'farm_fields.features.field_base');
// Revert the field_base component of farm_fields.
features_revert(array('farm_fields' => array('field_base')));
}
}
/**
* Update to Openlayers 3
*/
function farm_update_7001(&$sandbox) {
// Enable new module dependencies.
$modules = array(
'openlayers_geofield',
'views_geojson',
);
_farm_enable_modules($modules);
}
/**
* Enable Entity Reference View Widget.
*/
function farm_update_7002(&$sandbox) {
// Enable new module dependencies.
$modules = array(
'entityreference_view_widget',
);
_farm_enable_modules($modules);
}
2015-08-08 15:31:54 +02:00
/**
* Use the farm menu for primary links.
*/
function farm_update_7003(&$sandbox) {
variable_set('menu_main_links_source', 'farm');
}
/**
* Helper function: enable modules.
*/
function _farm_enable_modules($modules = array()) {
foreach ($modules as $module) {
if (!module_exists($module)) {
2015-07-31 20:32:46 +02:00
module_enable(array($module));
}
}
}