source: Dev/trunk/createObject.php @ 228

Last change on this file since 228 was 218, checked in by fpvanagthoven, 13 years ago

Laatste versies van alles!

File size: 1.3 KB
RevLine 
[163]1<?php
2
[165]3require 'classes/master.php'; //should be at top of every page
[163]4
[165]5if (isset($_POST['objectToCreate'])) {
6    if (!empty($_POST['objectToCreate'])) {
7        $otc = $_POST['objectToCreate'];
[185]8    } else {
[166]9        //die ("Invalid arguments passed!");
[165]10    }
[185]11} else {
[166]12    //die ("No arguments passed!");
[165]13}
[163]14
[165]15$dbi = new DatabaseInterface();
[191]16$creator_results = $dbi->get("User", array("uid" => $_SESSION['userUid']));
17$creator = $creator_results[0];
[188]18
[191]19if (!$creator) {
20    die("Stuff is broke, yo!");
[165]21}
22
23$uid = null;
24switch (strtolower($otc)) {
25    case "application":
26        $newApp = new Application(null, "New application", "Default description", "Default style");
27        $dbi->set($newApp);
28        $uid = $newApp->uid;
29        break;
30    case "survey":
31        $newSurvey = new Survey(null, "New Survey", "Default description", $creator, null);
32        $dbi->set($newSurvey);
33        $uid = $newSurvey->uid;
34        break;
35    case "dashboard":
36        //TODO
37        break;
[185]38    case "question":
39        $newQuestion = new Question(null, "new Question", "int", "Default description", "Standard category", array());
40        $dbi->set($newQuestion);
41        $uid = $newQuestion->uid;
42        break;
[165]43    default:
[166]44        //die ("Variable \$otc: $otc does not match a compatible object type!");
[165]45        break;
46}
47
48echo $uid;
[163]49?>
Note: See TracBrowser for help on using the repository browser.