Example #1
0
$original_etag = md5($request->raw_post);
$qry = new AwlQuery();
$qry->Begin();
$uid = $vcard->GetPValue('UID');
if (empty($uid)) {
    $uid = uuid();
    $vcard->AddProperty('UID', $uid);
}
$last_modified = $vcard->GetPValue('REV');
if (empty($last_modified)) {
    $last_modified = gmdate('Ymd\\THis\\Z');
    $vcard->AddProperty('REV', $last_modified);
} elseif (stripos($last_modified, 'TZ')) {
    // At least one of my examples has this crap.
    $last_modified = str_replace('TZ', 'T000000Z', $last_modified);
    $vcard->ClearProperties('REV');
    $vcard->AddProperty('REV', $last_modified);
} elseif (preg_match('{^(\\d{8})(\\d{6})Z?}', $last_modified, $matches)) {
    $last_modified = $matches[1] . 'T' . $matches[2] . 'Z';
    $vcard->ClearProperties('REV');
    $vcard->AddProperty('REV', $last_modified);
}
$rendered_card = $vcard->Render();
$etag = md5($rendered_card);
$params = array(':user_no' => $user_no, ':dav_name' => $dest->bound_from(), ':etag' => $etag, ':dav_data' => $rendered_card, ':session_user' => $session->user_no, ':modified' => $last_modified);
if ($dest->Exists()) {
    $sql = 'UPDATE caldav_data SET caldav_data=:dav_data, dav_etag=:etag, logged_user=:session_user,
          modified=:modified, user_no=:user_no, caldav_type=\'VCARD\' WHERE dav_name=:dav_name';
    $response_code = 200;
    $put_action_type = 'UPDATE';
    $qry->QDo($sql, $params);