actions_save

Versions
6
actions_save($function, $type, $params, $desc, $aid = NULL)
7
actions_save($function, $type, $params, $label, $aid = NULL)

Save an action and its associated 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.

$desc A user-supplied description 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.

▾ 3 functions call actions_save()

ec_store_install in contrib-6/ecommerce/ec_store/ec_store.install
Implementation of hook_install().
ec_store_update_6404 in contrib-6/ecommerce/ec_store/ec_store.install
Add action for shipping orders
system_actions_configure_submit in drupal-6/modules/system/system.module
Process system_actions_configure form submissions.

Code

drupal-6/includes/actions.inc, line 383

<?php
function actions_save($function, $type, $params, $desc, $aid = NULL) {
  $serialized = serialize($params);
  if ($aid) {
    db_query("UPDATE {actions} SET callback = '%s', type = '%s', parameters = '%s', description = '%s' WHERE aid = '%s'", $function, $type, $serialized, $desc, $aid);
    watchdog('actions', 'Action %action saved.', array('%action' => $desc));
  }
  else {
    // aid is the callback for singleton actions so we need to keep a
    // separate table for numeric aids.
    db_query('INSERT INTO {actions_aid} VALUES (default)');
    $aid = db_last_insert_id('actions_aid', 'aid');
    db_query("INSERT INTO {actions} (aid, callback, type, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $aid, $function, $type, $serialized, $desc);
    watchdog('actions', 'Action %action created.', array('%action' => $desc));
  }

  return $aid;
}
?>

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options