Index: Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- Dev/trunk/classes/pipelineSequencer.php	(revision 161)
+++ Dev/trunk/classes/pipelineSequencer.php	(revision 163)
@@ -15,18 +15,18 @@
     private $loadedSession;
     private $selectedStep;
+    private $dbi;
 
     public function __construct() {
-        //nothing yet
+        $this->dbi = new DatabaseInterface();
     }
 
     public function init() {
         $stringPipeline = "";
-        if (is_array($this->loadedSession->pipeline)){
-        foreach ($this->loadedSession->pipeline as $object) {
-            $stringPipeline .= "$object->uid,";
-        }
-        $stringPipeline = rtrim($stringPipeline, ",");
-        }
-        else {
+        if (is_array($this->loadedSession->pipeline)) {
+            foreach ($this->loadedSession->pipeline as $object) {
+                $stringPipeline .= "$object->uid,";
+            }
+            $stringPipeline = rtrim($stringPipeline, ",");
+        } else {
             $stringPipeline = $this->loadedSession->pipeline;
         }
@@ -83,18 +83,25 @@
     }
 
-    public function GetFromDB($currentSession) {   // Initialize variables on page load.
-        $dbi = new DatabaseInterface();
+    public function LoadSession($currentSession) {   // Initialize variables on page load.
         if (!isset($currentSession)) {
-            $_SESSION['message'] = "No session set!";
             redirect("selectSession.php");
         }
-
-        $sessionResults = $dbi->get("Session", array("uid" => $currentSession));
-        if (count($sessionResults) > 0) {
-            $this->loadedSession = $sessionResults[0];
-        } else {        //No session with that UID found in database!
-            die("Invalid session!");
+        if (isset($_SESSION['updateNeeded'])) {    // user has performed an operation that flags session to be reloaded from DB, or is first load of page for that session
+            $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession));
+            
+            if (count($sessionResults) > 0) {
+                $_SESSION['localSessionCopy'] = $sessionResults[0];
+            } else {
+                die("No session with that UID found!");
+            }
         }
-        var_dump($this->loadedSession->pipeline);
+            var_dump($_SESSION['localSessionCopy']);   
+        
+        if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
+            
+            $this->loadedSession = $_SESSION['localSessionCopy'];
+            unset($_SESSION['updateNeeded']);
+        }
+        
     }
 
@@ -152,4 +159,11 @@
     }
 
+    public function StoreToDb() {
+        if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
+            $this->dbi->set($_SESSION['localSessionCopy']);
+            unset($_SESSION['updateNeeded']);
+        }
+    }
+
 }
 ?>
Index: Dev/trunk/createObject.php
===================================================================
--- Dev/trunk/createObject.php	(revision 163)
+++ Dev/trunk/createObject.php	(revision 163)
@@ -0,0 +1,5 @@
+<?php
+
+
+
+?>
Index: Dev/trunk/createapplication.php
===================================================================
--- Dev/trunk/createapplication.php	(revision 161)
+++ Dev/trunk/createapplication.php	(revision 163)
@@ -9,14 +9,13 @@
 
 $dbi = new DatabaseInterface();
-$session_results = $dbi->get("session", array("uid" => $_SESSION['currentSession']));
-
-if (count($session_results) > 0) {
-    $session = $session_results[0];
-}
 
 $newApplication = new Application(null, "New application", "Default application", "Default style");
 $dbi->set($newApplication);
-$session->pipeline[] = $newApplication->uid;
-//$dbi->set($session);
+
+if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
+    $session = $_SESSION['localSessionCopy'];
+    $session->pipeline[] = $newApplication;
+    $_SESSION['localSessionCopy'] = $session;
+}
 
 redirect("pipelineEditor.php");
Index: Dev/trunk/createsurvey.php
===================================================================
--- Dev/trunk/createsurvey.php	(revision 161)
+++ Dev/trunk/createsurvey.php	(revision 163)
@@ -8,5 +8,5 @@
 
 $dbi = new DatabaseInterface();
-$creator_results = $dbi->get("user", array("name" => $_SESSION['username']));
+$creator_results = $dbi->get("user", array("name" => $_SESSION['username']));   // Determine if user exists, so we can add him/her as creator of the new survey
 if (count($creator_results) > 0) {
     $creator = $creator_results[0];
@@ -18,9 +18,9 @@
 
 // Optional part, for when the session needs to be set in pipelineEditor
-$session_results = $dbi->get("session", array("uid" => $_SESSION['currentSession']));
-if (count($session_results) > 0) {
-    $session = $session_results[0];
+// For now, store in local copy, only upload local copy to db when needed (page change, etc...)
+if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
+    $session = $_SESSION['localSessionCopy'];
     $session->pipeline[] = $newSurvey;
-    $dbi->set($session);
+    $_SESSION['localSessionCopy'] = $session;
 }
 
Index: Dev/trunk/pipelineEditor.php
===================================================================
--- Dev/trunk/pipelineEditor.php	(revision 161)
+++ Dev/trunk/pipelineEditor.php	(revision 163)
@@ -7,5 +7,5 @@
 
 $sequencer = new PipelineSequencer();
-$sequencer->GetFromDB($_SESSION['currentSession']); //load session into php part of the sequencer
+$sequencer->LoadSession($_SESSION['currentSession']); //load session into php part of the sequencer
 $sequencer->HandlePostData();
 ?>
Index: Dev/trunk/returnStep.php
===================================================================
--- Dev/trunk/returnStep.php	(revision 161)
+++ Dev/trunk/returnStep.php	(revision 163)
@@ -40,15 +40,4 @@
 function processUid($uid) {
 	$dbi = new DatabaseInterface();
-    if ($uid == "123") {        // test case for when steps aren't actually working
-        $imageURL = "images/icons/unknowntype.png";
-        $responsePart = '<div class="displayStep" id="' . "123" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';
-        return $responsePart;
-    } else if ($uid == '456') {
-        $imageURL = "images/icons/unknowntype.png";
-        $responsePart = '<div class="displayStep" id="' . "456" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';
-        return $responsePart;
-    } else {
-
-
         if ($uid == "divider") {    //a divider has been requested instead of a displaystep
             $responsePart = '<div class="divider"></div>';
@@ -68,5 +57,5 @@
             }
 
-            if ($result != null) {
+            if ($result == null) {
                 $applications = $dbi->get("Application", array("uid" => $uid));
                 if (count($applications) > 0) {
@@ -79,5 +68,5 @@
             }
 
-            if ($result != null) {
+            if ($result == null) {
                 $dashboards = $dbi->get("Dashboard", array("uid" => $uid));
                 if (count($dashboards) > 0) {
@@ -116,5 +105,5 @@
             }
         }
-    }
+    
 }
 
Index: Dev/trunk/selectSession.php
===================================================================
--- Dev/trunk/selectSession.php	(revision 161)
+++ Dev/trunk/selectSession.php	(revision 163)
@@ -22,5 +22,5 @@
                 // make new session!
                 unset($matching);
-                $session = new Session(null, $_POST['newSessionName'], null, null, null);
+                $session = new Session(null, $_POST['newSessionName'], $_SESSION['username'], new DateTime(), null, null);
                 $dbi->set($session);
             } else {
@@ -44,4 +44,5 @@
         if (count($matching) == 1 && $matching[0] != null) {
             $_SESSION['currentSession'] = $_POST['sessionUID'];
+            $_SESSION['updateNeeded'] = "true";
             redirect("pipelineEditor.php");
         }
@@ -77,9 +78,15 @@
             <?php
                         foreach ($sessions as $session) {
-                            echo '<option value="' . $session->uid . '">' . $session->title . '</option>' . "\n";
+                            $selected = "";
+                            if ($session->title == $_POST['newSessionName']) {
+                                $selected = ' selected="true"';
+                            }
+                            
+                            echo '<option value="' . $session->uid . '"' . $selected . '>' . $session->title . '</option>' . "\n";
                         }
                         ?>                    
                     </select>
                     <br /><br />
+                    <input type="hidden" name="updateNeeded" value="true" />
                     <input type="text" name="newSessionName" value="Name..." style="float: left;" /><br />
                     <input type="submit" name="createSession" value="Create new session" class="surveybutton" style="float: left;" />
