1 | <?php |
---|
2 | |
---|
3 | require 'classes/master.php'; |
---|
4 | |
---|
5 | //var_dump($_POST); |
---|
6 | if (isset($_POST['args']) && !empty($_POST['args'])) { |
---|
7 | // Get arguments and convert to object |
---|
8 | $input = $_POST['args']; |
---|
9 | $inputDecoded = json_decode($input); |
---|
10 | } else { |
---|
11 | die('DOESNT WORK...'); |
---|
12 | } |
---|
13 | |
---|
14 | $dbi = new DatabaseInterface(); |
---|
15 | $outputArray = array(); |
---|
16 | foreach ($inputDecoded as $request) { |
---|
17 | $results = $dbi->get($request->type, array("uid" => $request->uid)); |
---|
18 | if (isset($results) && !empty($results)) { |
---|
19 | is_array($results) ? $object = $results[0] : $object = $results; |
---|
20 | } |
---|
21 | // We now have the targeted object loaded in memory |
---|
22 | // First add all shared properties |
---|
23 | $objectProperties = array( |
---|
24 | "uid" => $object->uid, |
---|
25 | "title" => $object->title, |
---|
26 | "type" => get_class($object), |
---|
27 | "description" => $object->description |
---|
28 | ); |
---|
29 | // Then add object-specific properties? (E.G. pipeline for sessions, answertype for questions, age for respondents) |
---|
30 | // Nothing so far, though, because data structure changes all the time... |
---|
31 | // Then add the resulting array to the outputArray |
---|
32 | $outputArray[] = $objectProperties; |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | // Encode the output array in JSON format, then send back to the client |
---|
37 | $output = json_encode($outputArray); |
---|
38 | |
---|
39 | die($output); |
---|
40 | ?> |
---|