Page MenuHomePhabricator

D16870.diff
No OneTemporary

D16870.diff

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 @@
+<?php
+
+final class PhabricatorCalendarInviteeDatasource
+ extends PhabricatorTypeaheadCompositeDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Invitees');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a user or project name, or function...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorCalendarApplication';
+ }
+
+ public function getComponentDatasources() {
+ return array(
+ new PhabricatorCalendarInviteeUserDatasource(),
+ new PhabricatorCalendarInviteeViewerFunctionDatasource(),
+ new DifferentialExactUserFunctionDatasource(),
+ new PhabricatorProjectDatasource(),
+ );
+ }
+
+ public static function expandInvitees(
+ PhabricatorUser $viewer,
+ array $values) {
+
+ $phids = array();
+ foreach ($values as $value) {
+ if (phid_get_type($value) == PhabricatorPeopleUserPHIDType::TYPECONST) {
+ $phids[] = $value;
+ }
+ }
+
+ if (!$phids) {
+ return $values;
+ }
+
+ $projects = id(new PhabricatorProjectQuery())
+ ->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 @@
+<?php
+
+final class PhabricatorCalendarInviteeUserDatasource
+ extends PhabricatorTypeaheadCompositeDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Users');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a user name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorCalendarApplication';
+ }
+
+ public function getComponentDatasources() {
+ return array(
+ new PhabricatorPeopleDatasource(),
+ );
+ }
+
+ protected function evaluateValues(array $values) {
+ return PhabricatorCalendarInviteeDatasource::expandInvitees(
+ $this->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 @@
+<?php
+
+final class PhabricatorCalendarInviteeViewerFunctionDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Viewer');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type viewer()...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorPeopleApplication';
+ }
+
+ public function getDatasourceFunctions() {
+ return array(
+ 'viewer' => 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() {

File Metadata

Mime Type
text/plain
Expires
Thu, May 9, 8:11 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276467
Default Alt Text
D16870.diff (8 KB)

Event Timeline