Differential D12827 Diff 30840 src/applications/people/controller/PhabricatorPeopleCalendarController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/controller/PhabricatorPeopleCalendarController.php
Show All 35 Lines | public function processRequest() { | ||||
$day = phabricator_format_local_time($now, $user, 'j'); | $day = phabricator_format_local_time($now, $user, 'j'); | ||||
$holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere( | $holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere( | ||||
'day BETWEEN %s AND %s', | 'day BETWEEN %s AND %s', | ||||
"{$year}-{$month}-01", | "{$year}-{$month}-01", | ||||
"{$year}-{$month}-31"); | "{$year}-{$month}-31"); | ||||
$start_epoch = strtotime("{$year}-{$month}-01"); | |||||
$end_epoch = strtotime("{$year}-{$month}-01 next month"); | |||||
$statuses = id(new PhabricatorCalendarEventQuery()) | $statuses = id(new PhabricatorCalendarEventQuery()) | ||||
->setViewer($user) | ->setViewer($user) | ||||
->withInvitedPHIDs(array($user->getPHID())) | ->withInvitedPHIDs(array($user->getPHID())) | ||||
->withDateRange( | ->withDateRange( | ||||
strtotime("{$year}-{$month}-01"), | $start_epoch, | ||||
strtotime("{$year}-{$month}-01 next month")) | $end_epoch) | ||||
->execute(); | ->execute(); | ||||
$start_range_value = AphrontFormDateControlValue::newFromEpoch( | |||||
$user, | |||||
$start_epoch); | |||||
$end_range_value = AphrontFormDateControlValue::newFromEpoch( | |||||
$user, | |||||
$end_epoch); | |||||
if ($month == $month_d && $year == $year_d) { | if ($month == $month_d && $year == $year_d) { | ||||
$month_view = new PHUICalendarMonthView($month, $year, $day); | $month_view = new PHUICalendarMonthView( | ||||
$start_range_value, | |||||
$end_range_value, | |||||
$month, | |||||
$year, | |||||
$day); | |||||
} else { | } else { | ||||
$month_view = new PHUICalendarMonthView($month, $year); | $month_view = new PHUICalendarMonthView( | ||||
$start_range_value, | |||||
$end_range_value, | |||||
$month, | |||||
$year); | |||||
} | } | ||||
$month_view->setBrowseURI($request->getRequestURI()); | $month_view->setBrowseURI($request->getRequestURI()); | ||||
$month_view->setUser($user); | $month_view->setUser($user); | ||||
$month_view->setHolidays($holidays); | $month_view->setHolidays($holidays); | ||||
$month_view->setImage($picture); | $month_view->setImage($picture); | ||||
$phids = mpull($statuses, 'getUserPHID'); | $phids = mpull($statuses, 'getUserPHID'); | ||||
$handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
foreach ($statuses as $status) { | foreach ($statuses as $status) { | ||||
$event = new AphrontCalendarEventView(); | $event = new AphrontCalendarEventView(); | ||||
$event->setEpochRange($status->getDateFrom(), $status->getDateTo()); | $event->setEpochRange($status->getDateFrom(), $status->getDateTo()); | ||||
$event->setUserPHID($status->getUserPHID()); | $event->setUserPHID($status->getUserPHID()); | ||||
$event->setName($status->getHumanStatus()); | $event->setName($status->getName()); | ||||
$event->setDescription($status->getDescription()); | $event->setDescription($status->getDescription()); | ||||
$event->setEventID($status->getID()); | $event->setEventID($status->getID()); | ||||
$month_view->addEvent($event); | $month_view->addEvent($event); | ||||
} | } | ||||
$name = $user->getUsername(); | $name = $user->getUsername(); | ||||
$nav = $this->buildIconNavView($user); | $nav = $this->buildIconNavView($user); | ||||
Show All 10 Lines |