diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2160,6 +2160,9 @@ 'PhabricatorCalendarImportTriggerLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportTriggerLogType.php', 'PhabricatorCalendarImportUpdateLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php', 'PhabricatorCalendarImportViewController' => 'applications/calendar/controller/PhabricatorCalendarImportViewController.php', + 'PhabricatorCalendarInviteeDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php', + 'PhabricatorCalendarInviteeUserDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php', + 'PhabricatorCalendarInviteeViewerFunctionDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php', 'PhabricatorCalendarManagementNotifyWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementNotifyWorkflow.php', 'PhabricatorCalendarManagementReloadWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php', 'PhabricatorCalendarManagementWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementWorkflow.php', @@ -7041,6 +7044,9 @@ 'PhabricatorCalendarImportTriggerLogType' => 'PhabricatorCalendarImportLogType', 'PhabricatorCalendarImportUpdateLogType' => 'PhabricatorCalendarImportLogType', 'PhabricatorCalendarImportViewController' => 'PhabricatorCalendarController', + 'PhabricatorCalendarInviteeDatasource' => 'PhabricatorTypeaheadCompositeDatasource', + 'PhabricatorCalendarInviteeUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource', + 'PhabricatorCalendarInviteeViewerFunctionDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorCalendarManagementNotifyWorkflow' => 'PhabricatorCalendarManagementWorkflow', 'PhabricatorCalendarManagementReloadWorkflow' => 'PhabricatorCalendarManagementWorkflow', 'PhabricatorCalendarManagementWorkflow' => 'PhabricatorManagementWorkflow', diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -36,7 +36,7 @@ id(new PhabricatorSearchDatasourceField()) ->setLabel(pht('Invited')) ->setKey('invitedPHIDs') - ->setDatasource(new PhabricatorPeopleUserFunctionDatasource()), + ->setDatasource(new PhabricatorCalendarInviteeDatasource()), id(new PhabricatorSearchDateControlField()) ->setLabel(pht('Occurs After')) ->setKey('rangeStart'), diff --git a/src/applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php b/src/applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php new file mode 100644 --- /dev/null +++ b/src/applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php @@ -0,0 +1,53 @@ +setViewer($viewer) + ->withMemberPHIDs($phids) + ->execute(); + foreach ($projects as $project) { + $values[] = $project->getPHID(); + } + + return $values; + } + +} diff --git a/src/applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php b/src/applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php new file mode 100644 --- /dev/null +++ b/src/applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php @@ -0,0 +1,30 @@ +getViewer(), + $values); + } + +} diff --git a/src/applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php b/src/applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php new file mode 100644 --- /dev/null +++ b/src/applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php @@ -0,0 +1,77 @@ + array( + 'name' => pht('Current Viewer'), + 'summary' => pht('Use the current viewing user.'), + 'description' => pht( + 'Show invites the current viewer is invited to. This function '. + 'includes events the user is invited to because a project they '. + 'are a member of is invited.'), + ), + ); + } + + public function loadResults() { + if ($this->getViewer()->getPHID()) { + $results = array($this->renderViewerFunctionToken()); + } else { + $results = array(); + } + + return $this->filterResultsAgainstTokens($results); + } + + protected function canEvaluateFunction($function) { + if (!$this->getViewer()->getPHID()) { + return false; + } + + return parent::canEvaluateFunction($function); + } + + protected function evaluateFunction($function, array $argv_list) { + $results = array(); + foreach ($argv_list as $argv) { + $results[] = $this->getViewer()->getPHID(); + } + + return PhabricatorCalendarInviteeDatasource::expandInvitees( + $this->getViewer(), + $results); + } + + public function renderFunctionTokens($function, array $argv_list) { + $tokens = array(); + foreach ($argv_list as $argv) { + $tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult( + $this->renderViewerFunctionToken()); + } + return $tokens; + } + + private function renderViewerFunctionToken() { + return $this->newFunctionResult() + ->setName(pht('Current Viewer')) + ->setPHID('viewer()') + ->setIcon('fa-user') + ->setUnique(true); + } + +} diff --git a/src/applications/differential/typeahead/DifferentialExactUserFunctionDatasource.php b/src/applications/differential/typeahead/DifferentialExactUserFunctionDatasource.php --- a/src/applications/differential/typeahead/DifferentialExactUserFunctionDatasource.php +++ b/src/applications/differential/typeahead/DifferentialExactUserFunctionDatasource.php @@ -12,7 +12,7 @@ } public function getDatasourceApplicationClass() { - return 'PhabricatorDifferentialApplication'; + return 'PhabricatorPeopleApplication'; } public function getComponentDatasources() {