diff --git a/inc/iSchedule-POST.php b/inc/iSchedule-POST.php index 372e7c78..d110215b 100644 --- a/inc/iSchedule-POST.php +++ b/inc/iSchedule-POST.php @@ -15,6 +15,29 @@ require_once('vCalendar.php'); require_once('WritableCollection.php'); include_once('freebusy-functions.php'); + +class FakeSession { + function __construct($principal) { + // Assign each field in the selected record to the object + foreach( $principal AS $k => $v ) { + $this->{$k} = $v; + } + $this->username = $principal->username(); + $this->user_no = $principal->user_no(); + $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 true; + } +} + $d = new iSchedule (); if ( $d->validateRequest ( ) ) { $ical = new vCalendar( $request->raw_post ); @@ -163,6 +186,7 @@ function ischedule_freebusy_request( $ic, $attendees, $attendees_fail) { function ischedule_request( $ic, $attendees, $attendees_fail ) { global $c, $session, $request; + $oldSession = $session; $reply = new XMLDocument( array( "urn:ietf:params:xml:ns:ischedule" => "I" ) ); $responses = array(); $ical = $ic->GetComponents('VEVENT'); @@ -174,6 +198,7 @@ function ischedule_request( $ic, $attendees, $attendees_fail ) { $schedule_target = new Principal('email',$attendee->email); $response = '3.7'; // Attendee was not found on server. if ( $schedule_target->Exists() ) { + $session = new FakeSession($schedule_target); $attendee_calendar = new WritableCollection(array('path' => $schedule_target->internal_url('schedule-default-calendar'))); if ( !$attendee_calendar->Exists() ) { dbg_error_log('ERROR','Default calendar at "%s" does not exist for user "%s"', @@ -189,6 +214,7 @@ function ischedule_request( $ic, $attendees, $attendees_fail ) { $response = '2.0;delivered'; // Scheduling invitation delivered successfully } } + $session = $oldSession; } dbg_error_log( 'ischedule', 'Status for attendee <%s> set to "%s"', $attendee->email, $response ); $XMLresponse->NewElement("recipient", 'mailto:'.$attendee->email, false, 'urn:ietf:params:xml:ns:ischedule' ); diff --git a/testing/tests/ischedule/3040-iSchedule-POST-freebusy.result b/testing/tests/ischedule/3040-iSchedule-POST-freebusy.result index 2dc6d2d3..2bc1b27f 100644 --- a/testing/tests/ischedule/3040-iSchedule-POST-freebusy.result +++ b/testing/tests/ischedule/3040-iSchedule-POST-freebusy.result @@ -1,11 +1,9 @@ - + - - mailto:user1@example.net - - 2.0;Success - BEGIN:VCALENDAR + mailto:user1@example.net + 2.0;Success + BEGIN:VCALENDAR PRODID:-//davical.org//NONSGML AWL Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN @@ -15,8 +13,10 @@ DTSTAMP:yyyymmddThhmmssZ DTSTART:20111018T110000Z DTEND:20111019T110000Z UID:E9F98477-A9C2-43F9-8371-CBA0CBCB0300 +ORGANIZER:mailto:manager1@example.net +ATTENDEE:mailto:user1@example.net END:VFREEBUSY END:VCALENDAR - + diff --git a/testing/tests/ischedule/3041-iSchedule-POST-freebusy.result b/testing/tests/ischedule/3041-iSchedule-POST-freebusy.result index 1d6e92db..1d7527d5 100644 --- a/testing/tests/ischedule/3041-iSchedule-POST-freebusy.result +++ b/testing/tests/ischedule/3041-iSchedule-POST-freebusy.result @@ -1,11 +1,9 @@ - + - - mailto:user1@example.net - - 2.0;Success - BEGIN:VCALENDAR + mailto:user1@example.net + 2.0;Success + BEGIN:VCALENDAR PRODID:-//davical.org//NONSGML AWL Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN @@ -18,8 +16,10 @@ FREEBUSY:20111005T140000Z/20111005T150000Z FREEBUSY:20111005T184500Z/20111005T193000Z FREEBUSY:20111007T100000Z/20111007T110000Z UID:E9F98477-A9C2-43F9-8371-CBA0CBCB0300 +ORGANIZER:mailto:manager1@example.net +ATTENDEE:mailto:user1@example.net END:VFREEBUSY END:VCALENDAR - + diff --git a/testing/tests/ischedule/3050-PUT-with-attendees.result b/testing/tests/ischedule/3050-PUT-with-attendees.result index aeaa5536..fb3acc7b 100644 --- a/testing/tests/ischedule/3050-PUT-with-attendees.result +++ b/testing/tests/ischedule/3050-PUT-with-attendees.result @@ -2,34 +2,26 @@ HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Dow, 01 Jan 2000 00:00:00 GMT -ETag: "b951656a8843d8a7101d57896e278106" -Content-Length: 805 +ETag: "2f9bb75f51266683f713f8d382a67bff" +Content-Length: 672 Content-Type: text/xml; charset="utf-8" - + - - mailto:user1@example.net - + mailto:user1@example.net 2.0;delivered - - mailto:user2@example.net - + mailto:user2@example.net 2.0;delivered - - mailto:user3@example.net - + mailto:user3@example.net 2.0;delivered - - mailto:user4@example.net - + mailto:user4@example.net 2.0;delivered diff --git a/testing/tests/ischedule/3051-PUT-with-attendees.result b/testing/tests/ischedule/3051-PUT-with-attendees.result index d3b99793..bbd9cf6d 100644 --- a/testing/tests/ischedule/3051-PUT-with-attendees.result +++ b/testing/tests/ischedule/3051-PUT-with-attendees.result @@ -2,34 +2,26 @@ HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Dow, 01 Jan 2000 00:00:00 GMT -ETag: "b951656a8843d8a7101d57896e278106" -Content-Length: 805 +ETag: "2f9bb75f51266683f713f8d382a67bff" +Content-Length: 672 Content-Type: text/xml; charset="utf-8" - + - - mailto:user1@example.net - + mailto:user1@example.net 2.0;delivered - - mailto:user2@example.net - + mailto:user2@example.net 2.0;delivered - - mailto:user3@example.net - + mailto:user3@example.net 2.0;delivered - - mailto:user4@example.net - + mailto:user4@example.net 2.0;delivered @@ -93,7 +85,7 @@ END:VCALENDAR caldav_type: >VEVENT< dav_name: >/user2/.in/iSchedule-POST-attendees.ics< - logged_user: >10< + logged_user: >11< summary: >Multiple Beard Meeting< user_no: >11< vcalendar: >BEGIN:VCALENDAR @@ -150,7 +142,7 @@ END:VCALENDAR caldav_type: >VEVENT< dav_name: >/user3/.in/iSchedule-POST-attendees.ics< - logged_user: >10< + logged_user: >12< summary: >Multiple Beard Meeting< user_no: >12< vcalendar: >BEGIN:VCALENDAR @@ -207,7 +199,7 @@ END:VCALENDAR caldav_type: >VEVENT< dav_name: >/user4/.in/iSchedule-POST-attendees.ics< - logged_user: >10< + logged_user: >13< summary: >Multiple Beard Meeting< user_no: >13< vcalendar: >BEGIN:VCALENDAR