source: Dev/branches/jQueryUI/pages_old/createObject.php @ 246

Last change on this file since 246 was 246, checked in by hendrikvanantwerpen, 13 years ago

Created first page mainmenu in new system.
Moved old pages out of project root.
Fixed RDFAPI.php case for people with proper OS'es.

File size: 1.6 KB
RevLine 
[208]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
[233]15
16$creator_results = User::get(array("uid" => $_SESSION['userUid']));
[208]17$creator = $creator_results[0];
18
19//var_dump($creator);
20
21if (!$creator) {
22    die("Stuff is broke, yo!");
23}
24
25$uid = null;
26switch (strtolower($otc)) {
27    case "application":
28        $newApp = new Application(null, "New application", "Default description", "Default style");
[233]29        $newApp->save();
[208]30        $uid = $newApp->uid;
31        break;
32    case "survey":
33        $newSurvey = new Survey(null, "New Survey", "Default description", $creator, null);
[233]34        $newSurvey->save();
[208]35        $uid = $newSurvey->uid;
36        break;
37    case "dashboard":
38        //TODO
39        break;
40    case "question":
[233]41        $newQuestion = new Question(null, "QCode", "new Question", "int", "Default description", "Standard category", array());
42        $newQuestion->save();
[208]43        $uid = $newQuestion->uid;
44        break;
[238]45    case "session":
46        if (isset($_POST['newSessionName']) && !empty($_POST['newSessionName'])) {
47            $newSession = new Session(null, $_POST['newSessionName'], $creator, new DateTime(), null, null);
48            $newSession->save();
49            $uid = $newSession->uid;
50        } else {
51            die("No session name specified!");
52        }
53
54
55        break;
[208]56    default:
57        //die ("Variable \$otc: $otc does not match a compatible object type!");
58        break;
59}
60
61echo $uid;
62?>
Note: See TracBrowser for help on using the repository browser.