diff --git a/src/EcclesiaCRM/Service/CalendarService.php b/src/EcclesiaCRM/Service/CalendarService.php index 28dbff8aee..682b3c5b65 100644 --- a/src/EcclesiaCRM/Service/CalendarService.php +++ b/src/EcclesiaCRM/Service/CalendarService.php @@ -45,65 +45,68 @@ public function getEvents($start, $end) } $firstYear = $startDate->format('Y'); + + + if ($_SESSION['bSeePrivacyData'] || $_SESSION['bAdmin']) { + $peopleWithBirthDays = PersonQuery::create() + ->JoinWithFamily(); - $peopleWithBirthDays = PersonQuery::create() - ->JoinWithFamily(); - - // get the first and the last month - $firstMonth = $startDate->format('m'); - $endMonth = $endDate->format('m'); + // get the first and the last month + $firstMonth = $startDate->format('m'); + $endMonth = $endDate->format('m'); - $month = $firstMonth; + $month = $firstMonth; - $peopleWithBirthDays->filterByBirthMonth($firstMonth);// the event aren't more than a month + $peopleWithBirthDays->filterByBirthMonth($firstMonth);// the event aren't more than a month - while ($month != $endMonth) {// we loop to have all the months from the first in the start to the end - $month += 1; - if ($month == 13) { + while ($month != $endMonth) {// we loop to have all the months from the first in the start to the end + $month += 1; + if ($month == 13) { + $month = 1; + } + if ($month == 0) { $month = 1; + } + $peopleWithBirthDays->_or()->filterByBirthMonth($month);// the event aren't more than a month } - if ($month == 0) { - $month = 1; - } - $peopleWithBirthDays->_or()->filterByBirthMonth($month);// the event aren't more than a month - } - $peopleWithBirthDays->find(); + $peopleWithBirthDays->find(); - foreach ($peopleWithBirthDays as $person) { - $year = $firstYear; - if ($person->getBirthMonth() == 1 && $endsNextYear) { - $year = $firstYear + 1; - } + foreach ($peopleWithBirthDays as $person) { + $year = $firstYear; + if ($person->getBirthMonth() == 1 && $endsNextYear) { + $year = $firstYear + 1; + } - $start = date_create($year.'-'.$person->getBirthMonth().'-'.$person->getBirthDay()); + $start = date_create($year.'-'.$person->getBirthMonth().'-'.$person->getBirthDay()); - $event = $this->createCalendarItem('birthday', - $person->getFullName()." ".$person->getAge(), $start->format(DATE_ATOM), '', $person->getViewURI()); + $event = $this->createCalendarItem('birthday', + $person->getFullName()." ".$person->getAge(), $start->format(DATE_ATOM), '', $person->getViewURI()); - array_push($events, $event); - } + array_push($events, $event); + } - // we search the Anniversaries - $Anniversaries = FamilyQuery::create() - ->filterByWeddingDate(['min' => '0001-00-00']) // a Wedding Date - ->filterByDateDeactivated(null, Criteria::EQUAL) //Date Deactivated is null (active) - ->find(); + // we search the Anniversaries + $Anniversaries = FamilyQuery::create() + ->filterByWeddingDate(['min' => '0001-00-00']) // a Wedding Date + ->filterByDateDeactivated(null, Criteria::EQUAL) //Date Deactivated is null (active) + ->find(); - $curYear = date('Y'); - $curMonth = date('m'); - foreach ($Anniversaries as $anniversary) { - $year = $curYear; - if ($anniversary->getWeddingMonth() < $curMonth) { - $year = $year + 1; - } - $start = $year.'-'.$anniversary->getWeddingMonth().'-'.$anniversary->getWeddingDay(); - - $event = $this->createCalendarItem('anniversary', $anniversary->getName(), $start, '', $anniversary->getViewURI()); - - array_push($events, $event); + $curYear = date('Y'); + $curMonth = date('m'); + foreach ($Anniversaries as $anniversary) { + $year = $curYear; + if ($anniversary->getWeddingMonth() < $curMonth) { + $year = $year + 1; + } + $start = $year.'-'.$anniversary->getWeddingMonth().'-'.$anniversary->getWeddingDay(); + + $event = $this->createCalendarItem('anniversary', $anniversary->getName(), $start, '', $anniversary->getViewURI()); + + array_push($events, $event); + } } - + $activeEvents = EventQuery::create() ->filterByInActive('false') ->orderByStart()