2015-05-10 04:41:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* farmOS install file.
|
|
|
|
*/
|
|
|
|
|
2015-08-08 15:31:32 +02:00
|
|
|
/**
|
|
|
|
* 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');
|
|
|
|
|
2015-08-08 15:31:32 +02:00
|
|
|
// 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');
|
|
|
|
}
|
|
|
|
|
2015-05-10 04:41:26 +02:00
|
|
|
/**
|
|
|
|
* 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')));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-16 22:21:58 +02:00
|
|
|
/**
|
|
|
|
* Update to Openlayers 3
|
|
|
|
*/
|
|
|
|
function farm_update_7001(&$sandbox) {
|
|
|
|
|
|
|
|
// Enable new module dependencies.
|
|
|
|
$modules = array(
|
|
|
|
'openlayers_geofield',
|
|
|
|
'views_geojson',
|
|
|
|
);
|
2015-08-07 19:55:38 +02:00
|
|
|
_farm_enable_modules($modules);
|
|
|
|
}
|
|
|
|
|
2015-08-07 19:57:01 +02:00
|
|
|
/**
|
|
|
|
* 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');
|
|
|
|
}
|
|
|
|
|
2015-08-07 19:55:38 +02:00
|
|
|
/**
|
|
|
|
* Helper function: enable modules.
|
|
|
|
*/
|
|
|
|
function _farm_enable_modules($modules = array()) {
|
2015-06-16 22:21:58 +02:00
|
|
|
foreach ($modules as $module) {
|
|
|
|
if (!module_exists($module)) {
|
2015-07-31 20:32:46 +02:00
|
|
|
module_enable(array($module));
|
2015-06-16 22:21:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|