You are here

function redhen_engagement_rules_action_info in RedHen CRM 7

Implements hook_rules_action_info().

File

modules/redhen_engagement/redhen_engagement.rules.inc, line 11
Rules integration for RedHen Engagements.

Code

function redhen_engagement_rules_action_info() {
  $actions = array();

  // Declare some defaults for all actions.
  $defaults = array(
    'parameter' => array(
      'scores' => array(
        'type' => 'list<token>',
        'label' => t('Engagement Scores'),
        'description' => t('One or more scores that will be used for this engagement.'),
        'options list' => 'redhen_engagement_score_options',
      ),
    ),
    'group' => t('Engagement'),
    'access callback' => 'redhen_engagement_access',
  );

  // Add an action to score an engagement by email address.
  $actions['score_engagement_by_mail'] = $defaults + array(
    'label' => t('Score engagement by email'),
    'base' => 'redhen_engagement_rules_action_score_by_mail',
  );
  $actions['score_engagement_by_mail']['parameter']['mail'] = array(
    'type' => 'text',
    'label' => t('Email address'),
    'description' => t('The email address to score an engagement by.'),
  );

  // Add an action to score an engagement by user ID.
  $actions['score_engagement_by_uid'] = $defaults + array(
    'label' => t('Score engagement by user ID'),
    'base' => 'redhen_engagement_rules_action_score_by_uid',
  );
  $actions['score_engagement_by_uid']['parameter']['uid'] = array(
    'type' => 'integer',
    'label' => t('User ID'),
    'description' => t('The user ID to score an engagement by.'),
  );

  // webform
  if (module_exists('webform_rules')) {
    $actions['score_webform_engagement'] = $defaults + array(
      'label' => t('Score webform engagement'),
      'base' => 'redhen_engagement_rules_action_score_webform',
    );
    $actions['score_webform_engagement']['parameter']['webform'] = array(
      'type' => 'webform',
      'label' => t('Webform'),
      'description' => t('The webform submission to be scored. <em>Note: At this time scoring of anonymous webform submissions is not supported.</em>'),
    );
  }
  return $actions;
}