1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @copyright 2020 Christoph Wurst <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @author 2020 Christoph Wurst <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @license GNU AGPL version 3 or any later version |
11
|
|
|
* |
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
15
|
|
|
* License, or (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, |
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
* GNU Affero General Public License for more details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace OCA\ContactsInteraction; |
27
|
|
|
|
28
|
|
|
use OCA\ContactsInteraction\Db\RecentContact; |
29
|
|
|
use Sabre\CardDAV\ICard; |
30
|
|
|
use Sabre\DAV\Exception\NotImplemented; |
31
|
|
|
use Sabre\DAVACL\ACLTrait; |
32
|
|
|
use Sabre\DAVACL\IACL; |
33
|
|
|
|
34
|
|
|
class Card implements ICard, IACL { |
35
|
|
|
|
36
|
|
|
use ACLTrait; |
37
|
|
|
|
38
|
|
|
/** @var RecentContact */ |
39
|
|
|
private $contact; |
40
|
|
|
|
41
|
|
|
/** @var string */ |
42
|
|
|
private $principal; |
43
|
|
|
|
44
|
|
|
/** @var array */ |
45
|
|
|
private $acls; |
46
|
|
|
|
47
|
|
|
public function __construct(RecentContact $contact, string $principal, array $acls) { |
48
|
|
|
$this->contact = $contact; |
49
|
|
|
$this->principal = $principal; |
50
|
|
|
$this->acls = $acls; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritDoc |
55
|
|
|
*/ |
56
|
|
|
function getOwner(): ?string { |
|
|
|
|
57
|
|
|
$this->principal; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @inheritDoc |
62
|
|
|
*/ |
63
|
|
|
function getACL(): array { |
|
|
|
|
64
|
|
|
return $this->acls; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @inheritDoc |
69
|
|
|
*/ |
70
|
|
|
function setAcls(array $acls): void { |
|
|
|
|
71
|
|
|
throw new NotImplemented(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @inheritDoc |
76
|
|
|
*/ |
77
|
|
|
function put($data): ?string { |
|
|
|
|
78
|
|
|
throw new NotImplemented(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @inheritDoc |
83
|
|
|
*/ |
84
|
|
|
function get() { |
|
|
|
|
85
|
|
|
return $this->contact->getCard(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @inheritDoc |
90
|
|
|
*/ |
91
|
|
|
function getContentType(): ?string { |
|
|
|
|
92
|
|
|
return 'text/vcard; charset=utf-8'; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @inheritDoc |
97
|
|
|
*/ |
98
|
|
|
function getETag(): ?string { |
|
|
|
|
99
|
|
|
return null; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @inheritDoc |
104
|
|
|
*/ |
105
|
|
|
function getSize(): int { |
|
|
|
|
106
|
|
|
throw new NotImplemented(); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @inheritDoc |
111
|
|
|
*/ |
112
|
|
|
function delete(): void { |
|
|
|
|
113
|
|
|
throw new NotImplemented(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @inheritDoc |
118
|
|
|
*/ |
119
|
|
|
function getName(): string { |
|
|
|
|
120
|
|
|
return (string) $this->contact->getId(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @inheritDoc |
125
|
|
|
*/ |
126
|
|
|
function setName($name): void { |
|
|
|
|
127
|
|
|
throw new NotImplemented(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @inheritDoc |
132
|
|
|
*/ |
133
|
|
|
function getLastModified(): ?int { |
|
|
|
|
134
|
|
|
return $this->contact->getLastContact(); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.