@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make Calendar query for indirect invites/RSVPs by default, like Differential

Summary:
Ref T11816. Since the dashboard got updated, Differential now interprets "Responsible Users: epriestley" to mean "epriestley, or any project or package epriestley is part of". You can query for just "epriestley" with "exact(epriestley)".

Give Calendar invites the same behavior: "epriestley" means "any event epriestley is invited to, or a project they are a member of is invited to". Individual invites can be queried with "exact(epriestley)".

This is a little bit copy-pastey but I want to wait for a third use case to clean it up since I think I'm going to have to do a bunch of generalization around "how does an individual PHID get turned into a bunch of PHIDs".

Test Plan: Queried for "Invited: dog", "invited: viewer", "invited; exact(dog)", etc.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11816

Differential Revision: https://secure.phabricator.com/D16870

+168 -2
+6
src/__phutil_library_map__.php
··· 2160 2160 'PhabricatorCalendarImportTriggerLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportTriggerLogType.php', 2161 2161 'PhabricatorCalendarImportUpdateLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php', 2162 2162 'PhabricatorCalendarImportViewController' => 'applications/calendar/controller/PhabricatorCalendarImportViewController.php', 2163 + 'PhabricatorCalendarInviteeDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php', 2164 + 'PhabricatorCalendarInviteeUserDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php', 2165 + 'PhabricatorCalendarInviteeViewerFunctionDatasource' => 'applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php', 2163 2166 'PhabricatorCalendarManagementNotifyWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementNotifyWorkflow.php', 2164 2167 'PhabricatorCalendarManagementReloadWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementReloadWorkflow.php', 2165 2168 'PhabricatorCalendarManagementWorkflow' => 'applications/calendar/management/PhabricatorCalendarManagementWorkflow.php', ··· 7041 7044 'PhabricatorCalendarImportTriggerLogType' => 'PhabricatorCalendarImportLogType', 7042 7045 'PhabricatorCalendarImportUpdateLogType' => 'PhabricatorCalendarImportLogType', 7043 7046 'PhabricatorCalendarImportViewController' => 'PhabricatorCalendarController', 7047 + 'PhabricatorCalendarInviteeDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 7048 + 'PhabricatorCalendarInviteeUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 7049 + 'PhabricatorCalendarInviteeViewerFunctionDatasource' => 'PhabricatorTypeaheadDatasource', 7044 7050 'PhabricatorCalendarManagementNotifyWorkflow' => 'PhabricatorCalendarManagementWorkflow', 7045 7051 'PhabricatorCalendarManagementReloadWorkflow' => 'PhabricatorCalendarManagementWorkflow', 7046 7052 'PhabricatorCalendarManagementWorkflow' => 'PhabricatorManagementWorkflow',
+1 -1
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
··· 36 36 id(new PhabricatorSearchDatasourceField()) 37 37 ->setLabel(pht('Invited')) 38 38 ->setKey('invitedPHIDs') 39 - ->setDatasource(new PhabricatorPeopleUserFunctionDatasource()), 39 + ->setDatasource(new PhabricatorCalendarInviteeDatasource()), 40 40 id(new PhabricatorSearchDateControlField()) 41 41 ->setLabel(pht('Occurs After')) 42 42 ->setKey('rangeStart'),
+53
src/applications/calendar/typeahead/PhabricatorCalendarInviteeDatasource.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarInviteeDatasource 4 + extends PhabricatorTypeaheadCompositeDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Invitees'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type a user or project name, or function...'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorCalendarApplication'; 16 + } 17 + 18 + public function getComponentDatasources() { 19 + return array( 20 + new PhabricatorCalendarInviteeUserDatasource(), 21 + new PhabricatorCalendarInviteeViewerFunctionDatasource(), 22 + new DifferentialExactUserFunctionDatasource(), 23 + new PhabricatorProjectDatasource(), 24 + ); 25 + } 26 + 27 + public static function expandInvitees( 28 + PhabricatorUser $viewer, 29 + array $values) { 30 + 31 + $phids = array(); 32 + foreach ($values as $value) { 33 + if (phid_get_type($value) == PhabricatorPeopleUserPHIDType::TYPECONST) { 34 + $phids[] = $value; 35 + } 36 + } 37 + 38 + if (!$phids) { 39 + return $values; 40 + } 41 + 42 + $projects = id(new PhabricatorProjectQuery()) 43 + ->setViewer($viewer) 44 + ->withMemberPHIDs($phids) 45 + ->execute(); 46 + foreach ($projects as $project) { 47 + $values[] = $project->getPHID(); 48 + } 49 + 50 + return $values; 51 + } 52 + 53 + }
+30
src/applications/calendar/typeahead/PhabricatorCalendarInviteeUserDatasource.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarInviteeUserDatasource 4 + extends PhabricatorTypeaheadCompositeDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Users'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type a user name...'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorCalendarApplication'; 16 + } 17 + 18 + public function getComponentDatasources() { 19 + return array( 20 + new PhabricatorPeopleDatasource(), 21 + ); 22 + } 23 + 24 + protected function evaluateValues(array $values) { 25 + return PhabricatorCalendarInviteeDatasource::expandInvitees( 26 + $this->getViewer(), 27 + $values); 28 + } 29 + 30 + }
+77
src/applications/calendar/typeahead/PhabricatorCalendarInviteeViewerFunctionDatasource.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarInviteeViewerFunctionDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Viewer'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type viewer()...'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorPeopleApplication'; 16 + } 17 + 18 + public function getDatasourceFunctions() { 19 + return array( 20 + 'viewer' => array( 21 + 'name' => pht('Current Viewer'), 22 + 'summary' => pht('Use the current viewing user.'), 23 + 'description' => pht( 24 + 'Show invites the current viewer is invited to. This function '. 25 + 'includes events the user is invited to because a project they '. 26 + 'are a member of is invited.'), 27 + ), 28 + ); 29 + } 30 + 31 + public function loadResults() { 32 + if ($this->getViewer()->getPHID()) { 33 + $results = array($this->renderViewerFunctionToken()); 34 + } else { 35 + $results = array(); 36 + } 37 + 38 + return $this->filterResultsAgainstTokens($results); 39 + } 40 + 41 + protected function canEvaluateFunction($function) { 42 + if (!$this->getViewer()->getPHID()) { 43 + return false; 44 + } 45 + 46 + return parent::canEvaluateFunction($function); 47 + } 48 + 49 + protected function evaluateFunction($function, array $argv_list) { 50 + $results = array(); 51 + foreach ($argv_list as $argv) { 52 + $results[] = $this->getViewer()->getPHID(); 53 + } 54 + 55 + return PhabricatorCalendarInviteeDatasource::expandInvitees( 56 + $this->getViewer(), 57 + $results); 58 + } 59 + 60 + public function renderFunctionTokens($function, array $argv_list) { 61 + $tokens = array(); 62 + foreach ($argv_list as $argv) { 63 + $tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult( 64 + $this->renderViewerFunctionToken()); 65 + } 66 + return $tokens; 67 + } 68 + 69 + private function renderViewerFunctionToken() { 70 + return $this->newFunctionResult() 71 + ->setName(pht('Current Viewer')) 72 + ->setPHID('viewer()') 73 + ->setIcon('fa-user') 74 + ->setUnique(true); 75 + } 76 + 77 + }
+1 -1
src/applications/differential/typeahead/DifferentialExactUserFunctionDatasource.php
··· 12 12 } 13 13 14 14 public function getDatasourceApplicationClass() { 15 - return 'PhabricatorDifferentialApplication'; 15 + return 'PhabricatorPeopleApplication'; 16 16 } 17 17 18 18 public function getComponentDatasources() {