source: contrib/davical/inc/PublicSession.php @ 3733

Revision 3733, 1.6 KB checked in by gabriel.malheiros, 13 years ago (diff)

Ticket #1541 - <Davical customizado para o Expresso.Utiliza Caldav e CardDav?>

Line 
1<?php
2/**
3* A Class for faking sessions which are anonymous access to a resource
4*
5* @package davical
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
10*/
11
12/**
13* A Class for handling a public (anonymous) session
14*
15* @package davical
16*/
17class PublicSession {
18  /**#@+
19  * @access private
20  */
21
22  /**
23  * User ID number
24  * @var user_no int
25  */
26  var $user_no;
27
28  /**
29  * Principal ID
30  * @var principal_id int
31  */
32  var $principal_id;
33
34  /**
35  * User e-mail
36  * @var email string
37  */
38  var $email;
39
40  /**
41  * User full name
42  * @var fullname string
43  */
44  var $fullname;
45
46  /**
47  * Group rights
48  * @var groups array
49  */
50  var $groups;
51  /**#@-*/
52
53  /**
54  * The constructor, which just calls the actual type configured
55  */
56  function PublicSession() {
57    global $c;
58
59    $this->user_no = -1;
60    $this->principal_id = -1;
61    $this->email = null;
62    $this->username = 'guest';
63    $this->fullname = 'Anonymous';
64    $this->groups = ( isset($c->public_groups) ? $c->public_groups : array() );
65    $this->roles = array( 'Public' => true );
66    $this->logged_in = false;
67  }
68
69
70  /**
71  * Checks whether a user is allowed to do something.
72  *
73  * The check is performed to see if the user has that role.
74  *
75  * @param string $whatever The role we want to know if the user has.
76  * @return boolean Whether or not the user has the specified role.
77  */
78  function AllowedTo ( $whatever ) {
79    dbg_error_log('session', 'Checking whether "Public" is allowed to "%s"', $whatever);
80    return ( isset($this->roles[$whatever]) && $this->roles[$whatever] );
81  }
82
83}
84
Note: See TracBrowser for help on using the repository browser.