@@ -33,191 +33,191 @@ |
||
33 | 33 | */ |
34 | 34 | trait PrincipalProxyTrait { |
35 | 35 | |
36 | - /** |
|
37 | - * Returns the list of members for a group-principal |
|
38 | - * |
|
39 | - * @param string $principal |
|
40 | - * @return string[] |
|
41 | - * @throws Exception |
|
42 | - */ |
|
43 | - public function getGroupMemberSet($principal) { |
|
44 | - $members = []; |
|
45 | - |
|
46 | - if ($this->isProxyPrincipal($principal)) { |
|
47 | - $realPrincipal = $this->getPrincipalUriFromProxyPrincipal($principal); |
|
48 | - $principalArray = $this->getPrincipalByPath($realPrincipal); |
|
49 | - if (!$principalArray) { |
|
50 | - throw new Exception('Principal not found'); |
|
51 | - } |
|
52 | - |
|
53 | - $proxies = $this->proxyMapper->getProxiesOf($principalArray['uri']); |
|
54 | - foreach ($proxies as $proxy) { |
|
55 | - if ($this->isReadProxyPrincipal($principal) && $proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
56 | - $members[] = $proxy->getProxyId(); |
|
57 | - } |
|
58 | - |
|
59 | - if ($this->isWriteProxyPrincipal($principal) && $proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
60 | - $members[] = $proxy->getProxyId(); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
64 | - |
|
65 | - return $members; |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Returns the list of groups a principal is a member of |
|
70 | - * |
|
71 | - * @param string $principal |
|
72 | - * @param bool $needGroups |
|
73 | - * @return array |
|
74 | - * @throws Exception |
|
75 | - */ |
|
76 | - public function getGroupMembership($principal, $needGroups = false) { |
|
77 | - list($prefix, $name) = \Sabre\Uri\split($principal); |
|
78 | - |
|
79 | - if ($prefix !== $this->principalPrefix) { |
|
80 | - return []; |
|
81 | - } |
|
82 | - |
|
83 | - $principalArray = $this->getPrincipalByPath($principal); |
|
84 | - if (!$principalArray) { |
|
85 | - throw new Exception('Principal not found'); |
|
86 | - } |
|
87 | - |
|
88 | - $groups = []; |
|
89 | - $proxies = $this->proxyMapper->getProxiesFor($principal); |
|
90 | - foreach ($proxies as $proxy) { |
|
91 | - if ($proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
92 | - $groups[] = $proxy->getOwnerId() . '/calendar-proxy-read'; |
|
93 | - } |
|
94 | - |
|
95 | - if ($proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
96 | - $groups[] = $proxy->getOwnerId() . '/calendar-proxy-write'; |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - return $groups; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Updates the list of group members for a group principal. |
|
105 | - * |
|
106 | - * The principals should be passed as a list of uri's. |
|
107 | - * |
|
108 | - * @param string $principal |
|
109 | - * @param string[] $members |
|
110 | - * @throws Exception |
|
111 | - */ |
|
112 | - public function setGroupMemberSet($principal, array $members) { |
|
113 | - list($principalUri, $target) = \Sabre\Uri\split($principal); |
|
114 | - |
|
115 | - if ($target !== 'calendar-proxy-write' && $target !== 'calendar-proxy-read') { |
|
116 | - throw new Exception('Setting members of the group is not supported yet'); |
|
117 | - } |
|
118 | - |
|
119 | - $masterPrincipalArray = $this->getPrincipalByPath($principalUri); |
|
120 | - if (!$masterPrincipalArray) { |
|
121 | - throw new Exception('Principal not found'); |
|
122 | - } |
|
123 | - |
|
124 | - $permission = ProxyMapper::PERMISSION_READ; |
|
125 | - if ($target === 'calendar-proxy-write') { |
|
126 | - $permission |= ProxyMapper::PERMISSION_WRITE; |
|
127 | - } |
|
128 | - |
|
129 | - list($prefix, $owner) = \Sabre\Uri\split($principalUri); |
|
130 | - $proxies = $this->proxyMapper->getProxiesOf($principalUri); |
|
131 | - |
|
132 | - foreach ($members as $member) { |
|
133 | - list($prefix, $name) = \Sabre\Uri\split($member); |
|
134 | - |
|
135 | - if ($prefix !== $this->principalPrefix) { |
|
136 | - throw new Exception('Invalid member group prefix: ' . $prefix); |
|
137 | - } |
|
138 | - |
|
139 | - $principalArray = $this->getPrincipalByPath($member); |
|
140 | - if (!$principalArray) { |
|
141 | - throw new Exception('Principal not found'); |
|
142 | - } |
|
143 | - |
|
144 | - $found = false; |
|
145 | - foreach ($proxies as $proxy) { |
|
146 | - if ($proxy->getProxyId() === $member) { |
|
147 | - $found = true; |
|
148 | - $proxy->setPermissions($proxy->getPermissions() | $permission); |
|
149 | - $this->proxyMapper->update($proxy); |
|
150 | - |
|
151 | - $proxies = array_filter($proxies, function(Proxy $p) use ($proxy) { |
|
152 | - return $p->getId() !== $proxy->getId(); |
|
153 | - }); |
|
154 | - break; |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - if ($found === false) { |
|
159 | - $proxy = new Proxy(); |
|
160 | - $proxy->setOwnerId($principalUri); |
|
161 | - $proxy->setProxyId($member); |
|
162 | - $proxy->setPermissions($permission); |
|
163 | - $this->proxyMapper->insert($proxy); |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - // Delete all remaining proxies |
|
168 | - foreach ($proxies as $proxy) { |
|
169 | - // Write and Read Proxies have individual requests, |
|
170 | - // so only delete proxies of this permission |
|
171 | - if ($proxy->getPermissions() === $permission) { |
|
172 | - $this->proxyMapper->delete($proxy); |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string $principalUri |
|
179 | - * @return bool |
|
180 | - */ |
|
181 | - private function isProxyPrincipal(string $principalUri):bool { |
|
182 | - list($realPrincipalUri, $proxy) = \Sabre\Uri\split($principalUri); |
|
183 | - list($prefix, $userId) = \Sabre\Uri\split($realPrincipalUri); |
|
184 | - |
|
185 | - if (!isset($prefix) || !isset($userId)) { |
|
186 | - return false; |
|
187 | - } |
|
188 | - if ($prefix !== $this->principalPrefix) { |
|
189 | - return false; |
|
190 | - } |
|
191 | - |
|
192 | - return $proxy === 'calendar-proxy-read' |
|
193 | - || $proxy === 'calendar-proxy-write'; |
|
194 | - |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * @param string $principalUri |
|
199 | - * @return bool |
|
200 | - */ |
|
201 | - private function isReadProxyPrincipal(string $principalUri):bool { |
|
202 | - list(, $proxy) = \Sabre\Uri\split($principalUri); |
|
203 | - return $proxy === 'calendar-proxy-read'; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * @param string $principalUri |
|
208 | - * @return bool |
|
209 | - */ |
|
210 | - private function isWriteProxyPrincipal(string $principalUri):bool { |
|
211 | - list(, $proxy) = \Sabre\Uri\split($principalUri); |
|
212 | - return $proxy === 'calendar-proxy-write'; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * @param string $principalUri |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - private function getPrincipalUriFromProxyPrincipal(string $principalUri):string { |
|
220 | - list($realPrincipalUri, ) = \Sabre\Uri\split($principalUri); |
|
221 | - return $realPrincipalUri; |
|
222 | - } |
|
36 | + /** |
|
37 | + * Returns the list of members for a group-principal |
|
38 | + * |
|
39 | + * @param string $principal |
|
40 | + * @return string[] |
|
41 | + * @throws Exception |
|
42 | + */ |
|
43 | + public function getGroupMemberSet($principal) { |
|
44 | + $members = []; |
|
45 | + |
|
46 | + if ($this->isProxyPrincipal($principal)) { |
|
47 | + $realPrincipal = $this->getPrincipalUriFromProxyPrincipal($principal); |
|
48 | + $principalArray = $this->getPrincipalByPath($realPrincipal); |
|
49 | + if (!$principalArray) { |
|
50 | + throw new Exception('Principal not found'); |
|
51 | + } |
|
52 | + |
|
53 | + $proxies = $this->proxyMapper->getProxiesOf($principalArray['uri']); |
|
54 | + foreach ($proxies as $proxy) { |
|
55 | + if ($this->isReadProxyPrincipal($principal) && $proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
56 | + $members[] = $proxy->getProxyId(); |
|
57 | + } |
|
58 | + |
|
59 | + if ($this->isWriteProxyPrincipal($principal) && $proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
60 | + $members[] = $proxy->getProxyId(); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | + |
|
65 | + return $members; |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Returns the list of groups a principal is a member of |
|
70 | + * |
|
71 | + * @param string $principal |
|
72 | + * @param bool $needGroups |
|
73 | + * @return array |
|
74 | + * @throws Exception |
|
75 | + */ |
|
76 | + public function getGroupMembership($principal, $needGroups = false) { |
|
77 | + list($prefix, $name) = \Sabre\Uri\split($principal); |
|
78 | + |
|
79 | + if ($prefix !== $this->principalPrefix) { |
|
80 | + return []; |
|
81 | + } |
|
82 | + |
|
83 | + $principalArray = $this->getPrincipalByPath($principal); |
|
84 | + if (!$principalArray) { |
|
85 | + throw new Exception('Principal not found'); |
|
86 | + } |
|
87 | + |
|
88 | + $groups = []; |
|
89 | + $proxies = $this->proxyMapper->getProxiesFor($principal); |
|
90 | + foreach ($proxies as $proxy) { |
|
91 | + if ($proxy->getPermissions() === ProxyMapper::PERMISSION_READ) { |
|
92 | + $groups[] = $proxy->getOwnerId() . '/calendar-proxy-read'; |
|
93 | + } |
|
94 | + |
|
95 | + if ($proxy->getPermissions() === (ProxyMapper::PERMISSION_READ | ProxyMapper::PERMISSION_WRITE)) { |
|
96 | + $groups[] = $proxy->getOwnerId() . '/calendar-proxy-write'; |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + return $groups; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Updates the list of group members for a group principal. |
|
105 | + * |
|
106 | + * The principals should be passed as a list of uri's. |
|
107 | + * |
|
108 | + * @param string $principal |
|
109 | + * @param string[] $members |
|
110 | + * @throws Exception |
|
111 | + */ |
|
112 | + public function setGroupMemberSet($principal, array $members) { |
|
113 | + list($principalUri, $target) = \Sabre\Uri\split($principal); |
|
114 | + |
|
115 | + if ($target !== 'calendar-proxy-write' && $target !== 'calendar-proxy-read') { |
|
116 | + throw new Exception('Setting members of the group is not supported yet'); |
|
117 | + } |
|
118 | + |
|
119 | + $masterPrincipalArray = $this->getPrincipalByPath($principalUri); |
|
120 | + if (!$masterPrincipalArray) { |
|
121 | + throw new Exception('Principal not found'); |
|
122 | + } |
|
123 | + |
|
124 | + $permission = ProxyMapper::PERMISSION_READ; |
|
125 | + if ($target === 'calendar-proxy-write') { |
|
126 | + $permission |= ProxyMapper::PERMISSION_WRITE; |
|
127 | + } |
|
128 | + |
|
129 | + list($prefix, $owner) = \Sabre\Uri\split($principalUri); |
|
130 | + $proxies = $this->proxyMapper->getProxiesOf($principalUri); |
|
131 | + |
|
132 | + foreach ($members as $member) { |
|
133 | + list($prefix, $name) = \Sabre\Uri\split($member); |
|
134 | + |
|
135 | + if ($prefix !== $this->principalPrefix) { |
|
136 | + throw new Exception('Invalid member group prefix: ' . $prefix); |
|
137 | + } |
|
138 | + |
|
139 | + $principalArray = $this->getPrincipalByPath($member); |
|
140 | + if (!$principalArray) { |
|
141 | + throw new Exception('Principal not found'); |
|
142 | + } |
|
143 | + |
|
144 | + $found = false; |
|
145 | + foreach ($proxies as $proxy) { |
|
146 | + if ($proxy->getProxyId() === $member) { |
|
147 | + $found = true; |
|
148 | + $proxy->setPermissions($proxy->getPermissions() | $permission); |
|
149 | + $this->proxyMapper->update($proxy); |
|
150 | + |
|
151 | + $proxies = array_filter($proxies, function(Proxy $p) use ($proxy) { |
|
152 | + return $p->getId() !== $proxy->getId(); |
|
153 | + }); |
|
154 | + break; |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + if ($found === false) { |
|
159 | + $proxy = new Proxy(); |
|
160 | + $proxy->setOwnerId($principalUri); |
|
161 | + $proxy->setProxyId($member); |
|
162 | + $proxy->setPermissions($permission); |
|
163 | + $this->proxyMapper->insert($proxy); |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + // Delete all remaining proxies |
|
168 | + foreach ($proxies as $proxy) { |
|
169 | + // Write and Read Proxies have individual requests, |
|
170 | + // so only delete proxies of this permission |
|
171 | + if ($proxy->getPermissions() === $permission) { |
|
172 | + $this->proxyMapper->delete($proxy); |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string $principalUri |
|
179 | + * @return bool |
|
180 | + */ |
|
181 | + private function isProxyPrincipal(string $principalUri):bool { |
|
182 | + list($realPrincipalUri, $proxy) = \Sabre\Uri\split($principalUri); |
|
183 | + list($prefix, $userId) = \Sabre\Uri\split($realPrincipalUri); |
|
184 | + |
|
185 | + if (!isset($prefix) || !isset($userId)) { |
|
186 | + return false; |
|
187 | + } |
|
188 | + if ($prefix !== $this->principalPrefix) { |
|
189 | + return false; |
|
190 | + } |
|
191 | + |
|
192 | + return $proxy === 'calendar-proxy-read' |
|
193 | + || $proxy === 'calendar-proxy-write'; |
|
194 | + |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * @param string $principalUri |
|
199 | + * @return bool |
|
200 | + */ |
|
201 | + private function isReadProxyPrincipal(string $principalUri):bool { |
|
202 | + list(, $proxy) = \Sabre\Uri\split($principalUri); |
|
203 | + return $proxy === 'calendar-proxy-read'; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * @param string $principalUri |
|
208 | + * @return bool |
|
209 | + */ |
|
210 | + private function isWriteProxyPrincipal(string $principalUri):bool { |
|
211 | + list(, $proxy) = \Sabre\Uri\split($principalUri); |
|
212 | + return $proxy === 'calendar-proxy-write'; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * @param string $principalUri |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + private function getPrincipalUriFromProxyPrincipal(string $principalUri):string { |
|
220 | + list($realPrincipalUri, ) = \Sabre\Uri\split($principalUri); |
|
221 | + return $realPrincipalUri; |
|
222 | + } |
|
223 | 223 | } |
@@ -43,130 +43,130 @@ |
||
43 | 43 | |
44 | 44 | class RootCollection extends SimpleCollection { |
45 | 45 | |
46 | - public function __construct() { |
|
47 | - $config = \OC::$server->getConfig(); |
|
48 | - $l10n = \OC::$server->getL10N('dav'); |
|
49 | - $random = \OC::$server->getSecureRandom(); |
|
50 | - $logger = \OC::$server->getLogger(); |
|
51 | - $userManager = \OC::$server->getUserManager(); |
|
52 | - $userSession = \OC::$server->getUserSession(); |
|
53 | - $groupManager = \OC::$server->getGroupManager(); |
|
54 | - $shareManager = \OC::$server->getShareManager(); |
|
55 | - $db = \OC::$server->getDatabaseConnection(); |
|
56 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
57 | - $proxyMapper = \OC::$server->query(ProxyMapper::class); |
|
58 | - |
|
59 | - $userPrincipalBackend = new Principal( |
|
60 | - $userManager, |
|
61 | - $groupManager, |
|
62 | - $shareManager, |
|
63 | - \OC::$server->getUserSession(), |
|
64 | - \OC::$server->getAppManager(), |
|
65 | - $proxyMapper |
|
66 | - ); |
|
67 | - $groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $l10n); |
|
68 | - $calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper); |
|
69 | - $calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper); |
|
70 | - // as soon as debug mode is enabled we allow listing of principals |
|
71 | - $disableListing = !$config->getSystemValue('debug', false); |
|
72 | - |
|
73 | - // setup the first level of the dav tree |
|
74 | - $userPrincipals = new Collection($userPrincipalBackend, 'principals/users'); |
|
75 | - $userPrincipals->disableListing = $disableListing; |
|
76 | - $groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups'); |
|
77 | - $groupPrincipals->disableListing = $disableListing; |
|
78 | - $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system'); |
|
79 | - $systemPrincipals->disableListing = $disableListing; |
|
80 | - $calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources'); |
|
81 | - $calendarResourcePrincipals->disableListing = $disableListing; |
|
82 | - $calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms'); |
|
83 | - $calendarRoomPrincipals->disableListing = $disableListing; |
|
84 | - |
|
85 | - |
|
86 | - $filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users'); |
|
87 | - $filesCollection->disableListing = $disableListing; |
|
88 | - $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher); |
|
89 | - $userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users'); |
|
90 | - $userCalendarRoot->disableListing = $disableListing; |
|
91 | - |
|
92 | - $resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher); |
|
93 | - $resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources'); |
|
94 | - $resourceCalendarRoot->disableListing = $disableListing; |
|
95 | - $roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher); |
|
96 | - $roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms'); |
|
97 | - $roomCalendarRoot->disableListing = $disableListing; |
|
98 | - |
|
99 | - $publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config); |
|
100 | - $publicCalendarRoot->disableListing = $disableListing; |
|
101 | - |
|
102 | - $systemTagCollection = new SystemTag\SystemTagsByIdCollection( |
|
103 | - \OC::$server->getSystemTagManager(), |
|
104 | - \OC::$server->getUserSession(), |
|
105 | - $groupManager |
|
106 | - ); |
|
107 | - $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection( |
|
108 | - \OC::$server->getSystemTagManager(), |
|
109 | - \OC::$server->getSystemTagObjectMapper(), |
|
110 | - \OC::$server->getUserSession(), |
|
111 | - $groupManager, |
|
112 | - \OC::$server->getEventDispatcher() |
|
113 | - ); |
|
114 | - $commentsCollection = new Comments\RootCollection( |
|
115 | - \OC::$server->getCommentsManager(), |
|
116 | - $userManager, |
|
117 | - \OC::$server->getUserSession(), |
|
118 | - \OC::$server->getEventDispatcher(), |
|
119 | - \OC::$server->getLogger() |
|
120 | - ); |
|
121 | - |
|
122 | - $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher); |
|
123 | - $usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users'); |
|
124 | - $usersAddressBookRoot->disableListing = $disableListing; |
|
125 | - |
|
126 | - $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher); |
|
127 | - $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system'); |
|
128 | - $systemAddressBookRoot->disableListing = $disableListing; |
|
129 | - |
|
130 | - $uploadCollection = new Upload\RootCollection( |
|
131 | - $userPrincipalBackend, |
|
132 | - 'principals/users', |
|
133 | - \OC::$server->query(CleanupService::class)); |
|
134 | - $uploadCollection->disableListing = $disableListing; |
|
135 | - |
|
136 | - $avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users'); |
|
137 | - $avatarCollection->disableListing = $disableListing; |
|
138 | - |
|
139 | - $appleProvisioning = new AppleProvisioningNode( |
|
140 | - \OC::$server->query(ITimeFactory::class)); |
|
141 | - |
|
142 | - $children = [ |
|
143 | - new SimpleCollection('principals', [ |
|
144 | - $userPrincipals, |
|
145 | - $groupPrincipals, |
|
146 | - $systemPrincipals, |
|
147 | - $calendarResourcePrincipals, |
|
148 | - $calendarRoomPrincipals]), |
|
149 | - $filesCollection, |
|
150 | - $userCalendarRoot, |
|
151 | - new SimpleCollection('system-calendars', [ |
|
152 | - $resourceCalendarRoot, |
|
153 | - $roomCalendarRoot, |
|
154 | - ]), |
|
155 | - $publicCalendarRoot, |
|
156 | - new SimpleCollection('addressbooks', [ |
|
157 | - $usersAddressBookRoot, |
|
158 | - $systemAddressBookRoot]), |
|
159 | - $systemTagCollection, |
|
160 | - $systemTagRelationsCollection, |
|
161 | - $commentsCollection, |
|
162 | - $uploadCollection, |
|
163 | - $avatarCollection, |
|
164 | - new SimpleCollection('provisioning', [ |
|
165 | - $appleProvisioning |
|
166 | - ]) |
|
167 | - ]; |
|
168 | - |
|
169 | - parent::__construct('root', $children); |
|
170 | - } |
|
46 | + public function __construct() { |
|
47 | + $config = \OC::$server->getConfig(); |
|
48 | + $l10n = \OC::$server->getL10N('dav'); |
|
49 | + $random = \OC::$server->getSecureRandom(); |
|
50 | + $logger = \OC::$server->getLogger(); |
|
51 | + $userManager = \OC::$server->getUserManager(); |
|
52 | + $userSession = \OC::$server->getUserSession(); |
|
53 | + $groupManager = \OC::$server->getGroupManager(); |
|
54 | + $shareManager = \OC::$server->getShareManager(); |
|
55 | + $db = \OC::$server->getDatabaseConnection(); |
|
56 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
57 | + $proxyMapper = \OC::$server->query(ProxyMapper::class); |
|
58 | + |
|
59 | + $userPrincipalBackend = new Principal( |
|
60 | + $userManager, |
|
61 | + $groupManager, |
|
62 | + $shareManager, |
|
63 | + \OC::$server->getUserSession(), |
|
64 | + \OC::$server->getAppManager(), |
|
65 | + $proxyMapper |
|
66 | + ); |
|
67 | + $groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $l10n); |
|
68 | + $calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper); |
|
69 | + $calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper); |
|
70 | + // as soon as debug mode is enabled we allow listing of principals |
|
71 | + $disableListing = !$config->getSystemValue('debug', false); |
|
72 | + |
|
73 | + // setup the first level of the dav tree |
|
74 | + $userPrincipals = new Collection($userPrincipalBackend, 'principals/users'); |
|
75 | + $userPrincipals->disableListing = $disableListing; |
|
76 | + $groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups'); |
|
77 | + $groupPrincipals->disableListing = $disableListing; |
|
78 | + $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system'); |
|
79 | + $systemPrincipals->disableListing = $disableListing; |
|
80 | + $calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources'); |
|
81 | + $calendarResourcePrincipals->disableListing = $disableListing; |
|
82 | + $calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms'); |
|
83 | + $calendarRoomPrincipals->disableListing = $disableListing; |
|
84 | + |
|
85 | + |
|
86 | + $filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users'); |
|
87 | + $filesCollection->disableListing = $disableListing; |
|
88 | + $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher); |
|
89 | + $userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users'); |
|
90 | + $userCalendarRoot->disableListing = $disableListing; |
|
91 | + |
|
92 | + $resourceCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher); |
|
93 | + $resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources'); |
|
94 | + $resourceCalendarRoot->disableListing = $disableListing; |
|
95 | + $roomCalendarCaldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $random, $logger, $dispatcher); |
|
96 | + $roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $roomCalendarCaldavBackend, 'principals/calendar-rooms'); |
|
97 | + $roomCalendarRoot->disableListing = $disableListing; |
|
98 | + |
|
99 | + $publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config); |
|
100 | + $publicCalendarRoot->disableListing = $disableListing; |
|
101 | + |
|
102 | + $systemTagCollection = new SystemTag\SystemTagsByIdCollection( |
|
103 | + \OC::$server->getSystemTagManager(), |
|
104 | + \OC::$server->getUserSession(), |
|
105 | + $groupManager |
|
106 | + ); |
|
107 | + $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection( |
|
108 | + \OC::$server->getSystemTagManager(), |
|
109 | + \OC::$server->getSystemTagObjectMapper(), |
|
110 | + \OC::$server->getUserSession(), |
|
111 | + $groupManager, |
|
112 | + \OC::$server->getEventDispatcher() |
|
113 | + ); |
|
114 | + $commentsCollection = new Comments\RootCollection( |
|
115 | + \OC::$server->getCommentsManager(), |
|
116 | + $userManager, |
|
117 | + \OC::$server->getUserSession(), |
|
118 | + \OC::$server->getEventDispatcher(), |
|
119 | + \OC::$server->getLogger() |
|
120 | + ); |
|
121 | + |
|
122 | + $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher); |
|
123 | + $usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users'); |
|
124 | + $usersAddressBookRoot->disableListing = $disableListing; |
|
125 | + |
|
126 | + $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $userManager, $groupManager, $dispatcher); |
|
127 | + $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system'); |
|
128 | + $systemAddressBookRoot->disableListing = $disableListing; |
|
129 | + |
|
130 | + $uploadCollection = new Upload\RootCollection( |
|
131 | + $userPrincipalBackend, |
|
132 | + 'principals/users', |
|
133 | + \OC::$server->query(CleanupService::class)); |
|
134 | + $uploadCollection->disableListing = $disableListing; |
|
135 | + |
|
136 | + $avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users'); |
|
137 | + $avatarCollection->disableListing = $disableListing; |
|
138 | + |
|
139 | + $appleProvisioning = new AppleProvisioningNode( |
|
140 | + \OC::$server->query(ITimeFactory::class)); |
|
141 | + |
|
142 | + $children = [ |
|
143 | + new SimpleCollection('principals', [ |
|
144 | + $userPrincipals, |
|
145 | + $groupPrincipals, |
|
146 | + $systemPrincipals, |
|
147 | + $calendarResourcePrincipals, |
|
148 | + $calendarRoomPrincipals]), |
|
149 | + $filesCollection, |
|
150 | + $userCalendarRoot, |
|
151 | + new SimpleCollection('system-calendars', [ |
|
152 | + $resourceCalendarRoot, |
|
153 | + $roomCalendarRoot, |
|
154 | + ]), |
|
155 | + $publicCalendarRoot, |
|
156 | + new SimpleCollection('addressbooks', [ |
|
157 | + $usersAddressBookRoot, |
|
158 | + $systemAddressBookRoot]), |
|
159 | + $systemTagCollection, |
|
160 | + $systemTagRelationsCollection, |
|
161 | + $commentsCollection, |
|
162 | + $uploadCollection, |
|
163 | + $avatarCollection, |
|
164 | + new SimpleCollection('provisioning', [ |
|
165 | + $appleProvisioning |
|
166 | + ]) |
|
167 | + ]; |
|
168 | + |
|
169 | + parent::__construct('root', $children); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | } |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | use OCA\DAV\Connector\Sabre\Principal; |
35 | 35 | |
36 | 36 | $authBackend = new Auth( |
37 | - \OC::$server->getSession(), |
|
38 | - \OC::$server->getUserSession(), |
|
39 | - \OC::$server->getRequest(), |
|
40 | - \OC::$server->getTwoFactorAuthManager(), |
|
41 | - \OC::$server->getBruteForceThrottler(), |
|
42 | - 'principals/' |
|
37 | + \OC::$server->getSession(), |
|
38 | + \OC::$server->getUserSession(), |
|
39 | + \OC::$server->getRequest(), |
|
40 | + \OC::$server->getTwoFactorAuthManager(), |
|
41 | + \OC::$server->getBruteForceThrottler(), |
|
42 | + 'principals/' |
|
43 | 43 | ); |
44 | 44 | $principalBackend = new Principal( |
45 | - \OC::$server->getUserManager(), |
|
46 | - \OC::$server->getGroupManager(), |
|
47 | - \OC::$server->getShareManager(), |
|
48 | - \OC::$server->getUserSession(), |
|
49 | - \OC::$server->getAppManager(), |
|
50 | - \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class), |
|
51 | - 'principals/' |
|
45 | + \OC::$server->getUserManager(), |
|
46 | + \OC::$server->getGroupManager(), |
|
47 | + \OC::$server->getShareManager(), |
|
48 | + \OC::$server->getUserSession(), |
|
49 | + \OC::$server->getAppManager(), |
|
50 | + \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class), |
|
51 | + 'principals/' |
|
52 | 52 | ); |
53 | 53 | $db = \OC::$server->getDatabaseConnection(); |
54 | 54 | $userManager = \OC::$server->getUserManager(); |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | $addressBookRoot->disableListing = !$debugging; // Disable listing |
69 | 69 | |
70 | 70 | $nodes = array( |
71 | - $principalCollection, |
|
72 | - $addressBookRoot, |
|
71 | + $principalCollection, |
|
72 | + $addressBookRoot, |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | // Fire up server |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $server->addPlugin(new LegacyDAVACL()); |
87 | 87 | if ($debugging) { |
88 | - $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
88 | + $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
94 | 94 | |
95 | 95 | if ($sendInvitations) { |
96 | - $server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
96 | + $server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
97 | 97 | } |
98 | 98 | $server->addPlugin(new ExceptionLoggerPlugin('caldav', \OC::$server->getLogger())); |
99 | 99 |
@@ -35,21 +35,21 @@ discard block |
||
35 | 35 | use Sabre\CardDAV\Plugin; |
36 | 36 | |
37 | 37 | $authBackend = new Auth( |
38 | - \OC::$server->getSession(), |
|
39 | - \OC::$server->getUserSession(), |
|
40 | - \OC::$server->getRequest(), |
|
41 | - \OC::$server->getTwoFactorAuthManager(), |
|
42 | - \OC::$server->getBruteForceThrottler(), |
|
43 | - 'principals/' |
|
38 | + \OC::$server->getSession(), |
|
39 | + \OC::$server->getUserSession(), |
|
40 | + \OC::$server->getRequest(), |
|
41 | + \OC::$server->getTwoFactorAuthManager(), |
|
42 | + \OC::$server->getBruteForceThrottler(), |
|
43 | + 'principals/' |
|
44 | 44 | ); |
45 | 45 | $principalBackend = new Principal( |
46 | - \OC::$server->getUserManager(), |
|
47 | - \OC::$server->getGroupManager(), |
|
48 | - \OC::$server->getShareManager(), |
|
49 | - \OC::$server->getUserSession(), |
|
50 | - \OC::$server->getAppManager(), |
|
51 | - \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class), |
|
52 | - 'principals/' |
|
46 | + \OC::$server->getUserManager(), |
|
47 | + \OC::$server->getGroupManager(), |
|
48 | + \OC::$server->getShareManager(), |
|
49 | + \OC::$server->getUserSession(), |
|
50 | + \OC::$server->getAppManager(), |
|
51 | + \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class), |
|
52 | + 'principals/' |
|
53 | 53 | ); |
54 | 54 | $db = \OC::$server->getDatabaseConnection(); |
55 | 55 | $cardDavBackend = new CardDavBackend($db, $principalBackend, \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getEventDispatcher()); |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | $addressBookRoot->disableListing = !$debugging; // Disable listing |
65 | 65 | |
66 | 66 | $nodes = array( |
67 | - $principalCollection, |
|
68 | - $addressBookRoot, |
|
67 | + $principalCollection, |
|
68 | + $addressBookRoot, |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | // Fire up server |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | |
81 | 81 | $server->addPlugin(new LegacyDAVACL()); |
82 | 82 | if ($debugging) { |
83 | - $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
83 | + $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
87 | 87 | $server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); |
88 | 88 | $server->addPlugin(new \OCA\DAV\CardDAV\ImageExportPlugin(new \OCA\DAV\CardDAV\PhotoCache( |
89 | - \OC::$server->getAppDataDir('dav-photocache'), |
|
90 | - \OC::$server->getLogger() |
|
89 | + \OC::$server->getAppDataDir('dav-photocache'), |
|
90 | + \OC::$server->getLogger() |
|
91 | 91 | ))); |
92 | 92 | $server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->getLogger())); |
93 | 93 |
@@ -32,70 +32,70 @@ |
||
32 | 32 | use OCA\Files_Versions\Capabilities; |
33 | 33 | |
34 | 34 | class Application extends App { |
35 | - public function __construct(array $urlParams = array()) { |
|
36 | - parent::__construct('files_versions', $urlParams); |
|
35 | + public function __construct(array $urlParams = array()) { |
|
36 | + parent::__construct('files_versions', $urlParams); |
|
37 | 37 | |
38 | - $container = $this->getContainer(); |
|
38 | + $container = $this->getContainer(); |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | * Register capabilities |
42 | 42 | */ |
43 | - $container->registerCapability(Capabilities::class); |
|
43 | + $container->registerCapability(Capabilities::class); |
|
44 | 44 | |
45 | - /* |
|
45 | + /* |
|
46 | 46 | * Register $principalBackend for the DAV collection |
47 | 47 | */ |
48 | - $container->registerService('principalBackend', function (IAppContainer $c) { |
|
49 | - $server = $c->getServer(); |
|
50 | - return new Principal( |
|
51 | - $server->getUserManager(), |
|
52 | - $server->getGroupManager(), |
|
53 | - $server->getShareManager(), |
|
54 | - $server->getUserSession(), |
|
55 | - $server->getAppManager(), |
|
56 | - $server->query(ProxyMapper::class) |
|
57 | - ); |
|
58 | - }); |
|
48 | + $container->registerService('principalBackend', function (IAppContainer $c) { |
|
49 | + $server = $c->getServer(); |
|
50 | + return new Principal( |
|
51 | + $server->getUserManager(), |
|
52 | + $server->getGroupManager(), |
|
53 | + $server->getShareManager(), |
|
54 | + $server->getUserSession(), |
|
55 | + $server->getAppManager(), |
|
56 | + $server->query(ProxyMapper::class) |
|
57 | + ); |
|
58 | + }); |
|
59 | 59 | |
60 | - $container->registerService(IVersionManager::class, function(IAppContainer $c) { |
|
61 | - return new VersionManager(); |
|
62 | - }); |
|
60 | + $container->registerService(IVersionManager::class, function(IAppContainer $c) { |
|
61 | + return new VersionManager(); |
|
62 | + }); |
|
63 | 63 | |
64 | - $this->registerVersionBackends(); |
|
65 | - } |
|
64 | + $this->registerVersionBackends(); |
|
65 | + } |
|
66 | 66 | |
67 | - public function registerVersionBackends() { |
|
68 | - $server = $this->getContainer()->getServer(); |
|
69 | - $appManager = $server->getAppManager(); |
|
70 | - foreach($appManager->getInstalledApps() as $app) { |
|
71 | - $appInfo = $appManager->getAppInfo($app); |
|
72 | - if (isset($appInfo['versions'])) { |
|
73 | - $backends = $appInfo['versions']; |
|
74 | - foreach($backends as $backend) { |
|
75 | - if (isset($backend['@value'])) { |
|
76 | - $this->loadBackend($backend); |
|
77 | - } else { |
|
78 | - foreach ($backend as $singleBackend) { |
|
79 | - $this->loadBackend($singleBackend); |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
67 | + public function registerVersionBackends() { |
|
68 | + $server = $this->getContainer()->getServer(); |
|
69 | + $appManager = $server->getAppManager(); |
|
70 | + foreach($appManager->getInstalledApps() as $app) { |
|
71 | + $appInfo = $appManager->getAppInfo($app); |
|
72 | + if (isset($appInfo['versions'])) { |
|
73 | + $backends = $appInfo['versions']; |
|
74 | + foreach($backends as $backend) { |
|
75 | + if (isset($backend['@value'])) { |
|
76 | + $this->loadBackend($backend); |
|
77 | + } else { |
|
78 | + foreach ($backend as $singleBackend) { |
|
79 | + $this->loadBackend($singleBackend); |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - private function loadBackend(array $backend) { |
|
88 | - $server = $this->getContainer()->getServer(); |
|
89 | - $logger = $server->getLogger(); |
|
90 | - /** @var IVersionManager $versionManager */ |
|
91 | - $versionManager = $this->getContainer()->getServer()->query(IVersionManager::class); |
|
92 | - $class = $backend['@value']; |
|
93 | - $for = $backend['@attributes']['for']; |
|
94 | - try { |
|
95 | - $backendObject = $server->query($class); |
|
96 | - $versionManager->registerBackend($for, $backendObject); |
|
97 | - } catch (\Exception $e) { |
|
98 | - $logger->logException($e); |
|
99 | - } |
|
100 | - } |
|
87 | + private function loadBackend(array $backend) { |
|
88 | + $server = $this->getContainer()->getServer(); |
|
89 | + $logger = $server->getLogger(); |
|
90 | + /** @var IVersionManager $versionManager */ |
|
91 | + $versionManager = $this->getContainer()->getServer()->query(IVersionManager::class); |
|
92 | + $class = $backend['@value']; |
|
93 | + $for = $backend['@attributes']['for']; |
|
94 | + try { |
|
95 | + $backendObject = $server->query($class); |
|
96 | + $versionManager->registerBackend($for, $backendObject); |
|
97 | + } catch (\Exception $e) { |
|
98 | + $logger->logException($e); |
|
99 | + } |
|
100 | + } |
|
101 | 101 | } |
@@ -34,68 +34,68 @@ |
||
34 | 34 | use OCA\Files_Trashbin\Capabilities; |
35 | 35 | |
36 | 36 | class Application extends App { |
37 | - public function __construct (array $urlParams = []) { |
|
38 | - parent::__construct('files_trashbin', $urlParams); |
|
37 | + public function __construct (array $urlParams = []) { |
|
38 | + parent::__construct('files_trashbin', $urlParams); |
|
39 | 39 | |
40 | - $container = $this->getContainer(); |
|
41 | - /* |
|
40 | + $container = $this->getContainer(); |
|
41 | + /* |
|
42 | 42 | * Register capabilities |
43 | 43 | */ |
44 | - $container->registerCapability(Capabilities::class); |
|
44 | + $container->registerCapability(Capabilities::class); |
|
45 | 45 | |
46 | - /* |
|
46 | + /* |
|
47 | 47 | * Register expiration |
48 | 48 | */ |
49 | - $container->registerService('Expiration', function($c) { |
|
50 | - return new Expiration( |
|
51 | - $c->query('ServerContainer')->getConfig(), |
|
52 | - $c->query(ITimeFactory::class) |
|
53 | - ); |
|
54 | - }); |
|
49 | + $container->registerService('Expiration', function($c) { |
|
50 | + return new Expiration( |
|
51 | + $c->query('ServerContainer')->getConfig(), |
|
52 | + $c->query(ITimeFactory::class) |
|
53 | + ); |
|
54 | + }); |
|
55 | 55 | |
56 | - /* |
|
56 | + /* |
|
57 | 57 | * Register $principalBackend for the DAV collection |
58 | 58 | */ |
59 | - $container->registerService('principalBackend', function () { |
|
60 | - return new Principal( |
|
61 | - \OC::$server->getUserManager(), |
|
62 | - \OC::$server->getGroupManager(), |
|
63 | - \OC::$server->getShareManager(), |
|
64 | - \OC::$server->getUserSession(), |
|
65 | - \OC::$server->getAppManager(), |
|
66 | - \OC::$server->query(ProxyMapper::class) |
|
67 | - ); |
|
68 | - }); |
|
59 | + $container->registerService('principalBackend', function () { |
|
60 | + return new Principal( |
|
61 | + \OC::$server->getUserManager(), |
|
62 | + \OC::$server->getGroupManager(), |
|
63 | + \OC::$server->getShareManager(), |
|
64 | + \OC::$server->getUserSession(), |
|
65 | + \OC::$server->getAppManager(), |
|
66 | + \OC::$server->query(ProxyMapper::class) |
|
67 | + ); |
|
68 | + }); |
|
69 | 69 | |
70 | - $container->registerService(ITrashManager::class, function(IAppContainer $c) { |
|
71 | - return new TrashManager(); |
|
72 | - }); |
|
70 | + $container->registerService(ITrashManager::class, function(IAppContainer $c) { |
|
71 | + return new TrashManager(); |
|
72 | + }); |
|
73 | 73 | |
74 | - $this->registerTrashBackends(); |
|
75 | - } |
|
74 | + $this->registerTrashBackends(); |
|
75 | + } |
|
76 | 76 | |
77 | - public function registerTrashBackends() { |
|
78 | - $server = $this->getContainer()->getServer(); |
|
79 | - $logger = $server->getLogger(); |
|
80 | - $appManager = $server->getAppManager(); |
|
81 | - /** @var ITrashManager $trashManager */ |
|
82 | - $trashManager = $this->getContainer()->getServer()->query(ITrashManager::class); |
|
83 | - foreach($appManager->getInstalledApps() as $app) { |
|
84 | - $appInfo = $appManager->getAppInfo($app); |
|
85 | - if (isset($appInfo['trash'])) { |
|
86 | - $backends = $appInfo['trash']; |
|
87 | - foreach($backends as $backend) { |
|
88 | - $class = $backend['@value']; |
|
89 | - $for = $backend['@attributes']['for']; |
|
77 | + public function registerTrashBackends() { |
|
78 | + $server = $this->getContainer()->getServer(); |
|
79 | + $logger = $server->getLogger(); |
|
80 | + $appManager = $server->getAppManager(); |
|
81 | + /** @var ITrashManager $trashManager */ |
|
82 | + $trashManager = $this->getContainer()->getServer()->query(ITrashManager::class); |
|
83 | + foreach($appManager->getInstalledApps() as $app) { |
|
84 | + $appInfo = $appManager->getAppInfo($app); |
|
85 | + if (isset($appInfo['trash'])) { |
|
86 | + $backends = $appInfo['trash']; |
|
87 | + foreach($backends as $backend) { |
|
88 | + $class = $backend['@value']; |
|
89 | + $for = $backend['@attributes']['for']; |
|
90 | 90 | |
91 | - try { |
|
92 | - $backendObject = $server->query($class); |
|
93 | - $trashManager->registerBackend($for, $backendObject); |
|
94 | - } catch (\Exception $e) { |
|
95 | - $logger->logException($e); |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
91 | + try { |
|
92 | + $backendObject = $server->query($class); |
|
93 | + $trashManager->registerBackend($for, $backendObject); |
|
94 | + } catch (\Exception $e) { |
|
95 | + $logger->logException($e); |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | } |