public function channels_get(GalaxyContext $context) { $options = array('default' => GalaxyAPI::databaseForId($context->application)); $channels = GalaxyAPI::database(GalaxyAPIConstants::kDatabaseMongoDB, GalaxyAPIConstants::kDatabaseChannels, $options); $result = $channels->find(); $data = array(); foreach ($result as $channel) { $data[] = array('id' => $channel['_id'], 'type' => $channel['type'], 'label' => $channel['label'], 'description' => $channel['description'], 'source' => array('id' => $channel['application'], 'description' => $context->origin_description, 'domain' => $context->origin_domain), 'requests' => $channel['requests']); } return GalaxyResponse::responseWithData($data); }
public function start() { $request = $this->requestWithCommand($this->command); // API Debugging /* echo "<h3>GalaxyClientConnection - request</h3>\n"; echo $request."\n\n<hr>"; $data = $this->connect($request); echo "<h3>GalaxyClientConnection - response</h3>\n"; echo $data;exit; */ $data = $this->connect($request); $response = GalaxyResponse::responseWithData($data); if ($response->error) { throw new Exception((string) $command . ' Failed with error ' . $response->error['error'] . ': ' . $response->error['reason']); } return $response; }
public function topics_get(GalaxyContext $context) { $options = array('default' => GalaxyAPI::databaseForId($context->application)); $channel = GalaxyAPI::database(GalaxyAPIConstants::kDatabaseMongoDB, GalaxyAPI::databaseForId($context->channel), $options); $result = $channel->find(array('type' => GalaxyAPIConstants::kTypeForumTopic)); $data = array(); foreach ($result as $topic) { $data[] = array('id' => $topic['_id'], 'requests' => $topic['requests'], 'replies' => $topic['replies'], 'title' => $topic['title'], 'author' => $topic['author'], 'source' => $topic['source'], 'last_message' => $topic['last_message'], 'created' => $topic['created'], 'type' => $topic['type']); } return GalaxyResponse::responseWithData($data); }