@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | foreach ($favorites['folders'] as $favorite) { |
140 | 140 | $limitations[] = $query->expr()->like('file', $query->createNamedParameter( |
141 | - $this->db->escapeLikeParameter($favorite . '/') . '%' |
|
141 | + $this->db->escapeLikeParameter($favorite.'/').'%' |
|
142 | 142 | )); |
143 | 143 | } |
144 | 144 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | |
149 | 149 | $function = $query->createFunction(' |
150 | 150 | CASE |
151 | - WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1 |
|
152 | - WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . ' |
|
153 | - AND (' . implode(' OR ', $limitations) . ') |
|
151 | + WHEN ' . $query->getColumnName('app').' <> '.$query->createNamedParameter('files').' THEN 1 |
|
152 | + WHEN ' . $query->getColumnName('app').' = '.$query->createNamedParameter('files').' |
|
153 | + AND (' . implode(' OR ', $limitations).') |
|
154 | 154 | THEN 1 |
155 | 155 | END = 1' |
156 | 156 | ); |
@@ -15,115 +15,115 @@ |
||
15 | 15 | |
16 | 16 | class Favorites implements IFilter { |
17 | 17 | |
18 | - /** |
|
19 | - * @param IL10N $l |
|
20 | - * @param IURLGenerator $url |
|
21 | - * @param IManager $activityManager |
|
22 | - * @param Helper $helper |
|
23 | - * @param IDBConnection $db |
|
24 | - */ |
|
25 | - public function __construct( |
|
26 | - protected IL10N $l, |
|
27 | - protected IURLGenerator $url, |
|
28 | - protected IManager $activityManager, |
|
29 | - protected Helper $helper, |
|
30 | - protected IDBConnection $db, |
|
31 | - ) { |
|
32 | - } |
|
18 | + /** |
|
19 | + * @param IL10N $l |
|
20 | + * @param IURLGenerator $url |
|
21 | + * @param IManager $activityManager |
|
22 | + * @param Helper $helper |
|
23 | + * @param IDBConnection $db |
|
24 | + */ |
|
25 | + public function __construct( |
|
26 | + protected IL10N $l, |
|
27 | + protected IURLGenerator $url, |
|
28 | + protected IManager $activityManager, |
|
29 | + protected Helper $helper, |
|
30 | + protected IDBConnection $db, |
|
31 | + ) { |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @return string Lowercase a-z only identifier |
|
36 | - * @since 11.0.0 |
|
37 | - */ |
|
38 | - public function getIdentifier() { |
|
39 | - return 'files_favorites'; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @return string Lowercase a-z only identifier |
|
36 | + * @since 11.0.0 |
|
37 | + */ |
|
38 | + public function getIdentifier() { |
|
39 | + return 'files_favorites'; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string A translated string |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function getName() { |
|
47 | - return $this->l->t('Favorites'); |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return string A translated string |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function getName() { |
|
47 | + return $this->l->t('Favorites'); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return int |
|
52 | - * @since 11.0.0 |
|
53 | - */ |
|
54 | - public function getPriority() { |
|
55 | - return 10; |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return int |
|
52 | + * @since 11.0.0 |
|
53 | + */ |
|
54 | + public function getPriority() { |
|
55 | + return 10; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return string Full URL to an icon, empty string when none is given |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getIcon() { |
|
63 | - return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg')); |
|
64 | - } |
|
58 | + /** |
|
59 | + * @return string Full URL to an icon, empty string when none is given |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getIcon() { |
|
63 | + return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg')); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string[] $types |
|
68 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
69 | - * @since 11.0.0 |
|
70 | - */ |
|
71 | - public function filterTypes(array $types) { |
|
72 | - return array_intersect([ |
|
73 | - 'file_created', |
|
74 | - 'file_changed', |
|
75 | - 'file_deleted', |
|
76 | - 'file_restored', |
|
77 | - ], $types); |
|
78 | - } |
|
66 | + /** |
|
67 | + * @param string[] $types |
|
68 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
69 | + * @since 11.0.0 |
|
70 | + */ |
|
71 | + public function filterTypes(array $types) { |
|
72 | + return array_intersect([ |
|
73 | + 'file_created', |
|
74 | + 'file_changed', |
|
75 | + 'file_deleted', |
|
76 | + 'file_restored', |
|
77 | + ], $types); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
82 | - * @since 11.0.0 |
|
83 | - */ |
|
84 | - public function allowedApps() { |
|
85 | - return ['files']; |
|
86 | - } |
|
80 | + /** |
|
81 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
82 | + * @since 11.0.0 |
|
83 | + */ |
|
84 | + public function allowedApps() { |
|
85 | + return ['files']; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @param IQueryBuilder $query |
|
90 | - */ |
|
91 | - public function filterFavorites(IQueryBuilder $query) { |
|
92 | - try { |
|
93 | - $user = $this->activityManager->getCurrentUserId(); |
|
94 | - } catch (\UnexpectedValueException $e) { |
|
95 | - return; |
|
96 | - } |
|
88 | + /** |
|
89 | + * @param IQueryBuilder $query |
|
90 | + */ |
|
91 | + public function filterFavorites(IQueryBuilder $query) { |
|
92 | + try { |
|
93 | + $user = $this->activityManager->getCurrentUserId(); |
|
94 | + } catch (\UnexpectedValueException $e) { |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | - try { |
|
99 | - $favorites = $this->helper->getFavoriteFilePaths($user); |
|
100 | - } catch (\RuntimeException $e) { |
|
101 | - return; |
|
102 | - } |
|
98 | + try { |
|
99 | + $favorites = $this->helper->getFavoriteFilePaths($user); |
|
100 | + } catch (\RuntimeException $e) { |
|
101 | + return; |
|
102 | + } |
|
103 | 103 | |
104 | - $limitations = []; |
|
105 | - if (!empty($favorites['items'])) { |
|
106 | - $limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY)); |
|
107 | - } |
|
108 | - foreach ($favorites['folders'] as $favorite) { |
|
109 | - $limitations[] = $query->expr()->like('file', $query->createNamedParameter( |
|
110 | - $this->db->escapeLikeParameter($favorite . '/') . '%' |
|
111 | - )); |
|
112 | - } |
|
104 | + $limitations = []; |
|
105 | + if (!empty($favorites['items'])) { |
|
106 | + $limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY)); |
|
107 | + } |
|
108 | + foreach ($favorites['folders'] as $favorite) { |
|
109 | + $limitations[] = $query->expr()->like('file', $query->createNamedParameter( |
|
110 | + $this->db->escapeLikeParameter($favorite . '/') . '%' |
|
111 | + )); |
|
112 | + } |
|
113 | 113 | |
114 | - if (empty($limitations)) { |
|
115 | - return; |
|
116 | - } |
|
114 | + if (empty($limitations)) { |
|
115 | + return; |
|
116 | + } |
|
117 | 117 | |
118 | - $function = $query->createFunction(' |
|
118 | + $function = $query->createFunction(' |
|
119 | 119 | CASE |
120 | 120 | WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1 |
121 | 121 | WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . ' |
122 | 122 | AND (' . implode(' OR ', $limitations) . ') |
123 | 123 | THEN 1 |
124 | 124 | END = 1' |
125 | - ); |
|
125 | + ); |
|
126 | 126 | |
127 | - $query->andWhere($function); |
|
128 | - } |
|
127 | + $query->andWhere($function); |
|
128 | + } |
|
129 | 129 | } |
@@ -30,13 +30,13 @@ |
||
30 | 30 | $limit = null; |
31 | 31 | $offset = null; |
32 | 32 | if (isset($_GET['pattern'])) { |
33 | - $pattern = (string)$_GET['pattern']; |
|
33 | + $pattern = (string) $_GET['pattern']; |
|
34 | 34 | } |
35 | 35 | if (isset($_GET['limit'])) { |
36 | - $limit = (int)$_GET['limit']; |
|
36 | + $limit = (int) $_GET['limit']; |
|
37 | 37 | } |
38 | 38 | if (isset($_GET['offset'])) { |
39 | - $offset = (int)$_GET['offset']; |
|
39 | + $offset = (int) $_GET['offset']; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $groups = []; |
@@ -18,23 +18,23 @@ |
||
18 | 18 | $limit = null; |
19 | 19 | $offset = null; |
20 | 20 | if (isset($_GET['pattern'])) { |
21 | - $pattern = (string)$_GET['pattern']; |
|
21 | + $pattern = (string)$_GET['pattern']; |
|
22 | 22 | } |
23 | 23 | if (isset($_GET['limit'])) { |
24 | - $limit = (int)$_GET['limit']; |
|
24 | + $limit = (int)$_GET['limit']; |
|
25 | 25 | } |
26 | 26 | if (isset($_GET['offset'])) { |
27 | - $offset = (int)$_GET['offset']; |
|
27 | + $offset = (int)$_GET['offset']; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $groups = []; |
31 | 31 | foreach (Server::get(IGroupManager::class)->search($pattern, $limit, $offset) as $group) { |
32 | - $groups[$group->getGID()] = $group->getDisplayName(); |
|
32 | + $groups[$group->getGID()] = $group->getDisplayName(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $users = []; |
36 | 36 | foreach (Server::get(IUserManager::class)->searchDisplayName($pattern, $limit, $offset) as $user) { |
37 | - $users[$user->getUID()] = $user->getDisplayName(); |
|
37 | + $users[$user->getUID()] = $user->getDisplayName(); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $results = ['groups' => $groups, 'users' => $users]; |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OCA\Files_External\Service; |
25 | 25 | |
26 | 26 | class ImportLegacyStoragesService extends LegacyStoragesService { |
27 | - private $data; |
|
27 | + private $data; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param BackendService $backendService |
|
31 | - */ |
|
32 | - public function __construct(BackendService $backendService) { |
|
33 | - $this->backendService = $backendService; |
|
34 | - } |
|
29 | + /** |
|
30 | + * @param BackendService $backendService |
|
31 | + */ |
|
32 | + public function __construct(BackendService $backendService) { |
|
33 | + $this->backendService = $backendService; |
|
34 | + } |
|
35 | 35 | |
36 | - public function setData($data) { |
|
37 | - $this->data = $data; |
|
38 | - } |
|
36 | + public function setData($data) { |
|
37 | + $this->data = $data; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Read legacy config data |
|
42 | - * |
|
43 | - * @return array list of mount configs |
|
44 | - */ |
|
45 | - protected function readLegacyConfig() { |
|
46 | - return $this->data; |
|
47 | - } |
|
40 | + /** |
|
41 | + * Read legacy config data |
|
42 | + * |
|
43 | + * @return array list of mount configs |
|
44 | + */ |
|
45 | + protected function readLegacyConfig() { |
|
46 | + return $this->data; |
|
47 | + } |
|
48 | 48 | } |
@@ -172,11 +172,11 @@ |
||
172 | 172 | public function getStorageForAllUsers() { |
173 | 173 | $mounts = $this->dbConfig->getAllMounts(); |
174 | 174 | $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
175 | - $configs = array_filter($configs, function ($config) { |
|
175 | + $configs = array_filter($configs, function($config) { |
|
176 | 176 | return $config instanceof StorageConfig; |
177 | 177 | }); |
178 | 178 | |
179 | - $keys = array_map(function (StorageConfig $config) { |
|
179 | + $keys = array_map(function(StorageConfig $config) { |
|
180 | 180 | return $config->getId(); |
181 | 181 | }, $configs); |
182 | 182 |
@@ -14,151 +14,151 @@ |
||
14 | 14 | * Service class to manage global external storage |
15 | 15 | */ |
16 | 16 | class GlobalStoragesService extends StoragesService { |
17 | - /** |
|
18 | - * Triggers $signal for all applicable users of the given |
|
19 | - * storage |
|
20 | - * |
|
21 | - * @param StorageConfig $storage storage data |
|
22 | - * @param string $signal signal to trigger |
|
23 | - */ |
|
24 | - protected function triggerHooks(StorageConfig $storage, $signal) { |
|
25 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
26 | - $applicableUsers = $storage->getApplicableUsers(); |
|
27 | - $applicableGroups = $storage->getApplicableGroups(); |
|
28 | - if (empty($applicableUsers) && empty($applicableGroups)) { |
|
29 | - // raise for user "all" |
|
30 | - $this->triggerApplicableHooks( |
|
31 | - $signal, |
|
32 | - $storage->getMountPoint(), |
|
33 | - MountConfig::MOUNT_TYPE_USER, |
|
34 | - ['all'] |
|
35 | - ); |
|
36 | - return; |
|
37 | - } |
|
38 | - |
|
39 | - $this->triggerApplicableHooks( |
|
40 | - $signal, |
|
41 | - $storage->getMountPoint(), |
|
42 | - MountConfig::MOUNT_TYPE_USER, |
|
43 | - $applicableUsers |
|
44 | - ); |
|
45 | - $this->triggerApplicableHooks( |
|
46 | - $signal, |
|
47 | - $storage->getMountPoint(), |
|
48 | - MountConfig::MOUNT_TYPE_GROUP, |
|
49 | - $applicableGroups |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Triggers signal_create_mount or signal_delete_mount to |
|
55 | - * accommodate for additions/deletions in applicableUsers |
|
56 | - * and applicableGroups fields. |
|
57 | - * |
|
58 | - * @param StorageConfig $oldStorage old storage config |
|
59 | - * @param StorageConfig $newStorage new storage config |
|
60 | - */ |
|
61 | - protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) { |
|
62 | - // if mount point changed, it's like a deletion + creation |
|
63 | - if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) { |
|
64 | - $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount); |
|
65 | - $this->triggerHooks($newStorage, Filesystem::signal_create_mount); |
|
66 | - return; |
|
67 | - } |
|
68 | - |
|
69 | - $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers()); |
|
70 | - $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers()); |
|
71 | - $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); |
|
72 | - $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); |
|
73 | - |
|
74 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
75 | - // if no applicable were set, raise a signal for "all" |
|
76 | - $oldApplicableUsers = $oldStorage->getApplicableUsers(); |
|
77 | - $oldApplicableGroups = $oldStorage->getApplicableGroups(); |
|
78 | - if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { |
|
79 | - $this->triggerApplicableHooks( |
|
80 | - Filesystem::signal_delete_mount, |
|
81 | - $oldStorage->getMountPoint(), |
|
82 | - MountConfig::MOUNT_TYPE_USER, |
|
83 | - ['all'] |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - // trigger delete for removed users |
|
88 | - $this->triggerApplicableHooks( |
|
89 | - Filesystem::signal_delete_mount, |
|
90 | - $oldStorage->getMountPoint(), |
|
91 | - MountConfig::MOUNT_TYPE_USER, |
|
92 | - $userDeletions |
|
93 | - ); |
|
94 | - |
|
95 | - // trigger delete for removed groups |
|
96 | - $this->triggerApplicableHooks( |
|
97 | - Filesystem::signal_delete_mount, |
|
98 | - $oldStorage->getMountPoint(), |
|
99 | - MountConfig::MOUNT_TYPE_GROUP, |
|
100 | - $groupDeletions |
|
101 | - ); |
|
102 | - |
|
103 | - // and now add the new users |
|
104 | - $this->triggerApplicableHooks( |
|
105 | - Filesystem::signal_create_mount, |
|
106 | - $newStorage->getMountPoint(), |
|
107 | - MountConfig::MOUNT_TYPE_USER, |
|
108 | - $userAdditions |
|
109 | - ); |
|
110 | - |
|
111 | - // and now add the new groups |
|
112 | - $this->triggerApplicableHooks( |
|
113 | - Filesystem::signal_create_mount, |
|
114 | - $newStorage->getMountPoint(), |
|
115 | - MountConfig::MOUNT_TYPE_GROUP, |
|
116 | - $groupAdditions |
|
117 | - ); |
|
118 | - |
|
119 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
120 | - // if no applicable, raise a signal for "all" |
|
121 | - $newApplicableUsers = $newStorage->getApplicableUsers(); |
|
122 | - $newApplicableGroups = $newStorage->getApplicableGroups(); |
|
123 | - if (empty($newApplicableUsers) && empty($newApplicableGroups)) { |
|
124 | - $this->triggerApplicableHooks( |
|
125 | - Filesystem::signal_create_mount, |
|
126 | - $newStorage->getMountPoint(), |
|
127 | - MountConfig::MOUNT_TYPE_USER, |
|
128 | - ['all'] |
|
129 | - ); |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Get the visibility type for this controller, used in validation |
|
135 | - * |
|
136 | - * @return int BackendService::VISIBILITY_* constants |
|
137 | - */ |
|
138 | - public function getVisibilityType() { |
|
139 | - return BackendService::VISIBILITY_ADMIN; |
|
140 | - } |
|
141 | - |
|
142 | - protected function isApplicable(StorageConfig $config) { |
|
143 | - return true; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * Get all configured admin and personal mounts |
|
148 | - * |
|
149 | - * @return StorageConfig[] map of storage id to storage config |
|
150 | - */ |
|
151 | - public function getStorageForAllUsers() { |
|
152 | - $mounts = $this->dbConfig->getAllMounts(); |
|
153 | - $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
154 | - $configs = array_filter($configs, function ($config) { |
|
155 | - return $config instanceof StorageConfig; |
|
156 | - }); |
|
157 | - |
|
158 | - $keys = array_map(function (StorageConfig $config) { |
|
159 | - return $config->getId(); |
|
160 | - }, $configs); |
|
161 | - |
|
162 | - return array_combine($keys, $configs); |
|
163 | - } |
|
17 | + /** |
|
18 | + * Triggers $signal for all applicable users of the given |
|
19 | + * storage |
|
20 | + * |
|
21 | + * @param StorageConfig $storage storage data |
|
22 | + * @param string $signal signal to trigger |
|
23 | + */ |
|
24 | + protected function triggerHooks(StorageConfig $storage, $signal) { |
|
25 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
26 | + $applicableUsers = $storage->getApplicableUsers(); |
|
27 | + $applicableGroups = $storage->getApplicableGroups(); |
|
28 | + if (empty($applicableUsers) && empty($applicableGroups)) { |
|
29 | + // raise for user "all" |
|
30 | + $this->triggerApplicableHooks( |
|
31 | + $signal, |
|
32 | + $storage->getMountPoint(), |
|
33 | + MountConfig::MOUNT_TYPE_USER, |
|
34 | + ['all'] |
|
35 | + ); |
|
36 | + return; |
|
37 | + } |
|
38 | + |
|
39 | + $this->triggerApplicableHooks( |
|
40 | + $signal, |
|
41 | + $storage->getMountPoint(), |
|
42 | + MountConfig::MOUNT_TYPE_USER, |
|
43 | + $applicableUsers |
|
44 | + ); |
|
45 | + $this->triggerApplicableHooks( |
|
46 | + $signal, |
|
47 | + $storage->getMountPoint(), |
|
48 | + MountConfig::MOUNT_TYPE_GROUP, |
|
49 | + $applicableGroups |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Triggers signal_create_mount or signal_delete_mount to |
|
55 | + * accommodate for additions/deletions in applicableUsers |
|
56 | + * and applicableGroups fields. |
|
57 | + * |
|
58 | + * @param StorageConfig $oldStorage old storage config |
|
59 | + * @param StorageConfig $newStorage new storage config |
|
60 | + */ |
|
61 | + protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) { |
|
62 | + // if mount point changed, it's like a deletion + creation |
|
63 | + if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) { |
|
64 | + $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount); |
|
65 | + $this->triggerHooks($newStorage, Filesystem::signal_create_mount); |
|
66 | + return; |
|
67 | + } |
|
68 | + |
|
69 | + $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers()); |
|
70 | + $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers()); |
|
71 | + $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); |
|
72 | + $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); |
|
73 | + |
|
74 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
75 | + // if no applicable were set, raise a signal for "all" |
|
76 | + $oldApplicableUsers = $oldStorage->getApplicableUsers(); |
|
77 | + $oldApplicableGroups = $oldStorage->getApplicableGroups(); |
|
78 | + if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { |
|
79 | + $this->triggerApplicableHooks( |
|
80 | + Filesystem::signal_delete_mount, |
|
81 | + $oldStorage->getMountPoint(), |
|
82 | + MountConfig::MOUNT_TYPE_USER, |
|
83 | + ['all'] |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + // trigger delete for removed users |
|
88 | + $this->triggerApplicableHooks( |
|
89 | + Filesystem::signal_delete_mount, |
|
90 | + $oldStorage->getMountPoint(), |
|
91 | + MountConfig::MOUNT_TYPE_USER, |
|
92 | + $userDeletions |
|
93 | + ); |
|
94 | + |
|
95 | + // trigger delete for removed groups |
|
96 | + $this->triggerApplicableHooks( |
|
97 | + Filesystem::signal_delete_mount, |
|
98 | + $oldStorage->getMountPoint(), |
|
99 | + MountConfig::MOUNT_TYPE_GROUP, |
|
100 | + $groupDeletions |
|
101 | + ); |
|
102 | + |
|
103 | + // and now add the new users |
|
104 | + $this->triggerApplicableHooks( |
|
105 | + Filesystem::signal_create_mount, |
|
106 | + $newStorage->getMountPoint(), |
|
107 | + MountConfig::MOUNT_TYPE_USER, |
|
108 | + $userAdditions |
|
109 | + ); |
|
110 | + |
|
111 | + // and now add the new groups |
|
112 | + $this->triggerApplicableHooks( |
|
113 | + Filesystem::signal_create_mount, |
|
114 | + $newStorage->getMountPoint(), |
|
115 | + MountConfig::MOUNT_TYPE_GROUP, |
|
116 | + $groupAdditions |
|
117 | + ); |
|
118 | + |
|
119 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
120 | + // if no applicable, raise a signal for "all" |
|
121 | + $newApplicableUsers = $newStorage->getApplicableUsers(); |
|
122 | + $newApplicableGroups = $newStorage->getApplicableGroups(); |
|
123 | + if (empty($newApplicableUsers) && empty($newApplicableGroups)) { |
|
124 | + $this->triggerApplicableHooks( |
|
125 | + Filesystem::signal_create_mount, |
|
126 | + $newStorage->getMountPoint(), |
|
127 | + MountConfig::MOUNT_TYPE_USER, |
|
128 | + ['all'] |
|
129 | + ); |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Get the visibility type for this controller, used in validation |
|
135 | + * |
|
136 | + * @return int BackendService::VISIBILITY_* constants |
|
137 | + */ |
|
138 | + public function getVisibilityType() { |
|
139 | + return BackendService::VISIBILITY_ADMIN; |
|
140 | + } |
|
141 | + |
|
142 | + protected function isApplicable(StorageConfig $config) { |
|
143 | + return true; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * Get all configured admin and personal mounts |
|
148 | + * |
|
149 | + * @return StorageConfig[] map of storage id to storage config |
|
150 | + */ |
|
151 | + public function getStorageForAllUsers() { |
|
152 | + $mounts = $this->dbConfig->getAllMounts(); |
|
153 | + $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
154 | + $configs = array_filter($configs, function ($config) { |
|
155 | + return $config instanceof StorageConfig; |
|
156 | + }); |
|
157 | + |
|
158 | + $keys = array_map(function (StorageConfig $config) { |
|
159 | + return $config->getId(); |
|
160 | + }, $configs); |
|
161 | + |
|
162 | + return array_combine($keys, $configs); |
|
163 | + } |
|
164 | 164 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | * For auth mechanisms where the user needs to provide credentials |
29 | 29 | */ |
30 | 30 | interface IUserProvided { |
31 | - /** |
|
32 | - * @param IUser $user the user for which to save the user provided options |
|
33 | - * @param int $mountId the mount id to save the options for |
|
34 | - * @param array $options the user provided options |
|
35 | - */ |
|
36 | - public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
31 | + /** |
|
32 | + * @param IUser $user the user for which to save the user provided options |
|
33 | + * @param int $mountId the mount id to save the options for |
|
34 | + * @param array $options the user provided options |
|
35 | + */ |
|
36 | + public function saveBackendOptions(IUser $user, $mountId, array $options); |
|
37 | 37 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | interface IBackendProvider { |
32 | 32 | |
33 | - /** |
|
34 | - * @since 9.1.0 |
|
35 | - * @return Backend[] |
|
36 | - */ |
|
37 | - public function getBackends(); |
|
33 | + /** |
|
34 | + * @since 9.1.0 |
|
35 | + * @return Backend[] |
|
36 | + */ |
|
37 | + public function getBackends(); |
|
38 | 38 | |
39 | 39 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | */ |
31 | 31 | interface IAuthMechanismProvider { |
32 | 32 | |
33 | - /** |
|
34 | - * @since 9.1.0 |
|
35 | - * @return AuthMechanism[] |
|
36 | - */ |
|
37 | - public function getAuthMechanisms(); |
|
33 | + /** |
|
34 | + * @since 9.1.0 |
|
35 | + * @return AuthMechanism[] |
|
36 | + */ |
|
37 | + public function getAuthMechanisms(); |
|
38 | 38 | |
39 | 39 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | public function listen(callable $callback) { |
66 | 66 | $oldRenamePath = null; |
67 | - $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
67 | + $this->shareNotifyHandler->listen(function(\Icewind\SMB\Change $shareChange) use ($callback) { |
|
68 | 68 | $change = $this->mapChange($shareChange); |
69 | 69 | if (!is_null($change)) { |
70 | 70 | return $callback($change); |
@@ -11,119 +11,119 @@ |
||
11 | 11 | use OCP\Files\Notify\INotifyHandler; |
12 | 12 | |
13 | 13 | class SMBNotifyHandler implements INotifyHandler { |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - private $root; |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + private $root; |
|
18 | 18 | |
19 | - private $oldRenamePath = null; |
|
19 | + private $oldRenamePath = null; |
|
20 | 20 | |
21 | - /** |
|
22 | - * SMBNotifyHandler constructor. |
|
23 | - * |
|
24 | - * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler |
|
25 | - * @param string $root |
|
26 | - */ |
|
27 | - public function __construct( |
|
28 | - private \Icewind\SMB\INotifyHandler $shareNotifyHandler, |
|
29 | - $root, |
|
30 | - ) { |
|
31 | - $this->root = str_replace('\\', '/', $root); |
|
32 | - } |
|
21 | + /** |
|
22 | + * SMBNotifyHandler constructor. |
|
23 | + * |
|
24 | + * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler |
|
25 | + * @param string $root |
|
26 | + */ |
|
27 | + public function __construct( |
|
28 | + private \Icewind\SMB\INotifyHandler $shareNotifyHandler, |
|
29 | + $root, |
|
30 | + ) { |
|
31 | + $this->root = str_replace('\\', '/', $root); |
|
32 | + } |
|
33 | 33 | |
34 | - private function relativePath($fullPath) { |
|
35 | - if ($fullPath === $this->root) { |
|
36 | - return ''; |
|
37 | - } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { |
|
38 | - return substr($fullPath, strlen($this->root)); |
|
39 | - } else { |
|
40 | - return null; |
|
41 | - } |
|
42 | - } |
|
34 | + private function relativePath($fullPath) { |
|
35 | + if ($fullPath === $this->root) { |
|
36 | + return ''; |
|
37 | + } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { |
|
38 | + return substr($fullPath, strlen($this->root)); |
|
39 | + } else { |
|
40 | + return null; |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - public function listen(callable $callback) { |
|
45 | - $oldRenamePath = null; |
|
46 | - $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
47 | - $change = $this->mapChange($shareChange); |
|
48 | - if (!is_null($change)) { |
|
49 | - return $callback($change); |
|
50 | - } else { |
|
51 | - return true; |
|
52 | - } |
|
53 | - }); |
|
54 | - } |
|
44 | + public function listen(callable $callback) { |
|
45 | + $oldRenamePath = null; |
|
46 | + $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
47 | + $change = $this->mapChange($shareChange); |
|
48 | + if (!is_null($change)) { |
|
49 | + return $callback($change); |
|
50 | + } else { |
|
51 | + return true; |
|
52 | + } |
|
53 | + }); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get all changes detected since the start of the notify process or the last call to getChanges |
|
58 | - * |
|
59 | - * @return IChange[] |
|
60 | - */ |
|
61 | - public function getChanges() { |
|
62 | - $shareChanges = $this->shareNotifyHandler->getChanges(); |
|
63 | - $changes = []; |
|
64 | - foreach ($shareChanges as $shareChange) { |
|
65 | - $change = $this->mapChange($shareChange); |
|
66 | - if ($change) { |
|
67 | - $changes[] = $change; |
|
68 | - } |
|
69 | - } |
|
70 | - return $changes; |
|
71 | - } |
|
56 | + /** |
|
57 | + * Get all changes detected since the start of the notify process or the last call to getChanges |
|
58 | + * |
|
59 | + * @return IChange[] |
|
60 | + */ |
|
61 | + public function getChanges() { |
|
62 | + $shareChanges = $this->shareNotifyHandler->getChanges(); |
|
63 | + $changes = []; |
|
64 | + foreach ($shareChanges as $shareChange) { |
|
65 | + $change = $this->mapChange($shareChange); |
|
66 | + if ($change) { |
|
67 | + $changes[] = $change; |
|
68 | + } |
|
69 | + } |
|
70 | + return $changes; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Stop listening for changes |
|
75 | - * |
|
76 | - * Note that any pending changes will be discarded |
|
77 | - */ |
|
78 | - public function stop() { |
|
79 | - $this->shareNotifyHandler->stop(); |
|
80 | - } |
|
73 | + /** |
|
74 | + * Stop listening for changes |
|
75 | + * |
|
76 | + * Note that any pending changes will be discarded |
|
77 | + */ |
|
78 | + public function stop() { |
|
79 | + $this->shareNotifyHandler->stop(); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param \Icewind\SMB\Change $change |
|
84 | - * @return IChange|null |
|
85 | - */ |
|
86 | - private function mapChange(\Icewind\SMB\Change $change) { |
|
87 | - $path = $this->relativePath($change->getPath()); |
|
88 | - if (is_null($path)) { |
|
89 | - return null; |
|
90 | - } |
|
91 | - if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { |
|
92 | - $this->oldRenamePath = $path; |
|
93 | - return null; |
|
94 | - } |
|
95 | - $type = $this->mapNotifyType($change->getCode()); |
|
96 | - if (is_null($type)) { |
|
97 | - return null; |
|
98 | - } |
|
99 | - if ($type === IChange::RENAMED) { |
|
100 | - if (!is_null($this->oldRenamePath)) { |
|
101 | - $result = new RenameChange($type, $this->oldRenamePath, $path); |
|
102 | - $this->oldRenamePath = null; |
|
103 | - } else { |
|
104 | - $result = null; |
|
105 | - } |
|
106 | - } else { |
|
107 | - $result = new Change($type, $path); |
|
108 | - } |
|
109 | - return $result; |
|
110 | - } |
|
82 | + /** |
|
83 | + * @param \Icewind\SMB\Change $change |
|
84 | + * @return IChange|null |
|
85 | + */ |
|
86 | + private function mapChange(\Icewind\SMB\Change $change) { |
|
87 | + $path = $this->relativePath($change->getPath()); |
|
88 | + if (is_null($path)) { |
|
89 | + return null; |
|
90 | + } |
|
91 | + if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { |
|
92 | + $this->oldRenamePath = $path; |
|
93 | + return null; |
|
94 | + } |
|
95 | + $type = $this->mapNotifyType($change->getCode()); |
|
96 | + if (is_null($type)) { |
|
97 | + return null; |
|
98 | + } |
|
99 | + if ($type === IChange::RENAMED) { |
|
100 | + if (!is_null($this->oldRenamePath)) { |
|
101 | + $result = new RenameChange($type, $this->oldRenamePath, $path); |
|
102 | + $this->oldRenamePath = null; |
|
103 | + } else { |
|
104 | + $result = null; |
|
105 | + } |
|
106 | + } else { |
|
107 | + $result = new Change($type, $path); |
|
108 | + } |
|
109 | + return $result; |
|
110 | + } |
|
111 | 111 | |
112 | - private function mapNotifyType($smbType) { |
|
113 | - switch ($smbType) { |
|
114 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: |
|
115 | - return IChange::ADDED; |
|
116 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: |
|
117 | - return IChange::REMOVED; |
|
118 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: |
|
119 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: |
|
120 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: |
|
121 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: |
|
122 | - return IChange::MODIFIED; |
|
123 | - case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: |
|
124 | - return IChange::RENAMED; |
|
125 | - default: |
|
126 | - return null; |
|
127 | - } |
|
128 | - } |
|
112 | + private function mapNotifyType($smbType) { |
|
113 | + switch ($smbType) { |
|
114 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: |
|
115 | + return IChange::ADDED; |
|
116 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: |
|
117 | + return IChange::REMOVED; |
|
118 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: |
|
119 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: |
|
120 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: |
|
121 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: |
|
122 | + return IChange::MODIFIED; |
|
123 | + case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: |
|
124 | + return IChange::RENAMED; |
|
125 | + default: |
|
126 | + return null; |
|
127 | + } |
|
128 | + } |
|
129 | 129 | } |
@@ -29,14 +29,14 @@ |
||
29 | 29 | */ |
30 | 30 | trait DependencyTrait { |
31 | 31 | |
32 | - /** |
|
33 | - * Check if object is valid for use |
|
34 | - * |
|
35 | - * @return MissingDependency[] Unsatisfied dependencies |
|
36 | - */ |
|
37 | - public function checkDependencies() { |
|
38 | - return []; // no dependencies by default |
|
39 | - } |
|
32 | + /** |
|
33 | + * Check if object is valid for use |
|
34 | + * |
|
35 | + * @return MissingDependency[] Unsatisfied dependencies |
|
36 | + */ |
|
37 | + public function checkDependencies() { |
|
38 | + return []; // no dependencies by default |
|
39 | + } |
|
40 | 40 | |
41 | 41 | } |
42 | 42 |