ischedule: fake session info when writing into scheduling collections

update ischedule regression test results
This commit is contained in:
Rob Ostensen 2012-01-31 19:52:25 -06:00 committed by Andrew McMillan
parent d9c64f436e
commit 90f597f46c
5 changed files with 57 additions and 47 deletions

View File

@ -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' );

View File

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<I:schedule-response xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:schedule-response xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:response>
<C:recipient>
<href>mailto:user1@example.net</href>
</C:recipient>
<C:request-status>2.0;Success</C:request-status>
<C:calendar-data>BEGIN:VCALENDAR
<I:recipient>mailto:user1@example.net</I:recipient>
<I:request-status>2.0;Success</I:request-status>
<I:calendar-data>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
</C:calendar-data>
</I:calendar-data>
</I:response>
</I:schedule-response>

View File

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<I:schedule-response xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:schedule-response xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:response>
<C:recipient>
<href>mailto:user1@example.net</href>
</C:recipient>
<C:request-status>2.0;Success</C:request-status>
<C:calendar-data>BEGIN:VCALENDAR
<I:recipient>mailto:user1@example.net</I:recipient>
<I:request-status>2.0;Success</I:request-status>
<I:calendar-data>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
</C:calendar-data>
</I:calendar-data>
</I:response>
</I:schedule-response>

View File

@ -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"
<?xml version="1.0" encoding="utf-8" ?>
<I:schedule-response xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:schedule-response xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:response>
<I:recipient>
<href>mailto:user1@example.net</href>
</I:recipient>
<I:recipient>mailto:user1@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
<I:response>
<I:recipient>
<href>mailto:user2@example.net</href>
</I:recipient>
<I:recipient>mailto:user2@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
<I:response>
<I:recipient>
<href>mailto:user3@example.net</href>
</I:recipient>
<I:recipient>mailto:user3@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
<I:response>
<I:recipient>
<href>mailto:user4@example.net</href>
</I:recipient>
<I:recipient>mailto:user4@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
</I:schedule-response>

View File

@ -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"
<?xml version="1.0" encoding="utf-8" ?>
<I:schedule-response xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:schedule-response xmlns:I="urn:ietf:params:xml:ns:ischedule">
<I:response>
<I:recipient>
<href>mailto:user1@example.net</href>
</I:recipient>
<I:recipient>mailto:user1@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
<I:response>
<I:recipient>
<href>mailto:user2@example.net</href>
</I:recipient>
<I:recipient>mailto:user2@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
<I:response>
<I:recipient>
<href>mailto:user3@example.net</href>
</I:recipient>
<I:recipient>mailto:user3@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
<I:response>
<I:recipient>
<href>mailto:user4@example.net</href>
</I:recipient>
<I:recipient>mailto:user4@example.net</I:recipient>
<I:request-status>2.0;delivered</I:request-status>
</I:response>
</I:schedule-response>
@ -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