Rev | Line | |
---|
[163] | 1 | <?php |
---|
| 2 | |
---|
[165] | 3 | require 'classes/master.php'; //should be at top of every page |
---|
[163] | 4 | |
---|
[165] | 5 | if (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(); |
---|
[185] | 16 | $creator_results = $dbi->get("User", array("name" => $_SESSION['username'])); |
---|
[188] | 17 | |
---|
[165] | 18 | if (count($creator_results) > 0) { |
---|
| 19 | $creator = $creator_results[0]; |
---|
[185] | 20 | } else { |
---|
| 21 | //die ("Invalid creator, make sure you are logged in!"); |
---|
[165] | 22 | } |
---|
| 23 | |
---|
| 24 | $uid = null; |
---|
| 25 | switch (strtolower($otc)) { |
---|
| 26 | case "application": |
---|
| 27 | $newApp = new Application(null, "New application", "Default description", "Default style"); |
---|
| 28 | $dbi->set($newApp); |
---|
| 29 | $uid = $newApp->uid; |
---|
| 30 | break; |
---|
| 31 | case "survey": |
---|
| 32 | $newSurvey = new Survey(null, "New Survey", "Default description", $creator, null); |
---|
| 33 | $dbi->set($newSurvey); |
---|
| 34 | $uid = $newSurvey->uid; |
---|
| 35 | break; |
---|
| 36 | case "dashboard": |
---|
| 37 | //TODO |
---|
| 38 | break; |
---|
[185] | 39 | case "question": |
---|
| 40 | $newQuestion = new Question(null, "new Question", "int", "Default description", "Standard category", array()); |
---|
| 41 | $dbi->set($newQuestion); |
---|
| 42 | $uid = $newQuestion->uid; |
---|
| 43 | break; |
---|
[165] | 44 | default: |
---|
[166] | 45 | //die ("Variable \$otc: $otc does not match a compatible object type!"); |
---|
[165] | 46 | break; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | echo $uid; |
---|
[163] | 50 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.