3 |
// $Id$ |
// $Id$ |
4 |
// ----------------------------------------------------------------------------- |
// ----------------------------------------------------------------------------- |
5 |
// $Log$ |
// $Log$ |
6 |
|
// Revision 1.6 2002/12/18 22:46:06 jonen |
7 |
|
// + added function 'getUserGuid()' |
8 |
|
// (returns user's 'guid' read from database at function 'login()' (now)) |
9 |
|
// + function '_loadData()' loads user remote now via 'getUserGuid()' |
10 |
|
// |
11 |
|
// Revision 1.5 2002/12/12 21:34:32 joko |
12 |
|
// + fix in 'function update': invalidate data only if it's not for caching purposes |
13 |
|
// |
14 |
|
// Revision 1.4 2002/12/06 04:10:28 joko |
15 |
|
// + replaced 'xyzCache' through 'xyzProxy' |
16 |
|
// |
17 |
// Revision 1.3 2002/12/04 07:42:54 jonen |
// Revision 1.3 2002/12/04 07:42:54 jonen |
18 |
// + changes according to backend schema change |
// + changes according to backend schema change |
19 |
// |
// |
98 |
|
|
99 |
|
|
100 |
function _loadData() { |
function _loadData() { |
101 |
$this->pObject = new ProxyObject($this->state[id]); |
$this->pObject = new ProxyObject($this->getUserGuid(), array( remote => 1, classname => "NetPerson", guid => 1) ); |
102 |
if ($this->state[id]) { |
if ($this->getUserGuid()) { |
103 |
$this->data = $this->pObject->getAttributes(); |
$this->data = $this->pObject->getAttributes(); |
104 |
} |
} |
105 |
$this->meta[data_ready] = 1; |
$this->meta[data_ready] = 1; |
114 |
|
|
115 |
$this->_save("cache"); |
$this->_save("cache"); |
116 |
|
|
117 |
//$this->pObject->flushCache(); // done in "pObject->save" |
//$this->pObject->flushProxy(); // done in "pObject->save" |
118 |
|
|
119 |
} |
} |
120 |
|
|
121 |
function _save($type = '') { |
function _save($type = '') { |
122 |
|
//print Dumper($this->data); |
123 |
$this->pObject->save($this->data, $type); |
$this->pObject->save($this->data, $type); |
124 |
$this->meta[data_ready] = 0; |
// invalidate data only if it's not for caching purposes |
125 |
|
if ($type != 'cache') { |
126 |
|
$this->meta[data_ready] = 0; |
127 |
|
} |
128 |
} |
} |
129 |
|
|
130 |
function save() { |
function save() { |
177 |
function login($user,$passwd) { |
function login($user,$passwd) { |
178 |
connectdb(); |
connectdb(); |
179 |
//$sql = "SELECT * FROM td_users WHERE uname='$user'"; |
//$sql = "SELECT * FROM td_users WHERE uname='$user'"; |
180 |
$sql = "SELECT user_oid, uname, pass FROM td_users WHERE uname='$user'"; |
$sql = "SELECT user_oid, guid, uname, pass FROM td_users WHERE uname='$user'"; |
181 |
if ($res=send_sql($sql)) { |
if ($res=send_sql($sql)) { |
182 |
$row = mysql_fetch_array($res,MYSQL_ASSOC); |
$row = mysql_fetch_array($res,MYSQL_ASSOC); |
183 |
if (!is_array($row)) { return 0; } |
if (!is_array($row)) { return 0; } |
186 |
//return $uservars_db; |
//return $uservars_db; |
187 |
// store 1st priority user-data to state |
// store 1st priority user-data to state |
188 |
$this->state[id] = $row[user_oid]; |
$this->state[id] = $row[user_oid]; |
189 |
|
$this->state[guid] = $row[guid]; |
190 |
$this->state[status] = $this->meta[logontoken]; |
$this->state[status] = $this->meta[logontoken]; |
191 |
$this->_saveState(); |
$this->_saveState(); |
192 |
$this->site->log( get_class($this) . "->login ok", LOG_DEBUG ); |
$this->site->log( get_class($this) . "->login ok", LOG_DEBUG ); |
210 |
} |
} |
211 |
|
|
212 |
|
|
213 |
function update(&$uservars) { |
function update($vars) { |
214 |
$this->setPostVars($uservars); |
$this->setPostVars($vars); |
215 |
$data = $this->_transformInputData($uservars); |
//print Dumper($vars); |
216 |
|
$data = $this->_transformInputData($vars); |
217 |
$this->_saveData($data); |
$this->_saveData($data); |
218 |
} |
} |
219 |
|
|
233 |
global $site; |
global $site; |
234 |
|
|
235 |
// get information about user from site |
// get information about user from site |
236 |
$userid = $this->state[id]; |
$userid = $this->getUserId(); |
237 |
|
|
238 |
$this->site->log( get_class($this) . "->logout: userid $userid", LOG_DEBUG ); |
$this->site->log( get_class($this) . "->logout: userid $userid", LOG_DEBUG ); |
239 |
|
|
312 |
return $this->state[id]; |
return $this->state[id]; |
313 |
} |
} |
314 |
|
|
315 |
|
function getUserGuid() { |
316 |
|
return $this->state[guid]; |
317 |
|
} |
318 |
|
|
319 |
function getPostVars() { |
function getPostVars() { |
320 |
return $this->state[postvars]; |
return $this->state[postvars]; |