source: Dev/trunk/getInfo.php @ 185

Last change on this file since 185 was 185, checked in by fpvanagthoven, 13 years ago
File size: 3.6 KB
RevLine 
[152]1<?php
2
3require 'classes/master.php'; //should be at top of every page
4
[168]5if (isset($_POST['uid']) && isset($_POST['type'])) {
6    if (!empty($_POST['uid']) && !empty($_POST['type'])) {
[152]7        $uid = $_POST['uid'];
[168]8        $type = $_POST['type'];
[152]9    } else {
[168]10//$errors[] = "No uid passed!";
11        return;
[152]12    }
13} else {
[168]14//$errors[] = "Wrong call, no uid property in POST data!";
15    return;
[152]16}
17
18$dbi = new DatabaseInterface();
19
[168]20$results = $dbi->get($type, array("uid" => $uid));
[152]21
[168]22if (count($results) > 0) {      // check if DB object exists and assign it to variable
[152]23    if ($results[0] != null) {
[178]24        $returnString = "";
[168]25        $result = $results[0];
26    } else
27        return;
28} else
29    return;
[152]30
[185]31// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32// Note: the next part needs to be converted to JSON operation, so that the javascript can easily handle any style changes to the information retrieved. This implementation is just silly.
33// Basic idea: return a JSON array of property: value pairs, then let javascript loop through these properties and format them suitably. This is both more flexible and easier to adjust, as well as resulting in smaller packets.
34// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
[168]36switch ($type) {
37    case "Session":
[178]38        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
39        $returnString .= "<span class='property'>Created: </span><span class='value'>" . $result->datetime->format("H:i:s, d-m-Y") . " by " . $result->creator[0]->name . "</span>";
[168]40        $cS = 0; $cD = 0; $cA = 0;
41        foreach ($result->pipeline as $step) {
42            switch (get_class($step)){
43                case "Survey":
44                    $cS++;
45                    break;
46                case "Application":
47                    $cA++;
48                    break;
49                case "Dashboard":
50                    $cD++;
51                    break;
52                default:
53                    //derp?
54                    break;
55            }
56        }
[178]57        $returnString .= "<span class='property'>Number of steps: </span><span class='value'><ul style='list-style-type: none;'><li style='margin-left: -40px;'>$cS Surveys<li style='margin-left: -40px;'>$cA Applications<li style='margin-left: -40px;'>$cD Dashboards</ul></span>";
[168]58        break;
59    case "Survey":
[178]60        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
61        $returnString .= "<span class='property'>Creator: </span><span class='value'>LOLOL ME!!!</span>";
[168]62        $qCount = 0;
[178]63        $qCount = count($result->questions);
64        $returnString .= "<span class='property'>Questions: </span><span class='value'>$qCount</span>";
65        $returnString .= "<span class='property'>Description: </span><span class='value'>$result->description</span>";
[168]66        break;
67    case "Application":
[178]68        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
69        $returnString .= "<span class='property'>Path: </span><span class='value'>C:/folder_of_awesomeness/epicgame.exe</span>";
70        $returnString .= "<span class='property'>Description: </span><span class='value'>$result->description</span>";
[168]71        break;
72    case "Dashboard":
73        break;
74    case "Respondent":
75        break;
76    case "Question":
77        break;
78    case "Answer":
79        break;
80    default:
81        break;
[152]82}
83
84echo $returnString;
85?>
Note: See TracBrowser for help on using the repository browser.