Overview

Packages

  • awl
    • caldav-client-v2
    • RRule
  • davical
    • authentication
      • drivers
    • caldav
    • DAViCalSession
    • DAVTicket
    • external-bind
    • feed
    • HTTPAuthSession
    • iSchedule
    • iSchedule-POST
    • logging
    • metrics
    • Principal
    • propfind
    • PublicSession
    • Request
    • Resource
    • tzservice
  • None
  • PHP

Classes

  • PublicSession
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  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: */
 17: class PublicSession {
 18:   /**#@+
 19:   * @access private
 20:   */
 21: 
 22:   /**
 23:   * Username
 24:   * @var username string
 25:   */
 26:   public $username;
 27: 
 28:   /**
 29:   * User ID number
 30:   * @var user_no int
 31:   */
 32:   public $user_no;
 33: 
 34:   /**
 35:   * Principal ID
 36:   * @var principal_id int
 37:   */
 38:   public $principal_id;
 39: 
 40:   /**
 41:   * User e-mail
 42:   * @var email string
 43:   */
 44:   public $email;
 45: 
 46:   /**
 47:   * User full name
 48:   * @var fullname string
 49:   */
 50:   public $fullname;
 51: 
 52:   /**
 53:   * Group rights
 54:   * @var groups array
 55:   */
 56:   public $groups;
 57:   /**#@-*/
 58: 
 59:   /**
 60:   * The constructor, which just calls the actual type configured
 61:   */
 62:   function PublicSession() {
 63:     global $c;
 64: 
 65:     $principal = new Principal('username','unauthenticated');
 66: 
 67:     // Assign each field in the selected record to the object
 68:     foreach( $principal AS $k => $v ) {
 69:       $this->{$k} = $v;
 70:     }
 71: 
 72:     $this->username = $principal->username();
 73:     $this->user_no  = $principal->user_no();
 74:     $this->principal_id = $principal->principal_id();
 75:     $this->email = $principal->email();
 76:     $this->fullname = $principal->fullname;
 77:     $this->dav_name = $principal->dav_name();
 78:     $this->principal = $principal;
 79: 
 80:     if ( function_exists("awl_set_locale") && isset($this->locale) && $this->locale != "" ) {
 81:       awl_set_locale($this->locale);
 82:     }
 83: 
 84:     $this->groups = ( isset($c->public_groups) ? $c->public_groups : array() );
 85:     $this->roles = array( 'Public' => true );
 86:     $this->logged_in = false;
 87:   }
 88: 
 89: 
 90:   /**
 91:   * Checks whether a user is allowed to do something.
 92:   *
 93:   * The check is performed to see if the user has that role.
 94:   *
 95:   * @param string $whatever The role we want to know if the user has.
 96:   * @return boolean Whether or not the user has the specified role.
 97:   */
 98:   function AllowedTo ( $whatever ) {
 99:     dbg_error_log('session', 'Checking whether "Public" is allowed to "%s"', $whatever);
100:     return ( isset($this->roles[$whatever]) && $this->roles[$whatever] );
101:   }
102: 
103: }
104: 
105: 
DAViCal API documentation generated by ApiGen 2.8.0