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

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

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