public function BindDisplayDates(ISchedulePage $page, DateRange $dateRange, ISchedule $schedule) { $scheduleLength = $schedule->GetDaysVisible(); if ($page->GetShowFullWeek()) { $scheduleLength = 7; } $page->SetDisplayDates($dateRange); $startDate = $dateRange->GetBegin(); $startDay = $schedule->GetWeekdayStart(); if ($startDay == Schedule::Today) { $adjustment = $scheduleLength; $prevAdjustment = $scheduleLength; } else { $adjustment = max($scheduleLength, 7); $prevAdjustment = 7 * floor($adjustment / 7); // ie, if 10, we only want to go back 7 days so there is overlap } $page->SetPreviousNextDates($startDate->AddDays(-$prevAdjustment), $startDate->AddDays($adjustment)); $page->ShowFullWeekToggle($scheduleLength < 7); }
/** * @param ISchedule $schedule * @return bool */ public function IsScheduleAdminFor(ISchedule $schedule) { if ($this->isApplicationAdmin) { return true; } if (!$this->isScheduleAdmin) { return false; } foreach ($this->groups as $group) { if ($group->GroupId == $schedule->GetAdminGroupId()) { return true; } } return false; }
/** * @see ISchedulePageBuilder::BindDisplayDates() */ public function BindDisplayDates(ISchedulePage $page, DateRange $dateRange, UserSession $userSession, ISchedule $schedule) { $scheduleLength = $schedule->GetDaysVisible(); if ($page->GetShowFullWeek()) { $scheduleLength = 7; } // we don't want to display the last date in the range (it will be midnight of the last day) $adjustedDateRange = new DateRange($dateRange->GetBegin()->ToTimezone($userSession->Timezone), $dateRange->GetEnd()->ToTimezone($userSession->Timezone)->AddDays(-1)); $page->SetDisplayDates($adjustedDateRange); $startDate = $adjustedDateRange->GetBegin(); $startDay = $schedule->GetWeekdayStart(); if ($startDay == Schedule::Today) { $adjustment = $scheduleLength; $prevAdjustment = $scheduleLength; } else { $adjustment = max($scheduleLength, 7); $prevAdjustment = 7 * floor($adjustment / 7); // ie, if 10, we only want to go back 7 days so there is overlap } $page->SetPreviousNextDates($startDate->AddDays(-$prevAdjustment), $startDate->AddDays($adjustment)); $page->ShowFullWeekToggle($scheduleLength < 7); }