}
/**
* Something that we can handle, at least roughly correctly.
*/
$responses = array();
$target_collection = new DAVResource($request->path);
$bound_from = $target_collection->bound_from();
if (!$target_collection->Exists()) {
    $request->DoResponse(404);
}
$params = array();
if (!($target_collection->IsCalendar() || $target_collection->IsSchedulingCollection())) {
    if (!(isset($c->allow_recursive_report) && $c->allow_recursive_report)) {
        $request->DoResponse(403, translate('The calendar-query report must be run against a calendar or a scheduling collection'));
    } else {
        if ($request->path == '/' || $target_collection->IsPrincipal() || $target_collection->IsAddressbook()) {
            $request->DoResponse(403, translate('The calendar-query report may not be run against that URL.'));
        }
    }
    /**
     * We're here because they allow recursive reports, and this appears to be such a location.
     */
    $where = 'WHERE caldav_data.collection_id IN ';
    $where .= '(SELECT bound_source_id FROM dav_binding WHERE dav_binding.dav_name ~ :path_match ';
    $where .= 'UNION ';
    $where .= 'SELECT collection_id FROM collection WHERE collection.dav_name ~ :path_match) ';
    $distinct = 'DISTINCT ON (calendar_item.uid) ';
    $params[':path_match'] = '^' . $target_collection->bound_from();
} else {
    $where = ' WHERE caldav_data.collection_id = ' . $target_collection->resource_id();
    $distinct = '';
Пример #2
0
                break;
        }
    }
    dbg_error_log("cardquery", "Generated SQL was '%s'", $sql);
    return array('sql' => $sql, 'params' => $params);
}
/**
* Something that we can handle, at least roughly correctly.
*/
$responses = array();
$target_collection = new DAVResource($request->path);
$bound_from = $target_collection->bound_from();
if (!$target_collection->Exists()) {
    $request->DoResponse(404);
}
if (!($target_collection->IsAddressbook() || $target_collection->IsSchedulingCollection())) {
    $request->DoResponse(403, translate('The addressbook-query report must be run against an addressbook collection'));
}
/**
* @todo Once we are past DB version 1.2.1 we can change this query more radically.  The best performance to
* date seems to be:
*   SELECT caldav_data.*,address_item.* FROM collection JOIN address_item USING (collection_id,user_no)
*         JOIN caldav_data USING (dav_id) WHERE collection.dav_name = '/user1/home/'
*              AND caldav_data.caldav_type = 'VEVENT' ORDER BY caldav_data.user_no, caldav_data.dav_name;
*/
$params = array();
$where = ' WHERE caldav_data.collection_id = ' . $target_collection->resource_id();
if (is_array($qry_filters)) {
    dbg_log_array('cardquery', 'qry_filters', $qry_filters, true);
    $components = array();
    $filter_fragment = SqlFilterCardDAV($qry_filters, $components);
                break;
        }
    }
    dbg_error_log("cardquery", "Generated SQL was '%s'", $sql);
    return array('sql' => $sql, 'params' => $params);
}
/**
* Something that we can handle, at least roughly correctly.
*/
$responses = array();
$target_collection = new DAVResource($request->path);
$bound_from = $target_collection->bound_from();
if (!$target_collection->Exists()) {
    $request->DoResponse(404);
}
if (!$target_collection->IsAddressbook()) {
    $request->DoResponse(403, translate('The addressbook-query report must be run against an addressbook collection'));
}
/**
* @todo Once we are past DB version 1.2.1 we can change this query more radically.  The best performance to
* date seems to be:
*   SELECT caldav_data.*,address_item.* FROM collection JOIN address_item USING (collection_id,user_no)
*         JOIN caldav_data USING (dav_id) WHERE collection.dav_name = '/user1/home/'
*              AND caldav_data.caldav_type = 'VEVENT' ORDER BY caldav_data.user_no, caldav_data.dav_name;
*/
$params = array();
$where = ' WHERE caldav_data.collection_id = ' . $target_collection->resource_id();
if (is_array($qry_filters)) {
    dbg_log_array('cardquery', 'qry_filters', $qry_filters, true);
    $components = array();
    $filter_fragment = SqlFilterCardDAV($qry_filters, $components);