Index: Dev/trunk/classes/Logo.php
===================================================================
--- Dev/trunk/classes/Logo.php	(revision 150)
+++ Dev/trunk/classes/Logo.php	(revision 151)
@@ -15,7 +15,9 @@
     // hardcoded logo div, image is defined in stylesheet. (#logo background:"";)
     public function __construct() {
-        echo '
-            <div id="logo"><a href="index.php">Research Tool</a></div>
-';
+        echo '<div id="logo"><a href="index.php">Research Tool</a>';
+        if (isset($_SESSION['username'])) {
+            echo '<a href="logout.php" style="font-size: 12pt;">Log out</a>';
+        }
+        echo '</div>';
     
     }
Index: Dev/trunk/classes/PipelineSequencer_1.php
===================================================================
--- Dev/trunk/classes/PipelineSequencer_1.php	(revision 151)
+++ Dev/trunk/classes/PipelineSequencer_1.php	(revision 151)
@@ -0,0 +1,198 @@
+<?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 150)
+++ Dev/trunk/classes/SessionConnector.php	(revision 151)
@@ -186,6 +186,7 @@
 		$this->model->add(new Statement($resourceSession, $predicateTitle, $sessionTitle));
 
-		$sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp());
-		$predicateTimestamp = new Resource(DATETIME);
+		//$sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp());
+                $sessionTimestamp = new Literal($rToolObject->datetime);    // Edit of above function, allows for creation of session, but still results in errors...
+                $predicateTimestamp = new Resource(DATETIME);
 		$this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp));
 
Index: Dev/trunk/classes/pipelineSequencer.php
===================================================================
--- Dev/trunk/classes/pipelineSequencer.php	(revision 150)
+++ Dev/trunk/classes/pipelineSequencer.php	(revision 151)
@@ -6,12 +6,12 @@
 
 /**
- * Description of Sequencer
+ * A visual interface object for editing and viewing a session's pipeline.
  *
- * @author HP
+ * @author Tschipper
  */
 class PipelineSequencer {
 
     // properties
-    private $pipeline;
+    private $pipeline;      // array of UID strings.
     private $name = "empty";
     private $numStepsInArray = 0;
@@ -21,13 +21,14 @@
     public function __construct($uid) {
         $dbi = new DatabaseInterface();
-        $this->pipeline = $dbi->get("pipeline", array("uid"=>$uid));
+        $this->pipeline = $dbi->get("pipeline", array("uid" => $uid));
     }
 
     public function init() {
         ?>
-        <br /><form name="sequencer" action="pipelineEditor.php" method="post"><fieldset id="sequencer">
+        <br /><form name="sequencer" action="pipelineEditor.php" method="post">
+            <fieldset id="sequencer">
                 <div class="title">Name: <?php echo $this->pipeline->name; ?> </div>
 
-                <div class="seqContent">
+                <div id="seqContent">
                     <?php $this->DrawSteps(); ?>          
                 </div>
@@ -41,4 +42,6 @@
                     <input type="checkbox" name="confirmClear" onChange="IsCheckEnabled(this, document.sequencer.clearPipeline);" />Really clear?
                     <input type="hidden" name="selectedStep" />
+                    <input type="hidden" name="numSteps" />
+                    <input type="hidden" name="pipeline" />
                 </div>
             </fieldset>
@@ -47,130 +50,6 @@
     }
 
-    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 HandlePost() {
-
-        //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;
     }
 
@@ -180,11 +59,63 @@
         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;
+            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>
 
@@ -193,4 +124,12 @@
     }
 
+    public function GetDromDB() {   // Initialize variables on page load.
+        $dbi = new DatabaseInterface();
+        if (isset($_POST['currentSession'])) {
+            $currentSession = $dbi->get("Session", array("UID" => $uid));
+            $this->pipeline = $currentSession->pipeline;
+        }
+    }
+
 }
 ?>
Index: Dev/trunk/index.php
===================================================================
--- Dev/trunk/index.php	(revision 150)
+++ Dev/trunk/index.php	(revision 151)
@@ -2,20 +2,60 @@
 require 'classes/master.php'; //should be at top of every page
 
+/*  Page still has ambiguous design. Login and Register buttons are at same hierarchy level, makes user suspect the register button works based on input given here.
+ *  Instead redirects to anoter page.
+ *   
+ */
+
+//Even voor tijdelijk, aangezien er nog pagina's missen en redirects daarom niet goed werken:
+if (isset($_SESSION['username'])) {
+    redirect("logout.php");
+}
+
+$errorMessage[] = "";
+
 if (isset($_POST['register'])) {
     if ($_POST['username'] != null && $_POST['password'] != null) {
-        $userDBI = new UserDatabaseInterface();
-        $user_exists = $userDBI->checkUserName($_POST['username']);
+        $dbi = new DatabaseInterface();
+        $user_results = $dbi->get("user", array("name" => $_POST['username']));
+        $user_exists = (count($user_results) > 0);
         if (!$user_exists) {
-            $userDBI->addNewUser($_POST);
+            if (strlen($_POST['password']) > 6) {
+                $user = new User(null, $_POST['username'], $_POST['password']);
+                $dbi->set($user);
+                $_SESSION['username'] = $_POST['username'];
+            } else {
+                $errorMessage[] = "Password is too short!";
+                //echo "Password is too short!";
+            }
         }
         else
-            echo "Username already exists, try something else";
+            $errorMessage[] = "Username already exists, try something else!";
+        //echo "Username already exists, try something else";
     }
     else
-        echo "please fill in a username and password";
+        $errorMessage[] = "Please fill in a username and password";
+    //echo "please fill in a username and password";
 }
 
-if (isset($_SESSION['username']))
-    redirect('mainmenu.php');
+if (isset($_POST['login'])) {
+    $dbi = new DatabaseInterface();
+    $user_results = $dbi->get("user", array("name" => $_POST['username']));
+    if (isset($user_results[0])) {
+        if ($user_results[0]->password == $_POST['password']) {
+            $_SESSION['username'] = $user_results[0]->name;
+            // USER HAS LOGGED IN
+        } else {
+            $errorMessage[] = "Incorrect password!";
+            //echo "Incorrect password!";
+        }
+    } else {
+        $errorMessage[] = "Username doesn't exist!";
+        //echo "Username doesn't exist!";
+    }
+}
+
+if (isset($_SESSION['username'])) {
+    redirect('pipelineEditor.php');
+}
 ?>
 
@@ -27,8 +67,13 @@
         <?php new StyleSheet("awesome"); ?>
         <script type="text/javascript" src="js/menu.js"></script>
+        <script type="text/javascript">
+        
+    
+
+        </script>
     </head>
     <body>
         <div id="header">
-<?php new Logo(); ?>
+            <?php new Logo(); ?>
         </div>
 
@@ -37,9 +82,17 @@
             <div id="content">
                 <div class="menu">
-                    <form action="mainmenu.php" method="POST">
+                    <form action="index.php" method="POST">
                         <h3>Username</h3>
                         <input type="text" name="username"><br />
                         <h3>Password</h3>
-                        <input type="password" name="password"><br/><br/><br/>
+                        <input type="password" name="password"><br/><br />
+                        <div id="errorDisplay">
+                            <?php
+                            foreach ($errorMessage as $message) {
+                                echo "<h3 style='color: #FF0000;'>$message</h3>";
+                            }
+                            ?>
+                        </div>
+                        <br/>
                         <input type="submit" name="login" class="surveyButton bigSurveyButton" value="Log in">
                     </form>
Index: Dev/trunk/logout.php
===================================================================
--- Dev/trunk/logout.php	(revision 151)
+++ Dev/trunk/logout.php	(revision 151)
@@ -0,0 +1,10 @@
+<!--
+To change this template, choose Tools | Templates
+and open the template in the editor.
+-->
+<?php
+require 'classes/master.php';
+
+unset($_SESSION['username']);
+redirect("index.php");
+?>
Index: Dev/trunk/pipelineEditor.php
===================================================================
--- Dev/trunk/pipelineEditor.php	(revision 150)
+++ Dev/trunk/pipelineEditor.php	(revision 151)
@@ -2,7 +2,19 @@
 require 'classes/master.php'; //should be at top of every page
 
-/* if (!isset($_SESSION['user'])){
-  redirect('index.php');
-  } */
+if (!isset($_SESSION['username'])) {
+    redirect('index.php');
+}
+
+$dbtemp = new DatabaseInterface();
+
+
+if (!isset($_SESSION['currentSession'])) {
+    redirect('selectSession.php');
+}
+
+$dbi = new DatabaseInterface();
+$sessions = $dbi->get("session", array("user"=>$_SESSION['username']));
+
+
 
 
@@ -15,7 +27,4 @@
 
 $sequencer->HandlePost();    // doesn't actually currently get from db, uses session/post as a temporary alternative.
-
-
-
 ?>
 
@@ -43,5 +52,5 @@
             <div id="content">
 <?php $sequencer->init(); ?>
-                <?php $toolbox = new Toolbox(); ?>
+<?php $toolbox = new Toolbox(); ?>
             </div>
     </body>
Index: Dev/trunk/returnStep.php
===================================================================
--- Dev/trunk/returnStep.php	(revision 151)
+++ Dev/trunk/returnStep.php	(revision 151)
@@ -0,0 +1,85 @@
+<!--
+To change this template, choose Tools | Templates
+and open the template in the editor.
+-->
+<?php
+/*
+ * Return the HTML markup for visualisation of an object in a pipeline, to be used in the PipelineSequencer.php
+ * Called by PipelineSequencer, posting UID of the step in question.
+ *  TODO: Selection code. Onload doen of serverside?
+ * Javascript voor selection scripts staat ook nog niet in de -onclick- property, eerst dat script uitzoeken, daarna pas invoegen.
+ */
+
+// Check if calling script actually passed a uid to use
+if (isset($_POST['uid'])) {
+    if (!empty($_POST['uid'])) {
+        $uid = $_POST['uid'];
+    } else {
+        echo "Invalid UID passed!";
+    }
+} else {
+    echo "No UID passed!";
+}
+
+
+$dbi = new DatabaseInterface();
+//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";
+    }
+}
+
+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 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 {
+
+    // set relevant variables based on the type and properties of the step in question (currently stored in $result)
+    switch (strtolower($resultType)) {
+        case "questionnaire":
+            $imageURL = "images/icons/questionnaire.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
+    $response = '<div class="displayStep" id="' . $result->uid . '"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . $result->name . '</div>';
+    echo $response;
+}
+?>
Index: Dev/trunk/selectSession.php
===================================================================
--- Dev/trunk/selectSession.php	(revision 151)
+++ Dev/trunk/selectSession.php	(revision 151)
@@ -0,0 +1,69 @@
+<?php
+require 'classes/master.php'; //should be at top of every page
+
+if (!isset($_SESSION['username'])) {
+    redirect("index.php");
+}
+$dbi = new DatabaseInterface();
+if (isset($_POST['createSession'])) {
+    //check if name is set
+    if (isset($_POST['newSessionName'])) {
+        // check if name is available
+        if (!empty($_POST['newSessionName'])) {
+            $matchingNames = $dbi->get("Session", array("title" => $_POST['newSessionName']));
+            if (count($matchingNames) == 0) {
+                // make new session!
+                $session = new Session(null, $_POST['newSessionName'], null, null, null);
+                $dbi->set($session);
+            } else {
+                $errorMessage[] = "A session with the name " . $_POST['newSessionName'] . " already exists!";
+            }
+        }
+    } else {
+        $errorMessage[] = "Please enter a name for the new session!";
+    }
+}
+
+//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);
+?>
+
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>Select a session</title>
+        <?php new StyleSheet("awesome"); ?>
+    </head>
+    <body>
+        <form action="selectSession.php" method="POST">
+            <fieldset name="selectionMenu">
+                <select name="sessionName" style="float: left;">
+                    <?php
+                    foreach ($sessions as $session) {
+                        echo '<option value="' . $session->uid . '">' . $session->title . '</option>';
+                    }
+                    ?>                    
+                </select>
+                <br /><br />
+                <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;" />
+                <input type="submit" name="editSession" value="Edit session" class="surveybutton" style="float: left;" />
+                <input type="submit" name="deleteSession" value="Delete session" class="surveybutton" style="float: left;" />
+                <br /><br /><br />
+                <div id="errorDisplay"><?php
+                    if (isset($errorMessage)) {
+                        foreach ($errorMessage as $message) {
+                            echo $message;
+                        }
+                    }
+                    ?></div>
+            </fieldset>
+            <fieldset id="sessionDescription">
+
+            </fieldset>
+        </form>
+    </body>
+</html>
