Changeset 168 for Dev/trunk/getInfo.php


Ignore:
Timestamp:
11/29/11 17:26:07 (13 years ago)
Author:
fpvanagthoven
Message:
  • moveStep() [js] werkt weer, editor is nu op delete/clear na helemaal functioneel
  • Zit nog steeds een creator bug in savesession.php en selectSession.php
  • getInfo.php is nu aangepast om voor meerdere objecttypes te werken en relevante informatie terug te geven, geformatteerd als table. De styling hiervan moet wel nog beter geregeld worden.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/getInfo.php

    r152 r168  
    33require 'classes/master.php'; //should be at top of every page
    44
    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'])) {
     5if (isset($_POST['uid']) && isset($_POST['type'])) {
     6    if (!empty($_POST['uid']) && !empty($_POST['type'])) {
    137        $uid = $_POST['uid'];
     8        $type = $_POST['type'];
    149    } else {
    15         //$errors[] = "No uid passed!";
     10//$errors[] = "No uid passed!";
     11        return;
    1612    }
    1713} else {
    18     //$errors[] = "Wrong call, no uid property in POST data!";
     14//$errors[] = "Wrong call, no uid property in POST data!";
     15    return;
    1916}
    2017
    2118$dbi = new DatabaseInterface();
    2219
    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));
    2521
    26 if (count($results) > 0) {
     22if (count($results) > 0) {      // check if DB object exists and assign it to variable
    2723    if ($results[0] != null) {
    28         $returnString = "";
     24        $returnString = "<table border='0'>";
     25        $result = $results[0];
     26    } else
     27        return;
     28} else
     29    return;
    2930
    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!";
     31switch ($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;
    4080}
    4181
     82$returnString .= "</table>";
    4283echo $returnString;
    4384?>
Note: See TracChangeset for help on using the changeset viewer.