Page MenuHomePhabricator

D18028.diff
No OneTemporary

D18028.diff

diff --git a/src/applications/feed/query/PhabricatorFeedQuery.php b/src/applications/feed/query/PhabricatorFeedQuery.php
--- a/src/applications/feed/query/PhabricatorFeedQuery.php
+++ b/src/applications/feed/query/PhabricatorFeedQuery.php
@@ -89,6 +89,20 @@
return array('key');
}
+ public function getBuiltinOrders() {
+ return array(
+ 'newest' => array(
+ 'vector' => array('key'),
+ 'name' => pht('Creation (Newest First)'),
+ 'aliases' => array('created'),
+ ),
+ 'oldest' => array(
+ 'vector' => array('-key'),
+ 'name' => pht('Creation (Oldest First)'),
+ ),
+ );
+ }
+
public function getOrderableColumns() {
$table = ($this->filterPHIDs ? 'ref' : 'story');
return array(
diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
--- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php
+++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
@@ -11,50 +11,62 @@
return 'PhabricatorFeedApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'userPHIDs',
- $this->readUsersFromRequest($request, 'users'));
-
- $saved->setParameter(
- 'projectPHIDs',
- array_values($request->getArr('projectPHIDs')));
+ public function newQuery() {
+ return new PhabricatorFeedQuery();
+ }
- $saved->setParameter(
- 'viewerProjects',
- $request->getBool('viewerProjects'));
+ protected function shouldShowOrderField() {
+ return false;
+ }
- return $saved;
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorUsersSearchField())
+ ->setLabel(pht('Include Users'))
+ ->setKey('userPHIDs'),
+ // NOTE: This query is not executed with EdgeLogic, so we can't use
+ // a fancy logical datasource.
+ id(new PhabricatorSearchDatasourceField())
+ ->setDatasource(new PhabricatorProjectDatasource())
+ ->setLabel(pht('Include Projects'))
+ ->setKey('projectPHIDs'),
+
+ // NOTE: This is a legacy field retained only for backward
+ // compatibility. If the projects field used EdgeLogic, we could use
+ // `viewerprojects()` to execute an equivalent query.
+ id(new PhabricatorSearchCheckboxesField())
+ ->setKey('viewerProjects')
+ ->setOptions(
+ array(
+ 'self' => pht('Include stories about projects I am a member of.'),
+ )),
+ );
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new PhabricatorFeedQuery());
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
$phids = array();
-
- $user_phids = $saved->getParameter('userPHIDs');
- if ($user_phids) {
- $phids[] = $user_phids;
+ if ($map['userPHIDs']) {
+ $phids += array_fuse($map['userPHIDs']);
}
- $proj_phids = $saved->getParameter('projectPHIDs');
- if ($proj_phids) {
- $phids[] = $proj_phids;
+ if ($map['projectPHIDs']) {
+ $phids += array_fuse($map['projectPHIDs']);
}
- $viewer_projects = $saved->getParameter('viewerProjects');
+ // NOTE: This value may be `true` for older saved queries, or
+ // `array('self')` for newer ones.
+ $viewer_projects = $map['viewerProjects'];
if ($viewer_projects) {
$viewer = $this->requireViewer();
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withMemberPHIDs(array($viewer->getPHID()))
->execute();
- $phids[] = mpull($projects, 'getPHID');
+ $phids += array_fuse(mpull($projects, 'getPHID'));
}
- $phids = array_mergev($phids);
if ($phids) {
$query->withFilterPHIDs($phids);
}
@@ -62,36 +74,6 @@
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved_query) {
-
- $user_phids = $saved_query->getParameter('userPHIDs', array());
- $proj_phids = $saved_query->getParameter('projectPHIDs', array());
- $viewer_projects = $saved_query->getParameter('viewerProjects');
-
- $form
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
- ->setName('users')
- ->setLabel(pht('Include Users'))
- ->setValue($user_phids))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorProjectDatasource())
- ->setName('projectPHIDs')
- ->setLabel(pht('Include Projects'))
- ->setValue($proj_phids))
- ->appendChild(
- id(new AphrontFormCheckboxControl())
- ->addCheckbox(
- 'viewerProjects',
- 1,
- pht('Include stories about projects I am a member of.'),
- $viewer_projects));
- }
-
protected function getURI($path) {
return '/feed/'.$path;
}
@@ -117,7 +99,7 @@
case 'all':
return $query;
case 'projects':
- return $query->setParameter('viewerProjects', true);
+ return $query->setParameter('viewerProjects', array('self'));
}
return parent::buildSavedQueryFromBuiltin($query_key);

File Metadata

Mime Type
text/plain
Expires
Mon, Jun 10, 7:50 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6304834
Default Alt Text
D18028.diff (5 KB)

Event Timeline