Path: blob/master/src/applications/conpherence/conduit/ConpherenceQueryTransactionConduitAPIMethod.php
12256 views
<?php12final class ConpherenceQueryTransactionConduitAPIMethod3extends ConpherenceConduitAPIMethod {45public function getAPIMethodName() {6return 'conpherence.querytransaction';7}89public function getMethodDescription() {10return pht(11'Query for transactions for the logged in user within a specific '.12'Conpherence room. You can specify the room by ID or PHID. '.13'Otherwise, specify limit and offset to query the most recent '.14'transactions within the Conpherence room for the logged in user.');15}1617protected function defineParamTypes() {18return array(19'roomID' => 'optional int',20'roomPHID' => 'optional phid',21'limit' => 'optional int',22'offset' => 'optional int',23);24}2526protected function defineReturnType() {27return 'nonempty dict';28}2930protected function defineErrorTypes() {31return array(32'ERR_USAGE_NO_ROOM_ID' => pht(33'You must specify a room id or room PHID to query transactions '.34'from.'),35);36}3738protected function execute(ConduitAPIRequest $request) {39$user = $request->getUser();40$room_id = $request->getValue('roomID');41$room_phid = $request->getValue('roomPHID');42$limit = $request->getValue('limit');43$offset = $request->getValue('offset');4445$query = id(new ConpherenceThreadQuery())46->setViewer($user);4748if ($room_id) {49$query->withIDs(array($room_id));50} else if ($room_phid) {51$query->withPHIDs(array($room_phid));52} else {53throw new ConduitException('ERR_USAGE_NO_ROOM_ID');54}5556$conpherence = $query->executeOne();5758$query = id(new ConpherenceTransactionQuery())59->setViewer($user)60->withObjectPHIDs(array($conpherence->getPHID()))61->setLimit($limit)62->setOffset($offset);6364$transactions = $query->execute();6566$data = array();67foreach ($transactions as $transaction) {68$comment = null;69$comment_obj = $transaction->getComment();70if ($comment_obj) {71$comment = $comment_obj->getContent();72}73$title = null;74$title_obj = $transaction->getTitle();75if ($title_obj) {76$title = $title_obj->getHTMLContent();77}78$id = $transaction->getID();79$data[$id] = array(80'transactionID' => $id,81'transactionType' => $transaction->getTransactionType(),82'transactionTitle' => $title,83'transactionComment' => $comment,84'transactionOldValue' => $transaction->getOldValue(),85'transactionNewValue' => $transaction->getNewValue(),86'transactionMetadata' => $transaction->getMetadata(),87'authorPHID' => $transaction->getAuthorPHID(),88'dateCreated' => $transaction->getDateCreated(),89'roomID' => $conpherence->getID(),90'roomPHID' => $conpherence->getPHID(),91);92}93return $data;94}9596}979899