C:/drupal/includes/actions.inc File Reference

Go to the source code of this file.


Functions

 actions_do ($action_ids, $object=NULL, $context=NULL, $a1=NULL, $a2=NULL)
 actions_list ($reset=FALSE)
 actions_get_all_actions ()
 actions_actions_map ($actions)
 actions_function_lookup ($hash)
 actions_synchronize ($actions_in_code=array(), $delete_orphans=FALSE)
 actions_save ($function, $type, $params, $desc, $aid=NULL)
 actions_load ($aid)
 actions_delete ($aid)


Detailed Description

This is the actions engine for executing stored actions.

Definition in file actions.inc.


Function Documentation

actions_actions_map ( actions  ) 

Create an associative array keyed by md5 hashes of function names.

Hashes are used to prevent actual function names from going out into HTML forms and coming back.

Parameters:
$actions An associative array with function names as keys and associative arrays with keys 'description', 'type', etc. as values. Generally the output of actions_list() or actions_get_all_actions() is given as input to this function.
Returns:
An associative array keyed on md5 hash of function name. The value of each key is an associative array of function, description, and type for the action.

Definition at line 207 of file actions.inc.

Referenced by trigger_assign_form().

actions_delete ( aid  ) 

Delete a single action from the database.

Parameters:
$aid integer The ID of the action to delete.

Definition at line 360 of file actions.inc.

References db_query(), and module_invoke_all().

Referenced by actions_synchronize().

Here is the call graph for this function:

actions_do ( action_ids,
object = NULL,
context = NULL,
a1 = NULL,
a2 = NULL 
)

Perform a given list of actions by executing their callback functions.

Given the IDs of actions to perform, find out what the callbacks for the actions are by querying the database. Then call each callback using the function call $function($object, $context, $a1, $2) where $function is the name of a function written in compliance with the action specification; that is, foo($object, $context).

Parameters:
$action_ids The ID of the action to perform. Can be a single action ID or an array of IDs. IDs of instances will be numeric; IDs of singletons will be function names.
$object Parameter that will be passed along to the callback. Typically the object that the action will act on; a node, user or comment object.
$context Parameter that will be passed along to the callback. $context is a keyed array containing extra information about what is currently happening at the time of the call. Typically $context['hook'] and $context['op'] will tell which hook-op combination resulted in this call to actions_do().
$a1 Parameter that will be passed along to the callback.
$a2 Parameter that will be passed along to the callback.
Returns:
An associative array containing the result of the function that performs the action, keyed on action ID.

Definition at line 40 of file actions.inc.

References $result, actions_list(), db_fetch_object(), db_query(), variable_get(), and watchdog().

Here is the call graph for this function:

actions_function_lookup ( hash  ) 

Given an md5 hash of a function name, return the function name.

Faster than actions_actions_map() when you only need the function name.

Parameters:
$hash MD5 hash of a function name
Returns:
Function name

Definition at line 230 of file actions.inc.

References actions_list(), db_query(), and db_result().

Referenced by trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_unassign(), and trigger_unassign_submit().

Here is the call graph for this function:

actions_get_all_actions (  ) 

Retrieve all action instances from the database.

Compare with actions_list() which gathers actions by invoking hook_action_info(). The two are synchronized by visiting /admin/build/actions (when actions.module is enabled) which runs actions_synchronize().

Returns:
Associative array keyed by action ID. Each value is an associative array with keys 'callback', 'description', 'type' and 'configurable'.

Definition at line 176 of file actions.inc.

References $result, db_fetch_object(), and db_query().

Referenced by trigger_assign_form(), trigger_unassign(), and trigger_unassign_submit().

Here is the call graph for this function:

actions_list ( reset = FALSE  ) 

Discover all action functions by invoking hook_action_info().

mymodule_action_info() { return array( 'mymodule_functiondescription_action' => array( 'type' => 'node', 'description' => t('Save node'), 'configurable' => FALSE, 'hooks' => array( 'nodeapi' => array('delete', 'insert', 'update', 'view'), 'comment' => array('delete', 'insert', 'update', 'view'), ) ) ); }

The description is used in presenting possible actions to the user for configuration. The type is used to present these actions in a logical grouping and to denote context. Some types are 'node', 'user', 'comment', and 'system'. If an action is configurable it will provide form, validation and submission functions. The hooks the action supports are declared in the 'hooks' array.

Parameters:
$reset Reset the action info static cache.
Returns:
An associative array keyed on function name. The value of each key is an array containing information about the action, such as type of action and description of the action, e.g.,
   $actions['node_publish_action'] = array(
     'type' => 'node',
     'description' => t('Publish post'),
     'configurable' => FALSE,
     'hooks' => array(
       'nodeapi' => array('presave', 'insert', 'update', 'view'),
       'comment' => array('delete', 'insert', 'update', 'view'),
     ),
   );

Definition at line 152 of file actions.inc.

References drupal_alter(), and module_invoke_all().

Referenced by actions_do(), actions_function_lookup(), actions_synchronize(), trigger_assign_form(), and trigger_assign_form_submit().

Here is the call graph for this function:

actions_load ( aid  ) 

Retrieve a single action from the database.

Parameters:
$aid integer The ID of the action to retrieve.
Returns:
The appropriate action row from the database as an object.

Definition at line 350 of file actions.inc.

References db_fetch_object(), and db_query().

Here is the call graph for this function:

actions_save ( function,
type,
params,
desc,
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.
$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.
Returns:
The ID of the action.

Definition at line 323 of file actions.inc.

References $type, db_last_insert_id(), db_query(), and watchdog().

Here is the call graph for this function:

actions_synchronize ( actions_in_code = array(),
delete_orphans = FALSE 
)

Synchronize actions that are provided by modules.

They are synchronized with actions that are stored in the actions table. This is necessary so that actions that do not require configuration can receive action IDs. This is not necessarily the best approach, but it is the most straightforward.

Definition at line 251 of file actions.inc.

References $result, $results, actions_delete(), actions_list(), db_fetch_object(), db_query(), format_plural(), l(), t(), and watchdog().

Referenced by install_tasks(), DrupalWebTestCase::setUp(), and system_modules_submit().

Here is the call graph for this function:


Generated on Mon Jun 2 15:07:57 2008 for SimpleTest by  1.5.5