From ce9291d6e5785de57a932aefea794912584604ec Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 27 Jul 2017 14:41:16 -0600 Subject: [PATCH] * Calendar - Add placeholder for birthdays {{day/birthdays}} for day table --- calendar/inc/class.calendar_merge.inc.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/calendar/inc/class.calendar_merge.inc.php b/calendar/inc/class.calendar_merge.inc.php index 6ea97bf61d..12ce8886d7 100644 --- a/calendar/inc/class.calendar_merge.inc.php +++ b/calendar/inc/class.calendar_merge.inc.php @@ -412,7 +412,7 @@ class calendar_merge extends Api\Storage\Merge // Add in birthdays if(strpos($repeat, 'day/birthdays') !== false) { - $days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($_date); + $days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day); } } return $days[date('Ymd',$_date)][$plugin][0]; @@ -518,7 +518,7 @@ class calendar_merge extends Api\Storage\Merge // Add in birthdays if(strpos($repeat, 'day/birthdays') !== false) { - $days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($_date); + $days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day); } } return $days[date('Ymd',$_date)][$plugin][0]; @@ -612,16 +612,15 @@ class calendar_merge extends Api\Storage\Merge /** * Get replacement for birthdays placeholder - * @param int|DateTime $_date + * @param String $day Date in Ymd format */ - protected function get_birthdays($_date) + protected function get_birthdays($day) { - $day = date('Ymd', $_date); $contacts = new Api\Contacts(); $birthdays = Array(); foreach($contacts->get_addressbooks() as $owner => $name) { - $birthdays += $contacts->read_birthdays($owner, date('Y',$_date)); + $birthdays += $contacts->read_birthdays($owner, substr($day, 0, 4)); } return $birthdays[$day] ? implode(', ', array_column($birthdays[$day], 'name')) : ''; } @@ -727,8 +726,10 @@ class calendar_merge extends Api\Storage\Merge } echo '{{table/day_n}} ... {{endtable}}1 <= n <= 31'; echo ''; - echo '{{day/date}}'.lang('Date for the day of the week, available for the first entry inside each day of week or daily table inside the selected range.').''; - echo '{{day/name}}'.lang('Name of the week (ex: Monday), available for the first entry inside each day of week or daily table inside the selected range.').''; + echo 'Available for the first entry inside each day of week or daily table inside the selected range:'; + echo '{{day/date}}'.lang('Date for the day of the week').''; + echo '{{day/name}}'.lang('Name of the week (ex: Monday)').''; + echo '{{day/birthdays}}'.lang('Birthdays').''; echo '

'.lang('General fields:')."

"; foreach(array(