private function heartbeatParser::remove_variables_duplicates in Heartbeat 7
Same name and namespace in other branches
- 6.4 includes/heartbeatparser.inc \heartbeatParser::remove_variables_duplicates()
- 6.3 includes/heartbeatparser.inc \heartbeatParser::remove_variables_duplicates()
Function to remove duplicate messages valuating the variables and count properties
1 call to heartbeatParser::remove_variables_duplicates()
- heartbeatParser::clean_up in includes/
heartbeatparser.inc - Function to clean up dirty messages and xss attacks
File
- includes/
heartbeatparser.inc, line 176 - HeartbeatParser object Parses database messages into a well formed stream of activity messages.
Class
- heartbeatParser
- Class heartbeatParser
Code
private function remove_variables_duplicates() {
// Loop through the candidates, one set for each message.
foreach ($this->_candidates as $single_id => $info) {
$uniques = array();
// Loop through variables to check if there are identical.
foreach ($info['variables'] as $rid => $value) {
// If for some reason a defined group target was not found
// in the message, use a substitute.
if (!isset($value['!' . $info['group_target']])) {
$group_by = 'default';
}
else {
$group_by = $value['!' . $info['group_target']];
}
if (!isset($uniques[$group_by])) {
$uniques[$group_by] = $value;
}
else {
unset($this->_candidates[$single_id]['variables'][$rid]);
}
}
}
// Re-evaluate the counts.
foreach ($this->_candidates as $single_id => $info) {
$this->_candidates[$single_id]['count'] = count($this->_candidates[$single_id]['variables']);
}
}