3 |
// $Id$ |
// $Id$ |
4 |
// ----------------------------------------------------------------------------- |
// ----------------------------------------------------------------------------- |
5 |
// $Log$ |
// $Log$ |
6 |
|
// Revision 1.9 2003/02/09 17:46:26 joko |
7 |
|
// + now utilizing Data::Driver::Proxy and Data::Deep |
8 |
|
// |
9 |
|
// Revision 1.8 2002/12/28 01:16:42 jonen |
10 |
|
// + added clear of $this->state[autologout] at 'hadTimeout()' |
11 |
|
// |
12 |
|
// Revision 1.7 2002/12/23 11:32:28 jonen |
13 |
|
// + added inserting of uservars on '_create' to frontend db(needed to login user after create!) |
14 |
|
// + added hard link to page 'pub/register', TODO: move this out here |
15 |
|
// |
16 |
// Revision 1.6 2002/12/18 22:46:06 jonen |
// Revision 1.6 2002/12/18 22:46:06 jonen |
17 |
// + added function 'getUserGuid()' |
// + added function 'getUserGuid()' |
18 |
// (returns user's 'guid' read from database at function 'login()' (now)) |
// (returns user's 'guid' read from database at function 'login()' (now)) |
108 |
|
|
109 |
|
|
110 |
function _loadData() { |
function _loadData() { |
111 |
$this->pObject = new ProxyObject($this->getUserGuid(), array( remote => 1, classname => "NetPerson", guid => 1) ); |
$this->meta[data_ready] = 1; |
112 |
|
//$this->pObject = new ProxyObject($this->getUserGuid(), array( remote => 1, classname => "NetPerson", guid => 1) ); |
113 |
|
$rpcinfo = $this->site->configuration->get("rpcinfo"); |
114 |
|
$this->pObject = mkObject('Data::Driver::Proxy', $this->getUserGuid(), array( remote => 1, classname => "NetPerson", guid => 1, rpcinfo => $rpcinfo ) ); |
115 |
if ($this->getUserGuid()) { |
if ($this->getUserGuid()) { |
116 |
$this->data = $this->pObject->getAttributes(); |
$this->data = $this->pObject->getAttributes(); |
117 |
} |
} |
|
$this->meta[data_ready] = 1; |
|
118 |
} |
} |
119 |
|
|
120 |
function _saveData($newRawData) { |
function _saveData($newRawData) { |
155 |
//print "saving to backend: " . dumpVar($result) . "<br>"; |
//print "saving to backend: " . dumpVar($result) . "<br>"; |
156 |
$response = $this->pObject->backend->send('createUser', array('data' => $result) ); |
$response = $this->pObject->backend->send('createUser', array('data' => $result) ); |
157 |
$objectId = $response[oid]; |
$objectId = $response[oid]; |
158 |
|
if($objectId) { |
159 |
|
connectdb(); |
160 |
|
$guid = $response[guid]; |
161 |
|
$username = $this->get('userData.username'); |
162 |
|
$password = $this->get('userData.password'); |
163 |
|
$sql = "INSERT into td_users VALUES ( '$objectId', '$guid', '', '$username', '$password','' )"; |
164 |
|
$res = send_sql($sql); |
165 |
|
} |
166 |
|
else { |
167 |
|
// TODO: handle this with a generic rpc-debug/pending function |
168 |
|
$site->session->set('register_error', 'rpc_error'); |
169 |
|
$site->redirect( getlink('/pub/register/') ); |
170 |
|
} |
171 |
//$this->_init($objectId); |
//$this->_init($objectId); |
172 |
} |
} |
173 |
|
|
|
function _getHKR($key) { |
|
|
$attr_arr = split('\.', $key); |
|
|
$attr_hkr = '["' . join('"]["', $attr_arr) . '"]'; |
|
|
return $attr_hkr; |
|
|
} |
|
|
|
|
174 |
function get($attr) { |
function get($attr) { |
175 |
$this->_doDataReady(); |
$this->_doDataReady(); |
176 |
$hkr = $this->_getHKR($attr); |
$deep = new Data_Deep($this->data); |
177 |
$evalstr = 'return $this->data' . $hkr . ';'; |
return $deep->get($attr); |
|
$val = eval($evalstr); |
|
|
return $val; |
|
178 |
} |
} |
179 |
function set($attr, $val) { |
function set($attr, $val) { |
180 |
$this->_doDataReady(); |
$this->_doDataReady(); |
181 |
$hkr = $this->_getHKR($attr); |
$deep = new Data_Deep($this->data); |
182 |
$evalstr = '$this->data' . $hkr . ' = \'' . $val . '\';'; |
$deep->set($attr, $val); |
|
eval($evalstr); |
|
183 |
} |
} |
184 |
|
|
185 |
function isLoggedOn() { |
function isLoggedOn() { |
205 |
$this->state[guid] = $row[guid]; |
$this->state[guid] = $row[guid]; |
206 |
$this->state[status] = $this->meta[logontoken]; |
$this->state[status] = $this->meta[logontoken]; |
207 |
$this->_saveState(); |
$this->_saveState(); |
208 |
$this->site->log( get_class($this) . "->login ok", LOG_DEBUG ); |
$this->site->log( get_class($this) . "->login ok", PEAR_LOG_NOTICE ); |
209 |
return 1; |
return 1; |
210 |
} else { |
} else { |
211 |
return 0; |
return 0; |
238 |
$mapping_uservars2data = array_flip($def_mapping[data2uservars]); |
$mapping_uservars2data = array_flip($def_mapping[data2uservars]); |
239 |
foreach ($uservars as $key => $val) { |
foreach ($uservars as $key => $val) { |
240 |
$key_target = $mapping_uservars2data[$key]; |
$key_target = $mapping_uservars2data[$key]; |
241 |
//print "$key => $key_target: $val<br>"; |
if($key_target != '') { |
242 |
$target[$key_target] = $val; |
//print "$key => $key_target: $val<br>"; |
243 |
|
$target[$key_target] = $val; |
244 |
|
} |
245 |
} |
} |
246 |
return $target; |
return $target; |
247 |
} |
} |
253 |
// get information about user from site |
// get information about user from site |
254 |
$userid = $this->getUserId(); |
$userid = $this->getUserId(); |
255 |
|
|
256 |
$this->site->log( get_class($this) . "->logout: userid $userid", LOG_DEBUG ); |
$this->site->log( get_class($this) . "->logout: userid $userid", PEAR_LOG_NOTICE ); |
257 |
|
|
258 |
// get information about session from php |
// get information about session from php |
259 |
$session_id = session_id(); |
$session_id = session_id(); |
348 |
} |
} |
349 |
|
|
350 |
function hadTimeout() { |
function hadTimeout() { |
351 |
if ($this->state[autologout]) { return 1; } |
if ($this->state[autologout]) { $this->state[autologout] = ''; return 1; } |
352 |
} |
} |
353 |
|
|
354 |
} |
} |