Bugfix: Avoid duplicated birthday events

This commit is contained in:
Michael 2017-01-27 17:04:52 +00:00
parent 722b18ead7
commit cb0600976d
3 changed files with 48 additions and 7 deletions

View file

@ -493,6 +493,25 @@ function get_event_strings() {
return $i18n;
}
/**
* @brief Removes duplicated birthday events
*
* @param array $dates Array of possibly duplicated events
* @return array Cleaned events
*/
function event_remove_duplicates($dates) {
$dates2 = array();
foreach ($dates AS $date) {
if ($date['type'] == 'birthday') {
$dates2[$date['uid']."-".$date['cid']."-".$date['start']] = $date;
} else {
$dates2[] = $date;
}
}
return $dates2;
}
/**
* @brief Get an event by its event ID
*
@ -516,9 +535,9 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
intval($event_params["event_id"])
);
if (dbm::is_result($r))
return $r;
if (dbm::is_result($r)) {
return event_remove_duplicates($r);
}
}
/**
@ -558,8 +577,9 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
dbesc($event_params["adjust_finish"])
);
if (dbm::is_result($r))
return $r;
if (dbm::is_result($r)) {
return event_remove_duplicates($r);
}
}
/**
@ -568,7 +588,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
* @param array $arr Event query array
* @return array Event array for the template
*/
function process_events ($arr) {
function process_events($arr) {
$events=array();
$last_date = '';