Path: blob/master/src/applications/conpherence/conduit/ConpherenceQueryThreadConduitAPIMethod.php
12256 views
<?php12final class ConpherenceQueryThreadConduitAPIMethod3extends ConpherenceConduitAPIMethod {45public function getAPIMethodName() {6return 'conpherence.querythread';7}89public function getMethodDescription() {10return pht(11'Query for Conpherence threads for the logged in user. You can query '.12'by IDs or PHIDs for specific Conpherence threads. Otherwise, specify '.13'limit and offset to query the most recently updated Conpherences for '.14'the logged in user.');15}1617protected function defineParamTypes() {18return array(19'ids' => 'optional array<int>',20'phids' => 'optional array<phids>',21'limit' => 'optional int',22'offset' => 'optional int',23);24}2526protected function defineReturnType() {27return 'nonempty dict';28}2930protected function execute(ConduitAPIRequest $request) {31$user = $request->getUser();32$ids = $request->getValue('ids', array());33$phids = $request->getValue('phids', array());34$limit = $request->getValue('limit');35$offset = $request->getValue('offset');3637$query = id(new ConpherenceThreadQuery())38->setViewer($user);3940if ($ids) {41$conpherences = $query42->withIDs($ids)43->setLimit($limit)44->setOffset($offset)45->execute();46} else if ($phids) {47$conpherences = $query48->withPHIDs($phids)49->setLimit($limit)50->setOffset($offset)51->execute();52} else {53$participation = id(new ConpherenceParticipantQuery())54->withParticipantPHIDs(array($user->getPHID()))55->setLimit($limit)56->setOffset($offset)57->execute();58$conpherence_phids = mpull($participation, 'getConpherencePHID');59$query->withPHIDs($conpherence_phids);60$conpherences = $query->execute();61$conpherences = array_select_keys($conpherences, $conpherence_phids);62}6364$data = array();65foreach ($conpherences as $conpherence) {66$id = $conpherence->getID();67$data[$id] = array(68'conpherenceID' => $id,69'conpherencePHID' => $conpherence->getPHID(),70'conpherenceTitle' => $conpherence->getTitle(),71'messageCount' => $conpherence->getMessageCount(),72'conpherenceURI' => $this->getConpherenceURI($conpherence),73);74}75return $data;76}7778}798081