Ignore:
Timestamp:
11/18/11 15:28:51 (13 years ago)
Author:
fpvanagthoven
Message:
  • Basically alles gefixt om te werken met een local copy van de session, opgeslagen in $_SESSIONlocalSessionCopy?.
  • Flag $_SESSIONupdateNeeded? toegevoegd om aan te geven wanneer er een update uit de database nodig is in plaats van gewoon verder werken met de local copy.
  • '123'/'456' placeholder routine weggehaald uit returnStep.php
  • CreateObject? doet nog niets, maar dat komt volgende week! (AJAX-aangestuurd object creation, met als doel: pipeline editing zonder constante page refreshes).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/pipelineSequencer.php

    r156 r163  
    1515    private $loadedSession;
    1616    private $selectedStep;
     17    private $dbi;
    1718
    1819    public function __construct() {
    19         //nothing yet
     20        $this->dbi = new DatabaseInterface();
    2021    }
    2122
    2223    public function init() {
    2324        $stringPipeline = "";
    24         if (is_array($this->loadedSession->pipeline)){
    25         foreach ($this->loadedSession->pipeline as $object) {
    26             $stringPipeline .= "$object->uid,";
    27         }
    28         $stringPipeline = rtrim($stringPipeline, ",");
    29         }
    30         else {
     25        if (is_array($this->loadedSession->pipeline)) {
     26            foreach ($this->loadedSession->pipeline as $object) {
     27                $stringPipeline .= "$object->uid,";
     28            }
     29            $stringPipeline = rtrim($stringPipeline, ",");
     30        } else {
    3131            $stringPipeline = $this->loadedSession->pipeline;
    3232        }
     
    8383    }
    8484
    85     public function GetFromDB($currentSession) {   // Initialize variables on page load.
    86         $dbi = new DatabaseInterface();
     85    public function LoadSession($currentSession) {   // Initialize variables on page load.
    8786        if (!isset($currentSession)) {
    88             $_SESSION['message'] = "No session set!";
    8987            redirect("selectSession.php");
    9088        }
    91 
    92         $sessionResults = $dbi->get("Session", array("uid" => $currentSession));
    93         if (count($sessionResults) > 0) {
    94             $this->loadedSession = $sessionResults[0];
    95         } else {        //No session with that UID found in database!
    96             die("Invalid session!");
     89        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
     90            $sessionResults = $this->dbi->get("Session", array("uid" => $currentSession));
     91           
     92            if (count($sessionResults) > 0) {
     93                $_SESSION['localSessionCopy'] = $sessionResults[0];
     94            } else {
     95                die("No session with that UID found!");
     96            }
    9797        }
    98         var_dump($this->loadedSession->pipeline);
     98            var_dump($_SESSION['localSessionCopy']);   
     99       
     100        if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
     101           
     102            $this->loadedSession = $_SESSION['localSessionCopy'];
     103            unset($_SESSION['updateNeeded']);
     104        }
     105       
    99106    }
    100107
     
    152159    }
    153160
     161    public function StoreToDb() {
     162        if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) {
     163            $this->dbi->set($_SESSION['localSessionCopy']);
     164            unset($_SESSION['updateNeeded']);
     165        }
     166    }
     167
    154168}
    155169?>
Note: See TracChangeset for help on using the changeset viewer.