You are here

function ca_actions_form_update_actions in Ubercart 6.2

Updates a predicate's actions based on the values from an actions form.

Parameters

$pid: The ID of the predicate whose actions should be updated.

$data: The actions values from the form state that should be used to update the predicate; normally $form_state['values']['actions'].

Return value

An array representing the full, updated predicate.

3 calls to ca_actions_form_update_actions()
ca_actions_form_add_action_submit in ca/ca.admin.inc
Add action submit handler.
ca_actions_form_remove_action_submit in ca/ca.admin.inc
Remove action submit handler.
ca_actions_form_save_changes_submit in ca/ca.admin.inc
Save changes submit handler for the actions form.

File

ca/ca.admin.inc, line 535
Conditional actions overview UI.

Code

function ca_actions_form_update_actions($pid, $data) {
  $actions = array();

  // Unset top level components we don't want to get in the way.
  unset($data['add_action'], $data['add']);

  // Loop through the actions from the form and add them to our temporary array.
  foreach ((array) $data as $key => $value) {
    $actions[] = array(
      '#name' => $value['name'],
      '#title' => $value['title'],
      '#argument_map' => $value['argument_map'],
      '#settings' => empty($value['settings']) ? array() : $value['settings'],
    );
  }

  // Load the predicate as it is now.
  $predicate = ca_load_predicate($pid);

  // Update the actions and save the result.
  $predicate['#actions'] = $actions;
  ca_save_predicate($predicate);
  return $predicate;
}