Actions are a convenient way to package functionality in reusable chunks that can be called upon specific events. Countless modules expose actions, and at least the following consume them:
I found it useful to manually call actions in the business logic as well, typically during form submissions or in hook_nodeapi. Here's how I do it:
<?php
actions_call('Commission activated to author', $node, array('node' => $node));
function actions_call($title, $object, $context) {
$aid = db_result(db_query("SELECT aid FROM {actions} WHERE description='%s'", $title));
actions_do($aid, $object, $context);
}
?>Beware that if you change the action's title, you will need to change your calling code as well. This is because actions don't have internal names, which is a useful design pattern that Views and CCK, for example, implement.
Comments
thank you very much for that short and fast help i was searching to know something like this but your explanation here gives me the ideas thank you