Changeset 163
- Timestamp:
- 11/18/11 15:28:51 (13 years ago)
- Location:
- Dev/trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/pipelineSequencer.php
r156 r163 15 15 private $loadedSession; 16 16 private $selectedStep; 17 private $dbi; 17 18 18 19 public function __construct() { 19 //nothing yet20 $this->dbi = new DatabaseInterface(); 20 21 } 21 22 22 23 public function init() { 23 24 $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 { 31 31 $stringPipeline = $this->loadedSession->pipeline; 32 32 } … … 83 83 } 84 84 85 public function GetFromDB($currentSession) { // Initialize variables on page load. 86 $dbi = new DatabaseInterface(); 85 public function LoadSession($currentSession) { // Initialize variables on page load. 87 86 if (!isset($currentSession)) { 88 $_SESSION['message'] = "No session set!";89 87 redirect("selectSession.php"); 90 88 } 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 } 97 97 } 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 99 106 } 100 107 … … 152 159 } 153 160 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 154 168 } 155 169 ?> -
Dev/trunk/createapplication.php
r156 r163 9 9 10 10 $dbi = new DatabaseInterface(); 11 $session_results = $dbi->get("session", array("uid" => $_SESSION['currentSession']));12 13 if (count($session_results) > 0) {14 $session = $session_results[0];15 }16 11 17 12 $newApplication = new Application(null, "New application", "Default application", "Default style"); 18 13 $dbi->set($newApplication); 19 $session->pipeline[] = $newApplication->uid; 20 //$dbi->set($session); 14 15 if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { 16 $session = $_SESSION['localSessionCopy']; 17 $session->pipeline[] = $newApplication; 18 $_SESSION['localSessionCopy'] = $session; 19 } 21 20 22 21 redirect("pipelineEditor.php"); -
Dev/trunk/createsurvey.php
r156 r163 8 8 9 9 $dbi = new DatabaseInterface(); 10 $creator_results = $dbi->get("user", array("name" => $_SESSION['username'])); 10 $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 11 11 if (count($creator_results) > 0) { 12 12 $creator = $creator_results[0]; … … 18 18 19 19 // Optional part, for when the session needs to be set in pipelineEditor 20 $session_results = $dbi->get("session", array("uid" => $_SESSION['currentSession'])); 21 if ( count($session_results) > 0) {22 $session = $ session_results[0];20 // For now, store in local copy, only upload local copy to db when needed (page change, etc...) 21 if (isset($_SESSION['localSessionCopy']) && !empty($_SESSION['localSessionCopy'])) { 22 $session = $_SESSION['localSessionCopy']; 23 23 $session->pipeline[] = $newSurvey; 24 $ dbi->set($session);24 $_SESSION['localSessionCopy'] = $session; 25 25 } 26 26 -
Dev/trunk/pipelineEditor.php
r154 r163 7 7 8 8 $sequencer = new PipelineSequencer(); 9 $sequencer-> GetFromDB($_SESSION['currentSession']); //load session into php part of the sequencer9 $sequencer->LoadSession($_SESSION['currentSession']); //load session into php part of the sequencer 10 10 $sequencer->HandlePostData(); 11 11 ?> -
Dev/trunk/returnStep.php
r157 r163 40 40 function processUid($uid) { 41 41 $dbi = new DatabaseInterface(); 42 if ($uid == "123") { // test case for when steps aren't actually working43 $imageURL = "images/icons/unknowntype.png";44 $responsePart = '<div class="displayStep" id="' . "123" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "123" . '</div>';45 return $responsePart;46 } else if ($uid == '456') {47 $imageURL = "images/icons/unknowntype.png";48 $responsePart = '<div class="displayStep" id="' . "456" . '" onClick="selectStep(this.id);"><div class="displayStepIcon"><img src="' . $imageURL . '" /></div>' . "456" . '</div>';49 return $responsePart;50 } else {51 52 53 42 if ($uid == "divider") { //a divider has been requested instead of a displaystep 54 43 $responsePart = '<div class="divider"></div>'; … … 68 57 } 69 58 70 if ($result != null) {59 if ($result == null) { 71 60 $applications = $dbi->get("Application", array("uid" => $uid)); 72 61 if (count($applications) > 0) { … … 79 68 } 80 69 81 if ($result != null) {70 if ($result == null) { 82 71 $dashboards = $dbi->get("Dashboard", array("uid" => $uid)); 83 72 if (count($dashboards) > 0) { … … 116 105 } 117 106 } 118 }107 119 108 } 120 109 -
Dev/trunk/selectSession.php
r156 r163 22 22 // make new session! 23 23 unset($matching); 24 $session = new Session(null, $_POST['newSessionName'], null, null, null);24 $session = new Session(null, $_POST['newSessionName'], $_SESSION['username'], new DateTime(), null, null); 25 25 $dbi->set($session); 26 26 } else { … … 44 44 if (count($matching) == 1 && $matching[0] != null) { 45 45 $_SESSION['currentSession'] = $_POST['sessionUID']; 46 $_SESSION['updateNeeded'] = "true"; 46 47 redirect("pipelineEditor.php"); 47 48 } … … 77 78 <?php 78 79 foreach ($sessions as $session) { 79 echo '<option value="' . $session->uid . '">' . $session->title . '</option>' . "\n"; 80 $selected = ""; 81 if ($session->title == $_POST['newSessionName']) { 82 $selected = ' selected="true"'; 83 } 84 85 echo '<option value="' . $session->uid . '"' . $selected . '>' . $session->title . '</option>' . "\n"; 80 86 } 81 87 ?> 82 88 </select> 83 89 <br /><br /> 90 <input type="hidden" name="updateNeeded" value="true" /> 84 91 <input type="text" name="newSessionName" value="Name..." style="float: left;" /><br /> 85 92 <input type="submit" name="createSession" value="Create new session" class="surveybutton" style="float: left;" />
Note: See TracChangeset
for help on using the changeset viewer.