@@ -27,72 +27,72 @@ |
||
27 | 27 | use Sabre\DAV\File; |
28 | 28 | |
29 | 29 | class AvatarNode extends File { |
30 | - private $ext; |
|
31 | - private $size; |
|
32 | - private $avatar; |
|
30 | + private $ext; |
|
31 | + private $size; |
|
32 | + private $avatar; |
|
33 | 33 | |
34 | - /** |
|
35 | - * AvatarNode constructor. |
|
36 | - * |
|
37 | - * @param integer $size |
|
38 | - * @param string $ext |
|
39 | - * @param IAvatar $avatar |
|
40 | - */ |
|
41 | - public function __construct($size, $ext, $avatar) { |
|
42 | - $this->size = $size; |
|
43 | - $this->ext = $ext; |
|
44 | - $this->avatar = $avatar; |
|
45 | - } |
|
34 | + /** |
|
35 | + * AvatarNode constructor. |
|
36 | + * |
|
37 | + * @param integer $size |
|
38 | + * @param string $ext |
|
39 | + * @param IAvatar $avatar |
|
40 | + */ |
|
41 | + public function __construct($size, $ext, $avatar) { |
|
42 | + $this->size = $size; |
|
43 | + $this->ext = $ext; |
|
44 | + $this->avatar = $avatar; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Returns the name of the node. |
|
49 | - * |
|
50 | - * This is used to generate the url. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function getName() { |
|
55 | - return "$this->size.$this->ext"; |
|
56 | - } |
|
47 | + /** |
|
48 | + * Returns the name of the node. |
|
49 | + * |
|
50 | + * This is used to generate the url. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function getName() { |
|
55 | + return "$this->size.$this->ext"; |
|
56 | + } |
|
57 | 57 | |
58 | - public function get() { |
|
59 | - $image = $this->avatar->get($this->size); |
|
60 | - $res = $image->resource(); |
|
58 | + public function get() { |
|
59 | + $image = $this->avatar->get($this->size); |
|
60 | + $res = $image->resource(); |
|
61 | 61 | |
62 | - ob_start(); |
|
63 | - if ($this->ext === 'png') { |
|
64 | - imagepng($res); |
|
65 | - } else { |
|
66 | - imagejpeg($res); |
|
67 | - } |
|
62 | + ob_start(); |
|
63 | + if ($this->ext === 'png') { |
|
64 | + imagepng($res); |
|
65 | + } else { |
|
66 | + imagejpeg($res); |
|
67 | + } |
|
68 | 68 | |
69 | - return ob_get_clean(); |
|
70 | - } |
|
69 | + return ob_get_clean(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Returns the mime-type for a file |
|
74 | - * |
|
75 | - * If null is returned, we'll assume application/octet-stream |
|
76 | - * |
|
77 | - * @return string|null |
|
78 | - */ |
|
79 | - public function getContentType() { |
|
80 | - if ($this->ext === 'png') { |
|
81 | - return 'image/png'; |
|
82 | - } |
|
83 | - return 'image/jpeg'; |
|
84 | - } |
|
72 | + /** |
|
73 | + * Returns the mime-type for a file |
|
74 | + * |
|
75 | + * If null is returned, we'll assume application/octet-stream |
|
76 | + * |
|
77 | + * @return string|null |
|
78 | + */ |
|
79 | + public function getContentType() { |
|
80 | + if ($this->ext === 'png') { |
|
81 | + return 'image/png'; |
|
82 | + } |
|
83 | + return 'image/jpeg'; |
|
84 | + } |
|
85 | 85 | |
86 | - public function getETag() { |
|
87 | - return $this->avatar->getFile($this->size)->getEtag(); |
|
88 | - } |
|
86 | + public function getETag() { |
|
87 | + return $this->avatar->getFile($this->size)->getEtag(); |
|
88 | + } |
|
89 | 89 | |
90 | - public function getLastModified() { |
|
91 | - $timestamp = $this->avatar->getFile($this->size)->getMTime(); |
|
92 | - if (!empty($timestamp)) { |
|
93 | - return (int)$timestamp; |
|
94 | - } |
|
95 | - return $timestamp; |
|
90 | + public function getLastModified() { |
|
91 | + $timestamp = $this->avatar->getFile($this->size)->getMTime(); |
|
92 | + if (!empty($timestamp)) { |
|
93 | + return (int)$timestamp; |
|
94 | + } |
|
95 | + return $timestamp; |
|
96 | 96 | |
97 | - } |
|
97 | + } |
|
98 | 98 | } |
@@ -31,66 +31,66 @@ |
||
31 | 31 | */ |
32 | 32 | class CappedMemoryCache implements ICache, \ArrayAccess { |
33 | 33 | |
34 | - private $capacity; |
|
35 | - private $cache = []; |
|
36 | - |
|
37 | - public function __construct($capacity = 512) { |
|
38 | - $this->capacity = $capacity; |
|
39 | - } |
|
40 | - |
|
41 | - public function hasKey($key) { |
|
42 | - return isset($this->cache[$key]); |
|
43 | - } |
|
44 | - |
|
45 | - public function get($key) { |
|
46 | - return isset($this->cache[$key]) ? $this->cache[$key] : null; |
|
47 | - } |
|
48 | - |
|
49 | - public function set($key, $value, $ttl = 0) { |
|
50 | - if (is_null($key)) { |
|
51 | - $this->cache[] = $value; |
|
52 | - } else { |
|
53 | - $this->cache[$key] = $value; |
|
54 | - } |
|
55 | - $this->garbageCollect(); |
|
56 | - } |
|
57 | - |
|
58 | - public function remove($key) { |
|
59 | - unset($this->cache[$key]); |
|
60 | - return true; |
|
61 | - } |
|
62 | - |
|
63 | - public function clear($prefix = '') { |
|
64 | - $this->cache = []; |
|
65 | - return true; |
|
66 | - } |
|
67 | - |
|
68 | - public function offsetExists($offset) { |
|
69 | - return $this->hasKey($offset); |
|
70 | - } |
|
71 | - |
|
72 | - public function &offsetGet($offset) { |
|
73 | - return $this->cache[$offset]; |
|
74 | - } |
|
75 | - |
|
76 | - public function offsetSet($offset, $value) { |
|
77 | - $this->set($offset, $value); |
|
78 | - } |
|
79 | - |
|
80 | - public function offsetUnset($offset) { |
|
81 | - $this->remove($offset); |
|
82 | - } |
|
83 | - |
|
84 | - public function getData() { |
|
85 | - return $this->cache; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - private function garbageCollect() { |
|
90 | - while (count($this->cache) > $this->capacity) { |
|
91 | - reset($this->cache); |
|
92 | - $key = key($this->cache); |
|
93 | - $this->remove($key); |
|
94 | - } |
|
95 | - } |
|
34 | + private $capacity; |
|
35 | + private $cache = []; |
|
36 | + |
|
37 | + public function __construct($capacity = 512) { |
|
38 | + $this->capacity = $capacity; |
|
39 | + } |
|
40 | + |
|
41 | + public function hasKey($key) { |
|
42 | + return isset($this->cache[$key]); |
|
43 | + } |
|
44 | + |
|
45 | + public function get($key) { |
|
46 | + return isset($this->cache[$key]) ? $this->cache[$key] : null; |
|
47 | + } |
|
48 | + |
|
49 | + public function set($key, $value, $ttl = 0) { |
|
50 | + if (is_null($key)) { |
|
51 | + $this->cache[] = $value; |
|
52 | + } else { |
|
53 | + $this->cache[$key] = $value; |
|
54 | + } |
|
55 | + $this->garbageCollect(); |
|
56 | + } |
|
57 | + |
|
58 | + public function remove($key) { |
|
59 | + unset($this->cache[$key]); |
|
60 | + return true; |
|
61 | + } |
|
62 | + |
|
63 | + public function clear($prefix = '') { |
|
64 | + $this->cache = []; |
|
65 | + return true; |
|
66 | + } |
|
67 | + |
|
68 | + public function offsetExists($offset) { |
|
69 | + return $this->hasKey($offset); |
|
70 | + } |
|
71 | + |
|
72 | + public function &offsetGet($offset) { |
|
73 | + return $this->cache[$offset]; |
|
74 | + } |
|
75 | + |
|
76 | + public function offsetSet($offset, $value) { |
|
77 | + $this->set($offset, $value); |
|
78 | + } |
|
79 | + |
|
80 | + public function offsetUnset($offset) { |
|
81 | + $this->remove($offset); |
|
82 | + } |
|
83 | + |
|
84 | + public function getData() { |
|
85 | + return $this->cache; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + private function garbageCollect() { |
|
90 | + while (count($this->cache) > $this->capacity) { |
|
91 | + reset($this->cache); |
|
92 | + $key = key($this->cache); |
|
93 | + $this->remove($key); |
|
94 | + } |
|
95 | + } |
|
96 | 96 | } |
@@ -33,137 +33,137 @@ |
||
33 | 33 | |
34 | 34 | class FileSystemTags implements ICheck { |
35 | 35 | |
36 | - /** @var array */ |
|
37 | - protected $fileIds; |
|
38 | - |
|
39 | - /** @var array */ |
|
40 | - protected $fileSystemTags; |
|
41 | - |
|
42 | - /** @var IL10N */ |
|
43 | - protected $l; |
|
44 | - |
|
45 | - /** @var ISystemTagManager */ |
|
46 | - protected $systemTagManager; |
|
47 | - |
|
48 | - /** @var ISystemTagObjectMapper */ |
|
49 | - protected $systemTagObjectMapper; |
|
50 | - |
|
51 | - /** @var IStorage */ |
|
52 | - protected $storage; |
|
53 | - |
|
54 | - /** @var string */ |
|
55 | - protected $path; |
|
56 | - |
|
57 | - /** |
|
58 | - * @param IL10N $l |
|
59 | - * @param ISystemTagManager $systemTagManager |
|
60 | - * @param ISystemTagObjectMapper $systemTagObjectMapper |
|
61 | - */ |
|
62 | - public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) { |
|
63 | - $this->l = $l; |
|
64 | - $this->systemTagManager = $systemTagManager; |
|
65 | - $this->systemTagObjectMapper = $systemTagObjectMapper; |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @param IStorage $storage |
|
70 | - * @param string $path |
|
71 | - */ |
|
72 | - public function setFileInfo(IStorage $storage, $path) { |
|
73 | - $this->storage = $storage; |
|
74 | - $this->path = $path; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param string $operator |
|
79 | - * @param string $value |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function executeCheck($operator, $value) { |
|
83 | - $systemTags = $this->getSystemTags(); |
|
84 | - return ($operator === 'is') === in_array($value, $systemTags); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @param string $operator |
|
89 | - * @param string $value |
|
90 | - * @throws \UnexpectedValueException |
|
91 | - */ |
|
92 | - public function validateCheck($operator, $value) { |
|
93 | - if (!in_array($operator, ['is', '!is'])) { |
|
94 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
95 | - } |
|
96 | - |
|
97 | - try { |
|
98 | - $this->systemTagManager->getTagsByIds($value); |
|
99 | - } catch (TagNotFoundException $e) { |
|
100 | - throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2); |
|
101 | - } catch (\InvalidArgumentException $e) { |
|
102 | - throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Get the ids of the assigned system tags |
|
108 | - * @return string[] |
|
109 | - */ |
|
110 | - protected function getSystemTags() { |
|
111 | - $cache = $this->storage->getCache(); |
|
112 | - $fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class)); |
|
113 | - |
|
114 | - $systemTags = []; |
|
115 | - foreach ($fileIds as $i => $fileId) { |
|
116 | - if (isset($this->fileSystemTags[$fileId])) { |
|
117 | - $systemTags[] = $this->fileSystemTags[$fileId]; |
|
118 | - unset($fileIds[$i]); |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - if (!empty($fileIds)) { |
|
123 | - $mappedSystemTags = $this->systemTagObjectMapper->getTagIdsForObjects($fileIds, 'files'); |
|
124 | - foreach ($mappedSystemTags as $fileId => $fileSystemTags) { |
|
125 | - $this->fileSystemTags[$fileId] = $fileSystemTags; |
|
126 | - $systemTags[] = $fileSystemTags; |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - $systemTags = call_user_func_array('array_merge', $systemTags); |
|
131 | - $systemTags = array_unique($systemTags); |
|
132 | - return $systemTags; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Get the file ids of the given path and its parents |
|
137 | - * @param ICache $cache |
|
138 | - * @param string $path |
|
139 | - * @param bool $isExternalStorage |
|
140 | - * @return int[] |
|
141 | - */ |
|
142 | - protected function getFileIds(ICache $cache, $path, $isExternalStorage) { |
|
143 | - $cacheId = $cache->getNumericStorageId(); |
|
144 | - if (isset($this->fileIds[$cacheId][$path])) { |
|
145 | - return $this->fileIds[$cacheId][$path]; |
|
146 | - } |
|
147 | - |
|
148 | - $parentIds = []; |
|
149 | - if ($path !== $this->dirname($path)) { |
|
150 | - $parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage); |
|
151 | - } else if (!$isExternalStorage) { |
|
152 | - return []; |
|
153 | - } |
|
154 | - |
|
155 | - $fileId = $cache->getId($path); |
|
156 | - if ($fileId !== -1) { |
|
157 | - $parentIds[] = $cache->getId($path); |
|
158 | - } |
|
159 | - |
|
160 | - $this->fileIds[$cacheId][$path] = $parentIds; |
|
161 | - |
|
162 | - return $parentIds; |
|
163 | - } |
|
164 | - |
|
165 | - protected function dirname($path) { |
|
166 | - $dir = dirname($path); |
|
167 | - return $dir === '.' ? '' : $dir; |
|
168 | - } |
|
36 | + /** @var array */ |
|
37 | + protected $fileIds; |
|
38 | + |
|
39 | + /** @var array */ |
|
40 | + protected $fileSystemTags; |
|
41 | + |
|
42 | + /** @var IL10N */ |
|
43 | + protected $l; |
|
44 | + |
|
45 | + /** @var ISystemTagManager */ |
|
46 | + protected $systemTagManager; |
|
47 | + |
|
48 | + /** @var ISystemTagObjectMapper */ |
|
49 | + protected $systemTagObjectMapper; |
|
50 | + |
|
51 | + /** @var IStorage */ |
|
52 | + protected $storage; |
|
53 | + |
|
54 | + /** @var string */ |
|
55 | + protected $path; |
|
56 | + |
|
57 | + /** |
|
58 | + * @param IL10N $l |
|
59 | + * @param ISystemTagManager $systemTagManager |
|
60 | + * @param ISystemTagObjectMapper $systemTagObjectMapper |
|
61 | + */ |
|
62 | + public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) { |
|
63 | + $this->l = $l; |
|
64 | + $this->systemTagManager = $systemTagManager; |
|
65 | + $this->systemTagObjectMapper = $systemTagObjectMapper; |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @param IStorage $storage |
|
70 | + * @param string $path |
|
71 | + */ |
|
72 | + public function setFileInfo(IStorage $storage, $path) { |
|
73 | + $this->storage = $storage; |
|
74 | + $this->path = $path; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * @param string $operator |
|
79 | + * @param string $value |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function executeCheck($operator, $value) { |
|
83 | + $systemTags = $this->getSystemTags(); |
|
84 | + return ($operator === 'is') === in_array($value, $systemTags); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @param string $operator |
|
89 | + * @param string $value |
|
90 | + * @throws \UnexpectedValueException |
|
91 | + */ |
|
92 | + public function validateCheck($operator, $value) { |
|
93 | + if (!in_array($operator, ['is', '!is'])) { |
|
94 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
95 | + } |
|
96 | + |
|
97 | + try { |
|
98 | + $this->systemTagManager->getTagsByIds($value); |
|
99 | + } catch (TagNotFoundException $e) { |
|
100 | + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2); |
|
101 | + } catch (\InvalidArgumentException $e) { |
|
102 | + throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Get the ids of the assigned system tags |
|
108 | + * @return string[] |
|
109 | + */ |
|
110 | + protected function getSystemTags() { |
|
111 | + $cache = $this->storage->getCache(); |
|
112 | + $fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class)); |
|
113 | + |
|
114 | + $systemTags = []; |
|
115 | + foreach ($fileIds as $i => $fileId) { |
|
116 | + if (isset($this->fileSystemTags[$fileId])) { |
|
117 | + $systemTags[] = $this->fileSystemTags[$fileId]; |
|
118 | + unset($fileIds[$i]); |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + if (!empty($fileIds)) { |
|
123 | + $mappedSystemTags = $this->systemTagObjectMapper->getTagIdsForObjects($fileIds, 'files'); |
|
124 | + foreach ($mappedSystemTags as $fileId => $fileSystemTags) { |
|
125 | + $this->fileSystemTags[$fileId] = $fileSystemTags; |
|
126 | + $systemTags[] = $fileSystemTags; |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + $systemTags = call_user_func_array('array_merge', $systemTags); |
|
131 | + $systemTags = array_unique($systemTags); |
|
132 | + return $systemTags; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Get the file ids of the given path and its parents |
|
137 | + * @param ICache $cache |
|
138 | + * @param string $path |
|
139 | + * @param bool $isExternalStorage |
|
140 | + * @return int[] |
|
141 | + */ |
|
142 | + protected function getFileIds(ICache $cache, $path, $isExternalStorage) { |
|
143 | + $cacheId = $cache->getNumericStorageId(); |
|
144 | + if (isset($this->fileIds[$cacheId][$path])) { |
|
145 | + return $this->fileIds[$cacheId][$path]; |
|
146 | + } |
|
147 | + |
|
148 | + $parentIds = []; |
|
149 | + if ($path !== $this->dirname($path)) { |
|
150 | + $parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage); |
|
151 | + } else if (!$isExternalStorage) { |
|
152 | + return []; |
|
153 | + } |
|
154 | + |
|
155 | + $fileId = $cache->getId($path); |
|
156 | + if ($fileId !== -1) { |
|
157 | + $parentIds[] = $cache->getId($path); |
|
158 | + } |
|
159 | + |
|
160 | + $this->fileIds[$cacheId][$path] = $parentIds; |
|
161 | + |
|
162 | + return $parentIds; |
|
163 | + } |
|
164 | + |
|
165 | + protected function dirname($path) { |
|
166 | + $dir = dirname($path); |
|
167 | + return $dir === '.' ? '' : $dir; |
|
168 | + } |
|
169 | 169 | } |
@@ -35,80 +35,80 @@ |
||
35 | 35 | |
36 | 36 | class ActionProviderStore { |
37 | 37 | |
38 | - /** @var IServerContainer */ |
|
39 | - private $serverContainer; |
|
40 | - |
|
41 | - /** @var AppManager */ |
|
42 | - private $appManager; |
|
43 | - |
|
44 | - /** @var ILogger */ |
|
45 | - private $logger; |
|
46 | - |
|
47 | - /** |
|
48 | - * @param IServerContainer $serverContainer |
|
49 | - * @param AppManager $appManager |
|
50 | - * @param ILogger $logger |
|
51 | - */ |
|
52 | - public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) { |
|
53 | - $this->serverContainer = $serverContainer; |
|
54 | - $this->appManager = $appManager; |
|
55 | - $this->logger = $logger; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @param IUser $user |
|
60 | - * @return IProvider[] |
|
61 | - * @throws Exception |
|
62 | - */ |
|
63 | - public function getProviders(IUser $user) { |
|
64 | - $appClasses = $this->getAppProviderClasses($user); |
|
65 | - $providerClasses = $this->getServerProviderClasses(); |
|
66 | - $allClasses = array_merge($providerClasses, $appClasses); |
|
67 | - $providers = []; |
|
68 | - |
|
69 | - foreach ($allClasses as $class) { |
|
70 | - try { |
|
71 | - $providers[] = $this->serverContainer->query($class); |
|
72 | - } catch (QueryException $ex) { |
|
73 | - $this->logger->logException($ex, [ |
|
74 | - 'message' => "Could not load contacts menu action provider $class", |
|
75 | - 'app' => 'core', |
|
76 | - ]); |
|
77 | - throw new Exception("Could not load contacts menu action provider"); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - return $providers; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @return string[] |
|
86 | - */ |
|
87 | - private function getServerProviderClasses() { |
|
88 | - return [ |
|
89 | - EMailProvider::class, |
|
90 | - ]; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param IUser $user |
|
95 | - * @return string[] |
|
96 | - */ |
|
97 | - private function getAppProviderClasses(IUser $user) { |
|
98 | - return array_reduce($this->appManager->getEnabledAppsForUser($user), function($all, $appId) { |
|
99 | - $info = $this->appManager->getAppInfo($appId); |
|
100 | - |
|
101 | - if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) { |
|
102 | - // Nothing to add |
|
103 | - return $all; |
|
104 | - } |
|
105 | - |
|
106 | - $providers = array_reduce($info['contactsmenu'], function($all, $provider) { |
|
107 | - return array_merge($all, [$provider]); |
|
108 | - }, []); |
|
109 | - |
|
110 | - return array_merge($all, $providers); |
|
111 | - }, []); |
|
112 | - } |
|
38 | + /** @var IServerContainer */ |
|
39 | + private $serverContainer; |
|
40 | + |
|
41 | + /** @var AppManager */ |
|
42 | + private $appManager; |
|
43 | + |
|
44 | + /** @var ILogger */ |
|
45 | + private $logger; |
|
46 | + |
|
47 | + /** |
|
48 | + * @param IServerContainer $serverContainer |
|
49 | + * @param AppManager $appManager |
|
50 | + * @param ILogger $logger |
|
51 | + */ |
|
52 | + public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) { |
|
53 | + $this->serverContainer = $serverContainer; |
|
54 | + $this->appManager = $appManager; |
|
55 | + $this->logger = $logger; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @param IUser $user |
|
60 | + * @return IProvider[] |
|
61 | + * @throws Exception |
|
62 | + */ |
|
63 | + public function getProviders(IUser $user) { |
|
64 | + $appClasses = $this->getAppProviderClasses($user); |
|
65 | + $providerClasses = $this->getServerProviderClasses(); |
|
66 | + $allClasses = array_merge($providerClasses, $appClasses); |
|
67 | + $providers = []; |
|
68 | + |
|
69 | + foreach ($allClasses as $class) { |
|
70 | + try { |
|
71 | + $providers[] = $this->serverContainer->query($class); |
|
72 | + } catch (QueryException $ex) { |
|
73 | + $this->logger->logException($ex, [ |
|
74 | + 'message' => "Could not load contacts menu action provider $class", |
|
75 | + 'app' => 'core', |
|
76 | + ]); |
|
77 | + throw new Exception("Could not load contacts menu action provider"); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + return $providers; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @return string[] |
|
86 | + */ |
|
87 | + private function getServerProviderClasses() { |
|
88 | + return [ |
|
89 | + EMailProvider::class, |
|
90 | + ]; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param IUser $user |
|
95 | + * @return string[] |
|
96 | + */ |
|
97 | + private function getAppProviderClasses(IUser $user) { |
|
98 | + return array_reduce($this->appManager->getEnabledAppsForUser($user), function($all, $appId) { |
|
99 | + $info = $this->appManager->getAppInfo($appId); |
|
100 | + |
|
101 | + if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) { |
|
102 | + // Nothing to add |
|
103 | + return $all; |
|
104 | + } |
|
105 | + |
|
106 | + $providers = array_reduce($info['contactsmenu'], function($all, $provider) { |
|
107 | + return array_merge($all, [$provider]); |
|
108 | + }, []); |
|
109 | + |
|
110 | + return array_merge($all, $providers); |
|
111 | + }, []); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |
@@ -24,56 +24,56 @@ |
||
24 | 24 | use OCP\Lockdown\ILockdownManager; |
25 | 25 | |
26 | 26 | class LockdownManager implements ILockdownManager { |
27 | - /** @var ISession */ |
|
28 | - private $sessionCallback; |
|
27 | + /** @var ISession */ |
|
28 | + private $sessionCallback; |
|
29 | 29 | |
30 | - private $enabled = false; |
|
30 | + private $enabled = false; |
|
31 | 31 | |
32 | - /** @var array|null */ |
|
33 | - private $scope; |
|
32 | + /** @var array|null */ |
|
33 | + private $scope; |
|
34 | 34 | |
35 | - /** |
|
36 | - * LockdownManager constructor. |
|
37 | - * |
|
38 | - * @param callable $sessionCallback we need to inject the session lazily to avoid dependency loops |
|
39 | - */ |
|
40 | - public function __construct(callable $sessionCallback) { |
|
41 | - $this->sessionCallback = $sessionCallback; |
|
42 | - } |
|
35 | + /** |
|
36 | + * LockdownManager constructor. |
|
37 | + * |
|
38 | + * @param callable $sessionCallback we need to inject the session lazily to avoid dependency loops |
|
39 | + */ |
|
40 | + public function __construct(callable $sessionCallback) { |
|
41 | + $this->sessionCallback = $sessionCallback; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - public function enable() { |
|
46 | - $this->enabled = true; |
|
47 | - } |
|
45 | + public function enable() { |
|
46 | + $this->enabled = true; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return ISession |
|
51 | - */ |
|
52 | - private function getSession() { |
|
53 | - $callback = $this->sessionCallback; |
|
54 | - return $callback(); |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return ISession |
|
51 | + */ |
|
52 | + private function getSession() { |
|
53 | + $callback = $this->sessionCallback; |
|
54 | + return $callback(); |
|
55 | + } |
|
56 | 56 | |
57 | - private function getScopeAsArray() { |
|
58 | - if (!$this->scope) { |
|
59 | - $session = $this->getSession(); |
|
60 | - $sessionScope = $session->get('token_scope'); |
|
61 | - if ($sessionScope) { |
|
62 | - $this->scope = $sessionScope; |
|
63 | - } |
|
64 | - } |
|
65 | - return $this->scope; |
|
66 | - } |
|
57 | + private function getScopeAsArray() { |
|
58 | + if (!$this->scope) { |
|
59 | + $session = $this->getSession(); |
|
60 | + $sessionScope = $session->get('token_scope'); |
|
61 | + if ($sessionScope) { |
|
62 | + $this->scope = $sessionScope; |
|
63 | + } |
|
64 | + } |
|
65 | + return $this->scope; |
|
66 | + } |
|
67 | 67 | |
68 | - public function setToken(IToken $token) { |
|
69 | - $this->scope = $token->getScopeAsArray(); |
|
70 | - $session = $this->getSession(); |
|
71 | - $session->set('token_scope', $this->scope); |
|
72 | - $this->enable(); |
|
73 | - } |
|
68 | + public function setToken(IToken $token) { |
|
69 | + $this->scope = $token->getScopeAsArray(); |
|
70 | + $session = $this->getSession(); |
|
71 | + $session->set('token_scope', $this->scope); |
|
72 | + $this->enable(); |
|
73 | + } |
|
74 | 74 | |
75 | - public function canAccessFilesystem() { |
|
76 | - $scope = $this->getScopeAsArray(); |
|
77 | - return !$scope || $scope['filesystem']; |
|
78 | - } |
|
75 | + public function canAccessFilesystem() { |
|
76 | + $scope = $this->getScopeAsArray(); |
|
77 | + return !$scope || $scope['filesystem']; |
|
78 | + } |
|
79 | 79 | } |
@@ -23,36 +23,36 @@ |
||
23 | 23 | |
24 | 24 | /** @var $this \OCP\Route\IRouter */ |
25 | 25 | $this->create('user_ldap_ajax_clearMappings', 'ajax/clearMappings.php') |
26 | - ->actionInclude('user_ldap/ajax/clearMappings.php'); |
|
26 | + ->actionInclude('user_ldap/ajax/clearMappings.php'); |
|
27 | 27 | $this->create('user_ldap_ajax_deleteConfiguration', 'ajax/deleteConfiguration.php') |
28 | - ->actionInclude('user_ldap/ajax/deleteConfiguration.php'); |
|
28 | + ->actionInclude('user_ldap/ajax/deleteConfiguration.php'); |
|
29 | 29 | $this->create('user_ldap_ajax_getConfiguration', 'ajax/getConfiguration.php') |
30 | - ->actionInclude('user_ldap/ajax/getConfiguration.php'); |
|
30 | + ->actionInclude('user_ldap/ajax/getConfiguration.php'); |
|
31 | 31 | $this->create('user_ldap_ajax_getNewServerConfigPrefix', 'ajax/getNewServerConfigPrefix.php') |
32 | - ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); |
|
32 | + ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); |
|
33 | 33 | $this->create('user_ldap_ajax_setConfiguration', 'ajax/setConfiguration.php') |
34 | - ->actionInclude('user_ldap/ajax/setConfiguration.php'); |
|
34 | + ->actionInclude('user_ldap/ajax/setConfiguration.php'); |
|
35 | 35 | $this->create('user_ldap_ajax_testConfiguration', 'ajax/testConfiguration.php') |
36 | - ->actionInclude('user_ldap/ajax/testConfiguration.php'); |
|
36 | + ->actionInclude('user_ldap/ajax/testConfiguration.php'); |
|
37 | 37 | $this->create('user_ldap_ajax_wizard', 'ajax/wizard.php') |
38 | - ->actionInclude('user_ldap/ajax/wizard.php'); |
|
38 | + ->actionInclude('user_ldap/ajax/wizard.php'); |
|
39 | 39 | |
40 | 40 | $application = new \OCP\AppFramework\App('user_ldap'); |
41 | 41 | $application->registerRoutes($this, [ |
42 | - 'ocs' => [ |
|
43 | - ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
|
44 | - ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
45 | - ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
|
46 | - ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
|
47 | - ] |
|
42 | + 'ocs' => [ |
|
43 | + ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
|
44 | + ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
45 | + ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
|
46 | + ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
|
47 | + ] |
|
48 | 48 | ]); |
49 | 49 | |
50 | 50 | $application = new OCA\User_LDAP\AppInfo\Application(); |
51 | 51 | $application->registerRoutes($this, [ |
52 | - 'routes' => [ |
|
53 | - ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'], |
|
54 | - ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'], |
|
55 | - ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'], |
|
56 | - ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'], |
|
57 | - ] |
|
52 | + 'routes' => [ |
|
53 | + ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'], |
|
54 | + ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'], |
|
55 | + ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'], |
|
56 | + ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'], |
|
57 | + ] |
|
58 | 58 | ]); |
@@ -23,11 +23,11 @@ |
||
23 | 23 | |
24 | 24 | class PublicCalendarObject extends CalendarObject { |
25 | 25 | |
26 | - /** |
|
27 | - * public calendars are always shared |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - protected function isShared() { |
|
31 | - return true; |
|
32 | - } |
|
26 | + /** |
|
27 | + * public calendars are always shared |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + protected function isShared() { |
|
31 | + return true; |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -25,63 +25,63 @@ |
||
25 | 25 | |
26 | 26 | class PublicCalendar extends Calendar { |
27 | 27 | |
28 | - /** |
|
29 | - * @param string $name |
|
30 | - * @throws NotFound |
|
31 | - * @return PublicCalendarObject |
|
32 | - */ |
|
33 | - public function getChild($name) { |
|
34 | - $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
28 | + /** |
|
29 | + * @param string $name |
|
30 | + * @throws NotFound |
|
31 | + * @return PublicCalendarObject |
|
32 | + */ |
|
33 | + public function getChild($name) { |
|
34 | + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
35 | 35 | |
36 | - if (!$obj) { |
|
37 | - throw new NotFound('Calendar object not found'); |
|
38 | - } |
|
39 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) { |
|
40 | - throw new NotFound('Calendar object not found'); |
|
41 | - } |
|
42 | - $obj['acl'] = $this->getChildACL(); |
|
36 | + if (!$obj) { |
|
37 | + throw new NotFound('Calendar object not found'); |
|
38 | + } |
|
39 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) { |
|
40 | + throw new NotFound('Calendar object not found'); |
|
41 | + } |
|
42 | + $obj['acl'] = $this->getChildACL(); |
|
43 | 43 | |
44 | - return new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
45 | - } |
|
44 | + return new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return PublicCalendarObject[] |
|
49 | - */ |
|
50 | - public function getChildren() { |
|
51 | - $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); |
|
52 | - $children = []; |
|
53 | - foreach ($objs as $obj) { |
|
54 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) { |
|
55 | - continue; |
|
56 | - } |
|
57 | - $obj['acl'] = $this->getChildACL(); |
|
58 | - $children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
59 | - } |
|
60 | - return $children; |
|
61 | - } |
|
47 | + /** |
|
48 | + * @return PublicCalendarObject[] |
|
49 | + */ |
|
50 | + public function getChildren() { |
|
51 | + $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); |
|
52 | + $children = []; |
|
53 | + foreach ($objs as $obj) { |
|
54 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) { |
|
55 | + continue; |
|
56 | + } |
|
57 | + $obj['acl'] = $this->getChildACL(); |
|
58 | + $children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
59 | + } |
|
60 | + return $children; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param string[] $paths |
|
65 | - * @return PublicCalendarObject[] |
|
66 | - */ |
|
67 | - public function getMultipleChildren(array $paths) { |
|
68 | - $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); |
|
69 | - $children = []; |
|
70 | - foreach ($objs as $obj) { |
|
71 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) { |
|
72 | - continue; |
|
73 | - } |
|
74 | - $obj['acl'] = $this->getChildACL(); |
|
75 | - $children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
76 | - } |
|
77 | - return $children; |
|
78 | - } |
|
63 | + /** |
|
64 | + * @param string[] $paths |
|
65 | + * @return PublicCalendarObject[] |
|
66 | + */ |
|
67 | + public function getMultipleChildren(array $paths) { |
|
68 | + $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); |
|
69 | + $children = []; |
|
70 | + foreach ($objs as $obj) { |
|
71 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) { |
|
72 | + continue; |
|
73 | + } |
|
74 | + $obj['acl'] = $this->getChildACL(); |
|
75 | + $children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
76 | + } |
|
77 | + return $children; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * public calendars are always shared |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - protected function isShared() { |
|
85 | - return true; |
|
86 | - } |
|
80 | + /** |
|
81 | + * public calendars are always shared |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + protected function isShared() { |
|
85 | + return true; |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | \ No newline at end of file |
@@ -29,10 +29,10 @@ |
||
29 | 29 | */ |
30 | 30 | interface IProvider { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 12.0 |
|
34 | - * @param IEntry $entry |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public function process(IEntry $entry); |
|
32 | + /** |
|
33 | + * @since 12.0 |
|
34 | + * @param IEntry $entry |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public function process(IEntry $entry); |
|
38 | 38 | } |