Changeset 168 for Dev/trunk/getInfo.php
- Timestamp:
- 11/29/11 17:26:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/getInfo.php
r152 r168 3 3 require 'classes/master.php'; //should be at top of every page 4 4 5 /* 6 * Add extra POST variable in functions using this php return, describing object type. 7 * This makes it easier to decide what properties to echo and also to query the database. 8 * (Prevents repetitive session->query->question->application->user->respondent->etc queries!) 9 */ 10 11 if (isset($_POST['uid'])) { 12 if (!empty($_POST['uid'])) { 5 if (isset($_POST['uid']) && isset($_POST['type'])) { 6 if (!empty($_POST['uid']) && !empty($_POST['type'])) { 13 7 $uid = $_POST['uid']; 8 $type = $_POST['type']; 14 9 } else { 15 //$errors[] = "No uid passed!"; 10 //$errors[] = "No uid passed!"; 11 return; 16 12 } 17 13 } else { 18 //$errors[] = "Wrong call, no uid property in POST data!"; 14 //$errors[] = "Wrong call, no uid property in POST data!"; 15 return; 19 16 } 20 17 21 18 $dbi = new DatabaseInterface(); 22 19 23 // For the moment only supports sessions as object to get information for! 24 $results = $dbi->get("Session", array("uid" => $uid)); 20 $results = $dbi->get($type, array("uid" => $uid)); 25 21 26 if (count($results) > 0) { 22 if (count($results) > 0) { // check if DB object exists and assign it to variable 27 23 if ($results[0] != null) { 28 $returnString = ""; 24 $returnString = "<table border='0'>"; 25 $result = $results[0]; 26 } else 27 return; 28 } else 29 return; 29 30 30 $result = $results[0]; 31 $returnString = $returnString . "Title: $result->title. <br />"; 32 $length = count($result->pipeline); 33 $returnString = $returnString . "Number of steps: $length <br />"; 34 $returnString = $returnString . "UID: $uid"; 35 } else { 36 $returnString = "Null error!"; 37 } 38 } else { 39 $returnString = "Non-existing uid!"; 31 switch ($type) { 32 case "Session": 33 $returnString .= "<tr> <td>Name</td> <td>$result->title</td> </tr>"; 34 $returnString .= "<tr><td>Created</td><td>" . $result->datetime->format("H:i:s, d-m-Y") . " by " . $result->creator[0]->name . "</td></tr>"; 35 $cS = 0; $cD = 0; $cA = 0; 36 foreach ($result->pipeline as $step) { 37 switch (get_class($step)){ 38 case "Survey": 39 $cS++; 40 break; 41 case "Application": 42 $cA++; 43 break; 44 case "Dashboard": 45 $cD++; 46 break; 47 default: 48 //derp? 49 break; 50 } 51 } 52 $returnString .= "<tr><td>Number of steps</td><td><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></td></tr>"; 53 break; 54 case "Survey": 55 $returnString .= "<tr> <td>Name</td><td>$result->title</td> </tr>"; 56 $returnString .= "<tr> <td>Creator</td> <td>LOLOL ME!!!</td> </tr>"; 57 $qCount = 0; 58 foreach ($result->questions as $q) { 59 $qCount++; 60 } 61 $returnString .= "<tr> <td>Questions</td> <td>$qCount</td> </tr>"; 62 $returnString .= "<tr> <td>Description</td> <td>$result->description</td> </tr>"; 63 64 break; 65 case "Application": 66 $returnString .= "<tr> <td>Name</td> <td>$result->title</td> </tr>"; 67 $returnString .= "<tr> <td>Location</td> <td>C:/folder_of_awesomeness/epicgame.exe</td> </tr>"; 68 $returnString .= "<tr> <td>Description</td> <td>$result->description</td> </tr>"; 69 break; 70 case "Dashboard": 71 break; 72 case "Respondent": 73 break; 74 case "Question": 75 break; 76 case "Answer": 77 break; 78 default: 79 break; 40 80 } 41 81 82 $returnString .= "</table>"; 42 83 echo $returnString; 43 84 ?>
Note: See TracChangeset
for help on using the changeset viewer.