示例#1
0
/**
 * Add the calendar-proxy-read/write pseudocollections
 * @param responses array of responses to which to add the collections
 */
function add_proxy_response($which, $parent_path)
{
    global $request, $reply, $c, $session, $property_list;
    if ($parent_path != $request->principal->dav_name()) {
        dbg_error_log('PROPFIND', 'Not returning proxy response since "%s" != "%s"', $parent_path, $request->principal->dav_name());
        return null;
        // Nothing to proxy for
    }
    $collection = (object) '';
    if ($which == 'read') {
        $proxy_group = $request->principal->ReadProxyGroup();
    } else {
        if ($which == 'write') {
            $proxy_group = $request->principal->WriteProxyGroup();
        }
    }
    dbg_error_log('PROPFIND', 'Returning proxy response to "%s" for "%s"', $which, $parent_path);
    $collection->parent_container = $parent_path;
    $collection->dav_name = $parent_path . 'calendar-proxy-' . $which . '/';
    $collection->is_calendar = 'f';
    $collection->is_addressbook = 'f';
    $collection->is_principal = 't';
    $collection->is_proxy = 't';
    $collection->proxy_type = $which;
    $collection->type = 'proxy';
    $collection->dav_displayname = $collection->dav_name;
    $collection->collection_id = 0;
    $collection->user_no = $session->user_no;
    $collection->username = $session->username;
    $collection->email = $session->email;
    $collection->created = date('Ymd\\THis');
    $collection->dav_etag = md5($c->system_name . $collection->dav_name . implode($proxy_group));
    $collection->proxy_for = $proxy_group;
    $collection->resourcetypes = sprintf('<DAV::collection/><http://calendarserver.org/ns/:calendar-proxy-%s/>', $which);
    $collection->in_freebusy_set = 'f';
    $collection->schedule_transp = 'transp';
    $collection->timezone = null;
    $collection->description = '';
    $resource = new DAVResource($collection);
    $resource->FetchPrincipal();
    return $resource->RenderAsXML($property_list, $reply);
}