summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-09-11 14:50:05 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-09-11 14:50:05 +0000
commitac7637bc9bf5c4dae43a448511b67daf2825be1a (patch)
tree989d00ed976ff651d954a87b10315a99156f9cbd /modules
parentf73786d1e4c658c552f3cc103d83bb7801101c77 (diff)
downloadbrdo-ac7637bc9bf5c4dae43a448511b67daf2825be1a.tar.gz
brdo-ac7637bc9bf5c4dae43a448511b67daf2825be1a.tar.bz2
#172773 by numerous contributors: Make the actions interface usable by mere mortals (including rename of actions.module to trigger, but keeping the actions themselfs).
Complete previous history of actions module: - #148410 by jvandyk: added rewrite of the actions module! - #155986 by Uwe: fixed typos. - #155828 by Eaton, pwolanin and jvandyk: let actions live even if actions.module is not turned on
Diffstat (limited to 'modules')
-rw-r--r--modules/actions/actions.info6
-rw-r--r--modules/comment/comment.module12
-rw-r--r--modules/node/node.module53
-rw-r--r--modules/system/system.module56
-rw-r--r--modules/taxonomy/taxonomy.module6
-rw-r--r--modules/trigger/trigger.info6
-rw-r--r--modules/trigger/trigger.install (renamed from modules/actions/actions.install)8
-rw-r--r--modules/trigger/trigger.module (renamed from modules/actions/actions.module)202
-rw-r--r--modules/trigger/trigger.schema (renamed from modules/actions/actions.schema)4
-rw-r--r--modules/user/user.module30
10 files changed, 202 insertions, 181 deletions
diff --git a/modules/actions/actions.info b/modules/actions/actions.info
deleted file mode 100644
index ae431279b..000000000
--- a/modules/actions/actions.info
+++ /dev/null
@@ -1,6 +0,0 @@
-; $Id$
-name = Actions
-description = Enables triggerable Drupal actions.
-package = Core - optional
-version = VERSION
-core = 6.x
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 1ad7e08bc..59264a41c 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -2144,16 +2144,16 @@ function comment_hook_info() {
'comment' => array(
'comment' => array(
'insert' => array(
- 'runs when' => t('When a comment has been created'),
+ 'runs when' => t('After saving a new comment'),
),
'update' => array(
- 'runs when' => t('When a comment has been updated'),
+ 'runs when' => t('After saving an updated comment'),
),
'delete' => array(
- 'runs when' => t('When a comment has been deleted')
+ 'runs when' => t('After deleting a comment')
),
'view' => array(
- 'runs when' => t('When a comment is being viewed')
+ 'runs when' => t('When a comment is being viewed by an authenticated user')
),
),
),
@@ -2170,7 +2170,7 @@ function comment_action_info() {
'type' => 'comment',
'configurable' => FALSE,
'hooks' => array(
- 'comment' => array('insert', 'update', 'view'),
+ 'comment' => array('insert', 'update'),
)
),
'comment_unpublish_by_keyword_action' => array(
@@ -2209,7 +2209,7 @@ function comment_unpublish_by_keyword_action_form($context) {
$form['keywords'] = array(
'#title' => t('Keywords'),
'#type' => 'textarea',
- '#description' => t('The comment will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc.".'),
+ '#description' => t('The comment will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc.". Character sequences are case-sensitive.'),
'#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
);
return $form;
diff --git a/modules/node/node.module b/modules/node/node.module
index 1a7a78659..bcd5b3e40 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -2308,16 +2308,16 @@ function node_hook_info() {
'node' => array(
'nodeapi' => array(
'presave' => array(
- 'runs when' => t('When content is about to be saved'),
+ 'runs when' => t('When either saving a new post or updating an existing post'),
),
'insert' => array(
- 'runs when' => t('When content has been created'),
+ 'runs when' => t('After saving a new post'),
),
'update' => array(
- 'runs when' => t('When content has been updated'),
+ 'runs when' => t('After saving an updated post'),
),
'delete' => array(
- 'runs when' => t('When content has been deleted')
+ 'runs when' => t('After deleting a post')
),
'view' => array(
'runs when' => t('When content is viewed by an authenticated user')
@@ -2336,65 +2336,71 @@ function node_action_info() {
'type' => 'node',
'description' => t('Publish post'),
'configurable' => FALSE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('insert', 'update'),
),
),
'node_unpublish_action' => array(
'type' => 'node',
'description' => t('Unpublish post'),
'configurable' => FALSE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('delete', 'insert', 'update'),
),
),
'node_make_sticky_action' => array(
'type' => 'node',
'description' => t('Make post sticky'),
'configurable' => FALSE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('insert', 'update'),
),
),
'node_make_unsticky_action' => array(
'type' => 'node',
'description' => t('Make post unsticky'),
'configurable' => FALSE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('delete', 'insert', 'update'),
),
),
'node_promote_action' => array(
'type' => 'node',
'description' => t('Promote post to front page'),
'configurable' => FALSE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
- 'user' => array('login'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('insert', 'update'),
),
),
'node_unpromote_action' => array(
'type' => 'node',
'description' => t('Remove post from front page'),
'configurable' => FALSE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('delete', 'insert', 'update'),
),
),
'node_assign_owner_action' => array(
'type' => 'node',
'description' => t('Change the author of a post'),
'configurable' => TRUE,
+ 'behavior' => array('changes_node_property'),
'hooks' => array(
'any' => TRUE,
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave'),
+ 'comment' => array('delete', 'insert', 'update'),
),
),
'node_save_action' => array(
@@ -2402,9 +2408,7 @@ function node_action_info() {
'description' => t('Save post'),
'configurable' => FALSE,
'hooks' => array(
- 'nodeapi' => array('delete', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
- 'user' => array('login'),
+ 'comment' => array('delete', 'insert', 'update'),
),
),
'node_unpublish_by_keyword_action' => array(
@@ -2412,8 +2416,7 @@ function node_action_info() {
'description' => t('Unpublish post containing keyword(s)'),
'configurable' => TRUE,
'hooks' => array(
- 'nodeapi' => array('presave', 'insert', 'update', 'view'),
- 'comment' => array('delete', 'insert', 'update', 'view'),
+ 'nodeapi' => array('presave', 'insert', 'update'),
),
),
);
@@ -2546,7 +2549,7 @@ function node_unpublish_by_keyword_action_form($context) {
$form['keywords'] = array(
'#title' => t('Keywords'),
'#type' => 'textarea',
- '#description' => t('The node will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc.".'),
+ '#description' => t('The node will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc.". Character sequences are case-sensitive.'),
'#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
);
return $form;
diff --git a/modules/system/system.module b/modules/system/system.module
index a469c6cae..369de9289 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -52,14 +52,16 @@ function system_help($path, $arg) {
return $output;
case 'admin/build/modules/uninstall':
return '<p>'. t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it. Not all modules support this feature.') .'</p>';
- case 'admin/build/actions':
- case 'admin/build/actions/manage':
- $explanation = t('Actions are functions that Drupal can execute when certain events happen, such as when a post is added or a user logs in.');
- $output = '<p>'. $explanation .' '. t('A module, such as the actions module, may assign these actions to the specific events that will trigger them.') .'</p>';
- $output .= '<p>'. t('This page lists all actions that are available. Simple actions that do not require any configuration are listed automatically. Advanced actions that need to be configured are listed in the dropdown below. To add an advanced action, select the action and click the <em>Configure</em> button. After completing the configuration form, the action will be available for use by Drupal.') .'</p>';
+ case 'admin/settings/actions':
+ case 'admin/settings/actions/manage':
+ $output = '<p>'. t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the trigger module, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions.') .'</p>';
+ $output .= '<p>'. t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions can do more than simple actions; for example, send an e-mail to a specified address, or check for certain words within a piece of content. These actions need to be created and configured first before they may be used. To create an advanced action, select the action from the drop-down below and click the <em>Create</em> button.') .'</p>';
+ if (module_exists('trigger')) {
+ $output .= '<p>'. t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/build/trigger'))) .'</p>';
+ }
return $output;
- case 'admin/build/actions/config':
- return '<p>'. t('This is where you configure a certain action that will be performed at some time in the future. For example, you might configure an action to send email to your friend Joe. You would modify the description field, below, to read %send to remind you of that. The description you provide will be used to identify this action; for example, when assigning an action to a Drupal event such as a new comment being posted.', array('%send' => t('Send email to Joe'))) .'</p>';
+ case 'admin/settings/actions/configure':
+ return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
case 'admin/logs/status':
return '<p>'. t("Here you can find a short overview of your Drupal site's parameters as well as any problems detected with your installation. It is useful to copy/paste this information when you need support.") .'</p>';
}
@@ -273,33 +275,33 @@ function system_menu() {
);
// Actions:
- $items['admin/build/actions'] = array(
+ $items['admin/settings/actions'] = array(
'title' => 'Actions',
'description' => 'Manage the actions defined for your site.',
'access arguments' => array('administer actions'),
'page callback' => 'system_actions_manage'
);
- $items['admin/build/actions/manage'] = array(
+ $items['admin/settings/actions/manage'] = array(
'title' => 'Manage actions',
'description' => 'Manage the actions defined for your site.',
'page callback' => 'system_actions_manage',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -2,
);
- $items['admin/build/actions/config'] = array(
- 'title' => 'Configure an action',
+ $items['admin/settings/actions/configure'] = array(
+ 'title' => 'Configure an advanced action',
'page callback' => 'drupal_get_form',
'page arguments' => array('system_actions_configure'),
'type' => MENU_CALLBACK,
);
- $items['admin/build/actions/delete/%actions'] = array(
+ $items['admin/settings/actions/delete/%actions'] = array(
'title' => 'Delete action',
'description' => 'Delete an action.',
'page callback' => 'drupal_get_form',
'page arguments' => array('system_actions_delete_form', 4),
'type' => MENU_CALLBACK,
);
- $items['admin/build/actions/orphan'] = array(
+ $items['admin/settings/actions/orphan'] = array(
'title' => 'Remove orphans',
'page callback' => 'system_actions_remove_orphans',
'type' => MENU_CALLBACK,
@@ -1148,7 +1150,7 @@ function system_actions_manage() {
$row = array();
$instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters != ''"));
$header = array(
- array('data' => t('Action Type'), 'field' => 'type'),
+ array('data' => t('Action type'), 'field' => 'type'),
array('data' => t('Description'), 'field' => 'description'),
array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
);
@@ -1158,8 +1160,8 @@ function system_actions_manage() {
$row[] = array(
array('data' => $action->type),
array('data' => $action->description),
- array('data' => $action->parameters ? l(t('configure'), "admin/build/actions/config/$action->aid") : ''),
- array('data' => $action->parameters ? l(t('delete'), "admin/build/actions/delete/$action->aid") : '')
+ array('data' => $action->parameters ? l(t('configure'), "admin/settings/actions/configure/$action->aid") : ''),
+ array('data' => $action->parameters ? l(t('delete'), "admin/settings/actions/delete/$action->aid") : '')
);
}
@@ -1202,14 +1204,14 @@ function system_actions_manage_form($form_state, $options = array()) {
);
$form['parent']['buttons']['submit'] = array(
'#type' => 'submit',
- '#value' => t('Configure'),
+ '#value' => t('Create'),
);
return $form;
}
function system_actions_manage_form_submit($form, &$form_state) {
if ($form_state['values']['action']) {
- $form_state['redirect'] = 'admin/build/actions/config/'. $form_state['values']['action'];
+ $form_state['redirect'] = 'admin/settings/actions/configure/'. $form_state['values']['action'];
}
}
@@ -1230,7 +1232,7 @@ function system_actions_manage_form_submit($form, &$form_state) {
*/
function system_actions_configure($form_state, $action = NULL) {
if ($action === NULL) {
- drupal_goto('admin/build/actions');
+ drupal_goto('admin/settings/actions');
}
$actions_map = actions_actions_map(actions_list());
@@ -1259,14 +1261,12 @@ function system_actions_configure($form_state, $action = NULL) {
$edit['actions_type'] = $actions_map[$action]['type'];
}
-
$form['actions_description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $edit['actions_description'],
- '#size' => '70',
'#maxlength' => '255',
- '#description' => t('A unique description for this configuration of this action. This will be used to describe this action when assigning actions.'),
+ '#description' => t('A unique description for this advanced action. This description will be displayed in the interface of modules that integrate with actions, such as Trigger module.'),
'#weight' => -10
);
$action_form = $function .'_form';
@@ -1318,7 +1318,7 @@ function system_actions_configure_submit($form, &$form_state) {
actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_description'], $aid);
drupal_set_message(t('The action has been successfully saved.'));
- $form_state['redirect'] = 'admin/build/actions/manage';
+ $form_state['redirect'] = 'admin/settings/actions/manage';
}
/**
@@ -1335,7 +1335,7 @@ function system_actions_delete_form($form_state, $action) {
);
return confirm_form($form,
t('Are you sure you want to delete the action %action?', array('%action' => $action->description)),
- 'admin/build/actions/manage',
+ 'admin/settings/actions/manage',
t('This cannot be undone.'),
t('Delete'), t('Cancel')
);
@@ -1351,7 +1351,7 @@ function system_actions_delete_form_submit($form, &$form_state) {
$description = check_plain($action->description);
watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $description));
drupal_set_message(t('Action %action was deleted', array('%action' => $description)));
- $form_state['redirect'] = 'admin/build/actions/manage';
+ $form_state['redirect'] = 'admin/settings/actions/manage';
}
/**
* Post-deletion operations for deleting action orphans.
@@ -1368,7 +1368,7 @@ function system_action_delete_orphans_post($orphaned) {
*/
function system_actions_remove_orphans() {
actions_synchronize(actions_list(), TRUE);
- drupal_goto('admin/build/actions/manage');
+ drupal_goto('admin/settings/actions/manage');
}
/**
@@ -1395,15 +1395,13 @@ function system_send_email_action_form($context) {
'#type' => 'textfield',
'#title' => t('Recipient'),
'#default_value' => $context['recipient'],
- '#size' => '20',
'#maxlength' => '254',
- '#description' => t('The email address to which the message should be sent OR enter %author if you would like to send an e-mail to the original author of the post.', array('%author' => '%author')),
+ '#description' => t('The email address to which the message should be sent OR enter %author if you would like to send an e-mail to the author of the original post.', array('%author' => '%author')),
);
$form['subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => $context['subject'],
- '#size' => '20',
'#maxlength' => '254',
'#description' => t('The subject of the message.'),
);
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 13cf52c33..4c1aeb540 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1149,13 +1149,13 @@ function taxonomy_hook_info() {
'taxonomy' => array(
'taxonomy' => array(
'insert' => array(
- 'runs when' => t('When a new category has been created'),
+ 'runs when' => t('After saving a new category to the database'),
),
'update' => array(
- 'runs when' => t('When a category has been updated'),
+ 'runs when' => t('After saving an updated category to the database'),
),
'delete' => array(
- 'runs when' => t('When a category has been deleted')
+ 'runs when' => t('After deleting a category')
),
),
),
diff --git a/modules/trigger/trigger.info b/modules/trigger/trigger.info
new file mode 100644
index 000000000..ca08f85c6
--- /dev/null
+++ b/modules/trigger/trigger.info
@@ -0,0 +1,6 @@
+; $Id$
+name = Trigger
+description = Enables actions to be fired on certain system events, such as when new content is created.
+package = Core - optional
+version = VERSION
+core = 6.x
diff --git a/modules/actions/actions.install b/modules/trigger/trigger.install
index fecb8757e..13dd08ae1 100644
--- a/modules/actions/actions.install
+++ b/modules/trigger/trigger.install
@@ -4,9 +4,9 @@
/**
* Implementation of hook_install().
*/
-function actions_install() {
+function trigger_install() {
// Create tables.
- drupal_install_schema('actions');
+ drupal_install_schema('trigger');
// Do initial synchronization of actions in code and the database.
actions_synchronize(actions_list());
@@ -15,7 +15,7 @@ function actions_install() {
/**
* Implementation of hook_uninstall().
*/
-function actions_uninstall() {
+function trigger_uninstall() {
// Remove tables.
- drupal_uninstall_schema('actions');
+ drupal_uninstall_schema('trigger');
}
diff --git a/modules/actions/actions.module b/modules/trigger/trigger.module
index d4b790426..5cda17c01 100644
--- a/modules/actions/actions.module
+++ b/modules/trigger/trigger.module
@@ -10,21 +10,29 @@
/**
* Implementation of hook_help().
*/
-function actions_help($path, $arg) {
+function trigger_help($path, $arg) {
$output = '';
- $explanation = t('Actions are functions that Drupal can execute when certain events happen, such as when a post is added or a user logs in.');
+ $explanation = '<p>'. t('Triggers are system events, such as when new content is added or when a user logs in. Trigger module combines these triggers with actions (functional tasks), such as unpublishing content or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure additional actions.', array('@url' => url('admin/settings/actions'))) .'</p>';
switch ($path) {
- case 'admin/build/actions/assign/comment':
- $output = '<p>'. $explanation .' '. t('Below you can assign actions to run when certain comment-related operations happen. For example, you could promote a post to the front page when a comment is added.') .'</p>';
+ case 'admin/build/trigger/comment':
+ $output .= $explanation .'<p>'. t('Below you can assign actions to run when certain comment-related triggers happen. For example, you could promote a post to the front page when a comment is added.') .'</p>';
break;
- case 'admin/build/actions/assign/node':
- $output = '<p>'. $explanation .' '. t('Below you can assign actions to run when certain post-related operations happen. For example, you could remove a post from the front page when the post is updated. Note that if you are running actions that modify the characteristics of a post (such as making a post sticky or removing a post from the front page), you will need to add the %node_save action to save the changes.', array('%node_save' => t('Save post'))) .'</p>';
+ case 'admin/build/trigger/node':
+ $output .= $explanation .'<p>'. t('Below you can assign actions to run when certain content-related triggers happen. For example, you could remove a post from the front page when the post is updated.') .'</p>';
break;
- case 'admin/build/actions/assign/user':
- $output = '<p>'. $explanation .' '. t("Below you can assign actions to run when certain user-related operations happen. For example, you could block a user when the user's account is edited by assigning the %block_user action to the user %update operation.", array('%block_user' => t('Block user'), '%update' => t('update'))) .'</p>';
+ case 'admin/build/trigger/cron':
+ $output .= $explanation .'<p>'. t('Below you can assign actions to run when cron runs. More information on cron is available in the <a href="@system">System module help page</a>.', array('@system' => url('admin/help/system'))) .'</p>';
break;
- case 'admin/build/actions/assign/cron':
- $output = '<p>'. t('Actions are functions that Drupal can execute when certain events happen, such as when a post is added or a user logs in. Below you can assign actions to run when cron runs.') .'</p>';
+ case 'admin/build/trigger/taxonomy':
+ $output .= $explanation .'<p>'. t('Below you can assign actions to run when certain category-related triggers happen. For example, you could send an e-mail to an administrator when a category is deleted.') .'</p>';
+ break;
+ case 'admin/build/trigger/user':
+ $output .= $explanation .'<p>'. t("Below you can assign actions to run when certain user-related triggers happen. For example, you could send an e-mail to an administrator when a user account is deleted.") .'</p>';
+ break;
+ case 'admin/help#trigger':
+ $output .= '<p>'. t('The Trigger module provides the ability to trigger <a href="@actions">actions</a> upon system events, such as when new content is added or when a user logs in.', array('@actions' => url('admin/settings/actions'))) .'</p>';
+ $output .= '<p>'. t('The combination of actions and triggers can perform many useful tasks, such as e-mailing an administrator if a user account is deleted, or automatically unpublishing comments that contain certain words. By default, there are five "contexts" of events (Categories, Comments, Content, Cron, and Users), but more may be added by additional modules.') .'</p>';
+ $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="@trigger">Trigger</a> page.', array('@trigger' => 'http://drupal.org/handbook/modules/trigger/')) .'</p>';
break;
}
@@ -34,44 +42,49 @@ function actions_help($path, $arg) {
/**
* Implementation of hook_menu().
*/
-function actions_menu() {
- $items['admin/build/actions/assign'] = array(
- 'title' => 'Assign actions',
+function trigger_menu() {
+ $items['admin/build/trigger'] = array(
+ 'title' => 'Triggers',
'description' => 'Tell Drupal when to execute actions.',
- 'page callback' => 'actions_assign',
- 'type' => MENU_LOCAL_TASK,
+ 'page callback' => 'trigger_assign',
+ 'access callback' => 'trigger_access_check',
+ 'access arguments' => array('node'),
);
- $items['admin/build/actions/assign/node'] = array(
+ // We don't use a menu wildcard here because these are tabs,
+ // not invisible items.
+ $items['admin/build/trigger/node'] = array(
'title' => 'Content',
- 'page callback' => 'actions_assign',
+ 'page callback' => 'trigger_assign',
'page arguments' => array('node'),
+ 'access arguments' => array('node'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/actions/assign/user'] = array(
- 'title' => 'User',
- 'page callback' => 'actions_assign',
+ $items['admin/build/trigger/user'] = array(
+ 'title' => 'Users',
+ 'page callback' => 'trigger_assign',
'page arguments' => array('user'),
+ 'access arguments' => array('user'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/actions/assign/comment'] = array(
- 'title' => 'Comment',
- 'page callback' => 'actions_assign',
+ $items['admin/build/trigger/comment'] = array(
+ 'title' => 'Comments',
+ 'page callback' => 'trigger_assign',
'page arguments' => array('comment'),
- 'access callback' => 'actions_access_check',
+ 'access callback' => 'trigger_access_check',
'access arguments' => array('comment'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/actions/assign/taxonomy'] = array(
- 'title' => 'Taxonomy',
- 'page callback' => 'actions_assign',
+ $items['admin/build/trigger/taxonomy'] = array(
+ 'title' => 'Categories',
+ 'page callback' => 'trigger_assign',
'page arguments' => array('taxonomy'),
- 'access callback' => 'actions_access_check',
+ 'access callback' => 'trigger_access_check',
'access arguments' => array('taxonomy'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/actions/assign/cron'] = array(
+ $items['admin/build/trigger/cron'] = array(
'title' => 'Cron',
- 'page callback' => 'actions_assign',
+ 'page callback' => 'trigger_assign',
'page arguments' => array('cron'),
'type' => MENU_LOCAL_TASK,
);
@@ -80,24 +93,26 @@ function actions_menu() {
// their hooks and have actions assignable to them.
$hooks = module_invoke_all('hook_info');
foreach ($hooks as $module => $hook) {
+ // We've already done these.
if (in_array($module, array('node', 'comment', 'user', 'system', 'taxonomy'))) {
continue;
}
$info = db_result(db_query("SELECT info FROM {system} WHERE name = '%s'", $module));
$info = unserialize($info);
$nice_name = $info['name'];
- $items["admin/build/actions/assign/$module"] = array(
+ $items["admin/build/trigger/$module"] = array(
'title' => $nice_name,
- 'page callback' => 'actions_assign',
+ 'page callback' => 'trigger_assign',
'page arguments' => array($module),
+ 'access arguments' => array($module),
'type' => MENU_LOCAL_TASK,
);
}
- $items['admin/build/actions/assign/remove'] = array(
+ $items['admin/build/trigger/unassign'] = array(
'title' => 'Unassign',
- 'description' => 'Remove an action assignment.',
+ 'description' => 'Unassign an action from a trigger.',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('actions_unassign'),
+ 'page arguments' => array('trigger_unassign'),
'type' => MENU_CALLBACK,
);
@@ -107,12 +122,10 @@ function actions_menu() {
/**
* Access callback for menu system.
*/
-function actions_access_check($module) {
+function trigger_access_check($module) {
return (module_exists($module) && user_access('administer actions'));
}
-
-
/**
* Get the actions that have already been defined for this
* type-hook-op combination.
@@ -128,13 +141,13 @@ function actions_access_check($module) {
* @return
* An array of action descriptions keyed by action IDs.
*/
-function _actions_get_hook_actions($hook, $op, $type = NULL) {
+function _trigger_get_hook_actions($hook, $op, $type = NULL) {
$actions = array();
if ($type) {
- $result = db_query("SELECT h.aid, a.description FROM {actions_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE a.type = '%s' AND h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $type, $hook, $op);
+ $result = db_query("SELECT h.aid, a.description FROM {trigger_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE a.type = '%s' AND h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $type, $hook, $op);
}
else {
- $result = db_query("SELECT h.aid, a.description FROM {actions_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $hook, $op);
+ $result = db_query("SELECT h.aid, a.description FROM {trigger_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $hook, $op);
}
while ($action = db_fetch_object($result)) {
$actions[$action->aid] = $action->description;
@@ -153,9 +166,9 @@ function _actions_get_hook_actions($hook, $op, $type = NULL) {
* @return
* An array of action IDs.
*/
-function _actions_get_hook_aids($hook, $op = '') {
+function _trigger_get_hook_aids($hook, $op = '') {
$aids = array();
- $result = db_query("SELECT aa.aid, a.type FROM {actions_assignments} aa LEFT JOIN {actions} a ON aa.aid = a.aid WHERE aa.hook = '%s' AND aa.op = '%s' ORDER BY weight", $hook, $op);
+ $result = db_query("SELECT aa.aid, a.type FROM {trigger_assignments} aa LEFT JOIN {actions} a ON aa.aid = a.aid WHERE aa.hook = '%s' AND aa.op = '%s' ORDER BY weight", $hook, $op);
while ($action = db_fetch_object($result)) {
$aids[$action->aid]['type'] = $action->type;
}
@@ -175,7 +188,7 @@ function _actions_get_hook_aids($hook, $op = '') {
* A plain English description of what this hook operation does.
* @return
*/
-function actions_assign_form($form_state, $hook, $op, $description) {
+function trigger_assign_form($form_state, $hook, $op, $description) {
$form['hook'] = array(
'#type' => 'hidden',
'#value' => $hook,
@@ -185,7 +198,7 @@ function actions_assign_form($form_state, $hook, $op, $description) {
'#value' => $op,
);
// All of these forms use the same #submit function.
- $form['#submit'][] = 'actions_assign_form_submit';
+ $form['#submit'][] = 'trigger_assign_form_submit';
$options = array();
$functions = array();
@@ -203,17 +216,17 @@ function actions_assign_form($form_state, $hook, $op, $description) {
$form[$op] = array(
'#type' => 'fieldset',
- '#title' => $description,
- '#theme' => 'actions_display'
+ '#title' => t('Trigger: '). $description,
+ '#theme' => 'trigger_display'
);
// Retrieve actions that are already assigned to this hook-op combination.
- $actions = _actions_get_hook_actions($hook, $op);
+ $actions = _trigger_get_hook_actions($hook, $op);
$form[$op]['assigned']['#type'] = 'value';
$form[$op]['assigned']['#value'] = array();
foreach ($actions as $aid => $description) {
$form[$op]['assigned']['#value'][$aid] = array(
'description' => $description,
- 'link' => l(t('remove'), "admin/build/actions/assign/remove/$hook/$op/". md5($aid))
+ 'link' => l(t('unassign'), "admin/build/trigger/unassign/$hook/$op/". md5($aid))
);
}
@@ -235,27 +248,42 @@ function actions_assign_form($form_state, $hook, $op, $description) {
}
else {
$form[$op]['none'] = array(
- '#value' => t('No available actions support this context.')
+ '#value' => t('No available actions for this trigger.')
);
}
return $form;
}
-function actions_assign_form_submit($form, $form_state) {
+function trigger_assign_form_submit($form, $form_state) {
$form_values = $form_state['values'];
+
if (!empty($form_values['aid'])) {
$aid = actions_function_lookup($form_values['aid']);
- $weight = db_result(db_query("SELECT MAX(weight) FROM {actions_assignments} WHERE hook = '%s' AND op = '%s'", $form_values['hook'], $form_values['operation']));
- db_query("INSERT INTO {actions_assignments} values ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], $aid, $weight + 1);
+ $weight = db_result(db_query("SELECT MAX(weight) FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s'", $form_values['hook'], $form_values['operation']));
+ db_query("INSERT INTO {trigger_assignments} values ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], $aid, $weight + 1);
+ // If this action changes a node property, we need to save the node
+ // so the change will persist.
+ $actions = actions_list();
+ if (isset($actions[$aid]['behavior']) && in_array('changes_node_property', $actions[$aid]['behavior']) && ($form_values['operation'] != 'presave')) {
+ // Delete previous node_save_action if it exists, and re-add a new one at a higher weight.
+ $save_post_action_assigned = db_result(db_query("SELECT aid FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = 'node_save_action'", $form_values['hook'], $form_values['operation']));
+ if ($save_post_action_assigned) {
+ db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = 'node_save_action'", $form_values['hook'], $form_values['operation']);
+ }
+ db_query("INSERT INTO {trigger_assignments} VALUES ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], 'node_save_action', $weight + 2);
+ if (!$save_post_action_assigned) {
+ drupal_set_message(t('You have added an action that changes a the property of a post. A Save post action has been added so that the property change will be saved.'));
+ }
+ }
}
}
/**
* Implementation of hook_theme().
*/
-function actions_theme() {
+function trigger_theme() {
return array(
- 'actions_display' => array(
+ 'trigger_display' => array(
'arguments' => array('element')
),
);
@@ -269,7 +297,7 @@ function actions_theme() {
* @return
* The rendered form with the table prepended.
*/
-function theme_actions_display($element) {
+function theme_trigger_display($element) {
$header = array();
$rows = array();
if (count($element['assigned']['#value'])) {
@@ -291,12 +319,12 @@ function theme_actions_display($element) {
* Implementation of hook_forms(). We reuse code by using the
* same assignment form definition for each node-op combination.
*/
-function actions_forms() {
+function trigger_forms() {
$hooks = module_invoke_all('hook_info');
foreach ($hooks as $module => $info) {
foreach ($hooks[$module] as $hook => $ops) {
foreach ($ops as $op => $description) {
- $forms['actions_'. $hook .'_'. $op .'_assign_form'] = array('callback' => 'actions_assign_form');
+ $forms['trigger_'. $hook .'_'. $op .'_assign_form'] = array('callback' => 'trigger_assign_form');
}
}
}
@@ -312,11 +340,11 @@ function actions_forms() {
* @return
* HTML form.
*/
-function actions_assign($type = NULL) {
+function trigger_assign($type = NULL) {
// If no type is specified we default to node actions, since they
// are the most common.
if (!isset($type)) {
- drupal_goto('admin/build/actions/assign/node');
+ drupal_goto('admin/build/trigger/node');
}
if ($type == 'node') {
$type = 'nodeapi';
@@ -327,7 +355,7 @@ function actions_assign($type = NULL) {
foreach ($hooks as $module => $hook) {
if (isset($hook[$type])) {
foreach ($hook[$type] as $op => $description) {
- $form_id = 'actions_'. $type .'_'. $op .'_assign_form';
+ $form_id = 'trigger_'. $type .'_'. $op .'_assign_form';
$output .= drupal_get_form($form_id, $type, $op, $description['runs when']);
}
}
@@ -343,9 +371,9 @@ function actions_assign($type = NULL) {
* @param $aid
* The action ID.
*/
-function actions_unassign($form_state, $hook = NULL, $op = NULL, $aid = NULL) {
+function trigger_unassign($form_state, $hook = NULL, $op = NULL, $aid = NULL) {
if (!($hook && $op && $aid)) {
- drupal_goto('admin/build/actions/assign');
+ drupal_goto('admin/build/trigger/assign');
}
$form['hook'] = array(
@@ -364,29 +392,29 @@ function actions_unassign($form_state, $hook = NULL, $op = NULL, $aid = NULL) {
$action = actions_function_lookup($aid);
$actions = actions_get_all_actions();
- $destination = 'admin/build/actions/assign/'. ($hook == 'nodeapi' ? 'node' : $hook);
+ $destination = 'admin/build/trigger/'. ($hook == 'nodeapi' ? 'node' : $hook);
return confirm_form($form,
- t('Are you sure you want to remove the action %title?', array('%title' => $actions[$action]['description'])),
+ t('Are you sure you want to unassign the action %title?', array('%title' => $actions[$action]['description'])),
$destination,
t('You can assign it again later if you wish.'),
- t('Remove'), t('Cancel')
+ t('Unassign'), t('Cancel')
);
}
-function actions_unassign_submit($form, &$form_state) {
+function trigger_unassign_submit($form, &$form_state) {
$form_values = $form_state['values'];
if ($form_values['confirm'] == 1) {
$aid = actions_function_lookup($form_values['aid']);
- db_query("DELETE FROM {actions_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $form_values['hook'], $form_values['operation'], $aid);
+ db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $form_values['hook'], $form_values['operation'], $aid);
$actions = actions_get_all_actions();
watchdog('actions', 'Action %action has been unassigned.', array('%action' => check_plain($actions[$aid]['description'])));
drupal_set_message(t('Action %action has been unassigned.', array('%action' => $actions[$aid]['description'])));
$hook = $form_values['hook'] == 'nodeapi' ? 'node' : $form_values['hook'];
- $form_state['redirect'] = 'admin/build/actions/assign/'. $hook;
+ $form_state['redirect'] = 'admin/build/trigger/'. $hook;
}
else {
- drupal_goto('admin/build/actions');
+ drupal_goto('admin/build/trigger');
}
}
@@ -404,7 +432,7 @@ function actions_unassign_submit($form, &$form_state) {
* @return
* The object expected by the action that is about to be called.
*/
-function _actions_normalize_node_context($type, $node) {
+function _trigger_normalize_node_context($type, $node) {
switch ($type) {
// If an action that works on comments is being called in a node context,
// the action is expecting a comment object. But we do not know which comment
@@ -421,7 +449,7 @@ function _actions_normalize_node_context($type, $node) {
/**
* Implementation of hook_nodeapi().
*/
-function actions_nodeapi($node, $op, $a3, $a4) {
+function trigger_nodeapi($node, $op, $a3, $a4) {
// Keep objects for reuse so that changes actions make to objects can persist.
static $objects;
// Prevent recursion by tracking which operations have already been called.
@@ -432,7 +460,7 @@ function actions_nodeapi($node, $op, $a3, $a4) {
}
$recursion[$op] = TRUE;
- $aids = _actions_get_hook_aids('nodeapi', $op);
+ $aids = _trigger_get_hook_aids('nodeapi', $op);
if (!$aids) {
return;
}
@@ -447,7 +475,7 @@ function actions_nodeapi($node, $op, $a3, $a4) {
foreach ($aids as $aid => $action_info) {
if ($action_info['type'] != 'node') {
if (!isset($objects[$action_info['type']])) {
- $objects[$action_info['type']] = _actions_normalize_node_context($action_info['type'], $node);
+ $objects[$action_info['type']] = _trigger_normalize_node_context($action_info['type'], $node);
}
// Since we know about the node, we pass that info along to the action.
$context['node'] = $node;
@@ -473,7 +501,7 @@ function actions_nodeapi($node, $op, $a3, $a4) {
* @return
* The object expected by the action that is about to be called.
*/
-function _actions_normalize_comment_context($type, $comment) {
+function _trigger_normalize_comment_context($type, $comment) {
switch ($type) {
// An action that works with nodes is being called in a comment context.
case 'node':
@@ -488,14 +516,14 @@ function _actions_normalize_comment_context($type, $comment) {
/**
* Implementation of hook_comment().
*/
-function actions_comment($a1, $op) {
+function trigger_comment($a1, $op) {
// Keep objects for reuse so that changes actions make to objects can persist.
static $objects;
// We support a subset of operations.
if (!in_array($op, array('insert', 'update', 'delete', 'view'))) {
return;
}
- $aids = _actions_get_hook_aids('comment', $op);
+ $aids = _trigger_get_hook_aids('comment', $op);
$context = array(
'hook' => 'comment',
'op' => $op,
@@ -506,7 +534,7 @@ function actions_comment($a1, $op) {
foreach ($aids as $aid => $action_info) {
if ($action_info['type'] != 'comment') {
if (!isset($objects[$action_info['type']])) {
- $objects[$action_info['type']] = _actions_normalize_comment_context($action_info['type'], $a1);
+ $objects[$action_info['type']] = _trigger_normalize_comment_context($action_info['type'], $a1);
}
// Since we know about the comment, we pass it along to the action
// in case it wants to peek at it.
@@ -522,8 +550,8 @@ function actions_comment($a1, $op) {
/**
* Implementation of hook_cron().
*/
-function actions_cron() {
- $aids = _actions_get_hook_aids('cron');
+function trigger_cron() {
+ $aids = _trigger_get_hook_aids('cron');
$context = array(
'hook' => 'cron',
'op' => '',
@@ -547,7 +575,7 @@ function actions_cron() {
* @return
* The object expected by the action that is about to be called.
*/
-function _actions_normalize_user_context($type, $account) {
+function _trigger_normalize_user_context($type, $account) {
switch ($type) {
// If an action that works on comments is being called in a user context,
// the action is expecting a comment object. But we have no way of
@@ -567,14 +595,14 @@ function _actions_normalize_user_context($type, $account) {
/**
* Implementation of hook_user().
*/
-function actions_user($op, &$edit, &$account, $category = NULL) {
+function trigger_user($op, &$edit, &$account, $category = NULL) {
// Keep objects for reuse so that changes actions make to objects can persist.
static $objects;
// We support a subset of operations.
if (!in_array($op, array('login', 'logout', 'insert', 'update', 'delete', 'view'))) {
return;
}
- $aids = _actions_get_hook_aids('user', $op);
+ $aids = _trigger_get_hook_aids('user', $op);
$context = array(
'hook' => 'user',
'op' => $op,
@@ -583,7 +611,7 @@ function actions_user($op, &$edit, &$account, $category = NULL) {
foreach ($aids as $aid => $action_info) {
if ($action_info['type'] != 'user') {
if (!isset($objects[$action_info['type']])) {
- $objects[$action_info['type']] = _actions_normalize_user_context($action_info['type'], $account);
+ $objects[$action_info['type']] = _trigger_normalize_user_context($action_info['type'], $account);
}
$context['account'] = $account;
actions_do($aid, $objects[$action_info['type']], $context);
@@ -597,11 +625,11 @@ function actions_user($op, &$edit, &$account, $category = NULL) {
/**
* Implementation of hook_taxonomy().
*/
-function actions_taxonomy($op, $type, $array) {
+function trigger_taxonomy($op, $type, $array) {
if ($type != 'term') {
return;
}
- $aids = _actions_get_hook_aids('taxonomy', $op);
+ $aids = _trigger_get_hook_aids('taxonomy', $op);
$context = array(
'hook' => 'taxonomy',
'op' => $op
@@ -620,7 +648,7 @@ function actions_taxonomy($op, $type, $array) {
* @return
* Array keyed by action ID.
*/
-function actions_options($type = 'all') {
+function trigger_options($type = 'all') {
$options = array(t('Choose an action'));
foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
$options[$action['type']][$aid] = $action['description'];
diff --git a/modules/actions/actions.schema b/modules/trigger/trigger.schema
index 748f0c78c..d21069c1c 100644
--- a/modules/actions/actions.schema
+++ b/modules/trigger/trigger.schema
@@ -1,8 +1,8 @@
<?php
// $Id$
-function actions_schema() {
- $schema['actions_assignments'] = array(
+function trigger_schema() {
+ $schema['trigger_assignments'] = array(
'fields' => array(
'hook' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
'op' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
diff --git a/modules/user/user.module b/modules/user/user.module
index bc22987c0..e0c68f3fb 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1991,22 +1991,22 @@ function user_hook_info() {
'user' => array(
'user' => array(
'insert' => array(
- 'runs when' => t('When a user account has been created'),
+ 'runs when' => t('After a user account has been created'),
),
'update' => array(
- 'runs when' => t('When a user account has been updated'),
+ 'runs when' => t("After a user's profile has been updated"),
),
'delete' => array(
- 'runs when' => t('When a user account has been deleted')
+ 'runs when' => t('After a user has been deleted')
),
'login' => array(
- 'runs when' => t('When a user has logged in')
+ 'runs when' => t('After a user has logged in')
),
'logout' => array(
- 'runs when' => t('When a user has logged out')
+ 'runs when' => t('After a user has logged out')
),
'view' => array(
- 'runs when' => t("When a user's account information is displayed")
+ 'runs when' => t("When a user's profile is being viewed")
),
),
),
@@ -2022,21 +2022,13 @@ function user_action_info() {
'description' => t('Block current user'),
'type' => 'user',
'configurable' => FALSE,
- 'hooks' => array(
- 'nodeapi' => array('presave', 'delete', 'insert', 'update', 'view'),
- 'comment' => array('view', 'insert', 'update', 'delete'),
- 'user' => array('logout'),
- ),
- ),
+ 'hooks' => array(),
+ ),
'user_block_ip_action' => array(
'description' => t('Ban IP address of current user'),
'type' => 'user',
'configurable' => FALSE,
- 'hooks' => array(
- 'nodeapi' => array('presave', 'delete', 'insert', 'update', 'view'),
- 'comment' => array('view', 'insert', 'update', 'delete'),
- 'user' => array('logout'),
- )
+ 'hooks' => array(),
),
);
}
@@ -2073,8 +2065,8 @@ function user_block_ip_action() {
/**
* Submit handler for the user registration form.
- *
- * This function is shared by the installation form and the normal registration form,
+ *
+ * This function is shared by the installation form and the normal registration form,
* which is why it can't be in the user.pages.inc file.
*/
function user_register_submit($form, &$form_state) {