mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Add an "availaiblity" attachment for user.search
Summary: Ref T13222. See PHI990. The older `user.query` supports availability information, but it isn't currently available in a modern way. Make it available. Test Plan: {F6048126} Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13222 Differential Revision: https://secure.phabricator.com/D19851
This commit is contained in:
parent
1029081b28
commit
1e4bdc39a1
3 changed files with 52 additions and 1 deletions
|
@ -3761,6 +3761,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPeopleAnyOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleAnyOwnerDatasource.php',
|
'PhabricatorPeopleAnyOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleAnyOwnerDatasource.php',
|
||||||
'PhabricatorPeopleApplication' => 'applications/people/application/PhabricatorPeopleApplication.php',
|
'PhabricatorPeopleApplication' => 'applications/people/application/PhabricatorPeopleApplication.php',
|
||||||
'PhabricatorPeopleApproveController' => 'applications/people/controller/PhabricatorPeopleApproveController.php',
|
'PhabricatorPeopleApproveController' => 'applications/people/controller/PhabricatorPeopleApproveController.php',
|
||||||
|
'PhabricatorPeopleAvailabilitySearchEngineAttachment' => 'applications/people/engineextension/PhabricatorPeopleAvailabilitySearchEngineAttachment.php',
|
||||||
'PhabricatorPeopleBadgesProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php',
|
'PhabricatorPeopleBadgesProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php',
|
||||||
'PhabricatorPeopleCommitsProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php',
|
'PhabricatorPeopleCommitsProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php',
|
||||||
'PhabricatorPeopleController' => 'applications/people/controller/PhabricatorPeopleController.php',
|
'PhabricatorPeopleController' => 'applications/people/controller/PhabricatorPeopleController.php',
|
||||||
|
@ -9640,6 +9641,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPeopleAnyOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
|
'PhabricatorPeopleAnyOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'PhabricatorPeopleApplication' => 'PhabricatorApplication',
|
'PhabricatorPeopleApplication' => 'PhabricatorApplication',
|
||||||
'PhabricatorPeopleApproveController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleApproveController' => 'PhabricatorPeopleController',
|
||||||
|
'PhabricatorPeopleAvailabilitySearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||||
'PhabricatorPeopleBadgesProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
'PhabricatorPeopleBadgesProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorPeopleCommitsProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
'PhabricatorPeopleCommitsProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorPeopleController' => 'PhabricatorController',
|
'PhabricatorPeopleController' => 'PhabricatorController',
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPeopleAvailabilitySearchEngineAttachment
|
||||||
|
extends PhabricatorSearchEngineAttachment {
|
||||||
|
|
||||||
|
public function getAttachmentName() {
|
||||||
|
return pht('User Availability');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentDescription() {
|
||||||
|
return pht('Get availability information for users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willLoadAttachmentData($query, $spec) {
|
||||||
|
$query->needAvailability(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttachmentForObject($object, $data, $spec) {
|
||||||
|
|
||||||
|
$until = $object->getAwayUntil();
|
||||||
|
if ($until) {
|
||||||
|
$until = (int)$until;
|
||||||
|
} else {
|
||||||
|
$until = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $object->getDisplayAvailability();
|
||||||
|
if ($value === null) {
|
||||||
|
$value = PhabricatorCalendarEventInvitee::AVAILABILITY_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = PhabricatorCalendarEventInvitee::getAvailabilityName($value);
|
||||||
|
$color = PhabricatorCalendarEventInvitee::getAvailabilityColor($value);
|
||||||
|
|
||||||
|
$event_phid = $object->getAvailabilityEventPHID();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'value' => $value,
|
||||||
|
'until' => $until,
|
||||||
|
'name' => $name,
|
||||||
|
'color' => $color,
|
||||||
|
'eventPHID' => $event_phid,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1466,7 +1466,10 @@ final class PhabricatorUser
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConduitSearchAttachments() {
|
public function getConduitSearchAttachments() {
|
||||||
return array();
|
return array(
|
||||||
|
id(new PhabricatorPeopleAvailabilitySearchEngineAttachment())
|
||||||
|
->setAttachmentKey('availability'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue