}
-function sort_by_date(App $a) {
+function sort_by_date($a) {
usort($a,'ev_compare');
return $a;
return $i18n;
}
+/// @todo We should replace this with a separate update function if there is some time left
+/**
+ * @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
*
// query for the event by event id
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
- STRAIGHT_JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
+ LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra",
intval($owner_uid),
intval($event_params["event_id"])
);
- if (dbm::is_result($r))
- return $r;
-
+ if (dbm::is_result($r)) {
+ return event_remove_duplicates($r);
+ }
}
/**
// query for the event by date
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
- STRAIGHT_JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
+ LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
WHERE `event`.`uid` = %d AND event.ignore = %d
AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s'))
dbesc($event_params["adjust_finish"])
);
- if (dbm::is_result($r))
- return $r;
+ if (dbm::is_result($r)) {
+ return event_remove_duplicates($r);
+ }
}
/**
* @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 = '';