You are here

function farm_group_asset_membership_action_submit in farmOS 7

Submit handler for farm_group_asset_membership action configuration form.

Parameters

array $form: The form array.

array $form_state: The form state array.

Return value

array Returns an array that will end up in the action's context.

File

modules/farm/farm_group/farm_group.module, line 413

Code

function farm_group_asset_membership_action_submit(array $form, array $form_state) {

  // Start to build the context array.
  $context = array();

  // Load the groups.
  $context['groups'] = farm_asset_load_multiple($form_state['values']['groups']);

  // Convert the date to a timestamp.
  $timestamp = strtotime($form_state['values']['date']);

  // The action form only includes month, day, and year. If the event is today,
  // then we assume that the current time should also be included.
  if (date('Ymd', $timestamp) == date('Ymd', REQUEST_TIME)) {
    $context['timestamp'] = REQUEST_TIME;
  }
  else {
    $context['timestamp'] = $timestamp;
  }

  // Copy the "done" value as a boolean.
  $context['done'] = !empty($form_state['values']['done']) ? TRUE : FALSE;

  // Return the context array.
  return $context;
}