action.module 3.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<?php

/**
 * @file
 * This is the Actions module for executing stored actions.
 */

/**
 * Implements hook_help().
 */
function action_help($path, $arg) {
  switch ($path) {
    case 'admin/help#action':
      $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 action_permission() {
  return array(
    'administer actions' => array(
      'title' => t('Administer actions'),
    ),
  );
}

/**
 * Implements hook_menu().
 */
function action_menu() {
  $items['admin/config/system/actions'] = array(
    'title' => 'Actions',
    'description' => 'Manage the actions defined for your site.',
45
    'route_name' => 'action_admin',
46 47 48 49 50 51
  );
  $items['admin/config/system/actions/manage'] = array(
    'title' => 'Manage actions',
    'description' => 'Manage the actions defined for your site.',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
52 53 54 55 56
  $items['admin/config/system/actions/add'] = array(
    'title' => 'Create an advanced action',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
    'route_name' => 'action_admin_add',
  );
57 58 59
  $items['admin/config/system/actions/configure'] = array(
    'title' => 'Configure an advanced action',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
60
    'route_name' => 'action_admin_configure',
61
  );
62
  $items['admin/config/system/actions/configure/%/delete'] = array(
63 64
    'title' => 'Delete action',
    'description' => 'Delete an action.',
65
    'route_name' => 'action_delete',
66 67 68 69 70
  );
  return $items;
}

/**
71
 * Implements hook_entity_info().
72
 */
73 74 75 76
function action_entity_info(&$entity_info) {
  $entity_info['action']['controllers']['form']['add'] = 'Drupal\action\ActionAddFormController';
  $entity_info['action']['controllers']['form']['edit'] = 'Drupal\action\ActionEditFormController';
  $entity_info['action']['controllers']['list'] = 'Drupal\action\ActionListController';
77
}