Issue #2915011: Move farm_log_movement to farm_movement
This commit is contained in:
parent
01f95f3058
commit
7dc626a450
23
farm.install
23
farm.install
|
@ -626,6 +626,29 @@ function farm_update_7030(&$sandbox) {
|
|||
_farm_update_enable_modules(array('help'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename farm_log_movement to farm_movement in the {system} table.
|
||||
*/
|
||||
function farm_update_7031(&$sandbox) {
|
||||
|
||||
// Drupal will autodetect farm_movement as a new module, and will think
|
||||
// farm_log_movement is missing - so we need to do some tricky
|
||||
// bait-and-switch to rename the module and ensure that it stays enabled.
|
||||
|
||||
// Load the {system} record for farm_log_movement, and make our modifications.
|
||||
$record = db_query("SELECT * FROM {system} WHERE name = 'farm_log_movement' AND type = 'module'")->fetch();
|
||||
$record->name = str_replace('farm_log_movement', 'farm_movement', $record->name);
|
||||
$record->filename = str_replace('farm_log/farm_log_movement', 'farm_movement', $record->filename);
|
||||
$record->status = 1;
|
||||
|
||||
// Delete any farm_log_movement and farm_movement records.
|
||||
db_query("DELETE FROM {system} WHERE name = 'farm_log_movement' AND type = 'module'");
|
||||
db_query("DELETE FROM {system} WHERE name = 'farm_movement' AND type = 'module'");
|
||||
|
||||
// Re-save the original record.
|
||||
drupal_write_record('system', $record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update helper function: enable modules.
|
||||
*/
|
||||
|
|
|
@ -13,8 +13,8 @@ dependencies[] = farm_area
|
|||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_asset_children
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_map
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = farm_quantity
|
||||
dependencies[] = farm_season
|
||||
dependencies[] = features
|
||||
|
|
|
@ -22,8 +22,8 @@ function farm_crop_update_dependencies() {
|
|||
$dependencies['farm_crop'][7002] = array('farm' => 7019);
|
||||
|
||||
// Update 7003 (add movement field to seedings and transplantings) depends on
|
||||
// farm_log_movement_update_7000().
|
||||
$dependencies['farm_crop'][7003] = array('farm_log_movement' => 7000);
|
||||
// farm_movement_update_7000().
|
||||
$dependencies['farm_crop'][7003] = array('farm_movement' => 7000);
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ function farm_crop_planting_plan_submit(array $form, array &$form_state) {
|
|||
// If the location is available, load areas.
|
||||
$areas = array();
|
||||
if (!empty($form_state['values'][$type . '_location'])) {
|
||||
$areas = farm_log_movement_parse_areas($form_state['values'][$type . '_location']);
|
||||
$areas = farm_movement_parse_areas($form_state['values'][$type . '_location']);
|
||||
}
|
||||
|
||||
// Mark the log as done or not done.
|
||||
|
@ -129,7 +129,7 @@ function farm_crop_planting_plan_submit(array $form, array &$form_state) {
|
|||
}
|
||||
|
||||
// Create a log.
|
||||
farm_log_movement_create($asset, $areas, $timestamp, 'farm_' . $type, $done);
|
||||
farm_movement_create($asset, $areas, $timestamp, 'farm_' . $type, $done);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1222,7 +1222,7 @@ function farm_crop_views_default_views() {
|
|||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
|
||||
'action::farm_log_movement_asset_move_action' => array(
|
||||
'action::farm_movement_asset_move_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 1,
|
||||
'override_label' => 0,
|
||||
|
|
|
@ -10,7 +10,7 @@ dependencies[] = entityreference
|
|||
dependencies[] = entityreference_view_widget
|
||||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
dependencies[] = field_group
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
function farm_equipment_update_dependencies() {
|
||||
|
||||
// Update 7002 (add new movement field to maintenance logs) depends on
|
||||
// farm_log_movement_update_7000().
|
||||
$dependencies['farm_equipment'][7002] = array('farm_log_movement' => 7000);
|
||||
// farm_movement_update_7000().
|
||||
$dependencies['farm_equipment'][7002] = array('farm_movement' => 7000);
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ function farm_equipment_views_default_views() {
|
|||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
|
||||
'action::farm_log_movement_asset_move_action' => array(
|
||||
'action::farm_movement_asset_move_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 1,
|
||||
'override_label' => 0,
|
||||
|
|
|
@ -11,8 +11,8 @@ dependencies[] = entityreference_view_widget
|
|||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_asset_children
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_map
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
dependencies[] = field_group
|
||||
|
|
|
@ -14,8 +14,8 @@ function farm_livestock_update_dependencies() {
|
|||
$dependencies['farm_livestock'][7001] = array('farm' => 7019);
|
||||
|
||||
// Update 7003 (add movement field to medical logs) depends on
|
||||
// farm_log_movement_update_7000().
|
||||
$dependencies['farm_livestock'][7003] = array('farm_log_movement' => 7000);
|
||||
// farm_movement_update_7000().
|
||||
$dependencies['farm_livestock'][7003] = array('farm_movement' => 7000);
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ function farm_livestock_views_default_views() {
|
|||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
|
||||
'action::farm_log_movement_asset_move_action' => array(
|
||||
'action::farm_movement_asset_move_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 1,
|
||||
'override_label' => 0,
|
||||
|
|
|
@ -30,8 +30,8 @@ function farm_log_update_dependencies() {
|
|||
$dependencies['farm_log'][7001] = array('log' => 7002);
|
||||
|
||||
// Update 7006 (Add movement field to activities, harvests, inputs, and
|
||||
// observations.) depends on farm_log_movement_update_7000().
|
||||
$dependencies['farm_log'][7006] = array('farm_log_movement' => 7000);
|
||||
// observations.) depends on farm_movement_update_7000().
|
||||
$dependencies['farm_log'][7006] = array('farm_movement' => 7000);
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
|
@ -268,8 +268,8 @@ function farm_log_update_7004(&$sandbox) {
|
|||
'farm_log_activity',
|
||||
'farm_log_harvest',
|
||||
'farm_log_input',
|
||||
'farm_log_movement',
|
||||
'farm_log_observation',
|
||||
'farm_movement',
|
||||
);
|
||||
foreach ($modules as $module) {
|
||||
if (!module_exists($module)) {
|
||||
|
|
|
@ -13,8 +13,8 @@ dependencies[] = entityreference_view_widget
|
|||
dependencies[] = farm_area
|
||||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_map
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
dependencies[] = field_group
|
||||
|
|
|
@ -13,8 +13,8 @@ dependencies[] = entityreference_view_widget
|
|||
dependencies[] = farm_area
|
||||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_map
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = farm_quantity
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
|
|
|
@ -13,8 +13,8 @@ dependencies[] = entityreference_view_widget
|
|||
dependencies[] = farm_area
|
||||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_map
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = farm_quantity
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
|
|
|
@ -13,8 +13,8 @@ dependencies[] = entityreference_view_widget
|
|||
dependencies[] = farm_area
|
||||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_map
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = farm_quantity
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.default_openlayers_components.inc
|
||||
* farm_movement.default_openlayers_components.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_default_openlayers_components().
|
||||
*/
|
||||
function farm_log_movement_default_openlayers_components() {
|
||||
function farm_movement_default_openlayers_components() {
|
||||
$export = array();
|
||||
|
||||
// Get farm asset types.
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.default_openlayers_layers.inc
|
||||
* farm_movement.default_openlayers_layers.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_default_openlayers_layers().
|
||||
*/
|
||||
function farm_log_movement_default_openlayers_layers() {
|
||||
function farm_movement_default_openlayers_layers() {
|
||||
$export = array();
|
||||
|
||||
// Load all available asset types.
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.default_openlayers_maps.inc
|
||||
* farm_movement.default_openlayers_maps.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_default_openlayers_maps().
|
||||
*/
|
||||
function farm_log_movement_default_openlayers_maps() {
|
||||
function farm_movement_default_openlayers_maps() {
|
||||
$export = array();
|
||||
|
||||
// Get farm asset types.
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.default_openlayers_sources.inc
|
||||
* farm_movement.default_openlayers_sources.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_default_openlayers_sources().
|
||||
*/
|
||||
function farm_log_movement_default_openlayers_sources() {
|
||||
function farm_movement_default_openlayers_sources() {
|
||||
$export = array();
|
||||
|
||||
// Load all available farm asset types.
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.features.field_base.inc
|
||||
* farm_movement.features.field_base.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_bases().
|
||||
*/
|
||||
function farm_log_movement_field_default_field_bases() {
|
||||
function farm_movement_field_default_field_bases() {
|
||||
$field_bases = array();
|
||||
|
||||
// Exported field_base: 'field_farm_move_from'.
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.features.field_instance.inc
|
||||
* farm_movement.features.field_instance.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_instances().
|
||||
*/
|
||||
function farm_log_movement_field_default_field_instances() {
|
||||
function farm_movement_field_default_field_instances() {
|
||||
$field_instances = array();
|
||||
|
||||
// Exported field_instance:
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.features.inc
|
||||
* farm_movement.features.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function farm_log_movement_ctools_plugin_api($module = NULL, $api = NULL) {
|
||||
function farm_movement_ctools_plugin_api($module = NULL, $api = NULL) {
|
||||
if ($module == "field_group" && $api == "field_group") {
|
||||
return array("version" => "1");
|
||||
}
|
||||
|
@ -28,6 +28,6 @@ function farm_log_movement_ctools_plugin_api($module = NULL, $api = NULL) {
|
|||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function farm_log_movement_views_api($module = NULL, $api = NULL) {
|
||||
function farm_movement_views_api($module = NULL, $api = NULL) {
|
||||
return array("api" => "3.0");
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.field_group.inc
|
||||
* farm_movement.field_group.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_group_info().
|
||||
*/
|
||||
function farm_log_movement_field_group_info() {
|
||||
function farm_movement_field_group_info() {
|
||||
$field_groups = array();
|
||||
|
||||
$field_group = new stdClass();
|
|
@ -1,4 +1,4 @@
|
|||
name = Farm Log: Movement
|
||||
name = Farm Movement
|
||||
description = Provides movement field and related asset location code.
|
||||
core = 7.x
|
||||
package = farmOS
|
||||
|
@ -37,5 +37,5 @@ features[field_instance][] = field_collection_item-field_farm_movement-field_far
|
|||
features[field_instance][] = field_collection_item-field_farm_movement-field_farm_move_to
|
||||
features[views_view][] = farm_area_assets
|
||||
features[views_view][] = farm_asset_geojson
|
||||
features[views_view][] = farm_log_movement
|
||||
files[] = views/handlers/farm_log_movement_handler_relationship_location.inc
|
||||
features[views_view][] = farm_movement_log
|
||||
files[] = views/handlers/farm_movement_handler_relationship_location.inc
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Code for Farm Log: Movement installation/updates.
|
||||
* Code for farm movement installation/updates.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create new movement field collection.
|
||||
*/
|
||||
function farm_log_movement_update_7000(&$sandbox) {
|
||||
function farm_movement_update_7000(&$sandbox) {
|
||||
|
||||
// Revert this module's field_base and field_instance components
|
||||
features_revert(array('farm_log_movement' => array('field_base', 'field_instance')));
|
||||
features_revert(array('farm_movement' => array('field_base', 'field_instance')));
|
||||
|
||||
// Flush all caches.
|
||||
drupal_flush_all_caches();
|
||||
|
@ -47,7 +47,7 @@ function farm_log_movement_update_7000(&$sandbox) {
|
|||
/**
|
||||
* Migrate movement data into new field_farm_movement field collections.
|
||||
*/
|
||||
function farm_log_movement_update_7001(&$sandbox) {
|
||||
function farm_movement_update_7001(&$sandbox) {
|
||||
|
||||
// Process this in passes of 50 movements at a time.
|
||||
$sandbox['#finished'] = 0;
|
||||
|
@ -154,13 +154,13 @@ function farm_log_movement_update_7001(&$sandbox) {
|
|||
/**
|
||||
* Migrate movement logs to activity logs.
|
||||
*/
|
||||
function farm_log_movement_update_7002(&$sandbox) {
|
||||
function farm_movement_update_7002(&$sandbox) {
|
||||
|
||||
// Search for fields that exist on movements, but not on activities, so we can
|
||||
// move them to activities. This would only be the case if a user added their
|
||||
// own fields, movements do not have any extra fields in default farmOS.
|
||||
// (They used to, but the "move to" and "move from" moved to the new
|
||||
// field_farm_movement field collection. See farm_log_movement_update_7001()).
|
||||
// field_farm_movement field collection. See farm_movement_update_7001()).
|
||||
$log_types = array(
|
||||
'farm_movement',
|
||||
'farm_activity',
|
||||
|
@ -200,7 +200,7 @@ function farm_log_movement_update_7002(&$sandbox) {
|
|||
/**
|
||||
* Remove movement log type.
|
||||
*/
|
||||
function farm_log_movement_update_7003(&$sandbox) {
|
||||
function farm_movement_update_7003(&$sandbox) {
|
||||
|
||||
// Delete the movement log type, if it exists.
|
||||
$log_type = log_type_load('farm_movement');
|
|
@ -13,13 +13,13 @@
|
|||
* @return string
|
||||
* Returns rendered HTML.
|
||||
*/
|
||||
function farm_log_movement_asset_location_markup($asset) {
|
||||
function farm_movement_asset_location_markup($asset) {
|
||||
|
||||
// Start an output string.
|
||||
$output = '<strong>' . t('Location') . ':</strong> ';
|
||||
|
||||
// Get the asset's location.
|
||||
$areas = farm_log_movement_asset_location($asset);
|
||||
$areas = farm_movement_asset_location($asset);
|
||||
|
||||
// If locations were found, add links to them.
|
||||
if (!empty($areas)) {
|
||||
|
@ -38,7 +38,7 @@ function farm_log_movement_asset_location_markup($asset) {
|
|||
}
|
||||
|
||||
// Get the asset's most recent movement.
|
||||
$log = farm_log_movement_asset_latest_movement($asset);
|
||||
$log = farm_movement_asset_latest_movement($asset);
|
||||
|
||||
// Load the log's movement field, if it exists.
|
||||
if (!empty($log->field_farm_movement[LANGUAGE_NONE][0]['value'])) {
|
||||
|
@ -62,13 +62,13 @@ function farm_log_movement_asset_location_markup($asset) {
|
|||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*/
|
||||
function farm_log_movement_form_farm_asset_form_alter(&$form, &$form_state, $form_id) {
|
||||
function farm_movement_form_farm_asset_form_alter(&$form, &$form_state, $form_id) {
|
||||
|
||||
// Get the farm asset entity from the form.
|
||||
$asset = $form['farm_asset']['#value'];
|
||||
|
||||
// Get the asset's current location.
|
||||
$areas = farm_log_movement_asset_location($asset);
|
||||
$areas = farm_movement_asset_location($asset);
|
||||
$area_names = array();
|
||||
if (!empty($areas)) {
|
||||
foreach ($areas as $area) {
|
||||
|
@ -100,13 +100,13 @@ function farm_log_movement_form_farm_asset_form_alter(&$form, &$form_state, $for
|
|||
'#collapsed' => TRUE,
|
||||
'#weight' => 100,
|
||||
);
|
||||
$form['location']['farm_log_movement_asset_location'] = array(
|
||||
$form['location']['farm_movement_asset_location'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Current location'),
|
||||
'#autocomplete_path' => 'taxonomy/autocomplete/field_farm_area',
|
||||
'#default_value' => $location,
|
||||
);
|
||||
$form['actions']['submit']['#submit'][] = 'farm_log_movement_asset_location_submit';
|
||||
$form['actions']['submit']['#submit'][] = 'farm_movement_asset_location_submit';
|
||||
$form['#group_children']['location'] = 'group_farm_general';
|
||||
}
|
||||
|
||||
|
@ -118,15 +118,15 @@ function farm_log_movement_form_farm_asset_form_alter(&$form, &$form_state, $for
|
|||
* @param array $form_state
|
||||
* The form state array.
|
||||
*/
|
||||
function farm_log_movement_asset_location_submit(array $form, array &$form_state) {
|
||||
function farm_movement_asset_location_submit(array $form, array &$form_state) {
|
||||
|
||||
// Only proceed if farm_log_movement_asset_location has a value.
|
||||
if (empty($form_state['values']['farm_log_movement_asset_location'])) {
|
||||
// Only proceed if farm_movement_asset_location has a value.
|
||||
if (empty($form_state['values']['farm_movement_asset_location'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only proceed if the value is not the default value.
|
||||
if ($form_state['values']['farm_log_movement_asset_location'] == $form['location']['farm_log_movement_asset_location']['#default_value']) {
|
||||
if ($form_state['values']['farm_movement_asset_location'] == $form['location']['farm_movement_asset_location']['#default_value']) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -139,10 +139,10 @@ function farm_log_movement_asset_location_submit(array $form, array &$form_state
|
|||
$asset = $form_state['values']['farm_asset'];
|
||||
|
||||
// Load the areas.
|
||||
$areas = farm_log_movement_parse_areas($form_state['values']['farm_log_movement_asset_location']);
|
||||
$areas = farm_movement_parse_areas($form_state['values']['farm_movement_asset_location']);
|
||||
|
||||
// Create an observation log to record the movement.
|
||||
farm_log_movement_create($asset, $areas, REQUEST_TIME);
|
||||
farm_movement_create($asset, $areas, REQUEST_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +154,7 @@ function farm_log_movement_asset_location_submit(array $form, array &$form_state
|
|||
* @return array
|
||||
* Returns an array of loaded area entities.
|
||||
*/
|
||||
function farm_log_movement_parse_areas($area_names) {
|
||||
function farm_movement_parse_areas($area_names) {
|
||||
|
||||
// Start with an empty array.
|
||||
$areas = array();
|
||||
|
@ -207,11 +207,11 @@ function farm_log_movement_parse_areas($area_names) {
|
|||
* @return array
|
||||
* Returns an array of areas that the asset is in.
|
||||
*/
|
||||
function farm_log_movement_asset_location(FarmAsset $asset, $time = REQUEST_TIME, $done = TRUE) {
|
||||
function farm_movement_asset_location(FarmAsset $asset, $time = REQUEST_TIME, $done = TRUE) {
|
||||
$areas = array();
|
||||
|
||||
// Load the log using our helper function.
|
||||
$log = farm_log_movement_asset_latest_movement($asset, $time, $done);
|
||||
$log = farm_movement_asset_latest_movement($asset, $time, $done);
|
||||
|
||||
// If a movement field doesn't exist, bail.
|
||||
if (empty($log->field_farm_movement[LANGUAGE_NONE][0]['value'])) {
|
||||
|
@ -249,7 +249,7 @@ function farm_log_movement_asset_location(FarmAsset $asset, $time = REQUEST_TIME
|
|||
* @return Log|bool
|
||||
* Returns a log entity. FALSE if something goes wrong.
|
||||
*/
|
||||
function farm_log_movement_asset_latest_movement(FarmAsset $asset, $time = REQUEST_TIME, $done = TRUE) {
|
||||
function farm_movement_asset_latest_movement(FarmAsset $asset, $time = REQUEST_TIME, $done = TRUE) {
|
||||
|
||||
// If the asset doesn't have an ID (for instance if it is new and hasn't been
|
||||
// saved yet), bail.
|
||||
|
@ -258,7 +258,7 @@ function farm_log_movement_asset_latest_movement(FarmAsset $asset, $time = REQUE
|
|||
}
|
||||
|
||||
// Make a query for loading the latest movement log.
|
||||
$query = farm_log_movement_asset_movement_query($asset->id, $time, $done);
|
||||
$query = farm_movement_asset_movement_query($asset->id, $time, $done);
|
||||
|
||||
// Execute the query and gather the log id.
|
||||
$result = $query->execute();
|
||||
|
@ -278,7 +278,7 @@ function farm_log_movement_asset_latest_movement(FarmAsset $asset, $time = REQUE
|
|||
* The asset id to search for. This can either be a specific id, or a field
|
||||
* alias string from another query (ie: 'mytable.assetid'). For an example
|
||||
* of field alias string usage, see the Views field handler code in
|
||||
* farm_log_movement_handler_relationship_location::query().
|
||||
* farm_movement_handler_relationship_location::query().
|
||||
* @param int $time
|
||||
* Unix timestamp limiter. Only logs before this time will be included.
|
||||
* Defaults to the current time. Set to 0 to load the absolute last.
|
||||
|
@ -292,11 +292,11 @@ function farm_log_movement_asset_latest_movement(FarmAsset $asset, $time = REQUE
|
|||
* @return \SelectQuery
|
||||
* Returns a SelectQuery object.
|
||||
*/
|
||||
function farm_log_movement_asset_movement_query($asset_id, $time = REQUEST_TIME, $done = TRUE, $field = 'log_id') {
|
||||
function farm_movement_asset_movement_query($asset_id, $time = REQUEST_TIME, $done = TRUE, $field = 'log_id') {
|
||||
|
||||
/**
|
||||
* This query is used as a subquery join in the Views handler
|
||||
* farm_log_movement_handler_relationship_location (via the
|
||||
* farm_movement_handler_relationship_location (via the
|
||||
* views_join_subquery class). views_join_subquery does not support query
|
||||
* arguments, so we cannot use the query::condition() method, or any other
|
||||
* instances where args() are passed in and replaced in the query. So it is
|
||||
|
@ -317,7 +317,7 @@ function farm_log_movement_asset_movement_query($asset_id, $time = REQUEST_TIME,
|
|||
// Build a query to find an asset's latest log that defines a movement.
|
||||
// We use the "ss_" prefix throughout to indicate that this is generally going
|
||||
// to be used as a sub-select, and to avoid potential name conflicts when this
|
||||
// is used elsewhere (ie: farm_log_handler_relationship_location::query()).
|
||||
// is used elsewhere (ie: farm_movement_handler_relationship_location::query()).
|
||||
$query = db_select('log', 'ss_log');
|
||||
|
||||
// Join in asset references and filter to only include logs that reference the
|
||||
|
@ -365,9 +365,9 @@ function farm_log_movement_asset_movement_query($asset_id, $time = REQUEST_TIME,
|
|||
/**
|
||||
* Implements hook_action_info().
|
||||
*/
|
||||
function farm_log_movement_action_info() {
|
||||
function farm_movement_action_info() {
|
||||
return array(
|
||||
'farm_log_movement_asset_move_action' => array(
|
||||
'farm_movement_asset_move_action' => array(
|
||||
'type' => 'farm_asset',
|
||||
'label' => t('Move'),
|
||||
'configurable' => TRUE,
|
||||
|
@ -378,7 +378,7 @@ function farm_log_movement_action_info() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Configuration form for farm_log_movement_asset_move action.
|
||||
* Configuration form for farm_movement_asset_move action.
|
||||
*
|
||||
* @param array $context
|
||||
* The context passed into the action form function.
|
||||
|
@ -388,7 +388,7 @@ function farm_log_movement_action_info() {
|
|||
* @return array
|
||||
* Returns a form array.
|
||||
*/
|
||||
function farm_log_movement_asset_move_action_form(array $context, array $form_state) {
|
||||
function farm_movement_asset_move_action_form(array $context, array $form_state) {
|
||||
|
||||
// Date field.
|
||||
$form['date'] = array(
|
||||
|
@ -421,7 +421,7 @@ function farm_log_movement_asset_move_action_form(array $context, array $form_st
|
|||
}
|
||||
|
||||
/**
|
||||
* Submit handler for farm_log_movement_asset_move action configuration form.
|
||||
* Submit handler for farm_movement_asset_move action configuration form.
|
||||
*
|
||||
* @param array $form
|
||||
* The form array.
|
||||
|
@ -431,13 +431,13 @@ function farm_log_movement_asset_move_action_form(array $context, array $form_st
|
|||
* @return array
|
||||
* Returns an array that will end up in the action's context.
|
||||
*/
|
||||
function farm_log_movement_asset_move_action_submit(array $form, array $form_state) {
|
||||
function farm_movement_asset_move_action_submit(array $form, array $form_state) {
|
||||
|
||||
// Start to build the context array.
|
||||
$context = array();
|
||||
|
||||
// Load the areas.
|
||||
$context['areas'] = farm_log_movement_parse_areas($form_state['values']['areas']);
|
||||
$context['areas'] = farm_movement_parse_areas($form_state['values']['areas']);
|
||||
|
||||
// Convert the date to a timestamp.
|
||||
$timestamp = strtotime($form_state['values']['date']);
|
||||
|
@ -461,7 +461,7 @@ function farm_log_movement_asset_move_action_submit(array $form, array $form_sta
|
|||
}
|
||||
|
||||
/**
|
||||
* Action function for farm_log_movement_asset_move.
|
||||
* Action function for farm_movement_asset_move.
|
||||
*
|
||||
* Creates a new movement activity log for the specified assets.
|
||||
*
|
||||
|
@ -470,7 +470,7 @@ function farm_log_movement_asset_move_action_submit(array $form, array $form_sta
|
|||
* @param array $context
|
||||
* Array with parameters for this action.
|
||||
*/
|
||||
function farm_log_movement_asset_move_action(array $assets, $context = array()) {
|
||||
function farm_movement_asset_move_action(array $assets, $context = array()) {
|
||||
|
||||
// If we're missing assets, areas, or a timestamp, bail.
|
||||
if (empty($assets) || empty($context['areas']) || empty($context['timestamp'])) {
|
||||
|
@ -479,7 +479,7 @@ function farm_log_movement_asset_move_action(array $assets, $context = array())
|
|||
}
|
||||
|
||||
// Create a movement activity log.
|
||||
farm_log_movement_create($assets, $context['areas'], $context['timestamp'], 'farm_activity', $context['done']);
|
||||
farm_movement_create($assets, $context['areas'], $context['timestamp'], 'farm_activity', $context['done']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -497,7 +497,7 @@ function farm_log_movement_asset_move_action(array $assets, $context = array())
|
|||
* Boolean indicating whether or not the log should be marked "done". Defaults
|
||||
* to TRUE.
|
||||
*/
|
||||
function farm_log_movement_create($assets, $areas = array(), $timestamp = REQUEST_TIME, $log_type = 'farm_observation', $done = TRUE) {
|
||||
function farm_movement_create($assets, $areas = array(), $timestamp = REQUEST_TIME, $log_type = 'farm_observation', $done = TRUE) {
|
||||
|
||||
// If $assets isn't an array, wrap it.
|
||||
if (!is_array($assets)) {
|
|
@ -1,25 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Code for the Farm Log: Movement feature.
|
||||
* Farm movement.
|
||||
*/
|
||||
|
||||
// Include Features code.
|
||||
include_once 'farm_log_movement.features.inc';
|
||||
include_once 'farm_movement.features.inc';
|
||||
|
||||
// Include Asset Location code.
|
||||
include_once 'farm_log_movement.location.inc';
|
||||
include_once 'farm_movement.location.inc';
|
||||
|
||||
/**
|
||||
* Implements hook_farm_ui_entity_views().
|
||||
*/
|
||||
function farm_log_movement_farm_ui_entity_views($entity_type, $bundle, $entity) {
|
||||
function farm_movement_farm_ui_entity_views($entity_type, $bundle, $entity) {
|
||||
$views = array();
|
||||
|
||||
// Add asset movements View at the bottom of assets.
|
||||
if ($entity_type == 'farm_asset') {
|
||||
$views[] = array(
|
||||
'name' => 'farm_log_movement',
|
||||
'name' => 'farm_movement_log',
|
||||
'weight' => 100,
|
||||
);
|
||||
}
|
||||
|
@ -40,24 +40,24 @@ function farm_log_movement_farm_ui_entity_views($entity_type, $bundle, $entity)
|
|||
/**
|
||||
* Implements hook_entity_presave().
|
||||
*/
|
||||
function farm_log_movement_entity_presave($entity, $type) {
|
||||
function farm_movement_entity_presave($entity, $type) {
|
||||
|
||||
// When a movement field collection entity is being saved, populate the
|
||||
// geometry field from the "move to" area reference field.
|
||||
if ($type == 'field_collection_item' && $entity->field_name == 'field_farm_movement') {
|
||||
farm_log_movement_populate_geometry($entity);
|
||||
farm_movement_populate_geometry($entity);
|
||||
}
|
||||
|
||||
// When a log is being saved, populate the "move from" field with current
|
||||
// asset location(s).
|
||||
if ($type == 'log') {
|
||||
farm_log_movement_populate_move_from($entity);
|
||||
farm_movement_populate_move_from($entity);
|
||||
}
|
||||
|
||||
// If an activity log is being saved with movement information, auto-fill the
|
||||
// log title.
|
||||
if ($type == 'log' && $entity->type == 'farm_activity') {
|
||||
farm_log_movement_populate_name($entity);
|
||||
farm_movement_populate_name($entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ function farm_log_movement_entity_presave($entity, $type) {
|
|||
*
|
||||
* @see farm_log_entity_presave().
|
||||
*/
|
||||
function farm_log_movement_populate_geometry($entity) {
|
||||
function farm_movement_populate_geometry($entity) {
|
||||
|
||||
// Define the area field name.
|
||||
$area_field = 'field_farm_move_to';
|
||||
|
@ -109,7 +109,7 @@ function farm_log_movement_populate_geometry($entity) {
|
|||
* @param Entity $log
|
||||
* The log entity.
|
||||
*/
|
||||
function farm_log_movement_populate_move_from($log) {
|
||||
function farm_movement_populate_move_from($log) {
|
||||
|
||||
// Create an entity wrapper for the log.
|
||||
$log_wrapper = entity_metadata_wrapper('log', $log);
|
||||
|
@ -149,7 +149,7 @@ function farm_log_movement_populate_move_from($log) {
|
|||
foreach ($assets as $asset) {
|
||||
|
||||
// Load the asset's current location.
|
||||
$areas = farm_log_movement_asset_location($asset);
|
||||
$areas = farm_movement_asset_location($asset);
|
||||
|
||||
// Build a list of areas.
|
||||
if (!empty($areas)) {
|
||||
|
@ -176,7 +176,7 @@ function farm_log_movement_populate_move_from($log) {
|
|||
* @param Entity $log
|
||||
* The log entity.
|
||||
*/
|
||||
function farm_log_movement_populate_name($log) {
|
||||
function farm_movement_populate_name($log) {
|
||||
|
||||
// If the log already has a name, bail.
|
||||
if (!empty($log->name)) {
|
||||
|
@ -228,7 +228,7 @@ function farm_log_movement_populate_name($log) {
|
|||
/**
|
||||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function farm_log_movement_entity_view_alter(&$build, $type) {
|
||||
function farm_movement_entity_view_alter(&$build, $type) {
|
||||
|
||||
// If it's not a farm_asset, or if the entity object is not available, bail.
|
||||
if ($type != 'farm_asset' || empty($build['#entity'])) {
|
||||
|
@ -236,7 +236,7 @@ function farm_log_movement_entity_view_alter(&$build, $type) {
|
|||
}
|
||||
|
||||
// Generate markup to describe the location.
|
||||
$output = farm_log_movement_asset_location_markup($build['#entity']);
|
||||
$output = farm_movement_asset_location_markup($build['#entity']);
|
||||
|
||||
// Add it to the build array.
|
||||
$build['location'] = array(
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Farm Log: Movement Views data.
|
||||
* Farm movement views data.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function farm_log_movement_views_data_alter(&$data) {
|
||||
function farm_movement_views_data_alter(&$data) {
|
||||
|
||||
$data['farm_asset']['latest_movement'] = array(
|
||||
'title' => t('Latest movement'),
|
||||
|
@ -16,7 +16,7 @@ function farm_log_movement_views_data_alter(&$data) {
|
|||
'relationship' => array(
|
||||
'title' => t('Latest movement'),
|
||||
'help' => t('Relate the farm asset to its latest movement.'),
|
||||
'handler' => 'farm_log_movement_handler_relationship_location',
|
||||
'handler' => 'farm_movement_handler_relationship_location',
|
||||
'base' => 'field_collection_item',
|
||||
'base field' => 'item_id',
|
||||
'label' => t('Latest movement'),
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_log_movement.views_default.inc
|
||||
* farm_movement.views_default.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function farm_log_movement_views_default_views() {
|
||||
function farm_movement_views_default_views() {
|
||||
$export = array();
|
||||
|
||||
$view = new view();
|
||||
|
@ -384,11 +384,11 @@ function farm_log_movement_views_default_views() {
|
|||
$export['farm_asset_geojson'] = $view;
|
||||
|
||||
$view = new view();
|
||||
$view->name = 'farm_log_movement';
|
||||
$view->name = 'farm_movement_log';
|
||||
$view->description = '';
|
||||
$view->tag = 'farm_log';
|
||||
$view->tag = 'farm_movement';
|
||||
$view->base_table = 'log';
|
||||
$view->human_name = 'Farm Log: Logs with movements';
|
||||
$view->human_name = 'Farm movement logs';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
@ -749,7 +749,7 @@ function farm_log_movement_views_default_views() {
|
|||
'page' => 'page',
|
||||
'default' => 0,
|
||||
);
|
||||
$translatables['farm_log_movement'] = array(
|
||||
$translatables['farm_movement_log'] = array(
|
||||
t('Master'),
|
||||
t('Logs with movements'),
|
||||
t('more'),
|
||||
|
@ -789,7 +789,7 @@ function farm_log_movement_views_default_views() {
|
|||
t('Page'),
|
||||
t('Data export'),
|
||||
);
|
||||
$export['farm_log_movement'] = $view;
|
||||
$export['farm_movement_log'] = $view;
|
||||
|
||||
return $export;
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
* views_handler_relationship_entity_reverse
|
||||
* views_handler_relationship_node_term_data
|
||||
*/
|
||||
class farm_log_movement_handler_relationship_location extends views_handler_relationship {
|
||||
class farm_movement_handler_relationship_location extends views_handler_relationship {
|
||||
|
||||
/**
|
||||
* {@inheritfoc}
|
||||
|
@ -77,7 +77,7 @@ class farm_log_movement_handler_relationship_location extends views_handler_rela
|
|||
else {
|
||||
$time = REQUEST_TIME;
|
||||
}
|
||||
$query = farm_log_movement_asset_movement_query($asset_id_field, $time, $done, 'movement_id');
|
||||
$query = farm_movement_asset_movement_query($asset_id_field, $time, $done, 'movement_id');
|
||||
|
||||
// Build the join definition.
|
||||
$def = $this->definition;
|
|
@ -7,7 +7,7 @@ dependencies[] = ctools
|
|||
dependencies[] = entity
|
||||
dependencies[] = farm_asset
|
||||
dependencies[] = farm_fields
|
||||
dependencies[] = farm_log_movement
|
||||
dependencies[] = farm_movement
|
||||
dependencies[] = features
|
||||
dependencies[] = field_group
|
||||
dependencies[] = file
|
||||
|
|
|
@ -353,7 +353,7 @@ function farm_sensor_area_sensors($area_id, $type = '') {
|
|||
$query->condition('fa.type', 'sensor');
|
||||
|
||||
// Build a sub-select query for determining the latest movement log of assets.
|
||||
$subquery = farm_log_movement_asset_movement_query('fa.id');
|
||||
$subquery = farm_movement_asset_movement_query('fa.id');
|
||||
|
||||
// Join the latest movement log for each asset.
|
||||
$query->join('log', 'l', 'l.id = (' . $subquery . ')');
|
||||
|
|
|
@ -106,7 +106,7 @@ function farm_sensor_views_default_views() {
|
|||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
|
||||
'action::farm_log_movement_asset_move_action' => array(
|
||||
'action::farm_movement_asset_move_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 1,
|
||||
'override_label' => 0,
|
||||
|
|
|
@ -112,7 +112,7 @@ function farm_soil_compost_views_default_views() {
|
|||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
|
||||
'action::farm_log_movement_asset_move_action' => array(
|
||||
'action::farm_movement_asset_move_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 1,
|
||||
'override_label' => 0,
|
||||
|
|
Loading…
Reference in New Issue