fik fuk
[specialops2.git] / lib / class.anonuser.php
blob6363992a12b504ff03947d43cd6311eeb0631800
1 <?php
2 // $Id$
4 /* Anonymous user */
5 class anonuser
7 public $userlinks;
8 public $page;
9 protected $DB;
10 protected $attrcache;
11 protected $namecache;
13 function __construct($dbpointer)
15 $this->DB = $dbpointer;
16 $this->userlinks = array(
17 _('Log In') => '#footer'
20 $this->attrcache = array(
21 'level' => 0,
22 'points' => 0,
23 'theme' => null,
24 'language' => DEFAULT_LANGUAGE,
25 'msglist_layout' => 0,
26 'topiclist_layout' => 0,
27 'boardlist_layout' => 0,
28 'topics_page' => 35,
29 'msgs_page' => 35
33 function __get($varname)
35 if ( array_key_exists($varname, $this->attrcache) ) {
36 return $this->attrcache[$varname];
37 } else
38 throw new OutOfBoundsException('Error in $user->_get('.$varname.'): attribute not available.');
41 function userheader()
43 if ( ! ($this->page->headers & page::Pageheader) )
44 $this->page->pageheader();
46 if ( ! ($this->page->headers & page::Userheader) ) {
47 echo '<ul id="userheader" class="nl">',"\n";
48 foreach ( $this->userlinks as $text => $href )
49 echo ' <li><a href="',$href,'">',$text,"</a></li>\n";
50 echo "</ul>\n";
51 $this->page->headers |= page::Userheader;
55 function namelink($id, $name = null)
57 if ( empty($this->namecache[$id]) ) {
58 if ( $name === null )
59 $this->namecache[$id] = $this->DB->query('SELECT `alias` FROM `users` WHERE `userid` = '.$id)->fetch_object()->name;
60 else
61 $this->namecache[$id] = $name;
63 return $this->namecache[$id];
66 function fdate($timestamp)
68 return ( $timestamp == 0 ? 'N/A' : date('Y-m-d H:i:s', $timestamp) );