Beispiel #1
0
 $qry = new PgQuery($sql, $report_user_no);
 // echo $qry->querystring;
 if ($qry->Exec() && $qry->rows > 0) {
     while ($ts = $qry->Fetch()) {
         if ($ts->invoiced != "") {
             $ts->description .= "\n" . $ts->invoiced;
         }
         $response = new XMLElement("response");
         $prop = new XMLElement("prop");
         $ev = new vEvent(array('uid' => $ts->timesheet_id . "@" . $_SERVER['SERVER_NAME'], 'dtstart' => $ts->dtstart, 'duration' => $ts->duration, 'summary' => $ts->summary, 'location' => $ts->location, 'description' => $ts->description));
         if (isset($report[$i]['include_href']) && $report[$i]['include_href'] > 0) {
             $url = sprintf("http://%s:%d%s/%s/%d.ics", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['SCRIPT_NAME'], $report_user_name, $ts->timesheet_id);
             $response->NewElement("href", $url);
         }
         if (isset($report[$i]['include_data']) && $report[$i]['include_data'] > 0) {
             $caldata = $ev->Render();
             $prop->NewElement("calendar-data", $caldata, array("xmlns" => "urn:ietf:params:xml:ns:caldav"));
         }
         if (isset($report[$i]['properties']['GETETAG'])) {
             $prop->NewElement("getetag", '"' . $ts->dav_etag . '"');
         }
         $status = new XMLElement("status", "HTTP/1.1 200 OK");
         $response->NewElement("propstat", array($prop, $status));
         $responses[] = $response;
         dbg_error_log("REPORT", "TS Response: ETag >>%s<< >>%s<<", $ts->dav_etag, $url);
     }
 }
 /**
  * We also include _all_ caldav_data entries in there, since these
  * are events which failed to parse into timesheets.
  */
Beispiel #2
0
        header("HTTP/1.1 500 Infernal Server Error");
        dbg_error_log("ERROR", "Found %d rows matching request %d, timesheet %d for user %s(%d)", $request_id, $ts_id, $session->username, $session->user_no);
        exit(0);
    } elseif ($qry->rows == 1) {
        $dav_event = $qry->Fetch();
        $etag_match = $dav_event->dav_etag;
    }
}
dbg_error_log("PUT", " ETags In: if-match: '%s', if-none-match: '%s'", $etag_match, $etag_none_match);
if ($request_id == 0) {
    dbg_error_log("PUT", "No request_id found for '%s' in '%s' or '%s'", $session->username, $ev->Get("summary"), $ev->Get("location"));
    if (!preg_match('/^Not a timesheet!/', $ev->Get("summary"))) {
        $ev->Put("summary", "Not a timesheet! was: " . $ev->Get("summary"));
    }
    $ev->Put("description", 'No request ID.  Either the location should match #^(WR)?[0-9]+# or the summary should match #^WR[0-9]+/Description of work$# ');
    $reprocessed_event_data = $ev->Render();
    $etag = md5($reprocessed_event_data);
    if ($etag_match == '*' || $etag_match == '') {
        /**
         * If we got this far without an etag we must be inserting it.
         */
        $qry = new PgQuery("INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type, logged_user ) VALUES( ?, ?, ?, ?, ?, ?)", $session->user_no, $put_path, $etag, $reprocessed_event_data, $ev->type, $session->user_no);
        $qry->Exec("PUT");
        header("HTTP/1.1 201 Created");
        /**
         * From draft 13, 5.3.4 we understand that Since we screwed with it, we _don't_ send an etag
         */
    } else {
        $qry = new PgQuery("UPDATE caldav_data SET caldav_data=?, dav_etag=?, caldav_type=?, logged_user=? WHERE user_no=? AND dav_name=? AND dav_etag=?", $reprocessed_event_data, $etag, $ev->type, $session->user_no, $session->user_no, $put_path, $etag_match);
        $qry->Exec("PUT");
        header("HTTP/1.1 204 No Content");
Beispiel #3
0
EOSQL;
$qry = new PgQuery($sql, $get_user_no, $ts_id);
if ($qry->Exec("GET") && $qry->rows == 1) {
    $ts = $qry->Fetch();
    header("HTTP/1.1 200 OK");
    header("ETag: {$ts->dav_etag}");
    if (isset($debug)) {
        header("Content-Type: text/plain");
    } else {
        header("Content-Type: text/calendar");
    }
    if ($ts->invoiced != "") {
        $ts->description .= "\n" . $ts->invoiced;
    }
    $vevent = new vEvent(array('uid' => $ts_id . "@" . $_SERVER['SERVER_NAME'], 'dtstart' => $ts->dtstart, 'duration' => $ts->duration, 'summary' => $ts->summary, 'location' => $ts->location, 'description' => $ts->description));
    print $vevent->Render();
    dbg_error_log("GET", "User: %d, ETag: %s, Path: /%s/%d.ics", $get_user_no, $ts->dav_etag, $get_user_name, $ts_id);
} else {
    $qry = new PgQuery("SELECT * FROM caldav_data WHERE user_no = ? AND dav_name = ? ;", $get_user_no, $get_path);
    dbg_error_log("get", "%s", $qry->querystring);
    if ($qry->Exec("GET") && $qry->rows == 1) {
        $event = $qry->Fetch();
        header("HTTP/1.1 200 OK");
        header("ETag: {$event->dav_etag}");
        if (isset($debug)) {
            header("Content-Type: text/plain");
        } else {
            header("Content-Type: text/calendar");
        }
        print $event->caldav_data;
        dbg_error_log("GET", "User: %d, ETag: %s, Path: %s", $get_user_no, $event->dav_etag, $get_path);