2012-06-29 18:17:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Remove maniphest.find, then make this final.
|
|
|
|
*
|
|
|
|
* @concrete-extensible
|
|
|
|
*/
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
class ManiphestQueryConduitAPIMethod extends ManiphestConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'maniphest.query';
|
|
|
|
}
|
2012-06-29 18:17:19 +02:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Execute complex searches for Maniphest tasks.';
|
2012-06-29 18:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
$statuses = array(
|
|
|
|
ManiphestTaskQuery::STATUS_ANY,
|
|
|
|
ManiphestTaskQuery::STATUS_OPEN,
|
|
|
|
ManiphestTaskQuery::STATUS_CLOSED,
|
|
|
|
ManiphestTaskQuery::STATUS_RESOLVED,
|
|
|
|
ManiphestTaskQuery::STATUS_WONTFIX,
|
|
|
|
ManiphestTaskQuery::STATUS_INVALID,
|
|
|
|
ManiphestTaskQuery::STATUS_SPITE,
|
|
|
|
ManiphestTaskQuery::STATUS_DUPLICATE,
|
|
|
|
);
|
2014-05-15 06:59:03 +02:00
|
|
|
$status_const = $this->formatStringConstants($statuses);
|
2012-06-29 18:17:19 +02:00
|
|
|
|
2012-07-23 18:14:45 +02:00
|
|
|
$orders = array(
|
|
|
|
ManiphestTaskQuery::ORDER_PRIORITY,
|
|
|
|
ManiphestTaskQuery::ORDER_CREATED,
|
|
|
|
ManiphestTaskQuery::ORDER_MODIFIED,
|
|
|
|
);
|
2014-05-15 06:59:03 +02:00
|
|
|
$order_const = $this->formatStringConstants($orders);
|
2012-07-23 18:14:45 +02:00
|
|
|
|
2012-06-29 18:17:19 +02:00
|
|
|
return array(
|
2012-11-01 18:47:45 +01:00
|
|
|
'ids' => 'optional list<uint>',
|
|
|
|
'phids' => 'optional list<phid>',
|
|
|
|
'ownerPHIDs' => 'optional list<phid>',
|
|
|
|
'authorPHIDs' => 'optional list<phid>',
|
|
|
|
'projectPHIDs' => 'optional list<phid>',
|
|
|
|
'ccPHIDs' => 'optional list<phid>',
|
2012-07-23 18:14:45 +02:00
|
|
|
'fullText' => 'optional string',
|
2012-06-29 18:17:19 +02:00
|
|
|
|
2014-05-15 06:59:03 +02:00
|
|
|
'status' => 'optional '.$status_const,
|
|
|
|
'order' => 'optional '.$order_const,
|
2012-06-29 18:17:19 +02:00
|
|
|
|
|
|
|
'limit' => 'optional int',
|
|
|
|
'offset' => 'optional int',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'list';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
2014-07-10 00:12:48 +02:00
|
|
|
return array();
|
2012-06-29 18:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$query = new ManiphestTaskQuery();
|
|
|
|
|
2013-09-10 16:44:22 +02:00
|
|
|
$query->setViewer($request->getUser());
|
|
|
|
|
2012-11-01 18:47:45 +01:00
|
|
|
$task_ids = $request->getValue('ids');
|
|
|
|
if ($task_ids) {
|
2013-09-10 16:47:55 +02:00
|
|
|
$query->withIDs($task_ids);
|
2012-11-01 18:47:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$task_phids = $request->getValue('phids');
|
|
|
|
if ($task_phids) {
|
2013-09-10 16:47:55 +02:00
|
|
|
$query->withPHIDs($task_phids);
|
2012-11-01 18:47:45 +01:00
|
|
|
}
|
|
|
|
|
2012-06-29 18:17:19 +02:00
|
|
|
$owners = $request->getValue('ownerPHIDs');
|
|
|
|
if ($owners) {
|
|
|
|
$query->withOwners($owners);
|
|
|
|
}
|
|
|
|
|
|
|
|
$authors = $request->getValue('authorPHIDs');
|
|
|
|
if ($authors) {
|
|
|
|
$query->withAuthors($authors);
|
|
|
|
}
|
|
|
|
|
|
|
|
$projects = $request->getValue('projectPHIDs');
|
|
|
|
if ($projects) {
|
2012-10-05 00:31:04 +02:00
|
|
|
$query->withAllProjects($projects);
|
2012-06-29 18:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$ccs = $request->getValue('ccPHIDs');
|
|
|
|
if ($ccs) {
|
|
|
|
$query->withSubscribers($ccs);
|
|
|
|
}
|
|
|
|
|
2012-07-23 18:14:45 +02:00
|
|
|
$full_text = $request->getValue('fullText');
|
|
|
|
if ($full_text) {
|
|
|
|
$query->withFullTextSearch($full_text);
|
2012-06-29 18:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$status = $request->getValue('status');
|
|
|
|
if ($status) {
|
|
|
|
$query->withStatus($status);
|
|
|
|
}
|
|
|
|
|
2012-07-23 18:14:45 +02:00
|
|
|
$order = $request->getValue('order');
|
|
|
|
if ($order) {
|
|
|
|
$query->setOrderBy($order);
|
|
|
|
}
|
|
|
|
|
2012-06-29 18:17:19 +02:00
|
|
|
$limit = $request->getValue('limit');
|
|
|
|
if ($limit) {
|
|
|
|
$query->setLimit($limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
$offset = $request->getValue('offset');
|
|
|
|
if ($offset) {
|
|
|
|
$query->setOffset($offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
$results = $query->execute();
|
|
|
|
return $this->buildTaskInfoDictionaries($results);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|