source: Dev/trunk/createObject.php @ 316

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

Laatste versies van alles!

File size: 1.3 KB
Line 
1<?php
2
3require 'classes/master.php'; //should be at top of every page
4
5if (isset($_POST['objectToCreate'])) {
6    if (!empty($_POST['objectToCreate'])) {
7        $otc = $_POST['objectToCreate'];
8    } else {
9        //die ("Invalid arguments passed!");
10    }
11} else {
12    //die ("No arguments passed!");
13}
14
15$dbi = new DatabaseInterface();
16$creator_results = $dbi->get("User", array("uid" => $_SESSION['userUid']));
17$creator = $creator_results[0];
18
19if (!$creator) {
20    die("Stuff is broke, yo!");
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;
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;
43    default:
44        //die ("Variable \$otc: $otc does not match a compatible object type!");
45        break;
46}
47
48echo $uid;
49?>
Note: See TracBrowser for help on using the repository browser.