source: Dev/trunk/createObject.php @ 165

Last change on this file since 165 was 165, checked in by fpvanagthoven, 13 years ago
File size: 1.1 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    }
9    else {
10        die ("Invalid arguments passed!");
11    }
12}
13else {
14    die ("No arguments passed!");
15}
16
17$dbi = new DatabaseInterface();
18$creator_results = $dbi->get("User", array("name"=>$_SESSION['username']));
19if (count($creator_results) > 0) {
20    $creator = $creator_results[0];
21}
22else {
23    die ("Invalid creator, make sure you are logged in!");
24}
25
26$uid = null;
27switch (strtolower($otc)) {
28    case "application":
29        $newApp = new Application(null, "New application", "Default description", "Default style");
30        $dbi->set($newApp);
31        $uid = $newApp->uid;
32        break;
33    case "survey":
34        $newSurvey = new Survey(null, "New Survey", "Default description", $creator, null);
35        $dbi->set($newSurvey);
36        $uid = $newSurvey->uid;
37        break;
38    case "dashboard":
39        //TODO
40        break;
41    default:
42        die ("Variable \$otc: $otc does not match a compatible object type!");
43        break;
44}
45
46echo $uid;
47
48?>
Note: See TracBrowser for help on using the repository browser.