function __construct($user_no = null) { if (empty($user_no)) { $this->user_no = -1; $this->principal_id = -1; $this->logged_in = false; return; } $this->user_no = $user_no; $principal = new Principal('user_no', $user_no); // Assign each field in the selected record to the object foreach ($principal as $k => $v) { $this->{$k} = $v; } $this->username = $principal->username(); $this->principal_id = $principal->principal_id(); $this->email = $principal->email(); $this->dav_name = $principal->dav_name(); $this->principal = $principal; $this->logged_in = true; } function AllowedTo($do_something) { return $this->logged_in; } } $session = new FakeSession(); require "caldav-GET-functions.php"; $calendar = new DAVResource($source); echo export_iCalendar($calendar);
* @copyright Catalyst .Net Ltd, Morphoss Ltd <http://www.morphoss.com/> * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later */ dbg_error_log("get", "GET method handler"); require "caldav-GET-functions.php"; $dav_resource = new DAVResource($request->path); $dav_resource->NeedPrivilege(array('urn:ietf:params:xml:ns:caldav:read-free-busy', 'DAV::read')); if ($dav_resource->IsExternal()) { require_once "external-fetch.php"; update_external($dav_resource); } if (!$dav_resource->Exists()) { $request->DoResponse(404, translate("Resource Not Found.")); } if ($dav_resource->IsCollection()) { $response = export_iCalendar($dav_resource); header('Etag: ' . $dav_resource->unique_tag()); $request->DoResponse(200, $request->method == 'HEAD' ? '' : $response, 'text/calendar; charset="utf-8"'); } // Just a single event then $resource = $dav_resource->resource(); $ic = new iCalComponent($resource->caldav_data); $resource->caldav_data = preg_replace('{(?<!\\r)\\n}', "\r\n", $resource->caldav_data); /** Default deny... */ $allowed = false; if ($dav_resource->HavePrivilegeTo('all', false) || $session->user_no == $resource->user_no || $session->user_no == $resource->logged_user || $c->allow_get_email_visibility && $ic->IsAttendee($session->email)) { /** * These people get to see all of the event, and they should always * get any alarms as well. */ $allowed = true;