function webform_rules_token_values in Webform Rules 6
Implementation of hook_token_values().
File
- ./
webform_rules.module, line 190 - Adds rules integration for webform submissions.
Code
function webform_rules_token_values($type, $object = NULL, $options = array()) {
$values = array();
if (!is_array($object) || !isset($object['sid']) || !isset($object['components'])) {
return $values;
}
switch ($type) {
case 'webform':
// Get webform data as token values.
$values['sid'] = $object['sid'];
$values['data'] = webform_rules_prepare_component_value($object);
$values['data-raw'] = webform_rules_prepare_component_value($object, TRUE);
// Process components.
$components = array_keys($object['components']);
foreach ($components as $key) {
$component = $object['components'][$key]['component'];
$component_value = $object['components'][$key]['value'];
// Get component title as token value.
$values[$key . '-title'] = $component['name'];
// Get value as token and render as text.
// Full display (title: value).
$values[$key . '-display'] = webform_rules_render_component($component, $component_value);
// Get component value as token value.
$values[$key . '-value'] = webform_rules_render_component($component, $component_value, 'text', FALSE);
// Get value as token and render as html.
// Full display (title: value).
$values[$key . '-display-html'] = webform_rules_render_component($component, $component_value, 'html');
// Get component value as token value.
$values[$key . '-value-html'] = webform_rules_render_component($component, $component_value, 'html', FALSE);
// Raw value.
$values[$key . '-value-raw'] = webform_rules_prepare_component_value($component_value, TRUE);
}
break;
}
return $values;
}