@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class Setting implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'systemtags'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'systemtags'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('<strong>System tags</strong> for a file have been modified'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('<strong>System tags</strong> for a file have been modified'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 50; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 50; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -41,222 +41,222 @@ |
||
41 | 41 | use OCP\SystemTag\TagNotFoundException; |
42 | 42 | |
43 | 43 | class Listener { |
44 | - /** @var IGroupManager */ |
|
45 | - protected $groupManager; |
|
46 | - /** @var IManager */ |
|
47 | - protected $activityManager; |
|
48 | - /** @var IUserSession */ |
|
49 | - protected $session; |
|
50 | - /** @var IConfig */ |
|
51 | - protected $config; |
|
52 | - /** @var \OCP\SystemTag\ISystemTagManager */ |
|
53 | - protected $tagManager; |
|
54 | - /** @var \OCP\App\IAppManager */ |
|
55 | - protected $appManager; |
|
56 | - /** @var \OCP\Files\Config\IMountProviderCollection */ |
|
57 | - protected $mountCollection; |
|
58 | - /** @var \OCP\Files\IRootFolder */ |
|
59 | - protected $rootFolder; |
|
44 | + /** @var IGroupManager */ |
|
45 | + protected $groupManager; |
|
46 | + /** @var IManager */ |
|
47 | + protected $activityManager; |
|
48 | + /** @var IUserSession */ |
|
49 | + protected $session; |
|
50 | + /** @var IConfig */ |
|
51 | + protected $config; |
|
52 | + /** @var \OCP\SystemTag\ISystemTagManager */ |
|
53 | + protected $tagManager; |
|
54 | + /** @var \OCP\App\IAppManager */ |
|
55 | + protected $appManager; |
|
56 | + /** @var \OCP\Files\Config\IMountProviderCollection */ |
|
57 | + protected $mountCollection; |
|
58 | + /** @var \OCP\Files\IRootFolder */ |
|
59 | + protected $rootFolder; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Listener constructor. |
|
63 | - * |
|
64 | - * @param IGroupManager $groupManager |
|
65 | - * @param IManager $activityManager |
|
66 | - * @param IUserSession $session |
|
67 | - * @param IConfig $config |
|
68 | - * @param ISystemTagManager $tagManager |
|
69 | - * @param IAppManager $appManager |
|
70 | - * @param IMountProviderCollection $mountCollection |
|
71 | - * @param IRootFolder $rootFolder |
|
72 | - */ |
|
73 | - public function __construct(IGroupManager $groupManager, |
|
74 | - IManager $activityManager, |
|
75 | - IUserSession $session, |
|
76 | - IConfig $config, |
|
77 | - ISystemTagManager $tagManager, |
|
78 | - IAppManager $appManager, |
|
79 | - IMountProviderCollection $mountCollection, |
|
80 | - IRootFolder $rootFolder) { |
|
81 | - $this->groupManager = $groupManager; |
|
82 | - $this->activityManager = $activityManager; |
|
83 | - $this->session = $session; |
|
84 | - $this->config = $config; |
|
85 | - $this->tagManager = $tagManager; |
|
86 | - $this->appManager = $appManager; |
|
87 | - $this->mountCollection = $mountCollection; |
|
88 | - $this->rootFolder = $rootFolder; |
|
89 | - } |
|
61 | + /** |
|
62 | + * Listener constructor. |
|
63 | + * |
|
64 | + * @param IGroupManager $groupManager |
|
65 | + * @param IManager $activityManager |
|
66 | + * @param IUserSession $session |
|
67 | + * @param IConfig $config |
|
68 | + * @param ISystemTagManager $tagManager |
|
69 | + * @param IAppManager $appManager |
|
70 | + * @param IMountProviderCollection $mountCollection |
|
71 | + * @param IRootFolder $rootFolder |
|
72 | + */ |
|
73 | + public function __construct(IGroupManager $groupManager, |
|
74 | + IManager $activityManager, |
|
75 | + IUserSession $session, |
|
76 | + IConfig $config, |
|
77 | + ISystemTagManager $tagManager, |
|
78 | + IAppManager $appManager, |
|
79 | + IMountProviderCollection $mountCollection, |
|
80 | + IRootFolder $rootFolder) { |
|
81 | + $this->groupManager = $groupManager; |
|
82 | + $this->activityManager = $activityManager; |
|
83 | + $this->session = $session; |
|
84 | + $this->config = $config; |
|
85 | + $this->tagManager = $tagManager; |
|
86 | + $this->appManager = $appManager; |
|
87 | + $this->mountCollection = $mountCollection; |
|
88 | + $this->rootFolder = $rootFolder; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param ManagerEvent $event |
|
93 | - */ |
|
94 | - public function event(ManagerEvent $event) { |
|
95 | - $actor = $this->session->getUser(); |
|
96 | - if ($actor instanceof IUser) { |
|
97 | - $actor = $actor->getUID(); |
|
98 | - } else { |
|
99 | - $actor = ''; |
|
100 | - } |
|
101 | - $tag = $event->getTag(); |
|
91 | + /** |
|
92 | + * @param ManagerEvent $event |
|
93 | + */ |
|
94 | + public function event(ManagerEvent $event) { |
|
95 | + $actor = $this->session->getUser(); |
|
96 | + if ($actor instanceof IUser) { |
|
97 | + $actor = $actor->getUID(); |
|
98 | + } else { |
|
99 | + $actor = ''; |
|
100 | + } |
|
101 | + $tag = $event->getTag(); |
|
102 | 102 | |
103 | - $activity = $this->activityManager->generateEvent(); |
|
104 | - $activity->setApp('systemtags') |
|
105 | - ->setType('systemtags') |
|
106 | - ->setAuthor($actor) |
|
107 | - ->setObject('systemtag', $tag->getId(), $tag->getName()); |
|
108 | - if ($event->getEvent() === ManagerEvent::EVENT_CREATE) { |
|
109 | - $activity->setSubject(Provider::CREATE_TAG, [ |
|
110 | - $actor, |
|
111 | - $this->prepareTagAsParameter($event->getTag()), |
|
112 | - ]); |
|
113 | - } else if ($event->getEvent() === ManagerEvent::EVENT_UPDATE) { |
|
114 | - $activity->setSubject(Provider::UPDATE_TAG, [ |
|
115 | - $actor, |
|
116 | - $this->prepareTagAsParameter($event->getTag()), |
|
117 | - $this->prepareTagAsParameter($event->getTagBefore()), |
|
118 | - ]); |
|
119 | - } else if ($event->getEvent() === ManagerEvent::EVENT_DELETE) { |
|
120 | - $activity->setSubject(Provider::DELETE_TAG, [ |
|
121 | - $actor, |
|
122 | - $this->prepareTagAsParameter($event->getTag()), |
|
123 | - ]); |
|
124 | - } else { |
|
125 | - return; |
|
126 | - } |
|
103 | + $activity = $this->activityManager->generateEvent(); |
|
104 | + $activity->setApp('systemtags') |
|
105 | + ->setType('systemtags') |
|
106 | + ->setAuthor($actor) |
|
107 | + ->setObject('systemtag', $tag->getId(), $tag->getName()); |
|
108 | + if ($event->getEvent() === ManagerEvent::EVENT_CREATE) { |
|
109 | + $activity->setSubject(Provider::CREATE_TAG, [ |
|
110 | + $actor, |
|
111 | + $this->prepareTagAsParameter($event->getTag()), |
|
112 | + ]); |
|
113 | + } else if ($event->getEvent() === ManagerEvent::EVENT_UPDATE) { |
|
114 | + $activity->setSubject(Provider::UPDATE_TAG, [ |
|
115 | + $actor, |
|
116 | + $this->prepareTagAsParameter($event->getTag()), |
|
117 | + $this->prepareTagAsParameter($event->getTagBefore()), |
|
118 | + ]); |
|
119 | + } else if ($event->getEvent() === ManagerEvent::EVENT_DELETE) { |
|
120 | + $activity->setSubject(Provider::DELETE_TAG, [ |
|
121 | + $actor, |
|
122 | + $this->prepareTagAsParameter($event->getTag()), |
|
123 | + ]); |
|
124 | + } else { |
|
125 | + return; |
|
126 | + } |
|
127 | 127 | |
128 | - $group = $this->groupManager->get('admin'); |
|
129 | - if ($group instanceof IGroup) { |
|
130 | - foreach ($group->getUsers() as $user) { |
|
131 | - $activity->setAffectedUser($user->getUID()); |
|
132 | - $this->activityManager->publish($activity); |
|
133 | - } |
|
134 | - } |
|
128 | + $group = $this->groupManager->get('admin'); |
|
129 | + if ($group instanceof IGroup) { |
|
130 | + foreach ($group->getUsers() as $user) { |
|
131 | + $activity->setAffectedUser($user->getUID()); |
|
132 | + $this->activityManager->publish($activity); |
|
133 | + } |
|
134 | + } |
|
135 | 135 | |
136 | 136 | |
137 | - if ($actor !== '' && ($event->getEvent() === ManagerEvent::EVENT_CREATE || $event->getEvent() === ManagerEvent::EVENT_UPDATE)) { |
|
138 | - $this->updateLastUsedTags($actor, $event->getTag()); |
|
139 | - } |
|
140 | - } |
|
137 | + if ($actor !== '' && ($event->getEvent() === ManagerEvent::EVENT_CREATE || $event->getEvent() === ManagerEvent::EVENT_UPDATE)) { |
|
138 | + $this->updateLastUsedTags($actor, $event->getTag()); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * @param MapperEvent $event |
|
144 | - */ |
|
145 | - public function mapperEvent(MapperEvent $event) { |
|
146 | - $tagIds = $event->getTags(); |
|
147 | - if ($event->getObjectType() !== 'files' ||empty($tagIds) |
|
148 | - || !in_array($event->getEvent(), [MapperEvent::EVENT_ASSIGN, MapperEvent::EVENT_UNASSIGN]) |
|
149 | - || !$this->appManager->isInstalled('activity')) { |
|
150 | - // System tags not for files, no tags, not (un-)assigning or no activity-app enabled (save the energy) |
|
151 | - return; |
|
152 | - } |
|
142 | + /** |
|
143 | + * @param MapperEvent $event |
|
144 | + */ |
|
145 | + public function mapperEvent(MapperEvent $event) { |
|
146 | + $tagIds = $event->getTags(); |
|
147 | + if ($event->getObjectType() !== 'files' ||empty($tagIds) |
|
148 | + || !in_array($event->getEvent(), [MapperEvent::EVENT_ASSIGN, MapperEvent::EVENT_UNASSIGN]) |
|
149 | + || !$this->appManager->isInstalled('activity')) { |
|
150 | + // System tags not for files, no tags, not (un-)assigning or no activity-app enabled (save the energy) |
|
151 | + return; |
|
152 | + } |
|
153 | 153 | |
154 | - try { |
|
155 | - $tags = $this->tagManager->getTagsByIds($tagIds); |
|
156 | - } catch (TagNotFoundException $e) { |
|
157 | - // User assigned/unassigned a non-existing tag, ignore... |
|
158 | - return; |
|
159 | - } |
|
154 | + try { |
|
155 | + $tags = $this->tagManager->getTagsByIds($tagIds); |
|
156 | + } catch (TagNotFoundException $e) { |
|
157 | + // User assigned/unassigned a non-existing tag, ignore... |
|
158 | + return; |
|
159 | + } |
|
160 | 160 | |
161 | - if (empty($tags)) { |
|
162 | - return; |
|
163 | - } |
|
161 | + if (empty($tags)) { |
|
162 | + return; |
|
163 | + } |
|
164 | 164 | |
165 | - // Get all mount point owners |
|
166 | - $cache = $this->mountCollection->getMountCache(); |
|
167 | - $mounts = $cache->getMountsForFileId($event->getObjectId()); |
|
168 | - if (empty($mounts)) { |
|
169 | - return; |
|
170 | - } |
|
165 | + // Get all mount point owners |
|
166 | + $cache = $this->mountCollection->getMountCache(); |
|
167 | + $mounts = $cache->getMountsForFileId($event->getObjectId()); |
|
168 | + if (empty($mounts)) { |
|
169 | + return; |
|
170 | + } |
|
171 | 171 | |
172 | - $users = []; |
|
173 | - foreach ($mounts as $mount) { |
|
174 | - $owner = $mount->getUser()->getUID(); |
|
175 | - $ownerFolder = $this->rootFolder->getUserFolder($owner); |
|
176 | - $nodes = $ownerFolder->getById($event->getObjectId()); |
|
177 | - if (!empty($nodes)) { |
|
178 | - /** @var Node $node */ |
|
179 | - $node = array_shift($nodes); |
|
180 | - $path = $node->getPath(); |
|
181 | - if (strpos($path, '/' . $owner . '/files/') === 0) { |
|
182 | - $path = substr($path, strlen('/' . $owner . '/files')); |
|
183 | - } |
|
184 | - // Get all users that have access to the mount point |
|
185 | - $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true)); |
|
186 | - } |
|
187 | - } |
|
172 | + $users = []; |
|
173 | + foreach ($mounts as $mount) { |
|
174 | + $owner = $mount->getUser()->getUID(); |
|
175 | + $ownerFolder = $this->rootFolder->getUserFolder($owner); |
|
176 | + $nodes = $ownerFolder->getById($event->getObjectId()); |
|
177 | + if (!empty($nodes)) { |
|
178 | + /** @var Node $node */ |
|
179 | + $node = array_shift($nodes); |
|
180 | + $path = $node->getPath(); |
|
181 | + if (strpos($path, '/' . $owner . '/files/') === 0) { |
|
182 | + $path = substr($path, strlen('/' . $owner . '/files')); |
|
183 | + } |
|
184 | + // Get all users that have access to the mount point |
|
185 | + $users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true)); |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | - $actor = $this->session->getUser(); |
|
190 | - if ($actor instanceof IUser) { |
|
191 | - $actor = $actor->getUID(); |
|
192 | - } else { |
|
193 | - $actor = ''; |
|
194 | - } |
|
189 | + $actor = $this->session->getUser(); |
|
190 | + if ($actor instanceof IUser) { |
|
191 | + $actor = $actor->getUID(); |
|
192 | + } else { |
|
193 | + $actor = ''; |
|
194 | + } |
|
195 | 195 | |
196 | - $activity = $this->activityManager->generateEvent(); |
|
197 | - $activity->setApp('systemtags') |
|
198 | - ->setType('systemtags') |
|
199 | - ->setAuthor($actor) |
|
200 | - ->setObject($event->getObjectType(), (int) $event->getObjectId()); |
|
196 | + $activity = $this->activityManager->generateEvent(); |
|
197 | + $activity->setApp('systemtags') |
|
198 | + ->setType('systemtags') |
|
199 | + ->setAuthor($actor) |
|
200 | + ->setObject($event->getObjectType(), (int) $event->getObjectId()); |
|
201 | 201 | |
202 | - foreach ($users as $user => $path) { |
|
203 | - $activity->setAffectedUser($user); |
|
202 | + foreach ($users as $user => $path) { |
|
203 | + $activity->setAffectedUser($user); |
|
204 | 204 | |
205 | - foreach ($tags as $tag) { |
|
206 | - // don't publish activity for non-admins if tag is invisible |
|
207 | - if (!$tag->isUserVisible() && !$this->groupManager->isAdmin($user)) { |
|
208 | - continue; |
|
209 | - } |
|
210 | - if ($event->getEvent() === MapperEvent::EVENT_ASSIGN) { |
|
211 | - $activity->setSubject(Provider::ASSIGN_TAG, [ |
|
212 | - $actor, |
|
213 | - $path, |
|
214 | - $this->prepareTagAsParameter($tag), |
|
215 | - ]); |
|
216 | - } else if ($event->getEvent() === MapperEvent::EVENT_UNASSIGN) { |
|
217 | - $activity->setSubject(Provider::UNASSIGN_TAG, [ |
|
218 | - $actor, |
|
219 | - $path, |
|
220 | - $this->prepareTagAsParameter($tag), |
|
221 | - ]); |
|
222 | - } |
|
205 | + foreach ($tags as $tag) { |
|
206 | + // don't publish activity for non-admins if tag is invisible |
|
207 | + if (!$tag->isUserVisible() && !$this->groupManager->isAdmin($user)) { |
|
208 | + continue; |
|
209 | + } |
|
210 | + if ($event->getEvent() === MapperEvent::EVENT_ASSIGN) { |
|
211 | + $activity->setSubject(Provider::ASSIGN_TAG, [ |
|
212 | + $actor, |
|
213 | + $path, |
|
214 | + $this->prepareTagAsParameter($tag), |
|
215 | + ]); |
|
216 | + } else if ($event->getEvent() === MapperEvent::EVENT_UNASSIGN) { |
|
217 | + $activity->setSubject(Provider::UNASSIGN_TAG, [ |
|
218 | + $actor, |
|
219 | + $path, |
|
220 | + $this->prepareTagAsParameter($tag), |
|
221 | + ]); |
|
222 | + } |
|
223 | 223 | |
224 | - $this->activityManager->publish($activity); |
|
225 | - } |
|
226 | - } |
|
224 | + $this->activityManager->publish($activity); |
|
225 | + } |
|
226 | + } |
|
227 | 227 | |
228 | - if ($actor !== '' && $event->getEvent() === MapperEvent::EVENT_ASSIGN) { |
|
229 | - foreach ($tags as $tag) { |
|
230 | - $this->updateLastUsedTags($actor, $tag); |
|
231 | - } |
|
232 | - } |
|
233 | - } |
|
228 | + if ($actor !== '' && $event->getEvent() === MapperEvent::EVENT_ASSIGN) { |
|
229 | + foreach ($tags as $tag) { |
|
230 | + $this->updateLastUsedTags($actor, $tag); |
|
231 | + } |
|
232 | + } |
|
233 | + } |
|
234 | 234 | |
235 | - /** |
|
236 | - * @param string $actor |
|
237 | - * @param ISystemTag $tag |
|
238 | - */ |
|
239 | - protected function updateLastUsedTags($actor, ISystemTag $tag) { |
|
240 | - $lastUsedTags = $this->config->getUserValue($actor, 'systemtags', 'last_used', '[]'); |
|
241 | - $lastUsedTags = json_decode($lastUsedTags, true); |
|
235 | + /** |
|
236 | + * @param string $actor |
|
237 | + * @param ISystemTag $tag |
|
238 | + */ |
|
239 | + protected function updateLastUsedTags($actor, ISystemTag $tag) { |
|
240 | + $lastUsedTags = $this->config->getUserValue($actor, 'systemtags', 'last_used', '[]'); |
|
241 | + $lastUsedTags = json_decode($lastUsedTags, true); |
|
242 | 242 | |
243 | - array_unshift($lastUsedTags, $tag->getId()); |
|
244 | - array_unique($lastUsedTags); |
|
245 | - $lastUsedTags = array_slice($lastUsedTags, 0, 10); |
|
243 | + array_unshift($lastUsedTags, $tag->getId()); |
|
244 | + array_unique($lastUsedTags); |
|
245 | + $lastUsedTags = array_slice($lastUsedTags, 0, 10); |
|
246 | 246 | |
247 | - $this->config->setUserValue($actor, 'systemtags', 'last_used', json_encode($lastUsedTags)); |
|
248 | - } |
|
247 | + $this->config->setUserValue($actor, 'systemtags', 'last_used', json_encode($lastUsedTags)); |
|
248 | + } |
|
249 | 249 | |
250 | - /** |
|
251 | - * @param ISystemTag $tag |
|
252 | - * @return string |
|
253 | - */ |
|
254 | - protected function prepareTagAsParameter(ISystemTag $tag) { |
|
255 | - return json_encode([ |
|
256 | - 'id' => $tag->getId(), |
|
257 | - 'name' => $tag->getName(), |
|
258 | - 'assignable' => $tag->isUserAssignable(), |
|
259 | - 'visible' => $tag->isUserVisible(), |
|
260 | - ]); |
|
261 | - } |
|
250 | + /** |
|
251 | + * @param ISystemTag $tag |
|
252 | + * @return string |
|
253 | + */ |
|
254 | + protected function prepareTagAsParameter(ISystemTag $tag) { |
|
255 | + return json_encode([ |
|
256 | + 'id' => $tag->getId(), |
|
257 | + 'name' => $tag->getName(), |
|
258 | + 'assignable' => $tag->isUserAssignable(), |
|
259 | + 'visible' => $tag->isUserVisible(), |
|
260 | + ]); |
|
261 | + } |
|
262 | 262 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class LastUsedController extends Controller { |
32 | 32 | |
33 | - /** @var IConfig */ |
|
34 | - protected $config; |
|
35 | - |
|
36 | - /** @var IUserSession */ |
|
37 | - protected $userSession; |
|
38 | - |
|
39 | - /** |
|
40 | - * @param string $appName |
|
41 | - * @param IRequest $request |
|
42 | - * @param IConfig $config |
|
43 | - * @param IUserSession $userSession |
|
44 | - */ |
|
45 | - public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
46 | - parent::__construct($appName, $request); |
|
47 | - $this->config = $config; |
|
48 | - $this->userSession = $userSession; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @NoAdminRequired |
|
53 | - */ |
|
54 | - public function getLastUsedTagIds() { |
|
55 | - $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
56 | - $tagIds = json_decode($lastUsed, true); |
|
57 | - return new DataResponse(array_map(function($id) { return (string) $id; }, $tagIds)); |
|
58 | - } |
|
33 | + /** @var IConfig */ |
|
34 | + protected $config; |
|
35 | + |
|
36 | + /** @var IUserSession */ |
|
37 | + protected $userSession; |
|
38 | + |
|
39 | + /** |
|
40 | + * @param string $appName |
|
41 | + * @param IRequest $request |
|
42 | + * @param IConfig $config |
|
43 | + * @param IUserSession $userSession |
|
44 | + */ |
|
45 | + public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
46 | + parent::__construct($appName, $request); |
|
47 | + $this->config = $config; |
|
48 | + $this->userSession = $userSession; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @NoAdminRequired |
|
53 | + */ |
|
54 | + public function getLastUsedTagIds() { |
|
55 | + $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
56 | + $tagIds = json_decode($lastUsed, true); |
|
57 | + return new DataResponse(array_map(function($id) { return (string) $id; }, $tagIds)); |
|
58 | + } |
|
59 | 59 | } |
@@ -28,29 +28,29 @@ |
||
28 | 28 | |
29 | 29 | class Admin implements ISettings { |
30 | 30 | |
31 | - /** |
|
32 | - * @return TemplateResponse |
|
33 | - */ |
|
34 | - public function getForm() { |
|
35 | - return new TemplateResponse('systemtags', 'admin', [], ''); |
|
36 | - } |
|
31 | + /** |
|
32 | + * @return TemplateResponse |
|
33 | + */ |
|
34 | + public function getForm() { |
|
35 | + return new TemplateResponse('systemtags', 'admin', [], ''); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return string the section ID, e.g. 'sharing' |
|
40 | - */ |
|
41 | - public function getSection() { |
|
42 | - return 'workflow'; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @return string the section ID, e.g. 'sharing' |
|
40 | + */ |
|
41 | + public function getSection() { |
|
42 | + return 'workflow'; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return int whether the form should be rather on the top or bottom of |
|
47 | - * the admin section. The forms are arranged in ascending order of the |
|
48 | - * priority values. It is required to return a value between 0 and 100. |
|
49 | - * |
|
50 | - * E.g.: 70 |
|
51 | - */ |
|
52 | - public function getPriority() { |
|
53 | - return 70; |
|
54 | - } |
|
45 | + /** |
|
46 | + * @return int whether the form should be rather on the top or bottom of |
|
47 | + * the admin section. The forms are arranged in ascending order of the |
|
48 | + * priority values. It is required to return a value between 0 and 100. |
|
49 | + * |
|
50 | + * E.g.: 70 |
|
51 | + */ |
|
52 | + public function getPriority() { |
|
53 | + return 70; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | return [ |
25 | - 'routes' => [ |
|
26 | - ['name' => 'LastUsed#getLastUsedTagIds', 'url' => '/lastused', 'verb' => 'GET'], |
|
27 | - ] |
|
25 | + 'routes' => [ |
|
26 | + ['name' => 'LastUsed#getLastUsedTagIds', 'url' => '/lastused', 'verb' => 'GET'], |
|
27 | + ] |
|
28 | 28 | ]; |
@@ -48,8 +48,8 @@ |
||
48 | 48 | <div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div> |
49 | 49 | <div id="header-right"> |
50 | 50 | <?php if (!isset($_['hideFileList']) || (isset($_['hideFileList']) && $_['hideFileList'] === false)) { |
51 | - if ($_['server2serversharing']) { |
|
52 | - ?> |
|
51 | + if ($_['server2serversharing']) { |
|
52 | + ?> |
|
53 | 53 | <span id="save" data-protected="<?php p($_['protected']) ?>" |
54 | 54 | data-owner-display-name="<?php p($_['displayName']) ?>" data-owner="<?php p($_['owner']) ?>" data-name="<?php p($_['filename']) ?>"> |
55 | 55 | <button id="save-button"><?php p($l->t('Add to your Nextcloud')) ?></button> |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | - /** @var $_ array */ |
|
3 | - /** @var $l \OCP\IL10N */ |
|
4 | - style('files_sharing', 'authenticate'); |
|
5 | - script('files_sharing', 'authenticate'); |
|
2 | + /** @var $_ array */ |
|
3 | + /** @var $l \OCP\IL10N */ |
|
4 | + style('files_sharing', 'authenticate'); |
|
5 | + script('files_sharing', 'authenticate'); |
|
6 | 6 | ?> |
7 | 7 | <form method="post"> |
8 | 8 | <fieldset> |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | OCP\JSON::checkAppEnabled('files_sharing'); |
31 | 31 | |
32 | 32 | if (!isset($_GET['t'])) { |
33 | - \OC_Response::setStatus(400); //400 Bad Request |
|
34 | - exit; |
|
33 | + \OC_Response::setStatus(400); //400 Bad Request |
|
34 | + exit; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
38 | 38 | $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
39 | 39 | |
40 | 40 | if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false) { |
41 | - \OC_Response::setStatus(404); // 404 not found |
|
42 | - exit; |
|
41 | + \OC_Response::setStatus(404); // 404 not found |
|
42 | + exit; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $token = $_GET['t']; |
46 | 46 | |
47 | 47 | $password = null; |
48 | 48 | if (isset($_POST['password'])) { |
49 | - $password = $_POST['password']; |
|
49 | + $password = $_POST['password']; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $relativePath = null; |
53 | 53 | if (isset($_GET['dir'])) { |
54 | - $relativePath = $_GET['dir']; |
|
54 | + $relativePath = $_GET['dir']; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password); |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | |
64 | 64 | $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); |
65 | 65 | if (!$isWritable) { |
66 | - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
67 | - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
68 | - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
69 | - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
|
70 | - }); |
|
71 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
66 | + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
67 | + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
68 | + \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
69 | + return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
|
70 | + }); |
|
71 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $rootInfo = \OC\Files\Filesystem::getFileInfo($path); |
75 | 75 | $rootView = new \OC\Files\View(''); |
76 | 76 | |
77 | 77 | if($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { |
78 | - OCP\JSON::error(array('data' => 'Share is not readable.')); |
|
79 | - exit(); |
|
78 | + OCP\JSON::error(array('data' => 'Share is not readable.')); |
|
79 | + exit(); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,18 +85,18 @@ discard block |
||
85 | 85 | * @return array |
86 | 86 | */ |
87 | 87 | function getChildInfo($dir, $view, $sharePermissions) { |
88 | - $children = $view->getDirectoryContent($dir->getPath()); |
|
89 | - $result = array(); |
|
90 | - foreach ($children as $child) { |
|
91 | - $formatted = \OCA\Files\Helper::formatFileInfo($child); |
|
92 | - if ($child->getType() === 'dir') { |
|
93 | - $formatted['children'] = getChildInfo($child, $view, $sharePermissions); |
|
94 | - } |
|
95 | - $formatted['mtime'] = $formatted['mtime'] / 1000; |
|
96 | - $formatted['permissions'] = $sharePermissions & (int)$formatted['permissions']; |
|
97 | - $result[] = $formatted; |
|
98 | - } |
|
99 | - return $result; |
|
88 | + $children = $view->getDirectoryContent($dir->getPath()); |
|
89 | + $result = array(); |
|
90 | + foreach ($children as $child) { |
|
91 | + $formatted = \OCA\Files\Helper::formatFileInfo($child); |
|
92 | + if ($child->getType() === 'dir') { |
|
93 | + $formatted['children'] = getChildInfo($child, $view, $sharePermissions); |
|
94 | + } |
|
95 | + $formatted['mtime'] = $formatted['mtime'] / 1000; |
|
96 | + $formatted['permissions'] = $sharePermissions & (int)$formatted['permissions']; |
|
97 | + $result[] = $formatted; |
|
98 | + } |
|
99 | + return $result; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $result = \OCA\Files\Helper::formatFileInfo($rootInfo); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | |
107 | 107 | if ($rootInfo->getType() === 'dir') { |
108 | - $result['children'] = getChildInfo($rootInfo, $rootView, $share->getPermissions()); |
|
108 | + $result['children'] = getChildInfo($rootInfo, $rootView, $share->getPermissions()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | OCP\JSON::success(array('data' => $result)); |
@@ -31,52 +31,52 @@ |
||
31 | 31 | * Scanner for SharedStorage |
32 | 32 | */ |
33 | 33 | class Scanner extends \OC\Files\Cache\Scanner { |
34 | - /** |
|
35 | - * @var \OCA\Files_Sharing\SharedStorage $storage |
|
36 | - */ |
|
37 | - protected $storage; |
|
34 | + /** |
|
35 | + * @var \OCA\Files_Sharing\SharedStorage $storage |
|
36 | + */ |
|
37 | + protected $storage; |
|
38 | 38 | |
39 | - private $sourceScanner; |
|
39 | + private $sourceScanner; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Returns metadata from the shared storage, but |
|
43 | - * with permissions from the source storage. |
|
44 | - * |
|
45 | - * @param string $path path of the file for which to retrieve metadata |
|
46 | - * |
|
47 | - * @return array an array of metadata of the file |
|
48 | - */ |
|
49 | - public function getData($path) { |
|
50 | - $data = parent::getData($path); |
|
51 | - if ($data === null) { |
|
52 | - return null; |
|
53 | - } |
|
54 | - $internalPath = $this->storage->getSourcePath($path); |
|
55 | - $data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath); |
|
56 | - return $data; |
|
57 | - } |
|
41 | + /** |
|
42 | + * Returns metadata from the shared storage, but |
|
43 | + * with permissions from the source storage. |
|
44 | + * |
|
45 | + * @param string $path path of the file for which to retrieve metadata |
|
46 | + * |
|
47 | + * @return array an array of metadata of the file |
|
48 | + */ |
|
49 | + public function getData($path) { |
|
50 | + $data = parent::getData($path); |
|
51 | + if ($data === null) { |
|
52 | + return null; |
|
53 | + } |
|
54 | + $internalPath = $this->storage->getSourcePath($path); |
|
55 | + $data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath); |
|
56 | + return $data; |
|
57 | + } |
|
58 | 58 | |
59 | - private function getSourceScanner() { |
|
60 | - if ($this->sourceScanner) { |
|
61 | - return $this->sourceScanner; |
|
62 | - } |
|
63 | - if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { |
|
64 | - /** @var \OC\Files\Storage\Storage $storage */ |
|
65 | - list($storage) = $this->storage->resolvePath(''); |
|
66 | - $this->sourceScanner = $storage->getScanner(); |
|
67 | - return $this->sourceScanner; |
|
68 | - } else { |
|
69 | - return null; |
|
70 | - } |
|
71 | - } |
|
59 | + private function getSourceScanner() { |
|
60 | + if ($this->sourceScanner) { |
|
61 | + return $this->sourceScanner; |
|
62 | + } |
|
63 | + if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { |
|
64 | + /** @var \OC\Files\Storage\Storage $storage */ |
|
65 | + list($storage) = $this->storage->resolvePath(''); |
|
66 | + $this->sourceScanner = $storage->getScanner(); |
|
67 | + return $this->sourceScanner; |
|
68 | + } else { |
|
69 | + return null; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
74 | - $sourceScanner = $this->getSourceScanner(); |
|
75 | - if ($sourceScanner instanceof NoopScanner) { |
|
76 | - return []; |
|
77 | - } else { |
|
78 | - return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock); |
|
79 | - } |
|
80 | - } |
|
73 | + public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { |
|
74 | + $sourceScanner = $this->getSourceScanner(); |
|
75 | + if ($sourceScanner instanceof NoopScanner) { |
|
76 | + return []; |
|
77 | + } else { |
|
78 | + return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | } |
82 | 82 |