botcha.rules.inc in BOTCHA Spam Prevention 6.3
Same filename and directory in other branches
Rules integration for the BOTCHA module.
File
botcha.rules.incView source
<?php
/**
* @file
* Rules integration for the BOTCHA module.
*/
/**
* Implementation of hook_rules_event_info().
*/
function botcha_rules_event_info() {
return array(
'botcha_form_approved' => array(
'label' => t('A form submission is accepted'),
// @todo Abstract it.
'arguments' => botcha_rules_events_hook_arguments(),
'module' => 'BOTCHA',
),
'botcha_form_rejected' => array(
'label' => t('A form submission is rejected'),
// @todo Abstract it.
'arguments' => botcha_rules_events_hook_arguments(),
'module' => 'BOTCHA',
),
);
}
/**
* Describes the arguments available for the botcha_rules_event_info().
*/
function botcha_rules_events_hook_arguments() {
return array(
// 'form' => array('type' => 'form', 'label' => t('Form')),
// 'form_state' => array('type' => 'form_state', 'label' => t('Form state')),
'form_id' => array(
'type' => 'string',
'label' => t('Form ID'),
),
'total_recipes' => array(
'type' => 'number',
'label' => t('Total recipes'),
),
'passed_recipes' => array(
'type' => 'number',
'label' => t('Total passed recipes'),
),
'passed_recipes_names' => array(
'type' => 'string',
'label' => t('Passed recipes names'),
),
'last_recipe_name' => array(
'type' => 'string',
'label' => t('Last recipe name'),
),
'fail' => array(
'type' => 'string',
'label' => t('Fail condition'),
),
'failed_field' => array(
'type' => 'string',
'label' => t('Failed field (can be obscured)'),
),
'failed_error' => array(
'type' => 'string',
'label' => t('Failed error text (can be obscured)'),
),
) + rules_events_global_user_argument();
}
/**
* Implementation of hook_rules_action_info().
*/
function botcha_rules_action_info() {
return array(
'botcha_rules_action_regenerate_seed' => array(
'label' => t('Regenerate seed (invalidates all prepared forms that have not yet been submitted)'),
'arguments' => array(),
'group' => t('BOTCHA'),
),
);
}
/**
* Action: Regenerate seed.
*/
function botcha_rules_action_regenerate_seed() {
// Generate unique secret for this site
$secret = md5(uniqid(mt_rand(), TRUE));
variable_set('botcha_secret', $secret);
// drupal_set_message(t('New BOTCHA secret key have been generated.'));
}
Functions
Name | Description |
---|---|
botcha_rules_action_info | Implementation of hook_rules_action_info(). |
botcha_rules_action_regenerate_seed | Action: Regenerate seed. |
botcha_rules_events_hook_arguments | Describes the arguments available for the botcha_rules_event_info(). |
botcha_rules_event_info | Implementation of hook_rules_event_info(). |