New theme, fixed some minor stuff
[specialops2.git] / lib / class.anonuser.php
blobaae76e99448f6a693230ebceaf14baf5cd67bfff
1 <?php
2 // $Id$
4 /* Anonymous user */
5 class anonuser
7 // Debug stuff
8 public $gets = 0;
9 public $sets = 0;
11 public $userlinks;
12 protected $attrcache;
13 protected $namecache;
15 function __construct()
17 $this->userlinks = array(
18 'Log In' => '#login_u'
21 $this->attrcache = array(
22 'level' => 0,
23 'points' => 0,
24 'theme' => -1,
25 'msglist_layout' => 0,
26 'topiclist_layout' => 0,
27 'boardlist_layout' => 0,
28 'topics_page' => 10,
29 'msgs_page' => 5
33 function __get($varname)
35 $this->gets++;
36 if ( array_key_exists($varname, $this->attrcache) ) {
37 return $this->attrcache[$varname];
38 } else
39 throw new OutOfBoundsException('Error in $user->_get('.$varname.'): attribute not available.');
42 function userheader()
44 if ( ! ($GLOBALS['page']->headers & page::Pageheader) )
45 $GLOBALS['page']->pageheader();
47 if ( ! ($GLOBALS['page']->headers & page::Userheader) ) {
48 echo '<ul id="userheader" class="nl">',"\n";
49 foreach ( $this->userlinks as $text => $href )
50 echo ' <li><a href="',$href,'">',$text,"</a></li>\n";
51 echo "</ul>\n";
52 $GLOBALS['page']->headers |= page::Userheader;
56 function namelink($id, $name = null)
58 if ( empty($this->namecache[$id]) ) {
59 if ( $name === null )
60 $this->namecache[$id] = $GLOBALS['DB']->query('SELECT `alias` FROM `users`
61 WHERE `userid` = '.$id)->fetch_object()->alias;
62 else
63 $this->namecache[$id] = $name;
65 return $this->namecache[$id];
68 function fdate($timestamp)
70 return ( $timestamp == 0 ? 'N/A' : date('Y-m-d H:i:s', $timestamp) );