Here's a progress report on actions-in-core. Actions now have a new architecture. Instead of a single function, an action now consists of several functions. 1. An implementation of hook_actions_info(). In this hook, an action is described just like it was in the 'metadata' operation of the previous action architecture. And supported hooks are declared: function node_action_info() { return array( 'node_make_sticky_action' => array( 'type' => 'node', 'description' => t('Make node sticky'), 'configurable' => FALSE, 'hooks' => array( 'nodeapi' => array('delete','insert','update', 'view'), 'comment' => array('delete','insert','update', 'view'), ), ), ); } Batchability has been dropped. Instead of actions declaring themselves batchable and a node_save() being done at the end of the batch, "Save node" is now a separate action. 2. The action itself: /** * Implementation of a Drupal action. * Sets the sticky-at-top-of-list property of a node to 1. */ function node_make_sticky_action($context = array(), &$node) { $node->sticky = 1; $node->revision = 0; watchdog('action', t('Made node id %id sticky', array('%id' => $node->nid))); } 3. If the action is a configurable action such as the "Display a message to the user" action, it needs to define a form, validate, and submit function. The submit function is responsible for returning a keyed array with parameters that will be stored and used when the action is fired. E.g., (validate function not shown): function system_message_action_form($edit) { $form['message'] = array( '#type' => 'textarea', '#title' => t('Message'), '#default_value' => isset($edit['message']) ? $edit['message'] : '', '#required' => TRUE, '#rows' => '8', '#description' => t('The message to be displayed to the current user. You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body.'), ); return $form; } function system_message_action_form_submit($form_id, $form_values) { return array('message' => $form_values['message']); } The HEAD version of actions is now stable enough to demonstrate the assignment of actions to various hooks. It runs on Drupal 5 currently. I encourage you to check it out and give me feedback on http://groups.drupal.org/actions or just in an email. Hopefully we can have a facade action that hooks up to any Drupal form id, and uses drupal_execute() to fire the action. That would mean many Drupal forms become "scriptable" automatically. John
On 24 May 2007, at 22:56, John VanDyk wrote:
The HEAD version of actions is now stable enough to demonstrate the assignment of actions to various hooks. It runs on Drupal 5 currently. I encourage you to check it out and give me feedback on http://groups.drupal.org/actions or just in an email.
Hopefully we can have a facade action that hooks up to any Drupal form id, and uses drupal_execute() to fire the action. That would mean many Drupal forms become "scriptable" automatically.
I'm trying to keep my pants dry, but the sheer amount of excitement this brings makes this a challenge. Good stuff. ;-) -- Dries Buytaert :: http://www.buytaert.net/
On 24 May 2007, at 22:56, John VanDyk wrote:
The HEAD version of actions is now stable enough to demonstrate the assignment of actions to various hooks. It runs on Drupal 5 currently. I encourage you to check it out and give me feedback on http://groups.drupal.org/actions or just in an email.
Hopefully we can have a facade action that hooks up to any Drupal form id, and uses drupal_execute() to fire the action. That would mean many Drupal forms become "scriptable" automatically.
There are two pending core patches that may be action-ified: 1. http://drupal.org/node/146076 - ban the author while deleting content 2. http://drupal.org/node/146291 - replies module for core -- Dries Buytaert :: http://www.buytaert.net/
There are two pending core patches that may be action-ified: 1. http://drupal.org/node/146076 - ban the author while deleting content
May. Or may not. If the action patch lands. If this gets converted. The patch is there, the patch is ready. I really would like to see it committed -- we can always remove it when a better solution comes along.
On 5/24/07 4:56 PM, John VanDyk wrote:
Here's a progress report on actions-in-core.
Actions now have a new architecture. Instead of a single function, an action now consists of several functions.
1. An implementation of hook_actions_info(). In this hook, an action is described just like it was in the 'metadata' operation of the previous action architecture. And supported hooks are declared:
function node_action_info() { return array( 'node_make_sticky_action' => array( 'type' => 'node', 'description' => t('Make node sticky'), 'configurable' => FALSE, 'hooks' => array( 'nodeapi' => array('delete','insert','update', 'view'), 'comment' => array('delete','insert','update', 'view'), ), ), ); }
Batchability has been dropped. Instead of actions declaring themselves batchable and a node_save() being done at the end of the batch, "Save node" is now a separate action.
2. The action itself:
/** * Implementation of a Drupal action. * Sets the sticky-at-top-of-list property of a node to 1. */ function node_make_sticky_action($context = array(), &$node) { $node->sticky = 1; $node->revision = 0; watchdog('action', t('Made node id %id sticky', array('%id' => $node->nid))); }
3. If the action is a configurable action such as the "Display a message to the user" action, it needs to define a form, validate, and submit function. The submit function is responsible for returning a keyed array with parameters that will be stored and used when the action is fired. E.g., (validate function not shown):
function system_message_action_form($edit) { $form['message'] = array( '#type' => 'textarea', '#title' => t('Message'), '#default_value' => isset($edit['message']) ? $edit['message'] : '', '#required' => TRUE, '#rows' => '8', '#description' => t('The message to be displayed to the current user. You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body.'), ); return $form; }
function system_message_action_form_submit($form_id, $form_values) { return array('message' => $form_values['message']); }
The HEAD version of actions is now stable enough to demonstrate the assignment of actions to various hooks. It runs on Drupal 5 currently. I encourage you to check it out and give me feedback on http://groups.drupal.org/actions or just in an email.
Hopefully we can have a facade action that hooks up to any Drupal form id, and uses drupal_execute() to fire the action. That would mean many Drupal forms become "scriptable" automatically.
Dear John, You rock. Love, James -- James Walker :: http://walkah.net/ :: xmpp:walkah@walkah.net
+1 :-) This will be one of the killer features of D6, IMO! On May 25, 2007, at 15:13 , James Walker wrote:
On 5/24/07 4:56 PM, John VanDyk wrote:
... John's message ...
Dear John,
You rock.
Love, James -- James Walker :: http://walkah.net/ :: xmpp:walkah@walkah.net
participants (5)
-
Dries Buytaert -
James Walker -
John VanDyk -
Karoly Negyesi -
Wim Leers