diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index d7eccefc87..6a5260ee54 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -308,13 +308,61 @@ } } - function appsession($location = 'default', $appname = '', $data = '##NOTHING##') - { - global $phpgw_info, $phpgw; + function appsession($data = "##NOTHING##", $location = "default", $appname = "") + { + global $phpgw_info, $phpgw; + + if (! $appname) { + $appname = $phpgw_info['flags']['currentapp']; + } + + /* This allows the user to put "" as the value. */ + if ($data == "##NOTHING##") { + $query = 'select content from phpgw_app_sessions where' + .' sessionid = "'.$this->sessionid.'" and loginid = "'.$this->account_id.'"' + .' and app = "'.$appname.'" and location = "'.$location.'"'; - if (! $appname) { - $appname = $phpgw_info['flags']['currentapp']; + $phpgw->db->query($query,__LINE__,__FILE__); + + $phpgw->db->next_record(); + $data = $phpgw->db->f("content"); + #$data = $phpgw->common->decrypt($data); + return $data; + } else { + $phpgw->db->query('select content from phpgw_app_sessions where ' + . 'sessionid = "'.$this->sessionid.'" and loginid = "'.$this->account_id.'" ' + . 'and app = "'.$appname.'" and location = "'.$location.'"',__LINE__,__FILE__); + + if ($phpgw->db->num_rows()==0) { +# some how the next line is not working correctly! knecke +# $data = addslashes($phpgw->crypto->encrypt(serialize($data))); + $data = addslashes(serialize($data)); + $phpgw->db->query('INSERT INTO phpgw_app_sessions (sessionid,loginid,app,location,content) ' + . 'VALUES ("'.$this->sessionid.'","'.$this->account_id.'","'.$appname + . '","'.$location.'","'.$data.'")',__LINE__,__FILE__); + } else { +# some how the next line is not working correctly! knecke +# $data = addslashes($phpgw->crypto->encrypt(serialize($data))); + $data = addslashes(serialize($data)); + $phpgw->db->query('update phpgw_app_sessions set content = "'.$data.'" ' + . 'where sessionid = "'.$this->sessionid.'" ' + . 'and loginid = "'.$this->account_id.'" and app = "'.$appname.'" ' + . 'and location = "'.$location.'"',__LINE__,__FILE__); } +<<<<<<< class.sessions.inc.php + return $data; + } + } + + function restore() + { + global $phpgw; + + $serializedData = $phpgw->common->appsession(); + $sessionData = unserialize($serializedData); + + if (is_array($sessionData)) +======= /* This allows the user to put "" as the value. */ if ($data == '##NOTHING##') { @@ -347,14 +395,17 @@ } function restore() +>>>>>>> 1.33 { - global $phpgw; - - $serializedData = $phpgw->common->appsession(); - $sessionData = unserialize($serializedData); - - if (is_array($sessionData)) + reset($sessionData); + while(list($key,$value) = each($sessionData)) { +<<<<<<< class.sessions.inc.php + global $$key; + $$key = $value; + $this->variableNames[$key]="registered"; + #print "restored: ".$key.", $value
"; +======= reset($sessionData); while(list($key,$value) = each($sessionData)) { @@ -363,8 +414,10 @@ $this->variableNames[$key]='registered'; #print 'restored: '.$key.', '.$value.'
'; } +>>>>>>> 1.33 } } + } // save the current values of the variables function save() @@ -382,8 +435,7 @@ $sessionData[$key] = $$key; } } - $serializedData = addslashes(serialize($sessionData)); - $phpgw->common->appsession($serializedData); + $phpgw->common->appsession($sessionData); } }