Path: blob/master/src/applications/calendar/view/PHUIUserAvailabilityView.php
12256 views
<?php12final class PHUIUserAvailabilityView3extends AphrontTagView {45private $user;67public function setAvailableUser(PhabricatorUser $user) {8$this->user = $user;9return $this;10}1112public function getAvailableUser() {13return $this->user;14}1516protected function getTagContent() {17$viewer = $this->getViewer();18$user = $this->getAvailableUser();1920$until = $user->getAwayUntil();21if (!$until) {22return pht('Available');23}2425$const = $user->getDisplayAvailability();26$name = PhabricatorCalendarEventInvitee::getAvailabilityName($const);27$color = PhabricatorCalendarEventInvitee::getAvailabilityColor($const);2829$away_tag = id(new PHUITagView())30->setType(PHUITagView::TYPE_SHADE)31->setColor($color)32->setName($name)33->setDotColor($color);3435$now = PhabricatorTime::getNow();3637// Try to load the event handle. If it's invalid or the user can't see it,38// we'll just render a generic message.39$object_phid = $user->getAvailabilityEventPHID();40$handle = null;41if ($object_phid) {42$handles = $viewer->loadHandles(array($object_phid));43$handle = $handles[$object_phid];44if (!$handle->isComplete() || $handle->getPolicyFiltered()) {45$handle = null;46}47}4849switch ($const) {50case PhabricatorCalendarEventInvitee::AVAILABILITY_AWAY:51if ($handle) {52$description = pht(53'Away at %s until %s.',54$handle->renderLink(),55$viewer->formatShortDateTime($until, $now));56} else {57$description = pht(58'Away until %s.',59$viewer->formatShortDateTime($until, $now));60}61break;62case PhabricatorCalendarEventInvitee::AVAILABILITY_BUSY:63default:64if ($handle) {65$description = pht(66'Busy at %s until %s.',67$handle->renderLink(),68$viewer->formatShortDateTime($until, $now));69} else {70$description = pht(71'Busy until %s.',72$viewer->formatShortDateTime($until, $now));73}74break;75}7677return array(78$away_tag,79' ',80$description,81);82}8384}858687