function heartbeat_variables_compare in Heartbeat 6.4
Same name and namespace in other branches
- 6.3 heartbeat.common.inc \heartbeat_variables_compare()
compares variables that need to be included with variables that are already there and check their values to fit as default value in a textarea
Parameters
array $settings:
array $form_settings:
string $variables:
Return value
string fit for textarea
1 call to heartbeat_variables_compare()
- heartbeat_rule_action_get_variables in modules/
heartbeat_rules/ hrules.module - Helper function to fetch the defined variables for this message
File
- modules/
heartbeat_rules/ hrules.module, line 234 - Heartbeat rules implementation module
Code
function heartbeat_variables_compare($variables = array(), $defaults = array(), $flipped = TRUE) {
$default_values = '';
// normal settings from rules action, rules cache
$vars = array();
if (isset($defaults)) {
$vars = heartbeat_decode_message_variables($defaults, FALSE);
}
if ($flipped) {
$variables = array_flip($variables);
}
// See if there is already a token assignment on a variable
foreach ($variables as $variable_word => $key) {
// Standardize possible variable formats
$variable_normal = !eregi("@", $variable_word) ? "@" . $variable_word : $variable_word;
$variable_part = !eregi("#", $variable_word) ? "#" . $variable_word : $variable_word;
if (!empty($vars[$variable_normal])) {
$default_values .= $variable_normal . "=" . $vars[$variable_normal] . "\r\n";
}
elseif (!empty($vars[$variable_part])) {
$default_values .= $variable_part . "=" . $vars[$variable_part] . "\r\n";
}
elseif (!empty($vars[$variable_word])) {
$default_values .= $variable_normal . "=" . $vars[$variable_word] . "\r\n";
}
else {
$default_values .= $variable_normal . "=\r\n";
}
}
return $default_values;
}