diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -225,6 +225,8 @@ 'ConduitAPI_phragment_Method' => 'applications/phragment/conduit/ConduitAPI_phragment_Method.php', 'ConduitAPI_phragment_getpatch_Method' => 'applications/phragment/conduit/ConduitAPI_phragment_getpatch_Method.php', 'ConduitAPI_phragment_queryfragments_Method' => 'applications/phragment/conduit/ConduitAPI_phragment_queryfragments_Method.php', + 'ConduitAPI_phrequent_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_Method.php', + 'ConduitAPI_phrequent_query_Method' => 'applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php', 'ConduitAPI_phriction_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_Method.php', 'ConduitAPI_phriction_edit_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_edit_Method.php', 'ConduitAPI_phriction_history_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_history_Method.php', @@ -2898,6 +2900,8 @@ 'ConduitAPI_phragment_Method' => 'ConduitAPIMethod', 'ConduitAPI_phragment_getpatch_Method' => 'ConduitAPI_phragment_Method', 'ConduitAPI_phragment_queryfragments_Method' => 'ConduitAPI_phragment_Method', + 'ConduitAPI_phrequent_Method' => 'ConduitAPIMethod', + 'ConduitAPI_phrequent_query_Method' => 'ConduitAPI_phrequent_Method', 'ConduitAPI_phriction_Method' => 'ConduitAPIMethod', 'ConduitAPI_phriction_edit_Method' => 'ConduitAPI_phriction_Method', 'ConduitAPI_phriction_history_Method' => 'ConduitAPI_phriction_Method', diff --git a/src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php b/src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php new file mode 100644 --- /dev/null +++ b/src/applications/phrequent/conduit/ConduitAPI_phrequent_Method.php @@ -0,0 +1,46 @@ +getID()] = array( + 'id' => $block->getID(), + 'userPHID' => $block->getUserPHID(), + 'objectPHID' => $block->getObjectPHID(), + 'note' => $block->getNote(), + 'dateStarted' => $block->getDateStarted(), + 'dateEnded' => $block->getDateEnded(), + 'dateCreated' => $block->getDateCreated(), + 'dateModified' => $block->getDateModified()); + } + + return $result; + } +} diff --git a/src/applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php b/src/applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php new file mode 100644 --- /dev/null +++ b/src/applications/phrequent/conduit/ConduitAPI_phrequent_query_Method.php @@ -0,0 +1,68 @@ +formatStringConstants( + PhrequentUserTimeQuery::getEndedSearchOptions()); + $order_options = $this->formatStringConstants( + PhrequentUserTimeQuery::getOrderSearchOptions()); + + return array( + 'userPHIDs' => 'optional list', + 'objectPHIDs' => 'optional list', + 'ended' => 'optional '.$ended_options, + 'order' => 'optional '.$order_options); + } + + public function defineReturnType() { + return 'list'; + } + + public function defineErrorTypes() { + return array(); + } + + protected function execute(ConduitAPIRequest $request) { + $query = new PhrequentUserTimeQuery(); + $query->setViewer($request->getUser()); + + $users = $request->getValue('userPHIDs'); + $objects = $request->getValue('objectPHIDs'); + + $ended_options = $query->getEndedSearchOptions(); + $ended = array_search($request->getValue('ended'), $ended_options); + + $order_options = $query->getorderSearchOptions(); + $order = array_search($request->getValue('order'), $order_options); + + if ($users) { + $query->withUserPHIDs($users); + } + + if ($objects) { + $query->withObjectPHIDs($objects); + } + + if ($ended) { + $query->withEnded($ended); + } + + if ($order) { + $query->setOrder($order); + } + + $result = $query->execute(); + + return $this->buildBlockDictionary($result); + } +}