4 /* Registered user, logged in (i.e. yourself) */
5 class authuser
extends reguser
9 function __construct($userid, $prefetch = null)
11 $fields = array('`alias`', '`level`', '`language`', '`timezone`', '`theme`', '`date_format`');
13 $fields = array_merge($fields, $prefetch);
15 $this->userid
= $userid;
16 $this->attrcache
= array();
18 parent
::__construct($userid, $fields);
20 $this->namecache
[$userid] = $this->alias
;
22 $this->userlinks
= array(
23 $this->alias
.' ('.( $this->level
== LVL_DEV ?
'∞' : $this->level
).')' => 'user?id='.$this->userid
26 if ( $this->level
>= LVL_ADMIN
)
27 $this->userlinks
['Admin Stuff'] = 'admin';
29 //hack to get localized $page->title values
30 setlocale(LC_ALL
, explode(', ', $this->language
));
33 $GLOBALS['DB']->query('UPDATE `users` SET
34 `useragent` = \''.$GLOBALS['DB']->escape_string(substr($_SERVER['HTTP_USER_AGENT'], 0, 130)).'\',
35 `last_active_date` = UNIX_TIMESTAMP(),
36 `last_ip` = INET_ATON(\''.$_SERVER['REMOTE_ADDR'].'\')
37 WHERE `userid` = '.$this->userid
);
41 function namelink($id, $name = null)
43 if ( empty($this->namecache
[$id]) ) {
45 $this->namecache
[$id] = $GLOBALS['DB']->query('SELECT `alias` FROM `users`
46 WHERE `userid` = '.$id)->fetch_object()->alias
;
48 $this->namecache
[$id] = $name;
50 return '<a href="user?id='.$id.'">'.$this->namecache
[$id].'</a>';
53 // the "f" stands for fish
54 function fdate($timestamp)
56 return ( $timestamp == 0 ?
'N/A' : date($this->date_format
, $timestamp) );