From ccaf95feef1352adb2dae40d18253773b88442f1 Mon Sep 17 00:00:00 2001
From: Rob Loach <robloach@gmail.com>
Date: Tue, 19 Jun 2012 12:16:15 -0400
Subject: [PATCH] Add the actions module

---
 core/includes/common.inc                           |    1 -
 core/modules/actions/actions.admin.inc             |  280 ++++++++++++++++
 core/modules/actions/actions.api.php               |   98 ++++++
 core/modules/actions/actions.info                  |    6 +
 core/modules/actions/actions.install               |   53 +++
 .../actions.inc => modules/actions/actions.module} |  337 +++++++++++++++++++-
 .../Drupal/actions/Tests}/ConfigurationTest.php    |   12 +-
 .../lib/Drupal/actions/Tests}/LoopTest.php         |    6 +-
 .../actions_loop_test/actions_loop_test.info       |    1 +
 .../actions_loop_test/actions_loop_test.install    |    0
 .../actions_loop_test/actions_loop_test.module     |    0
 core/modules/system/system.admin.inc               |  275 ----------------
 core/modules/system/system.api.php                 |   88 -----
 core/modules/system/system.install                 |   61 ++--
 core/modules/system/system.module                  |  295 -----------------
 15 files changed, 792 insertions(+), 721 deletions(-)
 create mode 100644 core/modules/actions/actions.admin.inc
 create mode 100644 core/modules/actions/actions.api.php
 create mode 100644 core/modules/actions/actions.info
 create mode 100644 core/modules/actions/actions.install
 rename core/{includes/actions.inc => modules/actions/actions.module} (53%)
 rename core/modules/{system/lib/Drupal/system/Tests/Actions => actions/lib/Drupal/actions/Tests}/ConfigurationTest.php (92%)
 rename core/modules/{system/lib/Drupal/system/Tests/Actions => actions/lib/Drupal/actions/Tests}/LoopTest.php (94%)
 rename core/modules/{system/tests/modules => actions/tests}/actions_loop_test/actions_loop_test.info (84%)
 rename core/modules/{system/tests/modules => actions/tests}/actions_loop_test/actions_loop_test.install (100%)
 rename core/modules/{system/tests/modules => actions/tests}/actions_loop_test/actions_loop_test.module (100%)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index b78b7f3..efa64ad 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -5049,7 +5049,6 @@ function _drupal_bootstrap_code() {
   require_once DRUPAL_ROOT . '/core/includes/image.inc';
   require_once DRUPAL_ROOT . '/core/includes/form.inc';
   require_once DRUPAL_ROOT . '/core/includes/mail.inc';
-  require_once DRUPAL_ROOT . '/core/includes/actions.inc';
   require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
   require_once DRUPAL_ROOT . '/core/includes/token.inc';
   require_once DRUPAL_ROOT . '/core/includes/errors.inc';
diff --git a/core/modules/actions/actions.admin.inc b/core/modules/actions/actions.admin.inc
new file mode 100644
index 0000000..32e2cea
--- /dev/null
+++ b/core/modules/actions/actions.admin.inc
@@ -0,0 +1,280 @@
+<?php
+/**
+ * @file
+ * Admin page callbacks for the actions module.
+ */
+
+/**
+ * Menu callback; Displays an overview of available and configured actions.
+ */
+function actions_admin_manage() {
+  actions_synchronize();
+  $actions = actions_list();
+  $actions_map = actions_actions_map($actions);
+  $options = array();
+  $unconfigurable = array();
+
+  foreach ($actions_map as $key => $array) {
+    if ($array['configurable']) {
+      $options[$key] = $array['label'] . '...';
+    }
+    else {
+      $unconfigurable[] = $array;
+    }
+  }
+
+  $row = array();
+  $instances_present = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchField();
+  $header = array(
+    array('data' => t('Action type'), 'field' => 'type'),
+    array('data' => t('Label'), 'field' => 'label'),
+    array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
+  );
+  $query = db_select('actions')
+    ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+    ->extend('Drupal\Core\Database\Query\TableSortExtender');
+  $result = $query
+    ->fields('actions')
+    ->limit(50)
+    ->orderByHeader($header)
+    ->execute();
+
+  foreach ($result as $action) {
+    $row[] = array(
+      array('data' => $action->type),
+      array('data' => check_plain($action->label)),
+      array('data' => $action->parameters ? l(t('configure'), "admin/config/system/actions/configure/$action->aid") : ''),
+      array('data' => $action->parameters ? l(t('delete'), "admin/config/system/actions/delete/$action->aid") : '')
+    );
+  }
+
+  if ($row) {
+    $pager = theme('pager');
+    if (!empty($pager)) {
+      $row[] = array(array('data' => $pager, 'colspan' => '3'));
+    }
+    $build['actions_header'] = array('#markup' => '<h3>' . t('Available actions:') . '</h3>');
+    $build['actions_table'] = array('#markup' => theme('table', array('header' => $header, 'rows' => $row)));
+  }
+
+  if ($actions_map) {
+    $build['actions_admin_manage_form'] = drupal_get_form('actions_admin_manage_form', $options);
+  }
+
+  return $build;
+}
+
+/**
+ * Define the form for the actions overview page.
+ *
+ * @param $form_state
+ *   An associative array containing the current state of the form; not used.
+ * @param $options
+ *   An array of configurable actions.
+ * @return
+ *   Form definition.
+ *
+ * @ingroup forms
+ * @see actions_admin_manage_form_submit()
+ */
+function actions_admin_manage_form($form, &$form_state, $options = array()) {
+  $form['parent'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Create an advanced action'),
+    '#attributes' => array('class' => array('container-inline')),
+  );
+  $form['parent']['action'] = array(
+    '#type' => 'select',
+    '#title' => t('Action'),
+    '#title_display' => 'invisible',
+    '#options' => $options,
+    '#empty_option' => t('Choose an advanced action'),
+  );
+  $form['parent']['actions'] = array('#type' => 'actions');
+  $form['parent']['actions']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Create'),
+  );
+  return $form;
+}
+
+/**
+ * Process actions_admin_manage form submissions.
+ *
+ * @see actions_admin_manage_form()
+ */
+function actions_admin_manage_form_submit($form, &$form_state) {
+  if ($form_state['values']['action']) {
+    $form_state['redirect'] = 'admin/config/system/actions/configure/' . $form_state['values']['action'];
+  }
+}
+
+/**
+ * Menu callback; Creates the form for configuration of a single action.
+ *
+ * We provide the "Description" field. The rest of the form is provided by the
+ * action. We then provide the Save button. Because we are combining unknown
+ * form elements with the action configuration form, we use an 'actions_' prefix
+ * on our elements.
+ *
+ * @param $action
+ *   Hash of an action ID or an integer. If it is a hash, we are
+ *   creating a new instance. If it is an integer, we are editing an existing
+ *   instance.
+ * @return
+ *   A form definition.
+ *
+ * @see actions_admin_configure_validate()
+ * @see actions_admin_configure_submit()
+ */
+function actions_admin_configure($form, &$form_state, $action = NULL) {
+  if ($action === NULL) {
+    drupal_goto('admin/config/system/actions');
+  }
+
+  $actions_map = actions_actions_map(actions_list());
+  $edit = array();
+
+  // Numeric action denotes saved instance of a configurable action.
+  if (is_numeric($action)) {
+    $aid = $action;
+    // Load stored parameter values from database.
+    $data = db_query("SELECT * FROM {actions} WHERE aid = :aid", array(':aid' => $aid))->fetch();
+    $edit['actions_label'] = $data->label;
+    $edit['actions_type'] = $data->type;
+    $function = $data->callback;
+    $action = drupal_hash_base64($data->callback);
+    $params = unserialize($data->parameters);
+    if ($params) {
+      foreach ($params as $name => $val) {
+        $edit[$name] = $val;
+      }
+    }
+  }
+  // Otherwise, we are creating a new action instance.
+  else {
+    $function = $actions_map[$action]['callback'];
+    $edit['actions_label'] = $actions_map[$action]['label'];
+    $edit['actions_type'] = $actions_map[$action]['type'];
+  }
+
+  $form['actions_label'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Label'),
+    '#default_value' => $edit['actions_label'],
+    '#maxlength' => '255',
+    '#description' => t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
+    '#weight' => -10
+  );
+  $action_form = $function . '_form';
+  $form = array_merge($form, $action_form($edit));
+  $form['actions_type'] = array(
+    '#type' => 'value',
+    '#value' => $edit['actions_type'],
+  );
+  $form['actions_action'] = array(
+    '#type' => 'hidden',
+    '#value' => $action,
+  );
+  // $aid is set when configuring an existing action instance.
+  if (isset($aid)) {
+    $form['actions_aid'] = array(
+      '#type' => 'hidden',
+      '#value' => $aid,
+    );
+  }
+  $form['actions_configured'] = array(
+    '#type' => 'hidden',
+    '#value' => '1',
+  );
+  $form['actions'] = array('#type' => 'actions');
+  $form['actions']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+    '#weight' => 13
+  );
+
+  return $form;
+}
+
+/**
+ * Validate actions_admin_configure() form submissions.
+ */
+function actions_admin_configure_validate($form, &$form_state) {
+  $function = actions_function_lookup($form_state['values']['actions_action']) . '_validate';
+  // Hand off validation to the action.
+  if (function_exists($function)) {
+    $function($form, $form_state);
+  }
+}
+
+/**
+ * Process actions_admin_configure() form submissions.
+ */
+function actions_admin_configure_submit($form, &$form_state) {
+  $function = actions_function_lookup($form_state['values']['actions_action']);
+  $submit_function = $function . '_submit';
+
+  // Action will return keyed array of values to store.
+  $params = $submit_function($form, $form_state);
+  $aid = isset($form_state['values']['actions_aid']) ? $form_state['values']['actions_aid'] : NULL;
+
+  actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_label'], $aid);
+  drupal_set_message(t('The action has been successfully saved.'));
+
+  $form_state['redirect'] = 'admin/config/system/actions/manage';
+}
+
+/**
+ * Create the form for confirmation of deleting an action.
+ *
+ * @see actions_admin_delete_form_submit()
+ * @ingroup forms
+ */
+function actions_admin_delete_form($form, &$form_state, $action) {
+  $form['aid'] = array(
+    '#type' => 'hidden',
+    '#value' => $action->aid,
+  );
+  return confirm_form($form,
+    t('Are you sure you want to delete the action %action?', array('%action' => $action->label)),
+    'admin/config/system/actions/manage',
+    t('This cannot be undone.'),
+    t('Delete'),
+    t('Cancel')
+  );
+}
+
+/**
+ * Process actions_admin_delete form submissions.
+ *
+ * Post-deletion operations for action deletion.
+ */
+function actions_admin_delete_form_submit($form, &$form_state) {
+  $aid = $form_state['values']['aid'];
+  $action = actions_load($aid);
+  actions_delete($aid);
+  watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->label));
+  drupal_set_message(t('Action %action was deleted', array('%action' => $action->label)));
+  $form_state['redirect'] = 'admin/config/system/actions/manage';
+}
+
+/**
+ * Post-deletion operations for deleting action orphans.
+ *
+ * @param $orphaned
+ *   An array of orphaned actions.
+ */
+function actions_admin_delete_orphans_post($orphaned) {
+  foreach ($orphaned as $callback) {
+    drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
+  }
+}
+
+/**
+ * Remove actions that are in the database but not supported by any enabled module.
+ */
+function actions_admin_remove_orphans() {
+  actions_synchronize(TRUE);
+  drupal_goto('admin/config/system/actions/manage');
+}
diff --git a/core/modules/actions/actions.api.php b/core/modules/actions/actions.api.php
new file mode 100644
index 0000000..ed7aa15
--- /dev/null
+++ b/core/modules/actions/actions.api.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ * @file
+ * Hooks provided by the Actions module.
+ */
+
+/**
+ * Declares information about actions.
+ *
+ * Any module can define actions, and then call actions_do() to make those
+ * actions happen in response to events.
+ *
+ * An action consists of two or three parts:
+ * - an action definition (returned by this hook)
+ * - a function which performs the action (which by convention is named
+ *   MODULE_description-of-function_action)
+ * - an optional form definition function that defines a configuration form
+ *   (which has the name of the action function with '_form' appended to it.)
+ *
+ * The action function takes two to four arguments, which come from the input
+ * arguments to actions_do().
+ *
+ * @return
+ *   An associative array of action descriptions. The keys of the array
+ *   are the names of the action functions, and each corresponding value
+ *   is an associative array with the following key-value pairs:
+ *   - 'type': The type of object this action acts upon. Core actions have types
+ *     'node', 'user', 'comment', and 'system'.
+ *   - 'label': The human-readable name of the action, which should be passed
+ *     through the t() function for translation.
+ *   - 'configurable': If FALSE, then the action doesn't require any extra
+ *     configuration. If TRUE, then your module must define a form function with
+ *     the same name as the action function with '_form' appended (e.g., the
+ *     form for 'node_assign_owner_action' is 'node_assign_owner_action_form'.)
+ *     This function takes $context as its only parameter, and is paired with
+ *     the usual _submit function, and possibly a _validate function.
+ *   - 'triggers': An array of the events (that is, hooks) that can trigger this
+ *     action. For example: array('node_insert', 'user_update'). You can also
+ *     declare support for any trigger by returning array('any') for this value.
+ *   - 'behavior': (optional) A machine-readable array of behaviors of this
+ *     action, used to signal additionally required actions that may need to be
+ *     triggered. Modules that are processing actions should take special care
+ *     for the "presave" hook, in which case a dependent "save" action should
+ *     NOT be invoked.
+ *
+ * @ingroup actions
+ */
+function hook_action_info() {
+  return array(
+    'comment_unpublish_action' => array(
+      'type' => 'comment',
+      'label' => t('Unpublish comment'),
+      'configurable' => FALSE,
+      'behavior' => array('changes_property'),
+      'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
+    ),
+    'comment_unpublish_by_keyword_action' => array(
+      'type' => 'comment',
+      'label' => t('Unpublish comment containing keyword(s)'),
+      'configurable' => TRUE,
+      'behavior' => array('changes_property'),
+      'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
+    ),
+    'comment_save_action' => array(
+      'type' => 'comment',
+      'label' => t('Save comment'),
+      'configurable' => FALSE,
+      'triggers' => array('comment_insert', 'comment_update'),
+    ),
+  );
+}
+
+/**
+ * Executes code after an action is deleted.
+ *
+ * @param $aid
+ *   The action ID.
+ *
+ * @ingroup actions
+ */
+function hook_actions_delete($aid) {
+  db_delete('actions_assignments')
+    ->condition('aid', $aid)
+    ->execute();
+}
+
+/**
+ * Alters the actions declared by another module.
+ *
+ * Called by actions_list() to allow modules to alter the return values from
+ * implementations of hook_action_info().
+ *
+ * @ingroup actions
+ */
+function hook_action_info_alter(&$actions) {
+  $actions['node_unpublish_action']['label'] = t('Unpublish and remove from public view.');
+}
diff --git a/core/modules/actions/actions.info b/core/modules/actions/actions.info
new file mode 100644
index 0000000..ddddd63
--- /dev/null
+++ b/core/modules/actions/actions.info
@@ -0,0 +1,6 @@
+name = Actions
+description = Perform tasks on specific events triggered within the system.
+package = Core
+version = VERSION
+core = 8.x
+configure = admin/config/system/actions
diff --git a/core/modules/actions/actions.install b/core/modules/actions/actions.install
new file mode 100644
index 0000000..568e673
--- /dev/null
+++ b/core/modules/actions/actions.install
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the actions module.
+ */
+
+/**
+ * Implements hook_schema().
+ */
+function actions_schema() {
+  $schema['actions'] = array(
+    'description' => 'Stores action information.',
+    'fields' => array(
+      'aid' => array(
+        'description' => 'Primary Key: Unique actions ID.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '0',
+      ),
+      'type' => array(
+        'description' => 'The object that that action acts on (node, user, comment, system or custom types.)',
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'callback' => array(
+        'description' => 'The callback function that executes when the action runs.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'parameters' => array(
+        'description' => 'Parameters to be passed to the callback function.',
+        'type' => 'blob',
+        'not null' => TRUE,
+        'size' => 'big',
+      ),
+      'label' => array(
+        'description' => 'Label of the action.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '0',
+      ),
+    ),
+    'primary key' => array('aid'),
+  );
+  return $schema;
+}
diff --git a/core/includes/actions.inc b/core/modules/actions/actions.module
similarity index 53%
rename from core/includes/actions.inc
rename to core/modules/actions/actions.module
index 75cda42..621429b 100644
--- a/core/includes/actions.inc
+++ b/core/modules/actions/actions.module
@@ -2,26 +2,336 @@
 
 /**
  * @file
- * This is the actions engine for executing stored actions.
+ * This is the actions module for executing stored actions.
  */
 
 /**
- * @defgroup actions Actions
- * @{
- * Functions that perform an action on a certain system object.
+ * Implements hook_help().
+ */
+function actions_help($path, $arg) {
+  switch ($path) {
+    case 'admin/help#actions':
+      $output = '<p>' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Other modules 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. Visit the <a href="@actions">Actions page</a> to configure actions.', array('@actions' => url('admin/config/system/actions'))) . '</p>';
+      return $output;
+    case 'admin/config/system/actions':
+    case 'admin/config/system/actions/manage':
+      $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 need to be created and configured before they can be used because they have options that need to be specified; for example, sending an e-mail to a specified address or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
+      return $output;
+    case 'admin/config/system/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.');
+  }
+}
+
+/**
+ * Implements hook_permission().
+ */
+function actions_permission() {
+  return array(
+    'administer actions' => array(
+      'title' => t('Administer actions'),
+    ),
+  );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function actions_menu() {
+  $items['admin/config/system/actions'] = array(
+    'title' => 'Actions',
+    'description' => 'Manage the actions defined for your site.',
+    'access arguments' => array('administer actions'),
+    'page callback' => 'actions_admin_manage',
+    'file' => 'actions.admin.inc',
+  );
+  $items['admin/config/system/actions/manage'] = array(
+    'title' => 'Manage actions',
+    'description' => 'Manage the actions defined for your site.',
+    'page callback' => 'actions_admin_manage',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -2,
+    'file' => 'actions.admin.inc',
+  );
+  $items['admin/config/system/actions/configure'] = array(
+    'title' => 'Configure an advanced action',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('actions_admin_configure'),
+    'access arguments' => array('administer actions'),
+    'type' => MENU_VISIBLE_IN_BREADCRUMB,
+    'file' => 'actions.admin.inc',
+  );
+  $items['admin/config/system/actions/delete/%actions'] = array(
+    'title' => 'Delete action',
+    'description' => 'Delete an action.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('actions_admin_delete_form', 5),
+    'access arguments' => array('administer actions'),
+    'file' => 'actions.admin.inc',
+  );
+  $items['admin/config/system/actions/orphan'] = array(
+    'title' => 'Remove orphans',
+    'page callback' => 'actions_admin_remove_orphans',
+    'access arguments' => array('administer actions'),
+    'type' => MENU_CALLBACK,
+    'file' => 'actions.admin.inc',
+  );
+  return $items;
+}
+
+/**
+ * Implements hook_rebuild().
+ */
+function actions_rebuild() {
+  // Synchronize any actions that were added or removed.
+  actions_synchronize();
+}
+
+/**
+ * Implements hook_action_info().
+ *
+ * @ingroup actions
+ */
+function actions_action_info() {
+  return array(
+    'actions_message_action' => array(
+      'type' => 'system',
+      'label' => t('Display a message to the user'),
+      'configurable' => TRUE,
+      'triggers' => array('any'),
+    ),
+    'actions_send_email_action' => array(
+      'type' => 'system',
+      'label' => t('Send e-mail'),
+      'configurable' => TRUE,
+      'triggers' => array('any'),
+    ),
+    'actions_block_ip_action' => array(
+      'type' => 'user',
+      'label' => t('Ban IP address of current user'),
+      'configurable' => FALSE,
+      'triggers' => array('any'),
+    ),
+    'actions_goto_action' => array(
+      'type' => 'system',
+      'label' => t('Redirect to URL'),
+      'configurable' => TRUE,
+      'triggers' => array('any'),
+    ),
+  );
+}
+
+/**
+ * Return a form definition so the Send email action can be configured.
+ *
+ * @param $context
+ *   Default values (if we are editing an existing action instance).
+ *
+ * @return
+ *   Form definition.
+ *
+ * @see system_send_email_action_validate()
+ * @see system_send_email_action_submit()
+ *
+ * @ingroup actions
+ */
+function actions_send_email_action_form($context) {
+  // Set default values for form.
+  if (!isset($context['recipient'])) {
+    $context['recipient'] = '';
+  }
+  if (!isset($context['subject'])) {
+    $context['subject'] = '';
+  }
+  if (!isset($context['message'])) {
+    $context['message'] = '';
+  }
+
+  $form['recipient'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Recipient'),
+    '#default_value' => $context['recipient'],
+    '#maxlength' => '254',
+    '#description' => t('The e-mail address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'),
+  );
+  $form['subject'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Subject'),
+    '#default_value' => $context['subject'],
+    '#maxlength' => '254',
+    '#description' => t('The subject of the message.'),
+  );
+  $form['message'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Message'),
+    '#default_value' => $context['message'],
+    '#cols' => '80',
+    '#rows' => '20',
+    '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
+  );
+  return $form;
+}
+
+/**
+ * Validate system_send_email_action form submissions.
+ */
+function actions_send_email_action_validate($form, $form_state) {
+  $form_values = $form_state['values'];
+  // Validate the configuration form.
+  if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) {
+    // We want the literal %author placeholder to be emphasized in the error message.
+    form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]')));
+  }
+}
+
+/**
+ * Process system_send_email_action form submissions.
+ */
+function actions_send_email_action_submit($form, $form_state) {
+  $form_values = $form_state['values'];
+  // Process the HTML form to store configuration. The keyed array that
+  // we return will be serialized to the database.
+  $params = array(
+    'recipient' => $form_values['recipient'],
+    'subject'   => $form_values['subject'],
+    'message'   => $form_values['message'],
+  );
+  return $params;
+}
+
+/**
+ * Sends an e-mail message.
+ *
+ * @param object $entity
+ *   An optional node entity, which will be added as $context['node'] if
+ *   provided.
+ * @param array $context
+ *   Array with the following elements:
+ *   - 'recipient': E-mail message recipient. This will be passed through
+ *     token_replace().
+ *   - 'subject': The subject of the message. This will be passed through
+ *     token_replace().
+ *   - 'message': The message to send. This will be passed through
+ *     token_replace().
+ *   - Other elements will be used as the data for token replacement.
+ *
+ * @ingroup actions
+ */
+function actions_send_email_action($entity, $context) {
+  if (empty($context['node'])) {
+    $context['node'] = $entity;
+  }
+
+  $recipient = token_replace($context['recipient'], $context);
+
+  // If the recipient is a registered user with a language preference, use
+  // the recipient's preferred language. Otherwise, use the system default
+  // language.
+  $recipient_account = user_load_by_mail($recipient);
+  if ($recipient_account) {
+    $language = user_preferred_language($recipient_account);
+  }
+  else {
+    $language = language_default();
+  }
+  $params = array('context' => $context);
+
+  if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
+    watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
+  }
+  else {
+    watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
+  }
+}
+
+function actions_message_action_form($context) {
+  $form['message'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Message'),
+    '#default_value' => isset($context['message']) ? $context['message'] : '',
+    '#required' => TRUE,
+    '#rows' => '8',
+    '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
+  );
+  return $form;
+}
+
+function actions_message_action_submit($form, $form_state) {
+  return array('message' => $form_state['values']['message']);
+}
+
+/**
+ * Sends a message to the current user's screen.
+ *
+ * @param object $entity
+ *   An optional node entity, which will be added as $context['node'] if
+ *   provided.
+ * @param array $context
+ *   Array with the following elements:
+ *   - 'message': The message to send. This will be passed through
+ *     token_replace().
+ *   - Other elements will be used as the data for token replacement in
+ *     the message.
  *
- * Action functions are declared by modules by implementing hook_action_info().
- * Modules can cause action functions to run by calling actions_do().
+ * @ingroup actions
+ */
+function actions_message_action(&$entity, $context = array()) {
+  if (empty($context['node'])) {
+    $context['node'] = $entity;
+  }
+
+  $context['message'] = token_replace(filter_xss_admin($context['message']), $context);
+  drupal_set_message($context['message']);
+}
+
+/**
+ * Settings form for system_goto_action().
+ */
+function actions_goto_action_form($context) {
+  $form['url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('URL'),
+    '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like @url.', array('@url' => 'http://drupal.org')),
+    '#default_value' => isset($context['url']) ? $context['url'] : '',
+    '#required' => TRUE,
+  );
+  return $form;
+}
+
+function actions_goto_action_submit($form, $form_state) {
+  return array(
+    'url' => $form_state['values']['url']
+  );
+}
+
+/**
+ * Redirects to a different URL.
  *
- * Each action function takes two to four arguments:
- * - $entity: The object that the action acts on, such as a node, comment, or
- *   user.
- * - $context: Array of additional information about what triggered the action.
- * - $a1, $a2: Optional additional information, which can be passed into
- *   actions_do() and will be passed along to the action function.
+ * @param $entity
+ *   Ignored.
+ * @param array $context
+ *   Array with the following elements:
+ *   - 'url': URL to redirect to. This will be passed through
+ *     token_replace().
+ *   - Other elements will be used as the data for token replacement.
  *
- * @} End of "defgroup actions".
+ * @ingroup actions
  */
+function actions_goto_action($entity, $context) {
+  drupal_goto(token_replace($context['url'], $context));
+}
+
+/**
+ * Blocks the current user's IP address.
+ *
+ * @ingroup actions
+ */
+function actions_block_ip_action() {
+  $ip = ip_address();
+  db_insert('blocked_ips')
+    ->fields(array('ip' => $ip))
+    ->execute();
+  watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
+}
 
 /**
  * Performs a given list of actions by executing their callback functions.
@@ -384,4 +694,3 @@ function actions_delete($aid) {
     ->execute();
   module_invoke_all('actions_delete', $aid);
 }
-
diff --git a/core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php b/core/modules/actions/lib/Drupal/actions/Tests/ConfigurationTest.php
similarity index 92%
rename from core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php
rename to core/modules/actions/lib/Drupal/actions/Tests/ConfigurationTest.php
index 1a31fb4..a380a71 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php
+++ b/core/modules/actions/lib/Drupal/actions/Tests/ConfigurationTest.php
@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Definition of Drupal\system\Tests\Actions\ConfigurationTest.
+ * Definition of Drupal\actions\Tests\ConfigurationTest.
  */
 
-namespace Drupal\system\Tests\Actions;
+namespace Drupal\actions\Tests;
 
 use Drupal\simpletest\WebTestBase;
 
@@ -21,6 +21,10 @@ class ConfigurationTest extends WebTestBase {
     );
   }
 
+  function setUp() {
+    parent::setUp('actions');
+  }
+
   /**
    * Test the configuration of advanced actions through the administration
    * interface.
@@ -32,7 +36,7 @@ class ConfigurationTest extends WebTestBase {
 
     // Make a POST request to admin/config/system/actions/manage.
     $edit = array();
-    $edit['action'] = drupal_hash_base64('system_goto_action');
+    $edit['action'] = drupal_hash_base64('actions_goto_action');
     $this->drupalPost('admin/config/system/actions/manage', $edit, t('Create'));
 
     // Make a POST request to the individual action configuration page.
@@ -40,7 +44,7 @@ class ConfigurationTest extends WebTestBase {
     $action_label = $this->randomName();
     $edit['actions_label'] = $action_label;
     $edit['url'] = 'admin';
-    $this->drupalPost('admin/config/system/actions/configure/' . drupal_hash_base64('system_goto_action'), $edit, t('Save'));
+    $this->drupalPost('admin/config/system/actions/configure/' . drupal_hash_base64('actions_goto_action'), $edit, t('Save'));
 
     // Make sure that the new complex action was saved properly.
     $this->assertText(t('The action has been successfully saved.'), t("Make sure we get a confirmation that we've successfully saved the complex action."));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Actions/LoopTest.php b/core/modules/actions/lib/Drupal/actions/Tests/LoopTest.php
similarity index 94%
rename from core/modules/system/lib/Drupal/system/Tests/Actions/LoopTest.php
rename to core/modules/actions/lib/Drupal/actions/Tests/LoopTest.php
index 97667c0..89a4b15 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Actions/LoopTest.php
+++ b/core/modules/actions/lib/Drupal/actions/Tests/LoopTest.php
@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Definition of Drupal\system\Tests\Actions\LoopTest.
+ * Definition of Drupal\actions\Tests\LoopTest.
  */
 
-namespace Drupal\system\Tests\Actions;
+namespace Drupal\actions\Tests;
 
 use Drupal\simpletest\WebTestBase;
 
@@ -24,7 +24,7 @@ class LoopTest extends WebTestBase {
   }
 
   function setUp() {
-    parent::setUp('dblog', 'actions_loop_test');
+    parent::setUp('dblog', 'actions', 'actions_loop_test');
   }
 
   /**
diff --git a/core/modules/system/tests/modules/actions_loop_test/actions_loop_test.info b/core/modules/actions/tests/actions_loop_test/actions_loop_test.info
similarity index 84%
rename from core/modules/system/tests/modules/actions_loop_test/actions_loop_test.info
rename to core/modules/actions/tests/actions_loop_test/actions_loop_test.info
index 3507511..670d2f8 100644
--- a/core/modules/system/tests/modules/actions_loop_test/actions_loop_test.info
+++ b/core/modules/actions/tests/actions_loop_test/actions_loop_test.info
@@ -4,3 +4,4 @@ package = Testing
 version = VERSION
 core = 8.x
 hidden = TRUE
+dependencies[] = actions
diff --git a/core/modules/system/tests/modules/actions_loop_test/actions_loop_test.install b/core/modules/actions/tests/actions_loop_test/actions_loop_test.install
similarity index 100%
rename from core/modules/system/tests/modules/actions_loop_test/actions_loop_test.install
rename to core/modules/actions/tests/actions_loop_test/actions_loop_test.install
diff --git a/core/modules/system/tests/modules/actions_loop_test/actions_loop_test.module b/core/modules/actions/tests/actions_loop_test/actions_loop_test.module
similarity index 100%
rename from core/modules/system/tests/modules/actions_loop_test/actions_loop_test.module
rename to core/modules/actions/tests/actions_loop_test/actions_loop_test.module
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 819df67..9962a4d 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -2890,281 +2890,6 @@ function system_add_date_formats_form_submit($form, &$form_state) {
 }
 
 /**
- * Menu callback; Displays an overview of available and configured actions.
- */
-function system_actions_manage() {
-  actions_synchronize();
-  $actions = actions_list();
-  $actions_map = actions_actions_map($actions);
-  $options = array();
-  $unconfigurable = array();
-
-  foreach ($actions_map as $key => $array) {
-    if ($array['configurable']) {
-      $options[$key] = $array['label'] . '...';
-    }
-    else {
-      $unconfigurable[] = $array;
-    }
-  }
-
-  $row = array();
-  $instances_present = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchField();
-  $header = array(
-    array('data' => t('Action type'), 'field' => 'type'),
-    array('data' => t('Label'), 'field' => 'label'),
-    array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
-  );
-  $query = db_select('actions')
-    ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
-    ->extend('Drupal\Core\Database\Query\TableSortExtender');
-  $result = $query
-    ->fields('actions')
-    ->limit(50)
-    ->orderByHeader($header)
-    ->execute();
-
-  foreach ($result as $action) {
-    $row[] = array(
-      array('data' => $action->type),
-      array('data' => check_plain($action->label)),
-      array('data' => $action->parameters ? l(t('configure'), "admin/config/system/actions/configure/$action->aid") : ''),
-      array('data' => $action->parameters ? l(t('delete'), "admin/config/system/actions/delete/$action->aid") : '')
-    );
-  }
-
-  if ($row) {
-    $pager = theme('pager');
-    if (!empty($pager)) {
-      $row[] = array(array('data' => $pager, 'colspan' => '3'));
-    }
-    $build['system_actions_header'] = array('#markup' => '<h3>' . t('Available actions:') . '</h3>');
-    $build['system_actions_table'] = array('#markup' => theme('table', array('header' => $header, 'rows' => $row)));
-  }
-
-  if ($actions_map) {
-    $build['system_actions_manage_form'] = drupal_get_form('system_actions_manage_form', $options);
-  }
-
-  return $build;
-}
-
-/**
- * Define the form for the actions overview page.
- *
- * @param $form_state
- *   An associative array containing the current state of the form; not used.
- * @param $options
- *   An array of configurable actions.
- * @return
- *   Form definition.
- *
- * @ingroup forms
- * @see system_actions_manage_form_submit()
- */
-function system_actions_manage_form($form, &$form_state, $options = array()) {
-  $form['parent'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Create an advanced action'),
-    '#attributes' => array('class' => array('container-inline')),
-  );
-  $form['parent']['action'] = array(
-    '#type' => 'select',
-    '#title' => t('Action'),
-    '#title_display' => 'invisible',
-    '#options' => $options,
-    '#empty_option' => t('Choose an advanced action'),
-  );
-  $form['parent']['actions'] = array('#type' => 'actions');
-  $form['parent']['actions']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Create'),
-  );
-  return $form;
-}
-
-/**
- * Process system_actions_manage form submissions.
- *
- * @see system_actions_manage_form()
- */
-function system_actions_manage_form_submit($form, &$form_state) {
-  if ($form_state['values']['action']) {
-    $form_state['redirect'] = 'admin/config/system/actions/configure/' . $form_state['values']['action'];
-  }
-}
-
-/**
- * Menu callback; Creates the form for configuration of a single action.
- *
- * We provide the "Description" field. The rest of the form is provided by the
- * action. We then provide the Save button. Because we are combining unknown
- * form elements with the action configuration form, we use an 'actions_' prefix
- * on our elements.
- *
- * @param $action
- *   Hash of an action ID or an integer. If it is a hash, we are
- *   creating a new instance. If it is an integer, we are editing an existing
- *   instance.
- * @return
- *   A form definition.
- *
- * @see system_actions_configure_validate()
- * @see system_actions_configure_submit()
- */
-function system_actions_configure($form, &$form_state, $action = NULL) {
-  if ($action === NULL) {
-    drupal_goto('admin/config/system/actions');
-  }
-
-  $actions_map = actions_actions_map(actions_list());
-  $edit = array();
-
-  // Numeric action denotes saved instance of a configurable action.
-  if (is_numeric($action)) {
-    $aid = $action;
-    // Load stored parameter values from database.
-    $data = db_query("SELECT * FROM {actions} WHERE aid = :aid", array(':aid' => $aid))->fetch();
-    $edit['actions_label'] = $data->label;
-    $edit['actions_type'] = $data->type;
-    $function = $data->callback;
-    $action = drupal_hash_base64($data->callback);
-    $params = unserialize($data->parameters);
-    if ($params) {
-      foreach ($params as $name => $val) {
-        $edit[$name] = $val;
-      }
-    }
-  }
-  // Otherwise, we are creating a new action instance.
-  else {
-    $function = $actions_map[$action]['callback'];
-    $edit['actions_label'] = $actions_map[$action]['label'];
-    $edit['actions_type'] = $actions_map[$action]['type'];
-  }
-
-  $form['actions_label'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Label'),
-    '#default_value' => $edit['actions_label'],
-    '#maxlength' => '255',
-    '#description' => t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
-    '#weight' => -10
-  );
-  $action_form = $function . '_form';
-  $form = array_merge($form, $action_form($edit));
-  $form['actions_type'] = array(
-    '#type' => 'value',
-    '#value' => $edit['actions_type'],
-  );
-  $form['actions_action'] = array(
-    '#type' => 'hidden',
-    '#value' => $action,
-  );
-  // $aid is set when configuring an existing action instance.
-  if (isset($aid)) {
-    $form['actions_aid'] = array(
-      '#type' => 'hidden',
-      '#value' => $aid,
-    );
-  }
-  $form['actions_configured'] = array(
-    '#type' => 'hidden',
-    '#value' => '1',
-  );
-  $form['actions'] = array('#type' => 'actions');
-  $form['actions']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save'),
-    '#weight' => 13
-  );
-
-  return $form;
-}
-
-/**
- * Validate system_actions_configure() form submissions.
- */
-function system_actions_configure_validate($form, &$form_state) {
-  $function = actions_function_lookup($form_state['values']['actions_action']) . '_validate';
-  // Hand off validation to the action.
-  if (function_exists($function)) {
-    $function($form, $form_state);
-  }
-}
-
-/**
- * Process system_actions_configure() form submissions.
- */
-function system_actions_configure_submit($form, &$form_state) {
-  $function = actions_function_lookup($form_state['values']['actions_action']);
-  $submit_function = $function . '_submit';
-
-  // Action will return keyed array of values to store.
-  $params = $submit_function($form, $form_state);
-  $aid = isset($form_state['values']['actions_aid']) ? $form_state['values']['actions_aid'] : NULL;
-
-  actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_label'], $aid);
-  drupal_set_message(t('The action has been successfully saved.'));
-
-  $form_state['redirect'] = 'admin/config/system/actions/manage';
-}
-
-/**
- * Create the form for confirmation of deleting an action.
- *
- * @see system_actions_delete_form_submit()
- * @ingroup forms
- */
-function system_actions_delete_form($form, &$form_state, $action) {
-  $form['aid'] = array(
-    '#type' => 'hidden',
-    '#value' => $action->aid,
-  );
-  return confirm_form($form,
-    t('Are you sure you want to delete the action %action?', array('%action' => $action->label)),
-    'admin/config/system/actions/manage',
-    t('This cannot be undone.'),
-    t('Delete'),
-    t('Cancel')
-  );
-}
-
-/**
- * Process system_actions_delete form submissions.
- *
- * Post-deletion operations for action deletion.
- */
-function system_actions_delete_form_submit($form, &$form_state) {
-  $aid = $form_state['values']['aid'];
-  $action = actions_load($aid);
-  actions_delete($aid);
-  watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->label));
-  drupal_set_message(t('Action %action was deleted', array('%action' => $action->label)));
-  $form_state['redirect'] = 'admin/config/system/actions/manage';
-}
-
-/**
- * Post-deletion operations for deleting action orphans.
- *
- * @param $orphaned
- *   An array of orphaned actions.
- */
-function system_action_delete_orphans_post($orphaned) {
-  foreach ($orphaned as $callback) {
-    drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
-  }
-}
-
-/**
- * Remove actions that are in the database but not supported by any enabled module.
- */
-function system_actions_remove_orphans() {
-  actions_synchronize(TRUE);
-  drupal_goto('admin/config/system/actions/manage');
-}
-
-/**
  * Display edit date format links for each language.
  */
 function system_date_format_language_overview_page() {
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index d6fb89e..efb0cce 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -3375,94 +3375,6 @@ function hook_file_mimetype_mapping_alter(&$mapping) {
 }
 
 /**
- * Declares information about actions.
- *
- * Any module can define actions, and then call actions_do() to make those
- * actions happen in response to events.
- *
- * An action consists of two or three parts:
- * - an action definition (returned by this hook)
- * - a function which performs the action (which by convention is named
- *   MODULE_description-of-function_action)
- * - an optional form definition function that defines a configuration form
- *   (which has the name of the action function with '_form' appended to it.)
- *
- * The action function takes two to four arguments, which come from the input
- * arguments to actions_do().
- *
- * @return
- *   An associative array of action descriptions. The keys of the array
- *   are the names of the action functions, and each corresponding value
- *   is an associative array with the following key-value pairs:
- *   - 'type': The type of object this action acts upon. Core actions have types
- *     'node', 'user', 'comment', and 'system'.
- *   - 'label': The human-readable name of the action, which should be passed
- *     through the t() function for translation.
- *   - 'configurable': If FALSE, then the action doesn't require any extra
- *     configuration. If TRUE, then your module must define a form function with
- *     the same name as the action function with '_form' appended (e.g., the
- *     form for 'node_assign_owner_action' is 'node_assign_owner_action_form'.)
- *     This function takes $context as its only parameter, and is paired with
- *     the usual _submit function, and possibly a _validate function.
- *   - 'triggers': An array of the events (that is, hooks) that can trigger this
- *     action. For example: array('node_insert', 'user_update'). You can also
- *     declare support for any trigger by returning array('any') for this value.
- *   - 'behavior': (optional) A machine-readable array of behaviors of this
- *     action, used to signal additionally required actions that may need to be
- *     triggered. Modules that are processing actions should take special care
- *     for the "presave" hook, in which case a dependent "save" action should
- *     NOT be invoked.
- *
- * @ingroup actions
- */
-function hook_action_info() {
-  return array(
-    'comment_unpublish_action' => array(
-      'type' => 'comment',
-      'label' => t('Unpublish comment'),
-      'configurable' => FALSE,
-      'behavior' => array('changes_property'),
-      'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
-    ),
-    'comment_unpublish_by_keyword_action' => array(
-      'type' => 'comment',
-      'label' => t('Unpublish comment containing keyword(s)'),
-      'configurable' => TRUE,
-      'behavior' => array('changes_property'),
-      'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
-    ),
-    'comment_save_action' => array(
-      'type' => 'comment',
-      'label' => t('Save comment'),
-      'configurable' => FALSE,
-      'triggers' => array('comment_insert', 'comment_update'),
-    ),
-  );
-}
-
-/**
- * Executes code after an action is deleted.
- *
- * @param $aid
- *   The action ID.
- */
-function hook_actions_delete($aid) {
-  db_delete('actions_assignments')
-    ->condition('aid', $aid)
-    ->execute();
-}
-
-/**
- * Alters the actions declared by another module.
- *
- * Called by actions_list() to allow modules to alter the return values from
- * implementations of hook_action_info().
- */
-function hook_action_info_alter(&$actions) {
-  $actions['node_unpublish_action']['label'] = t('Unpublish and remove from public view.');
-}
-
-/**
  * Declare archivers to the system.
  *
  * An archiver is a class that is able to package and unpackage one or more files
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 9ba7c4c..dfddaff 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -563,47 +563,6 @@ function system_schema() {
     'primary key' => array('name'),
   );
 
-  $schema['actions'] = array(
-    'description' => 'Stores action information.',
-    'fields' => array(
-      'aid' => array(
-        'description' => 'Primary Key: Unique actions ID.',
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '0',
-      ),
-      'type' => array(
-        'description' => 'The object that that action acts on (node, user, comment, system or custom types.)',
-        'type' => 'varchar',
-        'length' => 32,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'callback' => array(
-        'description' => 'The callback function that executes when the action runs.',
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'parameters' => array(
-        'description' => 'Parameters to be passed to the callback function.',
-        'type' => 'blob',
-        'not null' => TRUE,
-        'size' => 'big',
-      ),
-      'label' => array(
-        'description' => 'Label of the action.',
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-        'default' => '0',
-      ),
-    ),
-    'primary key' => array('aid'),
-  );
-
   $schema['batch'] = array(
     'description' => 'Stores details about batches (processes that run in multiple HTTP requests).',
     'fields' => array(
@@ -1925,6 +1884,26 @@ function system_update_8010() {
 }
 
 /**
+ * Enable the Actions module without re-installing its database schema.
+ */
+function system_update_8011() {
+  // Reset the module data so that the actions module appears in the list.
+  drupal_static_reset('system_rebuild_module_data');
+  system_rebuild_module_data();
+
+  // Actions is now in the system table, so we can now enable the module without
+  // re-installing the schema.
+  db_update('system')
+    ->fields(array(
+      'status' => 1,
+      'schema_version' => 0,
+    ))
+    ->condition('type', 'module')
+    ->condition('name', 'actions')
+    ->execute();
+}
+
+/**
  * @} End of "defgroup updates-7.x-to-8.x".
  * The next series of updates should start at 9000.
  */
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index b9558e5..2d5c041 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -86,8 +86,6 @@ function system_help($path, $arg) {
       $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis. The System module manages this task by making use of a system cron job. You can verify the status of cron tasks by visiting the <a href="@status">Status report page</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>. You can set up cron job by visiting <a href="@cron">Cron configuration</a> page', array('@status' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron', '@cron' => url('admin/config/system/cron'))) . '</dd>';
       $output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
       $output .= '<dd>' . t('The System module also handles basic configuration options for your site, including <a href="@date-time-settings">Date and time settings</a>, <a href="@file-system">File system settings</a>, <a href="@site-info">Site name and other information</a>, and a <a href="@maintenance-mode">Maintenance mode</a> for taking your site temporarily offline.', array('@date-time-settings' => url('admin/config/regional/date-time'), '@file-system' => url('admin/config/media/file-system'), '@site-info' => url('admin/config/system/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</dd>';
-      $output .= '<dt>' . t('Configuring actions') . '</dt>';
-      $output .= '<dd>' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Other modules 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. Visit the <a href="@actions">Actions page</a> to configure actions.', array('@actions' => url('admin/config/system/actions'))) . '</dd>';
       $output .= '</dl>';
       return $output;
     case 'admin/index':
@@ -128,13 +126,6 @@ function system_help($path, $arg) {
         return '<p>' . t('Use maintenance mode when making major updates, particularly if the updates could disrupt visitors or the update process. Examples include upgrading, importing or exporting content, modifying a theme, modifying content types, and making backups.') . '</p>';
       }
       break;
-    case 'admin/config/system/actions':
-    case 'admin/config/system/actions/manage':
-      $output = '';
-      $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 need to be created and configured before they can be used because they have options that need to be specified; for example, sending an e-mail to a specified address or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
-      return $output;
-    case 'admin/config/system/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.');
     case 'admin/config/people/ip-blocking':
       return '<p>' . t('IP addresses listed here are blocked from your site. Blocked addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>';
     case 'admin/reports/status':
@@ -224,9 +215,6 @@ function system_permission() {
       'title' => t('Administer software updates'),
       'restrict access' => TRUE,
     ),
-    'administer actions' => array(
-      'title' => t('Administer actions'),
-    ),
     'access administration pages' => array(
       'title' => t('Use the administration pages and help'),
     ),
@@ -987,44 +975,6 @@ function system_menu() {
     'access arguments' => array('access administration pages'),
     'file' => 'system.admin.inc',
   );
-  $items['admin/config/system/actions'] = array(
-    'title' => 'Actions',
-    'description' => 'Manage the actions defined for your site.',
-    'access arguments' => array('administer actions'),
-    'page callback' => 'system_actions_manage',
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/system/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,
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/system/actions/configure'] = array(
-    'title' => 'Configure an advanced action',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_actions_configure'),
-    'access arguments' => array('administer actions'),
-    'type' => MENU_VISIBLE_IN_BREADCRUMB,
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/system/actions/delete/%actions'] = array(
-    'title' => 'Delete action',
-    'description' => 'Delete an action.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_actions_delete_form', 5),
-    'access arguments' => array('administer actions'),
-    'file' => 'system.admin.inc',
-  );
-  $items['admin/config/system/actions/orphan'] = array(
-    'title' => 'Remove orphans',
-    'page callback' => 'system_actions_remove_orphans',
-    'access arguments' => array('administer actions'),
-    'type' => MENU_CALLBACK,
-    'file' => 'system.admin.inc',
-  );
   $items['admin/config/system/site-information'] = array(
     'title' => 'Site information',
     'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.',
@@ -3257,161 +3207,6 @@ function system_cache_flush() {
 function system_rebuild() {
   // Rebuild list of date formats.
   system_date_formats_rebuild();
-  // Synchronize any actions that were added or removed.
-  actions_synchronize();
-}
-
-/**
- * Implements hook_action_info().
- */
-function system_action_info() {
-  return array(
-    'system_message_action' => array(
-      'type' => 'system',
-      'label' => t('Display a message to the user'),
-      'configurable' => TRUE,
-      'triggers' => array('any'),
-    ),
-    'system_send_email_action' => array(
-      'type' => 'system',
-      'label' => t('Send e-mail'),
-      'configurable' => TRUE,
-      'triggers' => array('any'),
-    ),
-    'system_block_ip_action' => array(
-      'type' => 'user',
-      'label' => t('Ban IP address of current user'),
-      'configurable' => FALSE,
-      'triggers' => array('any'),
-    ),
-    'system_goto_action' => array(
-      'type' => 'system',
-      'label' => t('Redirect to URL'),
-      'configurable' => TRUE,
-      'triggers' => array('any'),
-    ),
-  );
-}
-
-/**
- * Return a form definition so the Send email action can be configured.
- *
- * @param $context
- *   Default values (if we are editing an existing action instance).
- *
- * @return
- *   Form definition.
- *
- * @see system_send_email_action_validate()
- * @see system_send_email_action_submit()
- */
-function system_send_email_action_form($context) {
-  // Set default values for form.
-  if (!isset($context['recipient'])) {
-    $context['recipient'] = '';
-  }
-  if (!isset($context['subject'])) {
-    $context['subject'] = '';
-  }
-  if (!isset($context['message'])) {
-    $context['message'] = '';
-  }
-
-  $form['recipient'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Recipient'),
-    '#default_value' => $context['recipient'],
-    '#maxlength' => '254',
-    '#description' => t('The e-mail address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'),
-  );
-  $form['subject'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Subject'),
-    '#default_value' => $context['subject'],
-    '#maxlength' => '254',
-    '#description' => t('The subject of the message.'),
-  );
-  $form['message'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Message'),
-    '#default_value' => $context['message'],
-    '#cols' => '80',
-    '#rows' => '20',
-    '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
-  );
-  return $form;
-}
-
-/**
- * Validate system_send_email_action form submissions.
- */
-function system_send_email_action_validate($form, $form_state) {
-  $form_values = $form_state['values'];
-  // Validate the configuration form.
-  if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) {
-    // We want the literal %author placeholder to be emphasized in the error message.
-    form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]')));
-  }
-}
-
-/**
- * Process system_send_email_action form submissions.
- */
-function system_send_email_action_submit($form, $form_state) {
-  $form_values = $form_state['values'];
-  // Process the HTML form to store configuration. The keyed array that
-  // we return will be serialized to the database.
-  $params = array(
-    'recipient' => $form_values['recipient'],
-    'subject'   => $form_values['subject'],
-    'message'   => $form_values['message'],
-  );
-  return $params;
-}
-
-/**
- * Sends an e-mail message.
- *
- * @param object $entity
- *   An optional node entity, which will be added as $context['node'] if
- *   provided.
- * @param array $context
- *   Array with the following elements:
- *   - 'recipient': E-mail message recipient. This will be passed through
- *     token_replace().
- *   - 'subject': The subject of the message. This will be passed through
- *     token_replace().
- *   - 'message': The message to send. This will be passed through
- *     token_replace().
- *   - Other elements will be used as the data for token replacement.
- *
- * @ingroup actions
- */
-function system_send_email_action($entity, $context) {
-  if (empty($context['node'])) {
-    $context['node'] = $entity;
-  }
-
-  $recipient = token_replace($context['recipient'], $context);
-
-  // If the recipient is a registered user with a language preference, use
-  // the recipient's preferred language. Otherwise, use the system default
-  // language.
-  $recipient_account = user_load_by_mail($recipient);
-  if ($recipient_account) {
-    $language = user_preferred_language($recipient_account);
-  }
-  else {
-    $language = language_default();
-  }
-  $params = array('context' => $context);
-
-  if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
-    watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
-  }
-  else {
-    watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
-  }
 }
 
 /**
@@ -3427,96 +3222,6 @@ function system_mail($key, &$message, $params) {
   $message['body'][] = $body;
 }
 
-function system_message_action_form($context) {
-  $form['message'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Message'),
-    '#default_value' => isset($context['message']) ? $context['message'] : '',
-    '#required' => TRUE,
-    '#rows' => '8',
-    '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
-  );
-  return $form;
-}
-
-function system_message_action_submit($form, $form_state) {
-  return array('message' => $form_state['values']['message']);
-}
-
-/**
- * Sends a message to the current user's screen.
- *
- * @param object $entity
- *   An optional node entity, which will be added as $context['node'] if
- *   provided.
- * @param array $context
- *   Array with the following elements:
- *   - 'message': The message to send. This will be passed through
- *     token_replace().
- *   - Other elements will be used as the data for token replacement in
- *     the message.
- *
- * @ingroup actions
- */
-function system_message_action(&$entity, $context = array()) {
-  if (empty($context['node'])) {
-    $context['node'] = $entity;
-  }
-
-  $context['message'] = token_replace(filter_xss_admin($context['message']), $context);
-  drupal_set_message($context['message']);
-}
-
-/**
- * Settings form for system_goto_action().
- */
-function system_goto_action_form($context) {
-  $form['url'] = array(
-    '#type' => 'textfield',
-    '#title' => t('URL'),
-    '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like @url.', array('@url' => 'http://drupal.org')),
-    '#default_value' => isset($context['url']) ? $context['url'] : '',
-    '#required' => TRUE,
-  );
-  return $form;
-}
-
-function system_goto_action_submit($form, $form_state) {
-  return array(
-    'url' => $form_state['values']['url']
-  );
-}
-
-/**
- * Redirects to a different URL.
- *
- * @param $entity
- *   Ignored.
- * @param array $context
- *   Array with the following elements:
- *   - 'url': URL to redirect to. This will be passed through
- *     token_replace().
- *   - Other elements will be used as the data for token replacement.
- *
- * @ingroup actions
- */
-function system_goto_action($entity, $context) {
-  drupal_goto(token_replace($context['url'], $context));
-}
-
-/**
- * Blocks the current user's IP address.
- *
- * @ingroup actions
- */
-function system_block_ip_action() {
-  $ip = ip_address();
-  db_insert('blocked_ips')
-    ->fields(array('ip' => $ip))
-    ->execute();
-  watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
-}
-
 /**
  * Generate an array of time zones and their local time&date.
  *
-- 
1.7.9.5

