function uc_coupon_workflow_suspend_element in Ubercart Discount Coupons 7.2
Same name and namespace in other branches
- 7.3 uc_coupon_workflow/uc_coupon_workflow.module \uc_coupon_workflow_suspend_element()
Builds a form element allowing an administrator to suspend coupon workflow.
Parameters
$events: An array of event names. If specified, the listed rules will be limited to these events.
1 call to uc_coupon_workflow_suspend_element()
- uc_coupon_workflow_form_user_register_form_alter in uc_coupon_workflow/
uc_coupon_workflow.module - Implements hook_form_user_register_form_alter().
File
- uc_coupon_workflow/
uc_coupon_workflow.module, line 94 - Discount coupon workflow.
Code
function uc_coupon_workflow_suspend_element($events = FALSE) {
if ($events && !is_array($events)) {
$events = array(
$events,
);
}
if (user_access('suspend coupon workflow')) {
// Examine all rules to see if there are any which depend on our condition,
// so we can list them for the administrator.
$found = array();
$rules = rules_config_load_multiple(FALSE);
foreach ($rules as $name => $rule) {
if ($rule instanceof RulesReactionRule && $rule->active) {
foreach ($rule
->conditions() as $condition) {
if (method_exists($condition, 'getElementName') && $condition
->getElementName() == 'uc_coupon_workflow_suspended' && (!$events || count(array_intersect($rule
->events(), $events)))) {
$found[] = $rule->label;
}
}
}
}
// If we've found some applicable rules, then list them and offer to suspend.
if (count($found)) {
$element = array(
'#type' => 'fieldset',
'#title' => t('Discount coupon workflow'),
'#description' => t('Some automatic discount coupon actions are configured to be executed when this form is submitted.
You can suspend these actions by checking the box below.'),
);
$element['actions'] = array(
'#type' => 'item',
'#title' => t('The following actions are enabled:'),
'list' => array(
'#theme' => 'item_list',
'#items' => $found,
'#type' => 'ul',
),
);
$element['uc_coupon_workflow_suspended'] = array(
'#type' => 'checkbox',
'#title' => t('Prevent these actions from being executed this time.'),
);
return $element;
}
}
}