3 * A Class for faking sessions which are anonymous access to a resource
6 * @subpackage PublicSession
7 * @author Andrew McMillan <andrew@morphoss.com>
8 * @copyright Morphoss Ltd
9 * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
13 * A Class for handling a public (anonymous) session
30 * @var principal_id int
42 * @var fullname string
54 * The constructor, which just calls the actual type configured
56 function PublicSession() {
59 $principal = new Principal('username','unauthenticated');
61 // Assign each field in the selected record to the object
62 foreach( $principal AS $k => $v ) {
66 $this->username
= $principal->username();
67 $this->user_no
= $principal->user_no();
68 $this->principal_id
= $principal->principal_id();
69 $this->email
= $principal->email();
70 $this->dav_name
= $principal->dav_name();
71 $this->principal
= $principal;
73 if ( function_exists("awl_set_locale") && isset($this->locale
) && $this->locale
!= "" ) {
74 awl_set_locale($this->locale
);
78 $this->groups
= ( isset($c->public_groups
) ?
$c->public_groups
: array() );
79 $this->roles
= array( 'Public' => true );
80 $this->logged_in
= false;
85 * Checks whether a user is allowed to do something.
87 * The check is performed to see if the user has that role.
89 * @param string $whatever The role we want to know if the user has.
90 * @return boolean Whether or not the user has the specified role.
92 function AllowedTo ( $whatever ) {
93 dbg_error_log('session', 'Checking whether "Public" is allowed to "%s"', $whatever);
94 return ( isset($this->roles
[$whatever]) && $this->roles
[$whatever] );