View source
<?php
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',
),
),
);
}
function mail_logger_rules_condition_mailkey($mail, $settings) {
return $mail['id'] == $settings['mailkey'];
}
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,
);
}
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',
),
);
}
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',
),
);
}
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;
}
}