diff --git a/src/applications/feed/query/PhabricatorFeedTransactionQuery.php b/src/applications/feed/query/PhabricatorFeedTransactionQuery.php --- a/src/applications/feed/query/PhabricatorFeedTransactionQuery.php +++ b/src/applications/feed/query/PhabricatorFeedTransactionQuery.php @@ -4,6 +4,7 @@ extends PhabricatorCursorPagedPolicyAwareQuery { private $phids; + private $authorPHIDs; private $createdMin; private $createdMax; @@ -12,6 +13,11 @@ return $this; } + public function withAuthorPHIDs(array $phids) { + $this->authorPHIDs = $phids; + return $this; + } + public function withDateCreatedBetween($min, $max) { $this->createdMin = $min; $this->createdMax = $max; @@ -59,6 +65,7 @@ $created_max = $this->createdMax; $xaction_phids = $this->phids; + $author_phids = $this->authorPHIDs; foreach ($queries as $query) { $query->withDateCreatedBetween($created_min, $created_max); @@ -67,6 +74,10 @@ $query->withPHIDs($xaction_phids); } + if ($author_phids !== null) { + $query->withAuthorPHIDs($author_phids); + } + if ($limit !== null) { $query->setLimit($limit); } diff --git a/src/applications/feed/query/PhabricatorFeedTransactionSearchEngine.php b/src/applications/feed/query/PhabricatorFeedTransactionSearchEngine.php --- a/src/applications/feed/query/PhabricatorFeedTransactionSearchEngine.php +++ b/src/applications/feed/query/PhabricatorFeedTransactionSearchEngine.php @@ -16,12 +16,44 @@ } protected function buildCustomSearchFields() { - return array(); + return array( + id(new PhabricatorUsersSearchField()) + ->setLabel(pht('Authors')) + ->setKey('authorPHIDs') + ->setAliases(array('author', 'authors')), + id(new PhabricatorSearchDateField()) + ->setLabel(pht('Created After')) + ->setKey('createdStart'), + id(new PhabricatorSearchDateField()) + ->setLabel(pht('Created Before')) + ->setKey('createdEnd'), + ); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); + if ($map['authorPHIDs']) { + $query->withAuthorPHIDs($map['authorPHIDs']); + } + + $created_min = $map['createdStart']; + $created_max = $map['createdEnd']; + + if ($created_min && $created_max) { + if ($created_min > $created_max) { + throw new PhabricatorSearchConstraintException( + pht( + 'The specified "Created Before" date is earlier in time than the '. + 'specified "Created After" date, so this query can never match '. + 'any results.')); + } + } + + if ($created_min || $created_max) { + $query->withDateCreatedBetween($created_min, $created_max); + } + return $query; } @@ -93,7 +125,7 @@ $table = id(new AphrontTableView($rows)) ->setHeaders( array( - pht('Actor'), + pht('Author'), pht('Object'), pht('Transaction'), pht('Date'),