@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorPeopleAvailabilitySearchEngineAttachment
4 extends PhabricatorSearchEngineAttachment {
5
6 public function getAttachmentName() {
7 return pht('User Availability');
8 }
9
10 public function getAttachmentDescription() {
11 return pht('Get availability information for users.');
12 }
13
14 public function willLoadAttachmentData($query, $spec) {
15 $query->needAvailability(true);
16 }
17
18 public function getAttachmentForObject($object, $data, $spec) {
19
20 $until = $object->getAwayUntil();
21 if ($until) {
22 $until = (int)$until;
23 } else {
24 $until = null;
25 }
26
27 $value = $object->getDisplayAvailability();
28 if ($value === null) {
29 $value = PhabricatorCalendarEventInvitee::AVAILABILITY_AVAILABLE;
30 }
31
32 $name = PhabricatorCalendarEventInvitee::getAvailabilityName($value);
33 $color = PhabricatorCalendarEventInvitee::getAvailabilityColor($value);
34
35 $event_phid = $object->getAvailabilityEventPHID();
36
37 return array(
38 'value' => $value,
39 'until' => $until,
40 'name' => $name,
41 'color' => $color,
42 'eventPHID' => $event_phid,
43 );
44 }
45
46}