*/ class ConversationalContext { var $_cid; var $_cidvalue; function ConversationalContext($cid) { $this->_cid = $cid; $exists = isset($_REQUEST[$this->_cid]) && $_REQUEST[$this->_cid] != '' && isset($_SESSION[$this->_cid]) && isset($_SESSION[$this->_cid][$_REQUEST[$this->_cid]]); $this->_cidvalue = ($exists) ? $_REQUEST[$this->_cid] : $this->_startConversation(); } function getVariable($name) { if (array_key_exists($this->_cid, $_SESSION) && array_key_exists($this->_cidvalue, $_SESSION[$this->_cid]) && array_key_exists($name, $_SESSION[$this->_cid][$this->_cidvalue])) { return $_SESSION[$this->_cid][$this->_cidvalue][$name]; } else { return null; } } function setVariable($name, $value) { if (!array_key_exists($this->_cidvalue, $_SESSION[$this->_cid])) return; $_SESSION[$this->_cid][$this->_cidvalue][$name] = $value; } function _startConversation() { if (!array_key_exists($this->_cid, $_SESSION)) { $_SESSION[$this->_cid] = array(); } $cidvalue = count($_SESSION[$this->_cid]); $_SESSION[$this->_cid][$cidvalue] = array(); return $cidvalue; } function getId() { return $this->_cidvalue; } } ?>