[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ConpherenceQueryThreadConduitAPIMethod 4 extends ConpherenceConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'conpherence.querythread'; 8 } 9 10 public function getMethodDescription() { 11 return pht( 12 'Query for conpherence threads for the logged in user. '. 13 'You can query by ids or phids for specific conpherence threads. '. 14 'Otherwise, specify limit and offset to query the most recently '. 15 'updated conpherences for the logged in user.'); 16 } 17 18 public function defineParamTypes() { 19 return array( 20 'ids' => 'optional array<int>', 21 'phids' => 'optional array<phids>', 22 'limit' => 'optional int', 23 'offset' => 'optional int', 24 ); 25 } 26 27 public function defineReturnType() { 28 return 'nonempty dict'; 29 } 30 31 public function defineErrorTypes() { 32 return array(); 33 } 34 35 protected function execute(ConduitAPIRequest $request) { 36 $user = $request->getUser(); 37 $ids = $request->getValue('ids', array()); 38 $phids = $request->getValue('phids', array()); 39 $limit = $request->getValue('limit'); 40 $offset = $request->getValue('offset'); 41 42 $query = id(new ConpherenceThreadQuery()) 43 ->setViewer($user) 44 ->needParticipantCache(true) 45 ->needFilePHIDs(true); 46 47 if ($ids) { 48 $conpherences = $query 49 ->withIDs($ids) 50 ->setLimit($limit) 51 ->setOffset($offset) 52 ->execute(); 53 } else if ($phids) { 54 $conpherences = $query 55 ->withPHIDs($phids) 56 ->setLimit($limit) 57 ->setOffset($offset) 58 ->execute(); 59 } else { 60 $participation = id(new ConpherenceParticipantQuery()) 61 ->withParticipantPHIDs(array($user->getPHID())) 62 ->setLimit($limit) 63 ->setOffset($offset) 64 ->execute(); 65 $conpherence_phids = array_keys($participation); 66 $query->withPHIDs($conpherence_phids); 67 $conpherences = $query->execute(); 68 $conpherences = array_select_keys($conpherences, $conpherence_phids); 69 } 70 71 $data = array(); 72 foreach ($conpherences as $conpherence) { 73 $id = $conpherence->getID(); 74 $data[$id] = array( 75 'conpherenceID' => $id, 76 'conpherencePHID' => $conpherence->getPHID(), 77 'conpherenceTitle' => $conpherence->getTitle(), 78 'messageCount' => $conpherence->getMessageCount(), 79 'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(), 80 'filePHIDs' => $conpherence->getFilePHIDs(), 81 'conpherenceURI' => $this->getConpherenceURI($conpherence), 82 ); 83 } 84 return $data; 85 } 86 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |