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

  • CalDAVClient
  • CheckResult
  • setupFakeSession
  • VCard
  • VTimezone

Functions

  • access_ticket_browser
  • binding_row_editor
  • bindings_to_other_browser
  • bindings_to_us_browser
  • build_dependencies_table
  • build_privileges_html
  • build_site_statistics
  • BuildSqlFilter
  • calquery_apply_filter
  • cardquery_apply_filter
  • catch_setup_errors
  • check_awl_version
  • check_calendar
  • check_curl
  • check_database_connection
  • check_datetime
  • check_davical_version
  • check_gettext
  • check_iconv
  • check_ldap
  • check_magic_quotes_gpc
  • check_magic_quotes_runtime
  • check_pdo
  • check_pdo_pgsql
  • check_pgsql
  • check_real_php
  • check_schema_version
  • check_string
  • check_suhosin_server_strip
  • check_xml
  • collection_privilege_format_function
  • confirm_delete_bind_in
  • confirm_delete_binding
  • confirm_delete_collection
  • confirm_delete_principal
  • confirm_delete_ticket
  • do_error
  • edit_binding_row
  • edit_grant_row_collection
  • edit_grant_row_principal
  • edit_group_row
  • edit_ticket_row
  • errorResponse
  • expand_properties
  • fetch_external
  • get_address_properties
  • get_freebusy
  • get_href_containers
  • get_phpinfo
  • grant_row_editor
  • group_members_browser
  • group_memberships_browser
  • group_row_editor
  • handle_subaction
  • i18n
  • ischedule_get
  • log_setup_error
  • make_help_link
  • principal_collection_browser
  • principal_editor
  • principal_grants_browser
  • principal_privilege_format_function
  • send_page_header
  • SqlFilterCardDAV
  • SqlFilterFragment
  • ticket_row_editor
  • unicodeToUtf8
  • update_external
  • utf8ToUnicode
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: /**
 3:  * Errors are sent as an XML document.
 4:  * @param int $code
 5:  * @param string $message
 6:  * @param string $debugdata
 7:  */
 8: 
 9: require_once('HTTPAuthSession.php');
10: $session = new HTTPAuthSession();
11: 
12: require_once('CalDAVRequest.php');
13: $request = new CalDAVRequest();
14: 
15: if ( !isset($c->enable_autodiscover) || ! $c->enable_autodiscover ) {
16:   $request->DoResponse( 404 );
17:   exit(0); // unneccessary
18: }
19: 
20: $ns_outlook_req_2006 = "http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006";
21: $ns_exchange_resp_2006 = "http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006";
22: $ns_outlook_resp_2006a = "http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a";
23: 
24: function errorResponse( $code, $message, $debugdata = '' ) {
25:   global $request, $ns_exchange_resp_2006;
26: 
27:   $error_time_id = time();
28:   $error_time = gmdate('h:i:s', $error_time_id);
29:   $response = <<<ERROR
30: <?xml version="1.0" encoding="utf-8" ?>
31: <Autodiscover xmlns="$ns_exchange_resp_2006">
32:  <Response>
33:   <Error Time="$error_time" Id="$error_time_id">
34:    <ErrorCode>$code</ErrorCode>
35:    <Message>$message</Message>
36:    <DebugData>$debugdata</DebugData>
37:   </Error>
38:  </Response>
39: </Autodiscover>
40: ERROR;
41: 
42:   $request->DoResponse( $code, $response, 'text/xml; charset="utf-8"' );
43:   exit(0); // unneccessary
44: }
45: 
46: 
47: if ( !isset($request->xml_tags) )
48:   errorResponse( 406, translate("Body contains no XML data!") );
49: 
50: $position = 0;
51: $xmltree = BuildXMLTree( $request->xml_tags, $position);
52: if ( !is_object($xmltree) )
53:   errorResponse( 406, translate("REPORT body is not valid XML data!") );
54: 
55: $user_email = $xmltree->GetPath(
56: '/'.$ns_outlook_req_2006.':Autodiscover'.
57: '/'.$ns_outlook_req_2006.':Request'.
58: '/'.$ns_outlook_req_2006.':EMailAddress');
59: if ( count($user_email) < 1 ) errorResponse(500,"User not found.");
60: $user_email = $user_email[0]->GetContent();
61: 
62: $principal = new Principal();
63: 
64: $reply = new XMLDocument( array( $ns_outlook_resp_2006a => "" ) );
65: $response = array(
66:   new XMLElement( 'User',
67:     array(
68:       new XMLElement( 'DisplayName', $principal->$fullname ),
69:       new XMLElement('AutoDiscoverSMTPAddress',$user_email),
70:     )
71:   )
72: );
73: 
74: $response[] = new XMLElement('Account',
75:   array(
76:     new XMLElement( 'AccountType', 'email' ),  // The only allowed accounttype
77:     new XMLElement('Action','settings'),
78:     new XMLElement('Protocol',
79:       array(
80:         new XMLElement('Type', 'DAV'),
81:         new XMLElement('Server', $c->domain_name ),
82:         new XMLElement('LoginName', $principal->username())
83:       )
84:     )
85:   )
86: );
87: 
88: $autodiscover = new XMLElement( "Autodiscover", $responses, $reply->GetXmlNsArray(), $ns_exchange_resp_2006 );
89: 
90: $request->XMLResponse( 207, $autodiscover );
91: 
DAViCal API documentation generated by ApiGen 2.8.0