Issue #2481403: Duplicate "From" areas when moving bulk assets

This commit is contained in:
Michael Stenta 2015-05-01 09:59:19 -04:00
parent 99f62a6d8c
commit df3d5e1411
1 changed files with 6 additions and 1 deletions

View File

@ -583,6 +583,9 @@ function farm_log_move_assets($assets, $area_id, $timestamp, $done = FALSE) {
// Create a new movement log entity.
$log = entity_create('log', array('type' => 'farm_movement'));
// Keep track of what areas these assets are coming from.
$from_areas = array();
// Iterate through the assets.
foreach ($assets as $asset) {
@ -595,10 +598,12 @@ function farm_log_move_assets($assets, $area_id, $timestamp, $done = FALSE) {
$area = farm_log_asset_location($asset);
// If the asset has a current location, add it to the "from" field.
if (!empty($area->name) && !empty($area->tid)) {
// Avoid adding the same area more than once.
if (!empty($area->name) && !empty($area->tid) && !in_array($area->tid, $from_areas)) {
$log->field_farm_move_from[LANGUAGE_NONE][] = array(
'tid' => $area->tid,
);
$from_areas[] = $area->tid;
}
}