Index: Dev/trunk/classes/Toolbox.php
===================================================================
--- Dev/trunk/classes/Toolbox.php	(revision 164)
+++ Dev/trunk/classes/Toolbox.php	(revision 165)
@@ -20,7 +20,10 @@
                 <div class="title">Toolbox</div>
                 <p>Add new: </p>
-                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Survey'; SubmitToolbox();"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>
+<!--                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Survey'; SubmitToolbox();"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>
                 <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Application'; SubmitToolbox();"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div>
-                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>
+                <div class="creationButton" onClick="document.toolbox.objectToCreate.value = 'Dashboard'; SubmitToolbox();"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>-->
+                <div class="creationButton" onClick="SubmitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>
+                <div class="creationButton" onClick="SubmitToolbox('Application');"><img src="images/icons/application.png" class="buttonIcon"/><p>Application</p></div>
+                <div class="creationButton" onClick="SubmitToolbox('Dashboard');"><img src="images/icons/dashboard.png" class="buttonIcon"/><p>Dashboard</p></div>
                 <input type="hidden" name="objectToCreate" />
 
Index: Dev/trunk/createObject.php
===================================================================
--- Dev/trunk/createObject.php	(revision 164)
+++ Dev/trunk/createObject.php	(revision 165)
@@ -1,5 +1,48 @@
 <?php
 
+require 'classes/master.php'; //should be at top of every page
 
+if (isset($_POST['objectToCreate'])) {
+    if (!empty($_POST['objectToCreate'])) {
+        $otc = $_POST['objectToCreate'];
+    }
+    else {
+        die ("Invalid arguments passed!");
+    }
+}
+else {
+    die ("No arguments passed!");
+}
+
+$dbi = new DatabaseInterface();
+$creator_results = $dbi->get("User", array("name"=>$_SESSION['username']));
+if (count($creator_results) > 0) {
+    $creator = $creator_results[0];
+}
+else {
+    die ("Invalid creator, make sure you are logged in!");
+}
+
+$uid = null;
+switch (strtolower($otc)) {
+    case "application":
+        $newApp = new Application(null, "New application", "Default description", "Default style");
+        $dbi->set($newApp);
+        $uid = $newApp->uid;
+        break;
+    case "survey":
+        $newSurvey = new Survey(null, "New Survey", "Default description", $creator, null);
+        $dbi->set($newSurvey);
+        $uid = $newSurvey->uid;
+        break;
+    case "dashboard":
+        //TODO
+        break;
+    default:
+        die ("Variable \$otc: $otc does not match a compatible object type!");
+        break;
+}
+
+echo $uid;
 
 ?>
Index: Dev/trunk/js/sequencerScripts.js
===================================================================
--- Dev/trunk/js/sequencerScripts.js	(revision 164)
+++ Dev/trunk/js/sequencerScripts.js	(revision 165)
@@ -25,6 +25,27 @@
 }
 
+/*
 function SubmitToolbox() {
     document.forms['toolbox'].submit();
+}
+*/
+function SubmitToolbox(type) {
+    var c = "objectToCreate="+type;
+    var u = "createObject.php";
+    var a = true;
+    var pipeline = document.getElementById("pipelineStringField");
+    var pipelineType = document.getElementById("pipelineTypeField");
+    var pipelineUpdated = document.getElementById("pipelineUpdatedField");
+    
+    newAjaxRequest(c, u, function(result){
+        var resultUid = result.responseText;
+        console.log(resultUid);
+        console.log("lol");
+        console.log(resultUid);
+        pipeline.value += ","+resultUid;
+        pipelineType += ","+type;
+        pipelineUpdated += ",0";
+        updateSequencer();
+    }, a);
 }
 
@@ -138,6 +159,9 @@
  */
 
-function ajaxStepRequest(UIDS) {
+function ajaxStepRequest(UIDS, types) {
     var c = "uids="+UIDS;
+    if (types != "") {
+        c += "&types="+types;
+    }
     var u = "returnStep.php";
     newAjaxRequest(c, u, function(result) {
@@ -158,6 +182,8 @@
     var content = document.getElementById("seqContent");
     var pipeline = document.getElementById("pipelineStringField").value;
+    var pipelineTypes = document.getElementById("pipelineTypeField").value;
     pipeline = pipeline.replace(/,/g , ",divider,");    //regex search for commas, global (repeat), to represent them with visual dividers.
-    ajaxStepRequest(pipeline);
+    pipelineTypes = pipelineTypes.replace(/,/g, ",divider,");
+    ajaxStepRequest(pipeline, pipelineTypes);
 }
 
@@ -261,9 +287,8 @@
         newUpdatedString += plUpdated[i]+",";
     }
-    alert(newUpdatedString+": OLD");
     if (newUpdatedString.substring(newUpdatedString.length-1) == ",") {
         newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1);
     }
-    alert(newUpdatedString+": NEW!");
+    
     
     document.getElementById("pipelineUpdatedField").value = newUpdatedString;
Index: Dev/trunk/returnStep.php
===================================================================
--- Dev/trunk/returnStep.php	(revision 164)
+++ Dev/trunk/returnStep.php	(revision 165)
@@ -12,5 +12,5 @@
 if (isset($_POST['uids'])) {
     if (!empty($_POST['uids'])) {
-        $uids = $_POST['uids'];
+        $sUids = $_POST['uids'];    // string uids
     } else {
         echo "Invalid UIDs passed!";
@@ -21,10 +21,29 @@
 }
 
-$sUids = explode(",", $uids);
+$sTypes = "unknown";    // string types
+if (isset($_POST['types'])) {
+    if (!empty($_POST['types'])) {
+        $sTypes = $_POST['types'];
+    }
+}
+
+$uids = explode(",", $sUids);   // array uids
+if ($sTypes != "unknown") {
+    $types = explode(",", $sTypes);
+}
 $response = "";
 $dbi = new DatabaseInterface();
-foreach ($sUids as $uid) {
-    $response .= processUid($uid);
+
+if (isset($types)) {
+    for ($i = 0; $i < count($uids); $i++) {
+        $response .= processUid($uids[$i], $types[$i]);
+    }
+} else {
+    foreach ($uids as $uid) {
+        $response .= processUid($uid);
+    }
 }
+
+
 
 echo $response;
@@ -36,74 +55,82 @@
  */
 
+function processUid($uid, $type = null) {
+    $dbi = new DatabaseInterface();
 
+    if ($uid == "divider") {    //a divider has been requested instead of a displaystep
+        $responsePart = '<div class="divider"></div>';
+        return $responsePart;
+    }
 
-function processUid($uid) {
-	$dbi = new DatabaseInterface();
-        if ($uid == "divider") {    //a divider has been requested instead of a displaystep
-            $responsePart = '<div class="divider"></div>';
-            return $responsePart;
-        } else {        // an actual step has been requested.
-            
-//Check in order: survey, application, dashboard.
-            $result = null;
-            $resultType = null;
-            $surveys = $dbi->get("Survey", array("uid" => $uid));
-            if (count($surveys) > 0) {
-                if ($surveys[0] != null) {
-                    // A survey exists with the given UID!
-                    $result = $surveys[0];
-                    $resultType = "Survey";
+    $result = null;
+    $resultType = null;
+
+    if ($type != null) {    // Als er een type is gespecificeerd
+        $resultType = $type;
+        $results = $dbi->get($type, array("uid" => $uid));
+        if (count($results) > 0) {
+            $result = $results[0];
+        }
+    }
+
+    // Als er geen type is gespecificeerd, doorloop de queries in de volgorde: Survey, Application, Dashboard
+    else {
+        $surveys = $dbi->get("Survey", array("uid" => $uid));
+        if (count($surveys) > 0) {
+            if ($surveys[0] != null) {
+                // A survey exists with the given UID!
+                $result = $surveys[0];
+                $resultType = "Survey";
+            }
+        }
+
+        if ($result == null) {
+            $applications = $dbi->get("Application", array("uid" => $uid));
+            if (count($applications) > 0) {
+                if ($applications[0] != null) {
+                    // An application exists with the given UID!
+                    $result = $applications[0];
+                    $resultType = "Application";
                 }
             }
+        }
 
-            if ($result == null) {
-                $applications = $dbi->get("Application", array("uid" => $uid));
-                if (count($applications) > 0) {
-                    if ($applications[0] != null) {
-                        // An application exists with the given UID!
-                        $result = $applications[0];
-                        $resultType = "Application";
-                    }
+        if ($result == null) {
+            $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
+            if (count($dashboards) > 0) {
+                if ($dashboards[0] != null) {
+                    // A dashboard exists with the given UID!
+                    $result = $dashboards[0];
+                    $resultType = "Dashboard";
                 }
             }
-
-            if ($result == null) {
-                $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
-                if (count($dashboards) > 0) {
-                    if ($dashboards[0] != null) {
-                        // A dashboard exists with the given UID!
-                        $result = $dashboards[0];
-                        $resultType = "Dashboard";
-                    }
-                }
-            }
+        }
+    }
 
 // If result is still null at this point, the passed UID does not refer to an existing object!
-            if ($result == null || $resultType == null) {
-                echo "Non-existing UID passed!";
-            } else {
+    if ($result == null || $resultType == null) {
+        echo "Non-existing UID passed!";
+    } else {
 
-                // set relevant variables based on the type and properties of the step in question (currently stored in $result)
-                switch (strtolower($resultType)) {
-                    case "survey":
-                        $imageURL = "images/icons/survey.png";
-                        break;
-                    case "dashboard":
-                        $imageURL = "images/icons/dashboard.png";
-                        break;
-                    case "application":
-                        $imageURL = "images/icons/application.png";
-                        break;
-                    default:
-                        $imageURL = "images/icons/unknowntype.png";
-                        break;
-                }
+        // set relevant variables based on the type and properties of the step in question (currently stored in $result)
+        switch (strtolower($resultType)) {
+            case "survey":
+                $imageURL = "images/icons/survey.png";
+                break;
+            case "dashboard":
+                $imageURL = "images/icons/dashboard.png";
+                break;
+            case "application":
+                $imageURL = "images/icons/application.png";
+                break;
+            default:
+                $imageURL = "images/icons/unknowntype.png";
+                break;
+        }
 
 //echo out the HTML markup
-                $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->title . '</div>';
-                return $responsePart;
-            }
-        }
-    
+        $responsePart = '<div class="displayStep" id="' . $result->uid . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->title . '</div>';
+        return $responsePart;
+    }
 }
 
