1
1
Fork 0

bug 244 multiple birthday reminders from Diaspora if profile changed repeatedly

This commit is contained in:
friendica 2011-12-19 19:06:25 -08:00
parent 79f3bbbf2b
commit 63f66a5a93
3 changed files with 16 additions and 1 deletions

View file

@ -1036,6 +1036,8 @@ function get_birthdays() {
if($r && count($r)) { if($r && count($r)) {
$total = 0; $total = 0;
$now = strtotime('now'); $now = strtotime('now');
$cids = array();
$istoday = false; $istoday = false;
foreach($r as $rr) { foreach($r as $rr) {
if(strlen($rr['name'])) if(strlen($rr['name']))
@ -1052,6 +1054,13 @@ function get_birthdays() {
foreach($r as $rr) { foreach($r as $rr) {
if(! strlen($rr['name'])) if(! strlen($rr['name']))
continue; 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); $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
$sparkle = ''; $sparkle = '';
$url = $rr['url']; $url = $rr['url'];

View file

@ -11,7 +11,7 @@ function stripcode_br_cb($s) {
function tryoembed($match){ function tryoembed($match){
$url = ((count($match)==2)?$match[1]:$match[2]); $url = ((count($match)==2)?$match[1]:$match[2]);
logger('tryoembed: $url'); logger("tryoembed: $url");
$o = oembed_fetch_url($url); $o = oembed_fetch_url($url);

View file

@ -1679,6 +1679,12 @@ function diaspora_profile($importer,$xml) {
$birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d'); $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", $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($name),
dbesc(datetime_convert()), dbesc(datetime_convert()),