|
|
|
|
@ -611,6 +611,19 @@ class CardDavBackend implements BackendInterface, SyncSupport { |
|
|
|
|
$etag = md5($cardData); |
|
|
|
|
$uid = $this->getUID($cardData); |
|
|
|
|
|
|
|
|
|
$q = $this->db->getQueryBuilder(); |
|
|
|
|
$q->select('uid') |
|
|
|
|
->from('cards') |
|
|
|
|
->where($q->expr()->eq('addressbookid', $q->createNamedParameter($addressBookId))) |
|
|
|
|
->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid))) |
|
|
|
|
->setMaxResults(1); |
|
|
|
|
$result = $q->execute(); |
|
|
|
|
$count = (bool) $result->fetchColumn(); |
|
|
|
|
$result->closeCursor(); |
|
|
|
|
if ($count) { |
|
|
|
|
throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query = $this->db->getQueryBuilder(); |
|
|
|
|
$query->insert('cards') |
|
|
|
|
->values([ |
|
|
|
|
|