You are here

mail_logger.rules.inc in Mail Logger 6

Rules integration with Mail Logger.

File

mail_logger.rules.inc
View source
<?php

/**
 * @file
 * Rules integration with Mail Logger.
 */

/**
 * Implementation of hook_rules_condition_info().
 * @ingroup rules
 */
function mail_logger_rules_condition_info() {
  return array(
    'mail_logger_rules_condition_mailkey' => array(
      'label' => t('Match the mail key.'),
      'module' => 'Mail Logger',
      'arguments' => array(
        'message' => array(
          'type' => 'mail',
          'label' => t('The sent mail.'),
        ),
      ),
      'eval input' => array(
        'mailkey',
      ),
    ),
  );
}

/**
* Condition Implementation: Compare the mail type.
* @ingroup rules
*/
function mail_logger_rules_condition_mailkey($mail, $settings) {
  return $mail['id'] == $settings['mailkey'];
}

/**
* Action drupal message configuration form.
*/
function mail_logger_rules_condition_mailkey_form($settings, &$form) {
  $settings += array(
    'mailkey',
  );
  $options = array();
  foreach (_mail_logger_get_mailkey_types() as $type) {
    $options[$type] = t('@type', array(
      '@type' => t($type),
    ));
  }
  $form['settings']['mailkey'] = array(
    '#type' => 'select',
    '#title' => t('Mailkey type'),
    '#default_value' => $settings['mailkey'],
    '#description' => t('The mailkey type to match. Note that the allowed values here are based on e-mails already sent.'),
    '#options' => $options,
  );
}

/**
 * Implementation of hook_rules_event_info().
 * @ingroup rules
 */
function mail_logger_rules_event_info() {
  return array(
    'mail_logger_mail_sent' => array(
      'label' => t('An e-mail has been sent and logged.'),
      'arguments' => array(
        'message' => array(
          'type' => 'mail',
          'label' => t('The sent mail.'),
        ),
        'sender' => array(
          'type' => 'user',
          'label' => t('The message sender.'),
        ),
        'recipient' => array(
          'type' => 'user',
          'label' => t('The message recipient.'),
        ),
        'user' => array(
          'type' => 'user',
          'label' => t('The logged in user.'),
        ),
      ),
      'module' => 'Mail Logger',
    ),
  );
}

/**
* Implementation of hook_rules_data_type_info().
*/
function mail_logger_rules_data_type_info() {
  return array(
    'mail' => array(
      'label' => t('Mail'),
      'class' => 'rules_data_type_mail',
      'savable' => FALSE,
      'identifiable' => TRUE,
      'uses_input_form' => FALSE,
      'module' => 'Mail Logger',
    ),
  );
}

/**
 * @file
 * Information and classes required for Rules.
 */

/**
* Defines the rules mail data type.
*/
class rules_data_type_mail extends rules_data_type {
  function load($id) {
    return mail_logger_load($id);
  }
  function get_identifier() {
    $term =& $this
      ->get();
    return $term->mlid;
  }

}

Functions

Namesort descending Description
mail_logger_rules_condition_info Implementation of hook_rules_condition_info().
mail_logger_rules_condition_mailkey Condition Implementation: Compare the mail type.
mail_logger_rules_condition_mailkey_form Action drupal message configuration form.
mail_logger_rules_data_type_info Implementation of hook_rules_data_type_info().
mail_logger_rules_event_info Implementation of hook_rules_event_info().

Classes

Namesort descending Description
rules_data_type_mail Defines the rules mail data type.