function action_save

Saves an action and its user-supplied parameter values to the database.

Parameters

$function: The name of the function to be called when this action is performed.

$type: The type of action, to describe grouping and/or context, e.g., 'node', 'user', 'comment', or 'system'.

$params: An associative array with parameter names as keys and parameter values as values.

$label: A user-supplied label of this particular action, e.g., 'Send e-mail to Jim'.

$aid: The ID of this action. If omitted, a new action is created.

Return value

The ID of the action.

2 calls to action_save()
action_admin_configure_submit in drupal/core/modules/action/action.admin.inc
Form submission handler for action_admin_configure().
LoopTest::testActionLoop in drupal/core/modules/action/lib/Drupal/action/Tests/LoopTest.php
Sets up a loop with 3 - 12 recursions, and sees if it aborts properly.

File

drupal/core/modules/action/action.module, line 425
This is the Actions module for executing stored actions.

Code

function action_save($function, $type, $params, $label, $aid = NULL) {

  // aid is the callback for singleton actions so we need to keep a separate
  // table for numeric aids.
  if (!$aid) {
    $aid = db_next_id();
  }
  db_merge('actions')
    ->key(array(
    'aid' => $aid,
  ))
    ->fields(array(
    'callback' => $function,
    'type' => $type,
    'parameters' => serialize($params),
    'label' => $label,
  ))
    ->execute();
  watchdog('action', 'Action %action saved.', array(
    '%action' => $label,
  ));
  return $aid;
}