/[cvs]/nfo/php/libs/org.netfrag.flib/Tracker/User.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.flib/Tracker/User.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by joko, Fri Dec 6 04:10:28 2002 UTC revision 1.8 by jonen, Sat Dec 28 01:16:42 2002 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -----------------------------------------------------------------------------  //    -----------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.8  2002/12/28 01:16:42  jonen
7    //    + added clear of $this->state[autologout] at 'hadTimeout()'
8    //
9    //    Revision 1.7  2002/12/23 11:32:28  jonen
10    //    + added inserting of uservars on '_create' to frontend db(needed to login user after create!)
11    //      + added hard link to page 'pub/register', TODO: move this out here
12    //
13    //    Revision 1.6  2002/12/18 22:46:06  jonen
14    //    + added function 'getUserGuid()'
15    //       (returns user's 'guid' read from database at function 'login()'  (now))
16    //    + function '_loadData()' loads user remote now via 'getUserGuid()'
17    //
18    //    Revision 1.5  2002/12/12 21:34:32  joko
19    //    + fix in 'function update': invalidate data only if it's not for caching purposes
20    //
21  //    Revision 1.4  2002/12/06 04:10:28  joko  //    Revision 1.4  2002/12/06 04:10:28  joko
22  //    + replaced 'xyzCache' through 'xyzProxy'  //    + replaced 'xyzCache' through 'xyzProxy'
23  //  //
# Line 90  class User { Line 105  class User {
105    
106    
107    function _loadData() {    function _loadData() {
108      $this->pObject = new ProxyObject($this->state[id]);      $this->pObject = new ProxyObject($this->getUserGuid(), array( remote => 1, classname => "NetPerson", guid => 1) );
109      if ($this->state[id]) {      if ($this->getUserGuid()) {
110        $this->data = $this->pObject->getAttributes();        $this->data = $this->pObject->getAttributes();
111      }      }
112      $this->meta[data_ready] = 1;      $this->meta[data_ready] = 1;
# Line 111  class User { Line 126  class User {
126    }    }
127        
128    function _save($type = '') {    function _save($type = '') {
129    //print Dumper($this->data);
130      $this->pObject->save($this->data, $type);      $this->pObject->save($this->data, $type);
131      $this->meta[data_ready] = 0;      // invalidate data only if it's not for caching purposes
132        if ($type != 'cache') {
133          $this->meta[data_ready] = 0;
134        }
135    }    }
136        
137    function save() {    function save() {
# Line 131  class User { Line 150  class User {
150      //print "saving to backend: " . dumpVar($result) . "<br>";      //print "saving to backend: " . dumpVar($result) . "<br>";
151      $response = $this->pObject->backend->send('createUser', array('data' => $result) );      $response = $this->pObject->backend->send('createUser', array('data' => $result) );
152      $objectId = $response[oid];      $objectId = $response[oid];
153        if($objectId) {
154            connectdb();
155            $guid = $response[guid];
156            $username = $this->get('userData.username');
157            $password = $this->get('userData.password');
158            $sql = "INSERT into td_users VALUES ( '$objectId', '$guid', '', '$username', '$password','' )";
159                $res = send_sql($sql);
160              }
161              else {
162                // TODO: handle this with a generic rpc-debug/pending function
163          $site->session->set('register_error', 'rpc_error');
164          $site->redirect( getlink('/pub/register/') );
165              }
166      //$this->_init($objectId);      //$this->_init($objectId);
167    }    }
168    
# Line 165  class User { Line 197  class User {
197    function login($user,$passwd) {    function login($user,$passwd) {
198          connectdb();          connectdb();
199          //$sql = "SELECT * FROM td_users WHERE uname='$user'";          //$sql = "SELECT * FROM td_users WHERE uname='$user'";
200          $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'";
201          if ($res=send_sql($sql)) {          if ($res=send_sql($sql)) {
202                  $row = mysql_fetch_array($res,MYSQL_ASSOC);                  $row = mysql_fetch_array($res,MYSQL_ASSOC);
203                  if (!is_array($row)) { return 0; }                  if (!is_array($row)) { return 0; }
# Line 174  class User { Line 206  class User {
206        //return $uservars_db;        //return $uservars_db;
207        // store 1st priority user-data to state        // store 1st priority user-data to state
208          $this->state[id] = $row[user_oid];          $this->state[id] = $row[user_oid];
209            $this->state[guid] = $row[guid];
210          $this->state[status] = $this->meta[logontoken];          $this->state[status] = $this->meta[logontoken];
211          $this->_saveState();          $this->_saveState();
212        $this->site->log( get_class($this) . "->login ok", LOG_DEBUG );        $this->site->log( get_class($this) . "->login ok", LOG_DEBUG );
# Line 197  class User { Line 230  class User {
230    }    }
231        
232    
233    function update(&$uservars) {    function update($vars) {
234      $this->setPostVars($uservars);      $this->setPostVars($vars);
235      $data = $this->_transformInputData($uservars);  //print Dumper($vars);
236        $data = $this->_transformInputData($vars);
237      $this->_saveData($data);      $this->_saveData($data);
238    }    }
239    
# Line 208  class User { Line 242  class User {
242      $mapping_uservars2data = array_flip($def_mapping[data2uservars]);      $mapping_uservars2data = array_flip($def_mapping[data2uservars]);
243      foreach ($uservars as $key => $val) {      foreach ($uservars as $key => $val) {
244        $key_target = $mapping_uservars2data[$key];        $key_target = $mapping_uservars2data[$key];
245        //print "$key => $key_target: $val<br>";        if($key_target != '') {
246        $target[$key_target] = $val;          //print "$key => $key_target: $val<br>";
247            $target[$key_target] = $val;
248          }
249      }      }
250      return $target;      return $target;
251    }    }
# Line 219  class User { Line 255  class User {
255      global $site;      global $site;
256    
257      // get information about user from site      // get information about user from site
258        $userid = $this->state[id];        $userid = $this->getUserId();
259    
260        $this->site->log( get_class($this) . "->logout: userid $userid", LOG_DEBUG );        $this->site->log( get_class($this) . "->logout: userid $userid", LOG_DEBUG );
261            
# Line 298  class User { Line 334  class User {
334      return $this->state[id];      return $this->state[id];
335    }    }
336    
337      function getUserGuid() {
338        return $this->state[guid];
339      }
340    
341    function getPostVars() {    function getPostVars() {
342      return $this->state[postvars];      return $this->state[postvars];
# Line 313  class User { Line 352  class User {
352    }    }
353        
354    function hadTimeout() {    function hadTimeout() {
355      if ($this->state[autologout]) { return 1; }      if ($this->state[autologout]) { $this->state[autologout] = ''; return 1; }
356    }    }
357    
358  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.8

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed