Index: v/trunk/classes/PipelineSequencer_1.php
===================================================================
--- /Dev/trunk/classes/PipelineSequencer_1.php	(revision 151)
+++ 	(revision )
@@ -1,198 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of Sequencer
- *
- * @author HP
- */
-class PipelineSequencer {
-
-    // properties
-    private $pipeline = array();
-    private $name = "empty";
-    private $numStepsInArray = 0;
-    private $maxNumStepsInArray = 10;
-    private $selectedStep;
-
-    public function __construct($pipeline, $name, $id) {
-        $this->pipeline = $pipeline;
-        $this->name = $name;
-    }
-
-    public function init() {
-        ?>
-        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
-                <div class="title">Name: <?php echo $this->name; ?> </div>
-
-                <div class="seqContent">
-                    <?php $this->DrawSteps(); ?>          
-                </div>
-
-                <div id="controls">
-                    <input type="submit" name="moveSelectedLeft" value="< Move" class="surveyButton" />
-                    <input type="submit" name="moveSelectedRight" value="Move >" class="surveyButton" />
-                    <input type="submit" name="editSelected" value="Edit step" class="surveyButton" />
-                    <input type="submit" name="deleteSelected" value="Delete step" class="surveyButton" />
-                    <input type="submit" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/>
-                    <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
-                    <input type="hidden" name="selectedStep" />
-                </div>
-            </fieldset>
-        </form>
-        <?php
-    }
-
-    public function AddStep($newStep) {
-        $n = 1;
-        foreach ($this->pipeline as $existingStep) {
-            if ($existingStep->name == $newStep . " $n") {
-                $n++;
-            }
-        }
-
-        $this->pipeline[] = new Step($newStep, $newStep . " " . $n, count($this->pipeline) + 1);
-        //var_dump($this->pipeline);
-        ?>
-        <script type="text/javascript">
-            document.refresh();
-        </script>
-        <?php
-    }
-
-    public function RemoveStep($targetStep) {
-
-        $tempArray = array();
-        $removed = false;
-        foreach ($this->pipeline as $step) {
-            if ($step->id != $targetStep) {
-                $tempArray[] = $step;
-                if ($removed) {
-                    $step::AdjustID(-1);
-                }
-            } else {
-                $removed = true;
-            }
-        }
-        $this->pipeline = $tempArray;
-    }
-
-    public function GetPipeline() {
-        return $this->pipeline;
-    }
-
-    public function DrawSteps() {
-        //draw the actual icons in the container div.
-        if (!empty($this->pipeline)) {
-            foreach ($this->pipeline as $step) {
-                if ($this->numStepsInArray < $this->maxNumStepsInArray) {
-                    //var_dump($step);
-                    $step->init();
-                    $this->numStepsInArray++;
-                    if ($this->numStepsInArray < $this->maxNumStepsInArray && $this->numStepsInArray < count($this->pipeline)) {
-                        echo "<div class='divider'></div>";
-                    }
-                }
-            }
-        }
-    }
-
-    public function MoveStep($direction) {
-        $key = array_search($this->selectedStep, $this->pipeline);
-        //echo $key;
-    }
-
-    private function MoveEntry(&$array, $key, $dir) {
-        if ($dir == -1) {   // move up
-            if ($key > 0) {
-                $reverseArray = array_reverse(array_slice($array, $key - 1, 2, true));   // make a reversed array of the two entries, preserving keys
-                array_splice($array, $key - 1, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
-            }
-        } else if ($dir == 1) {   // move down
-            if ($key < count($array) - 1) {
-                $reverseArray = array_reverse(array_slice($array, $key, 2, true));   // make a reversed array of the two entries, preserving keys
-                array_splice($array, $key, 2, $reverseArray);    // replace the given range in the oldArray with the reversed Array
-            }
-        }
-    }
-
-    public function SetSelected($key) {
-
-        if ($key > 0 && $key < count($this->pipeline)) {
-            $this->selectedStep = $key;
-        }
-    }
-
-    public function GetName($name) {
-        if ($name && $name != "") {
-            $this->name = $name;
-        }
-    }
-
-    public function GetFromDB() {
-
-        $dbi = new DatabaseInterface();
-        $this->pipeline = $dbi->get("pipeline", array("uid"=>$uid));
-        //this doesn't actually work, the sequencer doesn't know what the uid is yet. This data should be POSTed upon refresh!
-        
-        
-        
-        if (isset($_POST['destroy'])) {
-            unset($_POST['destroy']);
-            unset($_SESSION['currentPipeline']);
-        }
-
-        if (isset($_POST['clearPipeline'])) {
-            $this->pipeline = array();
-            $_SESSION['currentPipeline'] = $this->pipeline;
-        }
-
-        if (isset($_SESSION['currentPipeline']) && !empty($_SESSION['currentPipeline'])) {      // take pipeline from session data
-            $this->pipeline = $_SESSION['currentPipeline'];
-        } else {
-            $pipeline = array();
-        }
-
-        if (isset($_POST['objectToCreate'])) {      // user clicked a button in the toolbox.
-            //$this->pipeline[] = new Step($_POST['objectToCreate'], $_POST['objectToCreate'] . " NEW", null);
-            $this::AddStep($_POST['objectToCreate']);
-        }
-
-        if (isset($_POST['deleteSelected'])) {
-            if (isset($_POST['selectedStep'])) {
-                $this->RemoveStep($_POST['selectedStep']);
-            }
-        }
-
-        //var_dump($_POST);
-
-        if (isset($_POST['selectedStep'])) {
-            $this::SetSelected($_POST['selectedStep']);
-        }
-
-        $_SESSION['currentPipeline'] = $this->pipeline;
-    }
-
-    private function Javascript() {
-        ?>
-        <!-- 
-        Add JS code for selecting steps, highlighting them, reordering, etc.
-        Is a refresh of the page (with subsequent querying of database really necessary?
-        
-        -->
-        <script type="text/javascript">
-            function selectStep(step) {
-                step.addClass("selected");
-                document.sequencer.controls.selectedStep.value = step.name;
-            }
-        </script>
-
-
-        <?php
-    }
-
-}
-?>
Index: /Dev/trunk/classes/SessionConnector.php
===================================================================
--- /Dev/trunk/classes/SessionConnector.php	(revision 151)
+++ /Dev/trunk/classes/SessionConnector.php	(revision 152)
@@ -60,5 +60,5 @@
 		$uid = ""; $title = ""; $datetime = ""; $applications = ""; $surveys = ""; $answersets = "";
 		if(in_array("uid", $keys))
-			$uid = 'predicates:uid \''.$arguements["uid"].'\' ';
+			$uid = 'predicates:uid \''.$arguments["uid"].'\' ';
 		if(in_array("title", $keys))
 			$title = 'predicates:title \''.$arguments["title"].'\' ';
Index: /Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- /Dev/trunk/classes/pipelineSequencer.php	(revision 151)
+++ /Dev/trunk/classes/pipelineSequencer.php	(revision 152)
@@ -13,13 +13,9 @@
 
     // properties
-    private $pipeline;      // array of UID strings.
-    private $name = "empty";
-    private $numStepsInArray = 0;
-    private $maxNumStepsInArray = 10;
+    private $loadedSession;
     private $selectedStep;
 
-    public function __construct($uid) {
-        $dbi = new DatabaseInterface();
-        $this->pipeline = $dbi->get("pipeline", array("uid" => $uid));
+    public function __construct() {
+        //nothing yet
     }
 
@@ -28,5 +24,5 @@
         <br /><form name="sequencer" action="pipelineEditor.php" method="post">
             <fieldset id="sequencer">
-                <div class="title">Name: <?php echo $this->pipeline->name; ?> </div>
+                <div class="title">Name: <?php echo $this->loadedSession->title; ?> </div>
 
                 <div id="seqContent">
@@ -56,77 +52,22 @@
     private function Javascript() {
         ?>
-        <!-- 
-        Add JS code for selecting steps, highlighting them, reordering, etc.
-        Is a refresh of the page (with subsequent querying of database really necessary?
-
-        -->
-        <script type="text/javascript">
-            function selectStep(uid) {
-                document.getElementById(uid).addClass("selected");
-                document.sequencer.controls.selectedStep.value = uid;
-            }
-                                                                            
-                                                                            
-            /*
-             * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
-             * Using ajax principle allows for editing of pipeline without constantly refreshing the page.
-             */
-                                                                            
-            function ajaxStepRequest(uid) {     
-                var xmlhttp;
-                if (window.XMLHttpRequest) {    // IE7+, FF, Chrome, Opera, Safari
-                    xmlhttp = new XMLHttpRequest();
-                }
-                else {  //IE 5, 6
-                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
-                }
-                                                                                
-                xmlhttp.onreadystatechange = function () {
-                    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
-                        if (xmlhttp.responseText.length > 0) {
-                            var newDiv = xmlhttp.responseText;
-                            document.getElementById("seqContent").appendChild(newDiv);
-                        }   
-                    }
-                }
-                                        
-                xmlhttp.open("POST", "returnStep.php", true);
-                xmlhttp.send();
-            }
-                            
-            function drawSteps() {
-                var sequencer = document.getElementById("sequencer");
-                var seqContent = document.getElementById("seqContent");
-                
-                // first delete all current children of seqContent (to reset the sequencer).
-                while (seqContent.childNodes.length > 0) {
-                    var step = seqContent.childNodes[0];
-                    step.parentNode.removeChild(step);
-                }
-                
-                // get pipeline contents from hidden form inputs.
-                var pipeline = sequencer.controls.pipeline.value;
-                var pipeline = pipeline.split(", ");
-                
-                // then do an xmlhttp request for each step to be added to the sequencer
-                var numberOfSteps = pipeline.length;
-                for (var i = 0; i > numberOfSteps; i++) {
-                    ajaxStepRequest(pipeline[i]);
-                }
-                
-            }
-                                                                                
-                                                
-        </script>
-
+        <script type="text/javascript" src="js/sequencerScripts.js"></script>
 
         <?php
     }
 
-    public function GetDromDB() {   // Initialize variables on page load.
+    public function GetFromDB($currentSession) {   // Initialize variables on page load.
         $dbi = new DatabaseInterface();
-        if (isset($_POST['currentSession'])) {
-            $currentSession = $dbi->get("Session", array("UID" => $uid));
-            $this->pipeline = $currentSession->pipeline;
+        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 {
+            die("Invalid session!");
         }
     }
Index: /Dev/trunk/getInfo.php
===================================================================
--- /Dev/trunk/getInfo.php	(revision 152)
+++ /Dev/trunk/getInfo.php	(revision 152)
@@ -0,0 +1,43 @@
+<?php
+
+require 'classes/master.php'; //should be at top of every page
+
+/*
+ * Add extra POST variable in functions using this php return, describing object type.
+ * This makes it easier to decide what properties to echo and also to query the database.
+ * (Prevents repetitive session->query->question->application->user->respondent->etc queries!)
+ */
+
+if (isset($_POST['uid'])) {
+    if (!empty($_POST['uid'])) {
+        $uid = $_POST['uid'];
+    } else {
+        //$errors[] = "No uid passed!";
+    }
+} else {
+    //$errors[] = "Wrong call, no uid property in POST data!";
+}
+
+$dbi = new DatabaseInterface();
+
+// For the moment only supports sessions as object to get information for!
+$results = $dbi->get("Session", array("uid" => $uid));
+
+if (count($results) > 0) {
+    if ($results[0] != null) {
+        $returnString = "";
+
+        $result = $results[0];
+        $returnString = $returnString . "Title: $result->title. <br />";
+        $length = count($result->pipeline);
+        $returnString = $returnString .  "Number of steps: $length <br />";
+        $returnString = $returnString . "UID: $uid";
+    } else {
+        $returnString = "Null error!";
+    }
+} else {
+    $returnString = "Non-existing uid!";
+}
+
+echo $returnString;
+?>
Index: /Dev/trunk/index.php
===================================================================
--- /Dev/trunk/index.php	(revision 151)
+++ /Dev/trunk/index.php	(revision 152)
@@ -56,5 +56,5 @@
 
 if (isset($_SESSION['username'])) {
-    redirect('pipelineEditor.php');
+    redirect('selectSession.php');
 }
 ?>
Index: /Dev/trunk/js/sequencerScripts.js
===================================================================
--- /Dev/trunk/js/sequencerScripts.js	(revision 151)
+++ /Dev/trunk/js/sequencerScripts.js	(revision 152)
@@ -29,45 +29,130 @@
 }
 
-
-
-/*
- * Selection code
- * 
- */
-
-function checkSelectedStep(number){
-    document.sequencer.selectedStep.value = number;
-    var step = document.getElementById("seqContent")
-    document.refresh();
-}
-
-function highlightSelectedStep() {
-    
-}
-
-
-
-
-
-
-
-
-
-
 // Class manipulation
 
 function hasClass(ele,cls) {
-	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
+    return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
 }
  
 function addClass(ele,cls) {
-	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
+    if (!this.hasClass(ele,cls)) ele.className += " "+cls;
 }
  
 function removeClass(ele,cls) {
-	if (hasClass(ele,cls)) {
-    	var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
-		ele.className=ele.className.replace(reg,' ');
-	}
+    if (hasClass(ele,cls)) {
+        var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
+        ele.className=ele.className.replace(reg,' ');
+    }
 }
 
+//new scripts!
+//start here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+function selectStep(uid) {
+    document.getElementById(uid).addClass("selected");
+    document.sequencer.controls.selectedStep.value = uid;
+}
+                                                                            
+                                                                            
+/*
+ * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
+ * Using ajax principle allows for editing of pipeline without constantly refreshing the page.
+ */
+
+function ajaxStepRequest(UID) {
+    var c = "uid="+UID;
+    var u = "returnStep.php";
+    newAjaxRequest(c, u, function(result) {
+        var newDiv = result.responseText;
+        document.getElementById("seqContent").appendChild(newDiv);
+    });
+}
+
+function ajaxInfoRequest(id, el) {
+    var uid = id;
+    var c = "uid="+uid;
+    var u = "getInfo.php";
+    newAjaxRequest(c, u, function(result) {
+        el.innerHTML = result.responseText;
+    });
+}
+
+/*
+ * This function allows for simple use of AJAX requests.
+ * Calling format:
+ * 
+ * var c[] = "uid=123";
+ *  var c[] = "name=tschipper";
+ *  var u = "getResult.php";
+ *  newAjaxRequest(c, u, function(xml) {
+ *      <!--Do something-->
+ *  });
+ *  
+ *  It is of course also possible to refer to an external function instead of 
+ *  defining function(xml){} in the call itself, as below:
+ *  
+ *  newAjaxRequest(c, u, externalFunction(xml));
+ */
+
+function newAjaxRequest(c, u, cb) {
+    
+    var xml;
+    var content = c;    //an array of strings, in "key=value"  format.
+    // assign a compatible request format
+    if (window.XMLHttpRequest) {    //Not IE5, IE6
+        xml = new XMLHttpRequest();
+    }
+    else {                          //IE5, IE6
+        xml = new ActiveXObject("Microsoft.XMLHTTP");
+    }
+    // subscribe the callback function to a response event
+    xml.onreadystatechange = function() {
+        if (xml.readyState == 4 && xml.status == 200) {
+            //alert("Received!");
+            cb(xml);
+        }
+    };
+    // initialize XMLRequest
+    xml.open("POST", u, true);
+    xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+    var contentString = "";
+    //iterate through parameters passed in variable c
+    if (typeof(content)=='object'&&(input instanceof Array)) {    // parameters were passed as an array of key=value strings
+        for (var i = 0; i < content.length; i++) {
+            contentString += content[i];
+            if (i != (content.length - 1)) {
+                contentString += "&";
+            }
+        }
+    }
+    else {                      // single parameter or string already formatted by calling function
+        contentString = content;
+    }
+    // finally send the formatted request
+    //alert(contentString);
+    xml.send(contentString);
+}
+                            
+
+function drawSteps() {
+    var sequencer = document.getElementById("sequencer");
+    var seqContent = document.getElementById("seqContent");
+                
+    // first delete all current children of seqContent (to reset the sequencer).
+    while (seqContent.childNodes.length > 0) {
+        var step = seqContent.childNodes[0];
+        step.parentNode.removeChild(step);
+    }
+                
+    // get pipeline contents from hidden form inputs.
+    var pipeline = sequencer.controls.pipeline.value;
+    var pipeline = pipeline.split(", ");
+                
+    // then do an xmlhttp request for each step to be added to the sequencer
+    var numberOfSteps = pipeline.length;
+    for (var i = 0; i > numberOfSteps; i++) {
+        ajaxStepRequest(pipeline[i]);
+    }
+                
+}
+
Index: /Dev/trunk/logout.php
===================================================================
--- /Dev/trunk/logout.php	(revision 151)
+++ /Dev/trunk/logout.php	(revision 152)
@@ -6,5 +6,5 @@
 require 'classes/master.php';
 
-unset($_SESSION['username']);
+session_destroy();
 redirect("index.php");
 ?>
Index: /Dev/trunk/pipelineEditor.php
===================================================================
--- /Dev/trunk/pipelineEditor.php	(revision 151)
+++ /Dev/trunk/pipelineEditor.php	(revision 152)
@@ -3,28 +3,10 @@
 
 if (!isset($_SESSION['username'])) {
+    $_SESSION['message'] = "You were redirected here because your session timed out or you used an invalid link.";
     redirect('index.php');
 }
 
-$dbtemp = new DatabaseInterface();
-
-
-if (!isset($_SESSION['currentSession'])) {
-    redirect('selectSession.php');
-}
-
-$dbi = new DatabaseInterface();
-$sessions = $dbi->get("session", array("user"=>$_SESSION['username']));
-
-
-
-
-
-if (isset($_SESSION['currentPipeline'])) {
-    $sequencer = new PipelineSequencer($_SESSION['currentPipeline'], "Test Pipeline #1", 1);
-} else {
-    $sequencer = new PipelineSequencer(null, "Test Pipeline #1", 1);
-}
-
-$sequencer->HandlePost();    // doesn't actually currently get from db, uses session/post as a temporary alternative.
+$sequencer = new PipelineSequencer();
+$sequencer->GetFromDB($_SESSION['currentSession']);
 ?>
 
@@ -39,5 +21,5 @@
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <title></title>
-<?php new StyleSheet("awesome"); ?>
+        <?php new StyleSheet("awesome"); ?>
         <script type="text/javascript" src="js/menu.js"></script>
         <script type="text/javascript" src="js/jquery.jps"></script>
@@ -46,11 +28,11 @@
     <body>
         <div id="header">
-<?php new Logo(); ?>
+            <?php new Logo(); ?>
         </div>
 
         <div id="wrapper">
             <div id="content">
-<?php $sequencer->init(); ?>
-<?php $toolbox = new Toolbox(); ?>
+                <?php $sequencer->init(); ?>
+                <?php $toolbox = new Toolbox(); ?>
             </div>
     </body>
Index: /Dev/trunk/selectSession.php
===================================================================
--- /Dev/trunk/selectSession.php	(revision 151)
+++ /Dev/trunk/selectSession.php	(revision 152)
@@ -5,5 +5,12 @@
     redirect("index.php");
 }
+
+if (isset($_SESSION['message'])) {
+    echo $_SESSION['message'];
+    unset($_SESSION['message']);
+}
+
 $dbi = new DatabaseInterface();
+
 if (isset($_POST['createSession'])) {
     //check if name is set
@@ -11,7 +18,8 @@
         // check if name is available
         if (!empty($_POST['newSessionName'])) {
-            $matchingNames = $dbi->get("Session", array("title" => $_POST['newSessionName']));
-            if (count($matchingNames) == 0) {
+            $matching = $dbi->get("Session", array("title" => $_POST['newSessionName']));
+            if (count($matching) == 0) {
                 // make new session!
+                unset($matching);
                 $session = new Session(null, $_POST['newSessionName'], null, null, null);
                 $dbi->set($session);
@@ -25,8 +33,24 @@
 }
 
+if (isset($_POST['deleteSession'])) {
+    if (isset($_POST['sessionUID'])) {
+        //Kan de database al objecten verwijderen?
+    }
+}
+
+if (isset($_POST['editSession'])) {
+    if (isset($_POST['sessionUID'])) {
+        $matching = $dbi->get("SESSION", array("uid" => $_POST['sessionUID']));
+        if (count($matching) == 1 && $matching[0] != null) {
+            $_SESSION['currentSession'] = $_POST['sessionUID'];
+            redirect("pipelineEditor.php");
+        }
+    }
+}
+
 //Get available sessions for current user
-//$sessions = $dbi->get("Session", array("creator"=>$_SESSION['username']));  //Dit werkt niet, SessionConnector/Session.php hebben nog geen creator property
-$sessions = $dbi->get("Session", array());  // In plaats daarvan maar gewoon alles laden dan... lol
-var_dump($sessions);
+//$sessions = $dbi->get("Session", array("creator"=>$_SESSION['username']));  //This does not work, session.php does not yet have a property 'creator'
+$sessions = $dbi->get("Session", array());  // Let's just load everything then...
+//var_dump($sessions);
 ?>
 
@@ -37,12 +61,14 @@
         <title>Select a session</title>
         <?php new StyleSheet("awesome"); ?>
+        <script type="text/javascript" src="js/sequencerScripts.js"></script>
     </head>
     <body>
         <form action="selectSession.php" method="POST">
             <fieldset name="selectionMenu">
-                <select name="sessionName" style="float: left;">
+                <!-- onchange van volgende select linkt deze aan de ajax-based info panel, script staat in sequencerScripts.js -->
+                <select name="sessionUID" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('sessionDescription'));">
                     <?php
                     foreach ($sessions as $session) {
-                        echo '<option value="' . $session->uid . '">' . $session->title . '</option>';
+                        echo '<option value="' . $session->uid . '">' . $session->title . '</option>' . "\n";
                     }
                     ?>                    
@@ -63,5 +89,5 @@
             </fieldset>
             <fieldset id="sessionDescription">
-
+                Info goes here: 
             </fieldset>
         </form>
