From 63f66a5a93661cfc327449561a2150aa8187a228 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 Dec 2011 19:06:25 -0800 Subject: [PATCH] bug 244 multiple birthday reminders from Diaspora if profile changed repeatedly --- boot.php | 9 +++++++++ include/bbcode.php | 2 +- include/diaspora.php | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 9f00d8d4b3..61f14d9bc0 100644 --- a/boot.php +++ b/boot.php @@ -1036,6 +1036,8 @@ function get_birthdays() { if($r && count($r)) { $total = 0; $now = strtotime('now'); + $cids = array(); + $istoday = false; foreach($r as $rr) { if(strlen($rr['name'])) @@ -1052,6 +1054,13 @@ function get_birthdays() { foreach($r as $rr) { if(! strlen($rr['name'])) continue; + + // avoid duplicates + + if(in_array($rr['cid'],$cids)) + continue; + $cids[] = $rr['cid']; + $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); $sparkle = ''; $url = $rr['url']; diff --git a/include/bbcode.php b/include/bbcode.php index a8e3bed701..5218a06e85 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -11,7 +11,7 @@ function stripcode_br_cb($s) { function tryoembed($match){ $url = ((count($match)==2)?$match[1]:$match[2]); - logger('tryoembed: $url'); + logger("tryoembed: $url"); $o = oembed_fetch_url($url); diff --git a/include/diaspora.php b/include/diaspora.php index 3ab4542462..fdf756610e 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1679,6 +1679,12 @@ function diaspora_profile($importer,$xml) { $birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d'); + // this is to prevent multiple birthday notifications in a single year + // if we already have a stored birthday and the 'm-d' part hasn't changed, preserve the entry, which will preserve the notify year + + if(substr($birthday,5) === substr($contact['bd'],5)) + $birthday = $contact['bd']; + $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($name), dbesc(datetime_convert()),