source: Dev/branches/Cartis/getInfo.php @ 287

Last change on this file since 287 was 207, checked in by cartis, 13 years ago

Got latest classes from trunk & update 05-12-2012

File size: 3.7 KB
Line 
1<?php
2
3require 'classes/master.php'; //should be at top of every page
4
5if (isset($_POST['uid']) && isset($_POST['type'])) {
6    if (!empty($_POST['uid']) && !empty($_POST['type'])) {
7        $uid = $_POST['uid'];
8        $type = $_POST['type'];
9    } else {
10//$errors[] = "No uid passed!";
11        return;
12    }
13} else {
14//$errors[] = "Wrong call, no uid property in POST data!";
15    return;
16}
17
18$dbi = new DatabaseInterface();
19
20$results = $dbi->get($type, array("uid" => $uid));
21
22if (count($results) > 0) {      // check if DB object exists and assign it to variable
23    if ($results[0] != null) {
24        $returnString = "";
25        $result = $results[0];
26    } else
27        return;
28} else
29    return;
30
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
36switch ($type) {
37    case "Session":
38        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
39        $result->evaluate();
40        $returnString .= "<span class='property'>Created: </span><span class='value'>" . $result->creationdate->format("H:i:s, d-m-Y") . " by " . $result->creator->name . "</span>";
41        $cS = 0; $cD = 0; $cA = 0;
42        foreach ($result->pipeline as $step) {
43            switch (get_class($step)){
44                case "Survey":
45                    $cS++;
46                    break;
47                case "Application":
48                    $cA++;
49                    break;
50                case "Dashboard":
51                    $cD++;
52                    break;
53                default:
54                    //derp?
55                    break;
56            }
57        }
58        $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>";
59        break;
60    case "Survey":
61        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
62        $returnString .= "<span class='property'>Creator: </span><span class='value'>LOLOL ME!!!</span>";
63        $qCount = 0;
64        $qCount = count($result->questions);
65        $returnString .= "<span class='property'>Questions: </span><span class='value'>$qCount</span>";
66        $returnString .= "<span class='property'>Description: </span><span class='value'>$result->description</span>";
67        break;
68    case "Application":
69        $returnString .= "<span class='property'>Title: </span><span class='value'>$result->title</span>";
70        $returnString .= "<span class='property'>Path: </span><span class='value'>C:/folder_of_awesomeness/epicgame.exe</span>";
71        $returnString .= "<span class='property'>Description: </span><span class='value'>$result->description</span>";
72        break;
73    case "Dashboard":
74        break;
75    case "Respondent":
76        break;
77    case "Question":
78        break;
79    case "Answer":
80        break;
81    default:
82        break;
83}
84
85echo $returnString;
86?>
Note: See TracBrowser for help on using the repository browser.