Posted by Seph on February 25, 2013 at 9:00pm
I need to fix Registration Codes integration with Rules. I already contacted the maintainer for help and he is no longer actively maintaining Regcode.
I have also tried the IRC support channels and haven't had any luck there.
The problem is some where in the condition function in regcode.rules.inc. When I try to choose the either condition " Code comparison or Tagged with", it doesn't register in Rules configuration and nothing happens.
I need to get this working so I can get my site up and running. I'm really new to coding, but willing to learn.
The following is the rules.inc file for regcode.
<?php
/<strong>
* @file
* Rules integration for the regcode module.
*/
/</strong>
* Implementation of module_rules_event_info()
*
* @ingroup rules
*/
function regcode_rules_event_info() {
return array(
'regcode_used' => array(
'label' => t('User has used a registration code'),
'group' => 'Regcode',
'arguments' => array(
'user' => array(
'type' => 'user',
'label' => t('The user using the code'),
),
'regcode' => array(
'type' => 'regcode',
'label' => t('The regcode which was used'),
),
),
),
);
}
/<strong>
* Implement module_rules_condition_info()
*
* @ingroup rules
*/
function regcode_rules_condition_info() {
return array(
'rules_condition_regcode_term_compare' => array(
'label' => t('Tagged with'),
'arguments' => array(
'regcode' => array(
'type' => 'regcode',
'label' => t('Tag'),
),
),
'group' => 'Regcode',
),
'rules_condition_regcode_code_compare' => array(
'label' => t('Code comparison'),
'arguments' => array(
'regcode' => array(
'type' => 'regcode',
'label' => t('Code'),
),
),
'group' => 'Regcode',
),
);
}
/</strong>
* Comparison function
*
* @ingroup rules
*/
function rules_condition_regcode_term_compare($regcode, $settings) {
$present = array_keys($regcode->tags);
$expected = array_keys($settings['regcode_terms']);
$match = (bool) count(array_intersect($present, $expected));
return $match;
}
/<strong>
* Form to select terms to match against
*
* @param array $settings
* @param array $form
* @ingroup rules
*/
function rules_condition_regcode_term_compare_form($settings, &$form) {
$form['settings']['regcode_terms'] = array(
'#type' => 'checkboxes',
'#options' => regcode_get_vocab_terms(),
'#title' => t('Tags'),
'#required' => TRUE,
'#description' => t('Condition evaluates to TRUE if registration code used was tagged with any of the selected terms.'),
'#default_value' => (array) $settings['regcode_terms'],
);
}
/</strong>
* Compare a submitted form
*
* @ingroup rules
*/
function rules_condition_regcode_term_compare_submit(&$settings, $form, $form_state) {
$settings['regcode_terms'] = array_filter($settings['regcode_terms']);
}
/<strong>
* Comparison function
*
* @ingroup rules
*/
function rules_condition_regcode_code_compare($regcode, $settings) {
return $regcode->code === $settings['regcode_code'];
}
/</strong>
* Form to select terms to match against
*
* @param array $settings
* @param array $form
* @ingroup rules
*/
function rules_condition_regcode_code_compare_form($settings, &$form) {
$form['settings']['regcode_code'] = array(
'#type' => 'textfield',
'#title' => t('Registration code'),
'#required' => TRUE,
'#description' => t('Condition evaluates to TRUE if registration code used matches this string exactly.'),
'#default_value' => $settings['regcode_code'],
);
}
?>