summaryrefslogtreecommitdiffstats
path: root/public/lib/AddressbookCollectionManager.php
blob: c8e91620c57af00b0e21cde9d758cc3ed655e899 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

class AddressbookCollectionManager extends GenericCollectionManager {
	public $dataFolder         = PATH.'/../data/';
	public $collectionsFile    = 'addressbooks/addressbooks.json';
	public $collectionsFolder  = 'addressbooks/';
	public $collectionType     = 'Addressbook';
	public $datafield          = 'carddata';


	public function newCollection ($username, $uri, array $properties) {
		$collection = [ 
				'id'           => $this->getHighestCollectionId()+1,
				'principaluri' => $username,
				'displayname'  => NULL,
				'uri'          => $uri,
				'description'  => NULL,
				'synctoken'    => 1,
			];

		$collection = array_merge($collection, $properties);

		return $collection;
	}

	public function newObject ($collectionId, $uri, $data, $extraData = NULL) {
		$object = [
				'id'            => $this->getHighestObjectId($collectionId)+1,
				'uri'           => $uri,
				'etag'          => md5($data),
				'size'          => strlen($data),
				'lastmodified'  => time(),
			];

		return $object;
	}

	public function newObjectUpdate ($collectionId, $uri, $data, $extraData = NULL) {
		$update = [
				'etag'          => md5($data),
				'size'          => strlen($data),
				'lastmodified'  => time(),
			];

		return $update;
	}
}