Beispiel #1
0
<?php

/**
* We support both LOCK and UNLOCK methods in this function
*/
require_once 'XMLDocument.php';
$reply = new XMLDocument(array('DAV:' => ''));
if (!$request->AllowedTo('write')) {
    $request->NeedPrivilege('write', $request->path);
}
if (!isset($request->xml_tags)) {
    if (isset($request->lock_token)) {
        // It's OK for LOCK refresh requests to be empty.
        $request->xml_tags = array();
    } else {
        $request->XMLResponse(400, new XMLElement('error', new XMLElement('missing-xml-for-request'), $reply->GetXmlNsArray()));
    }
}
$unsupported = array();
$lockinfo = array();
$inside = array();
foreach ($request->xml_tags as $k => $v) {
    $tag = $v['tag'];
    dbg_error_log("LOCK", " Handling Tag '%s' => '%s' ", $k, $v);
    switch ($tag) {
        case 'DAV::lockinfo':
            dbg_error_log("LOCK", ":Request: %s -> %s", $v['type'], $tag);
            if ($v['type'] == "open") {
                $lockscope = "";
                $locktype = "";
                $lockowner = "";
Beispiel #2
0
* than the DAV: namespace.
*
* @package   davical
* @subpackage   caldav
* @author    Andrew McMillan <*****@*****.**>
* @copyright Morphoss Ltd - http://www.morphoss.com/
* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
*/
dbg_error_log('MKTICKET', 'method handler');
require_once 'DAVResource.php';
$request->NeedPrivilege('DAV::bind');
require_once 'XMLDocument.php';
$reply = new XMLDocument(array('DAV:' => '', 'http://www.xythos.com/namespaces/StorageServer' => 'T'));
$target = new DAVResource($request->path);
if (!$target->Exists()) {
    $request->XMLResponse(404, new XMLElement('error', new XMLElement('resource-must-not-be-null'), $reply->GetXmlNsArray()));
}
if (!isset($request->xml_tags)) {
    $request->XMLResponse(400, new XMLElement('error', new XMLElement('missing-xml-for-request'), $reply->GetXmlNsArray()));
}
$xmltree = BuildXMLTree($request->xml_tags, $position);
if ($xmltree->GetTag() != 'http://www.xythos.com/namespaces/StorageServer:ticketinfo' && $xmltree->GetTag() != 'DAV::ticketinfo') {
    $request->XMLResponse(400, new XMLElement('error', new XMLElement('invalid-xml-for-request'), $reply->GetXmlNsArray()));
}
$ticket_timeout = 'Seconds-3600';
$ticket_privs_array = array('read-free-busy');
foreach ($xmltree->GetContent() as $k => $v) {
    // <!ELEMENT ticketinfo (id?, owner?, timeout, visits, privilege)>
    switch ($v->GetTag()) {
        case 'DAV::timeout':
        case 'http://www.xythos.com/namespaces/StorageServer:timeout':
  <Error Time="{$error_time}" Id="{$error_time_id}">
   <ErrorCode>{$code}</ErrorCode>
   <Message>{$message}</Message>
   <DebugData>{$debugdata}</DebugData>
  </Error>
 </Response>
</Autodiscover>
ERROR;
    $request->DoResponse($code, $response, 'text/xml; charset="utf-8"');
    exit(0);
    // unneccessary
}
if (!isset($request->xml_tags)) {
    errorResponse(406, translate("Body contains no XML data!"));
}
$position = 0;
$xmltree = BuildXMLTree($request->xml_tags, $position);
if (!is_object($xmltree)) {
    errorResponse(406, translate("REPORT body is not valid XML data!"));
}
$user_email = $xmltree->GetPath('/' . $ns_outlook_req_2006 . ':Autodiscover' . '/' . $ns_outlook_req_2006 . ':Request' . '/' . $ns_outlook_req_2006 . ':EMailAddress');
if (count($user_email) < 1) {
    errorResponse(500, "User not found.");
}
$user_email = $user_email[0]->GetContent();
$principal = new Principal();
$reply = new XMLDocument(array($ns_outlook_resp_2006a => ""));
$response = array(new XMLElement('User', array(new XMLElement('DisplayName', $principal->{$fullname}), new XMLElement('AutoDiscoverSMTPAddress', $user_email))));
$response[] = new XMLElement('Account', array(new XMLElement('AccountType', 'email'), new XMLElement('Action', 'settings'), new XMLElement('Protocol', array(new XMLElement('Type', 'DAV'), new XMLElement('Server', $c->domain_name), new XMLElement('LoginName', $principal->username())))));
$autodiscover = new XMLElement("Autodiscover", $responses, $reply->GetXmlNsArray(), $ns_exchange_resp_2006);
$request->XMLResponse(207, $autodiscover);
Beispiel #4
0
function handle_cancel_request($ic)
{
    global $c, $session, $request;
    $request->NeedPrivilege('CALDAV:schedule-send-reply');
    $reply = new XMLDocument(array("DAV:" => "", "urn:ietf:params:xml:ns:caldav" => "C"));
    $response = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:caldav');
    $reply->CalDAVElement($response, "request-status", "2.0;Success");
    // Cargo-cult setting
    $response = $reply->NewXMLElement("schedule-response", $response, $reply->GetXmlNsArray());
    $request->XMLResponse(200, $response);
}
Beispiel #5
0
function ischedule_cancel($ic, $attendees, $attendees_fail)
{
    global $c, $session, $request;
    $reply = new XMLDocument(array("DAV:" => "", "urn:ietf:params:xml:ns:caldav" => "C", "urn:ietf:params:xml:ns:ischedule" => "I"));
    $responses = array();
    $ical = $ic->GetComponents('VEVENT');
    $ical = $ical[0];
    foreach ($attendees as $k => $attendee) {
        $XMLresponse = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:ischedule');
        dbg_error_log('ischedule', 'scheduling event for ' . $attendee->email);
        $schedule_target = new Principal('email', $attendee->email);
        $response = '3.7';
        // Attendee was not found on server.
        if ($schedule_target->Exists()) {
            $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"', $attendee_calendar->dav_name(), $schedule_target->username());
                $response = '5.3;cannot schedule this user, unknown or access denied';
                // No scheduling support for user
            } else {
                $attendee_inbox = new WritableCollection(array('path' => $schedule_target->internal_url('schedule-inbox')));
                if (!$attendee_inbox->HavePrivilegeTo('schedule-deliver-invite')) {
                    $response = '3.8;denied';
                    //  No authority to deliver invitations to user.
                } else {
                    if ($attendee_inbox->WriteCalendarMember($ic, false) !== false) {
                        $response = '2.0;delivered';
                        // Scheduling invitation delivered successfully
                    }
                }
            }
        }
        dbg_error_log('PUT', 'Status for attendee <%s> set to "%s"', $attendee->email, $response);
        $XMLresponse->NewElement("recipient", $reply->href('mailto:' . $attendee->email), false, 'urn:ietf:params:xml:ns:ischedule');
        $XMLresponse->NewElement("request-status", $response, false, 'urn:ietf:params:xml:ns:ischedule');
        $responses[] = $XMLresponse;
    }
    foreach ($attendees_fail as $k => $attendee) {
        $XMLresponse = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:ischedule');
        $XMLresponse->NewElement("recipient", $reply->href('mailto:' . $attendee->email), false, 'urn:ietf:params:xml:ns:ischedule');
        $XMLresponse->NewElement("request-status", '5.3;cannot schedule this user, unknown or access denied', false, 'urn:ietf:params:xml:ns:ischedule');
        $responses[] = $XMLresponse;
    }
    $response = $reply->NewXMLElement("schedule-response", $responses, $reply->GetXmlNsArray(), 'urn:ietf:params:xml:ns:ischedule');
    $request->XMLResponse(200, $response);
}