diff --git a/src/applications/paste/query/PhabricatorPasteQuery.php b/src/applications/paste/query/PhabricatorPasteQuery.php index 5c31b65931..768f0cf20b 100644 --- a/src/applications/paste/query/PhabricatorPasteQuery.php +++ b/src/applications/paste/query/PhabricatorPasteQuery.php @@ -14,6 +14,8 @@ final class PhabricatorPasteQuery private $includeNoLanguage; private $dateCreatedAfter; private $dateCreatedBefore; + private $statuses; + public function withIDs(array $ids) { $this->ids = $ids; @@ -67,6 +69,11 @@ final class PhabricatorPasteQuery return $this; } + public function withStatuses(array $statuses) { + $this->statuses = $statuses; + return $this; + } + public function newResultObject() { return new PhabricatorPaste(); } @@ -139,6 +146,13 @@ final class PhabricatorPasteQuery $this->dateCreatedBefore); } + if ($this->statuses !== null) { + $where[] = qsprintf( + $conn, + 'status IN (%Ls)', + $this->statuses); + } + return $where; } diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php index 935799ae0d..e27445d078 100644 --- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php +++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php @@ -35,6 +35,10 @@ final class PhabricatorPasteSearchEngine $query->withDateCreatedBefore($map['createdEnd']); } + if ($map['statuses']) { + $query->withStatuses($map['statuses']); + } + return $query; } @@ -53,6 +57,12 @@ final class PhabricatorPasteSearchEngine id(new PhabricatorSearchDateField()) ->setKey('createdEnd') ->setLabel(pht('Created Before')), + id(new PhabricatorSearchCheckboxesField()) + ->setKey('statuses') + ->setLabel(pht('Status')) + ->setOptions( + id(new PhabricatorPaste()) + ->getStatusNameMap()), ); } @@ -70,6 +80,7 @@ final class PhabricatorPasteSearchEngine protected function getBuiltinQueryNames() { $names = array( + 'active' => pht('Active Pastes'), 'all' => pht('All Pastes'), ); @@ -86,6 +97,12 @@ final class PhabricatorPasteSearchEngine $query->setQueryKey($query_key); switch ($query_key) { + case 'active': + return $query->setParameter( + 'statuses', + array( + PhabricatorPaste::STATUS_ACTIVE, + )); case 'all': return $query; case 'authored': @@ -151,6 +168,10 @@ final class PhabricatorPasteSearchEngine ->addIcon('none', $line_count) ->appendChild($source_code); + if ($paste->isArchived()) { + $item->setDisabled(true); + } + $lang_name = $paste->getLanguage(); if ($lang_name) { $lang_name = idx($lang_map, $lang_name, $lang_name);