@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <fieldset id="ldapWizard2"> |
2 | 2 | <div> |
3 | 3 | <p> |
4 | - <?php p($l->t('Listing and searching for users is constrained by these criteria:'));?> |
|
4 | + <?php p($l->t('Listing and searching for users is constrained by these criteria:')); ?> |
|
5 | 5 | </p> |
6 | 6 | <p> |
7 | 7 | <label for="ldap_userfilter_objectclass"> |
8 | - <?php p($l->t('Only these object classes:'));?> |
|
8 | + <?php p($l->t('Only these object classes:')); ?> |
|
9 | 9 | </label> |
10 | 10 | |
11 | 11 | <select id="ldap_userfilter_objectclass" multiple="multiple" |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | </p> |
15 | 15 | <p> |
16 | 16 | <label></label> |
17 | - <span class="ldapInputColElement"><?php p($l->t('The most common object classes for users are organizationalPerson, person, user, and inetOrgPerson. If you are not sure which object class to select, please consult your directory admin.'));?></span> |
|
17 | + <span class="ldapInputColElement"><?php p($l->t('The most common object classes for users are organizationalPerson, person, user, and inetOrgPerson. If you are not sure which object class to select, please consult your directory admin.')); ?></span> |
|
18 | 18 | </p> |
19 | 19 | <p> |
20 | 20 | <label for="ldap_userfilter_groups"> |
21 | - <?php p($l->t('Only from these groups:'));?> |
|
21 | + <?php p($l->t('Only from these groups:')); ?> |
|
22 | 22 | </label> |
23 | 23 | |
24 | - <input type="text" class="ldapManyGroupsSupport ldapManyGroupsSearch hidden" placeholder="<?php p($l->t('Search groups'));?>" /> |
|
24 | + <input type="text" class="ldapManyGroupsSupport ldapManyGroupsSearch hidden" placeholder="<?php p($l->t('Search groups')); ?>" /> |
|
25 | 25 | |
26 | 26 | <select id="ldap_userfilter_groups" multiple="multiple" |
27 | 27 | name="ldap_userfilter_groups" class="multiSelectPlugin"> |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | <p class="ldapManyGroupsSupport hidden"> |
31 | 31 | <label></label> |
32 | 32 | <select class="ldapGroupList ldapGroupListAvailable" multiple="multiple" |
33 | - title="<?php p($l->t('Available groups'));?>"></select> |
|
33 | + title="<?php p($l->t('Available groups')); ?>"></select> |
|
34 | 34 | <span class="buttonSpan"> |
35 | 35 | <button class="ldapGroupListSelect" type="button">></button><br/> |
36 | 36 | <button class="ldapGroupListDeselect" type="button"><</button> |
37 | 37 | </span> |
38 | 38 | <select class="ldapGroupList ldapGroupListSelected" multiple="multiple" |
39 | - title="<?php p($l->t('Selected groups'));?>"></select> |
|
39 | + title="<?php p($l->t('Selected groups')); ?>"></select> |
|
40 | 40 | </p> |
41 | 41 | <p> |
42 | - <label><a id='toggleRawUserFilter' class='ldapToggle'>↓ <?php p($l->t('Edit LDAP Query'));?></a></label> |
|
42 | + <label><a id='toggleRawUserFilter' class='ldapToggle'>↓ <?php p($l->t('Edit LDAP Query')); ?></a></label> |
|
43 | 43 | </p> |
44 | 44 | <p id="ldapReadOnlyUserFilterContainer" class="hidden ldapReadOnlyFilterContainer"> |
45 | - <label><?php p($l->t('LDAP Filter:'));?></label> |
|
45 | + <label><?php p($l->t('LDAP Filter:')); ?></label> |
|
46 | 46 | <span class="ldapFilterReadOnlyElement ldapInputColElement"></span> |
47 | 47 | </p> |
48 | 48 | <p id="rawUserFilterContainer"> |
49 | 49 | <textarea type="text" id="ldap_userlist_filter" name="ldap_userlist_filter" |
50 | 50 | class="ldapFilterInputElement" |
51 | - placeholder="<?php p($l->t('Edit LDAP Query'));?>" |
|
52 | - title="<?php p($l->t('The filter specifies which LDAP users shall have access to the %s instance.', [$theme->getName()]));?>"> |
|
51 | + placeholder="<?php p($l->t('Edit LDAP Query')); ?>" |
|
52 | + title="<?php p($l->t('The filter specifies which LDAP users shall have access to the %s instance.', [$theme->getName()])); ?>"> |
|
53 | 53 | </textarea> |
54 | 54 | </p> |
55 | 55 | <p> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | </p> |
58 | 58 | <p class="ldap_count"> |
59 | 59 | <button class="ldapGetEntryCount ldapGetUserCount" name="ldapGetEntryCount" type="button"> |
60 | - <?php p($l->t('Verify settings and count users'));?> |
|
60 | + <?php p($l->t('Verify settings and count users')); ?> |
|
61 | 61 | </button> |
62 | 62 | <span id="ldap_user_count"></span> |
63 | 63 | </p> |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <fieldset id="ldapWizard4"> |
2 | 2 | <div> |
3 | 3 | <p> |
4 | - <?php p($l->t('Groups meeting these criteria are available in %s:', [$theme->getName()]));?> |
|
4 | + <?php p($l->t('Groups meeting these criteria are available in %s:', [$theme->getName()])); ?> |
|
5 | 5 | </p> |
6 | 6 | <p> |
7 | 7 | <label for="ldap_groupfilter_objectclass"> |
8 | - <?php p($l->t('Only these object classes:'));?> |
|
8 | + <?php p($l->t('Only these object classes:')); ?> |
|
9 | 9 | </label> |
10 | 10 | |
11 | 11 | <select id="ldap_groupfilter_objectclass" multiple="multiple" |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | </p> |
15 | 15 | <p> |
16 | 16 | <label for="ldap_groupfilter_groups"> |
17 | - <?php p($l->t('Only from these groups:'));?> |
|
17 | + <?php p($l->t('Only from these groups:')); ?> |
|
18 | 18 | </label> |
19 | 19 | |
20 | - <input type="text" class="ldapManyGroupsSupport ldapManyGroupsSearch hidden" placeholder="<?php p($l->t('Search groups'));?>" /> |
|
20 | + <input type="text" class="ldapManyGroupsSupport ldapManyGroupsSearch hidden" placeholder="<?php p($l->t('Search groups')); ?>" /> |
|
21 | 21 | |
22 | 22 | <select id="ldap_groupfilter_groups" multiple="multiple" |
23 | 23 | name="ldap_groupfilter_groups" class="multiSelectPlugin"> |
@@ -27,25 +27,25 @@ discard block |
||
27 | 27 | <p class="ldapManyGroupsSupport hidden"> |
28 | 28 | <label></label> |
29 | 29 | <select class="ldapGroupList ldapGroupListAvailable" multiple="multiple" |
30 | - title="<?php p($l->t('Available groups'));?>"></select> |
|
30 | + title="<?php p($l->t('Available groups')); ?>"></select> |
|
31 | 31 | <span class="buttonSpan"> |
32 | 32 | <button class="ldapGroupListSelect" type="button">></button><br/> |
33 | 33 | <button class="ldapGroupListDeselect" type="button"><</button> |
34 | 34 | </span> |
35 | 35 | <select class="ldapGroupList ldapGroupListSelected" multiple="multiple" |
36 | - title="<?php p($l->t('Selected groups'));?>"></select> |
|
36 | + title="<?php p($l->t('Selected groups')); ?>"></select> |
|
37 | 37 | </p> |
38 | 38 | <p> |
39 | - <label><a id='toggleRawGroupFilter' class='ldapToggle'>↓ <?php p($l->t('Edit LDAP Query'));?></a></label> |
|
39 | + <label><a id='toggleRawGroupFilter' class='ldapToggle'>↓ <?php p($l->t('Edit LDAP Query')); ?></a></label> |
|
40 | 40 | </p> |
41 | 41 | <p id="ldapReadOnlyGroupFilterContainer" class="hidden ldapReadOnlyFilterContainer"> |
42 | - <label><?php p($l->t('LDAP Filter:'));?></label> |
|
42 | + <label><?php p($l->t('LDAP Filter:')); ?></label> |
|
43 | 43 | <span class="ldapFilterReadOnlyElement ldapInputColElement"></span> |
44 | 44 | </p> |
45 | 45 | <p id="rawGroupFilterContainer" class="invisible"> |
46 | 46 | <textarea type="text" id="ldap_group_filter" name="ldap_group_filter" |
47 | - placeholder="<?php p($l->t('Edit LDAP Query'));?>" |
|
48 | - title="<?php p($l->t('The filter specifies which LDAP groups shall have access to the %s instance.', [$theme->getName()]));?>"> |
|
47 | + placeholder="<?php p($l->t('Edit LDAP Query')); ?>" |
|
48 | + title="<?php p($l->t('The filter specifies which LDAP groups shall have access to the %s instance.', [$theme->getName()])); ?>"> |
|
49 | 49 | </textarea> |
50 | 50 | </p> |
51 | 51 | <p> |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | </p> |
54 | 54 | <p class="ldap_count"> |
55 | 55 | <button class="ldapGetEntryCount ldapGetGroupCount" name="ldapGetEntryCount" type="button"> |
56 | - <?php p($l->t('Verify settings and count the groups'));?> |
|
56 | + <?php p($l->t('Verify settings and count the groups')); ?> |
|
57 | 57 | </button> |
58 | 58 | <span id="ldap_group_count"></span> |
59 | 59 | </p> |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <fieldset id="ldapWizard3"> |
2 | 2 | <div> |
3 | 3 | <p> |
4 | - <?php p($l->t('When logging in, %s will find the user based on the following attributes:', [$theme->getName()]));?> |
|
4 | + <?php p($l->t('When logging in, %s will find the user based on the following attributes:', [$theme->getName()])); ?> |
|
5 | 5 | </p> |
6 | 6 | <p> |
7 | 7 | <label for="ldap_loginfilter_username"> |
8 | - <?php p($l->t('LDAP / AD Username:'));?> |
|
8 | + <?php p($l->t('LDAP / AD Username:')); ?> |
|
9 | 9 | </label> |
10 | 10 | |
11 | 11 | <input type="checkbox" id="ldap_loginfilter_username" |
12 | - title="<?php p($l->t('Allows login against the LDAP / AD username, which is either "uid" or "sAMAccountName" and will be detected.'));?>" |
|
12 | + title="<?php p($l->t('Allows login against the LDAP / AD username, which is either "uid" or "sAMAccountName" and will be detected.')); ?>" |
|
13 | 13 | name="ldap_loginfilter_username" value="1" /> |
14 | 14 | </p> |
15 | 15 | <p> |
16 | 16 | <label for="ldap_loginfilter_email"> |
17 | - <?php p($l->t('LDAP / AD Email Address:'));?> |
|
17 | + <?php p($l->t('LDAP / AD Email Address:')); ?> |
|
18 | 18 | </label> |
19 | 19 | |
20 | 20 | <input type="checkbox" id="ldap_loginfilter_email" |
21 | - title="<?php p($l->t('Allows login against an email attribute. "mail" and "mailPrimaryAddress" allowed.'));?>" |
|
21 | + title="<?php p($l->t('Allows login against an email attribute. "mail" and "mailPrimaryAddress" allowed.')); ?>" |
|
22 | 22 | name="ldap_loginfilter_email" value="1" /> |
23 | 23 | </p> |
24 | 24 | <p> |
25 | 25 | <label for="ldap_loginfilter_attributes"> |
26 | - <?php p($l->t('Other Attributes:'));?> |
|
26 | + <?php p($l->t('Other Attributes:')); ?> |
|
27 | 27 | </label> |
28 | 28 | |
29 | 29 | <select id="ldap_loginfilter_attributes" multiple="multiple" |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | </select> |
32 | 32 | </p> |
33 | 33 | <p> |
34 | - <label><a id='toggleRawLoginFilter' class='ldapToggle'>↓ <?php p($l->t('Edit LDAP Query'));?></a></label> |
|
34 | + <label><a id='toggleRawLoginFilter' class='ldapToggle'>↓ <?php p($l->t('Edit LDAP Query')); ?></a></label> |
|
35 | 35 | </p> |
36 | 36 | <p id="ldapReadOnlyLoginFilterContainer" class="hidden ldapReadOnlyFilterContainer"> |
37 | - <label><?php p($l->t('LDAP Filter:'));?></label> |
|
37 | + <label><?php p($l->t('LDAP Filter:')); ?></label> |
|
38 | 38 | <span class="ldapFilterReadOnlyElement ldapInputColElement"></span> |
39 | 39 | </p> |
40 | 40 | <p id="rawLoginFilterContainer" class="invisible"> |
41 | 41 | <textarea type="text" id="ldap_login_filter" name="ldap_login_filter" |
42 | 42 | class="ldapFilterInputElement" |
43 | - placeholder="<?php p($l->t('Edit LDAP Query'));?>" |
|
44 | - title="<?php p($l->t('Defines the filter to apply, when login is attempted. "%%uid" replaces the username in the login action. Example: "uid=%%uid"'));?>"> |
|
43 | + placeholder="<?php p($l->t('Edit LDAP Query')); ?>" |
|
44 | + title="<?php p($l->t('Defines the filter to apply, when login is attempted. "%%uid" replaces the username in the login action. Example: "uid=%%uid"')); ?>"> |
|
45 | 45 | </textarea> |
46 | 46 | </p> |
47 | 47 | <p> |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | </p> |
50 | 50 | <p class="ldap_verify"> |
51 | 51 | <input type="text" id="ldap_test_loginname" name="ldap_test_loginname" |
52 | - placeholder="<?php p($l->t('Test Loginname'));?>" |
|
52 | + placeholder="<?php p($l->t('Test Loginname')); ?>" |
|
53 | 53 | class="ldapVerifyInput" |
54 | 54 | title="Attempts to receive a DN for the given loginname and the current login filter"/> |
55 | 55 | <button class="ldapVerifyLoginName" name="ldapTestLoginSettings" type="button" disabled="disabled"> |
56 | - <?php p($l->t('Verify settings'));?> |
|
56 | + <?php p($l->t('Verify settings')); ?> |
|
57 | 57 | </button> |
58 | 58 | </p> |
59 | 59 | <?php print_unescaped($_['wizardControls']); ?> |
@@ -36,7 +36,7 @@ |
||
36 | 36 | * @package OC\AppFramework\Middleware\Security\Exceptions |
37 | 37 | */ |
38 | 38 | class NotAdminException extends SecurityException { |
39 | - public function __construct(string $message) { |
|
40 | - parent::__construct($message, Http::STATUS_FORBIDDEN); |
|
41 | - } |
|
39 | + public function __construct(string $message) { |
|
40 | + parent::__construct($message, Http::STATUS_FORBIDDEN); |
|
41 | + } |
|
42 | 42 | } |
@@ -29,53 +29,53 @@ |
||
29 | 29 | |
30 | 30 | abstract class Session implements \ArrayAccess, ISession { |
31 | 31 | |
32 | - /** |
|
33 | - * @var bool |
|
34 | - */ |
|
35 | - protected $sessionClosed = false; |
|
32 | + /** |
|
33 | + * @var bool |
|
34 | + */ |
|
35 | + protected $sessionClosed = false; |
|
36 | 36 | |
37 | - /** |
|
38 | - * $name serves as a namespace for the session keys |
|
39 | - * |
|
40 | - * @param string $name |
|
41 | - */ |
|
42 | - abstract public function __construct(string $name); |
|
37 | + /** |
|
38 | + * $name serves as a namespace for the session keys |
|
39 | + * |
|
40 | + * @param string $name |
|
41 | + */ |
|
42 | + abstract public function __construct(string $name); |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param mixed $offset |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function offsetExists($offset): bool { |
|
49 | - return $this->exists($offset); |
|
50 | - } |
|
44 | + /** |
|
45 | + * @param mixed $offset |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function offsetExists($offset): bool { |
|
49 | + return $this->exists($offset); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param mixed $offset |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - public function offsetGet($offset) { |
|
57 | - return $this->get($offset); |
|
58 | - } |
|
52 | + /** |
|
53 | + * @param mixed $offset |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + public function offsetGet($offset) { |
|
57 | + return $this->get($offset); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param mixed $offset |
|
62 | - * @param mixed $value |
|
63 | - */ |
|
64 | - public function offsetSet($offset, $value) { |
|
65 | - $this->set($offset, $value); |
|
66 | - } |
|
60 | + /** |
|
61 | + * @param mixed $offset |
|
62 | + * @param mixed $value |
|
63 | + */ |
|
64 | + public function offsetSet($offset, $value) { |
|
65 | + $this->set($offset, $value); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param mixed $offset |
|
70 | - */ |
|
71 | - public function offsetUnset($offset) { |
|
72 | - $this->remove($offset); |
|
73 | - } |
|
68 | + /** |
|
69 | + * @param mixed $offset |
|
70 | + */ |
|
71 | + public function offsetUnset($offset) { |
|
72 | + $this->remove($offset); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Close the session and release the lock |
|
77 | - */ |
|
78 | - public function close() { |
|
79 | - $this->sessionClosed = true; |
|
80 | - } |
|
75 | + /** |
|
76 | + * Close the session and release the lock |
|
77 | + */ |
|
78 | + public function close() { |
|
79 | + $this->sessionClosed = true; |
|
80 | + } |
|
81 | 81 | } |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
160 | - $keys = array_map(function ($header) { |
|
160 | + $keys = array_map(function($header) { |
|
161 | 161 | return strtolower(str_replace(' ', '_', $header)); |
162 | 162 | }, $headers); |
163 | 163 | |
164 | - $pairs = array_map(function (StorageConfig $config) use ($keys, $userId) { |
|
164 | + $pairs = array_map(function(StorageConfig $config) use ($keys, $userId) { |
|
165 | 165 | $values = [ |
166 | 166 | $config->getId(), |
167 | 167 | $config->getMountPoint(), |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | 'encoding_compatibility' => false, |
196 | 196 | 'readonly' => false, |
197 | 197 | ]; |
198 | - $rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) { |
|
198 | + $rows = array_map(function(StorageConfig $config) use ($userId, $defaultMountOptions, $full) { |
|
199 | 199 | $storageConfig = $config->getBackendOptions(); |
200 | 200 | $keys = array_keys($storageConfig); |
201 | 201 | $values = array_values($storageConfig); |
202 | 202 | |
203 | 203 | if (!$full) { |
204 | - $values = array_map(function ($value) { |
|
204 | + $values = array_map(function($value) { |
|
205 | 205 | if (is_string($value) && strlen($value) > 32) { |
206 | - return substr($value, 0, 6) . '...' . substr($value, -6, 6); |
|
206 | + return substr($value, 0, 6).'...'.substr($value, -6, 6); |
|
207 | 207 | } else { |
208 | 208 | return $value; |
209 | 209 | } |
210 | 210 | }, $values); |
211 | 211 | } |
212 | 212 | |
213 | - $configStrings = array_map(function ($key, $value) { |
|
214 | - return $key . ': ' . json_encode($value); |
|
213 | + $configStrings = array_map(function($key, $value) { |
|
214 | + return $key.': '.json_encode($value); |
|
215 | 215 | }, $keys, $values); |
216 | 216 | $configString = implode(', ', $configStrings); |
217 | 217 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | $keys = array_keys($mountOptions); |
226 | 226 | $values = array_values($mountOptions); |
227 | 227 | |
228 | - $optionsStrings = array_map(function ($key, $value) { |
|
229 | - return $key . ': ' . json_encode($value); |
|
228 | + $optionsStrings = array_map(function($key, $value) { |
|
229 | + return $key.': '.json_encode($value); |
|
230 | 230 | }, $keys, $values); |
231 | 231 | $optionsString = implode(', ', $optionsStrings); |
232 | 232 |
@@ -39,239 +39,239 @@ |
||
39 | 39 | use Symfony\Component\Console\Output\OutputInterface; |
40 | 40 | |
41 | 41 | class ListCommand extends Base { |
42 | - /** |
|
43 | - * @var GlobalStoragesService |
|
44 | - */ |
|
45 | - protected $globalService; |
|
42 | + /** |
|
43 | + * @var GlobalStoragesService |
|
44 | + */ |
|
45 | + protected $globalService; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @var UserStoragesService |
|
49 | - */ |
|
50 | - protected $userService; |
|
47 | + /** |
|
48 | + * @var UserStoragesService |
|
49 | + */ |
|
50 | + protected $userService; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var IUserSession |
|
54 | - */ |
|
55 | - protected $userSession; |
|
52 | + /** |
|
53 | + * @var IUserSession |
|
54 | + */ |
|
55 | + protected $userSession; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var IUserManager |
|
59 | - */ |
|
60 | - protected $userManager; |
|
57 | + /** |
|
58 | + * @var IUserManager |
|
59 | + */ |
|
60 | + protected $userManager; |
|
61 | 61 | |
62 | - public const ALL = -1; |
|
62 | + public const ALL = -1; |
|
63 | 63 | |
64 | - public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
65 | - parent::__construct(); |
|
66 | - $this->globalService = $globalService; |
|
67 | - $this->userService = $userService; |
|
68 | - $this->userSession = $userSession; |
|
69 | - $this->userManager = $userManager; |
|
70 | - } |
|
64 | + public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
65 | + parent::__construct(); |
|
66 | + $this->globalService = $globalService; |
|
67 | + $this->userService = $userService; |
|
68 | + $this->userSession = $userSession; |
|
69 | + $this->userManager = $userManager; |
|
70 | + } |
|
71 | 71 | |
72 | - protected function configure() { |
|
73 | - $this |
|
74 | - ->setName('files_external:list') |
|
75 | - ->setDescription('List configured admin or personal mounts') |
|
76 | - ->addArgument( |
|
77 | - 'user_id', |
|
78 | - InputArgument::OPTIONAL, |
|
79 | - 'user id to list the personal mounts for, if no user is provided admin mounts will be listed' |
|
80 | - )->addOption( |
|
81 | - 'show-password', |
|
82 | - '', |
|
83 | - InputOption::VALUE_NONE, |
|
84 | - 'show passwords and secrets' |
|
85 | - )->addOption( |
|
86 | - 'full', |
|
87 | - null, |
|
88 | - InputOption::VALUE_NONE, |
|
89 | - 'don\'t truncate long values in table output' |
|
90 | - )->addOption( |
|
91 | - 'all', |
|
92 | - 'a', |
|
93 | - InputOption::VALUE_NONE, |
|
94 | - 'show both system wide mounts and all personal mounts' |
|
95 | - ); |
|
96 | - parent::configure(); |
|
97 | - } |
|
72 | + protected function configure() { |
|
73 | + $this |
|
74 | + ->setName('files_external:list') |
|
75 | + ->setDescription('List configured admin or personal mounts') |
|
76 | + ->addArgument( |
|
77 | + 'user_id', |
|
78 | + InputArgument::OPTIONAL, |
|
79 | + 'user id to list the personal mounts for, if no user is provided admin mounts will be listed' |
|
80 | + )->addOption( |
|
81 | + 'show-password', |
|
82 | + '', |
|
83 | + InputOption::VALUE_NONE, |
|
84 | + 'show passwords and secrets' |
|
85 | + )->addOption( |
|
86 | + 'full', |
|
87 | + null, |
|
88 | + InputOption::VALUE_NONE, |
|
89 | + 'don\'t truncate long values in table output' |
|
90 | + )->addOption( |
|
91 | + 'all', |
|
92 | + 'a', |
|
93 | + InputOption::VALUE_NONE, |
|
94 | + 'show both system wide mounts and all personal mounts' |
|
95 | + ); |
|
96 | + parent::configure(); |
|
97 | + } |
|
98 | 98 | |
99 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
100 | - /** @var StorageConfig[] $mounts */ |
|
101 | - if ($input->getOption('all')) { |
|
102 | - $mounts = $this->globalService->getStorageForAllUsers(); |
|
103 | - $userId = self::ALL; |
|
104 | - } else { |
|
105 | - $userId = $input->getArgument('user_id'); |
|
106 | - $storageService = $this->getStorageService($userId); |
|
107 | - $mounts = $storageService->getAllStorages(); |
|
108 | - } |
|
99 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
100 | + /** @var StorageConfig[] $mounts */ |
|
101 | + if ($input->getOption('all')) { |
|
102 | + $mounts = $this->globalService->getStorageForAllUsers(); |
|
103 | + $userId = self::ALL; |
|
104 | + } else { |
|
105 | + $userId = $input->getArgument('user_id'); |
|
106 | + $storageService = $this->getStorageService($userId); |
|
107 | + $mounts = $storageService->getAllStorages(); |
|
108 | + } |
|
109 | 109 | |
110 | - $this->listMounts($userId, $mounts, $input, $output); |
|
111 | - return 0; |
|
112 | - } |
|
110 | + $this->listMounts($userId, $mounts, $input, $output); |
|
111 | + return 0; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @param string $userId |
|
116 | - * @param StorageConfig[] $mounts |
|
117 | - * @param InputInterface $input |
|
118 | - * @param OutputInterface $output |
|
119 | - */ |
|
120 | - public function listMounts($userId, array $mounts, InputInterface $input, OutputInterface $output) { |
|
121 | - $outputType = $input->getOption('output'); |
|
122 | - if (count($mounts) === 0) { |
|
123 | - if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
|
124 | - $output->writeln('[]'); |
|
125 | - } else { |
|
126 | - if ($userId === self::ALL) { |
|
127 | - $output->writeln("<info>No mounts configured</info>"); |
|
128 | - } elseif ($userId) { |
|
129 | - $output->writeln("<info>No mounts configured by $userId</info>"); |
|
130 | - } else { |
|
131 | - $output->writeln("<info>No admin mounts configured</info>"); |
|
132 | - } |
|
133 | - } |
|
134 | - return; |
|
135 | - } |
|
114 | + /** |
|
115 | + * @param string $userId |
|
116 | + * @param StorageConfig[] $mounts |
|
117 | + * @param InputInterface $input |
|
118 | + * @param OutputInterface $output |
|
119 | + */ |
|
120 | + public function listMounts($userId, array $mounts, InputInterface $input, OutputInterface $output) { |
|
121 | + $outputType = $input->getOption('output'); |
|
122 | + if (count($mounts) === 0) { |
|
123 | + if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
|
124 | + $output->writeln('[]'); |
|
125 | + } else { |
|
126 | + if ($userId === self::ALL) { |
|
127 | + $output->writeln("<info>No mounts configured</info>"); |
|
128 | + } elseif ($userId) { |
|
129 | + $output->writeln("<info>No mounts configured by $userId</info>"); |
|
130 | + } else { |
|
131 | + $output->writeln("<info>No admin mounts configured</info>"); |
|
132 | + } |
|
133 | + } |
|
134 | + return; |
|
135 | + } |
|
136 | 136 | |
137 | - $headers = ['Mount ID', 'Mount Point', 'Storage', 'Authentication Type', 'Configuration', 'Options']; |
|
137 | + $headers = ['Mount ID', 'Mount Point', 'Storage', 'Authentication Type', 'Configuration', 'Options']; |
|
138 | 138 | |
139 | - if (!$userId || $userId === self::ALL) { |
|
140 | - $headers[] = 'Applicable Users'; |
|
141 | - $headers[] = 'Applicable Groups'; |
|
142 | - } |
|
143 | - if ($userId === self::ALL) { |
|
144 | - $headers[] = 'Type'; |
|
145 | - } |
|
139 | + if (!$userId || $userId === self::ALL) { |
|
140 | + $headers[] = 'Applicable Users'; |
|
141 | + $headers[] = 'Applicable Groups'; |
|
142 | + } |
|
143 | + if ($userId === self::ALL) { |
|
144 | + $headers[] = 'Type'; |
|
145 | + } |
|
146 | 146 | |
147 | - if (!$input->getOption('show-password')) { |
|
148 | - $hideKeys = ['password', 'refresh_token', 'token', 'client_secret', 'public_key', 'private_key']; |
|
149 | - foreach ($mounts as $mount) { |
|
150 | - $config = $mount->getBackendOptions(); |
|
151 | - foreach ($config as $key => $value) { |
|
152 | - if (in_array($key, $hideKeys)) { |
|
153 | - $mount->setBackendOption($key, '***'); |
|
154 | - } |
|
155 | - } |
|
156 | - } |
|
157 | - } |
|
147 | + if (!$input->getOption('show-password')) { |
|
148 | + $hideKeys = ['password', 'refresh_token', 'token', 'client_secret', 'public_key', 'private_key']; |
|
149 | + foreach ($mounts as $mount) { |
|
150 | + $config = $mount->getBackendOptions(); |
|
151 | + foreach ($config as $key => $value) { |
|
152 | + if (in_array($key, $hideKeys)) { |
|
153 | + $mount->setBackendOption($key, '***'); |
|
154 | + } |
|
155 | + } |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
|
160 | - $keys = array_map(function ($header) { |
|
161 | - return strtolower(str_replace(' ', '_', $header)); |
|
162 | - }, $headers); |
|
159 | + if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
|
160 | + $keys = array_map(function ($header) { |
|
161 | + return strtolower(str_replace(' ', '_', $header)); |
|
162 | + }, $headers); |
|
163 | 163 | |
164 | - $pairs = array_map(function (StorageConfig $config) use ($keys, $userId) { |
|
165 | - $values = [ |
|
166 | - $config->getId(), |
|
167 | - $config->getMountPoint(), |
|
168 | - $config->getBackend()->getStorageClass(), |
|
169 | - $config->getAuthMechanism()->getIdentifier(), |
|
170 | - $config->getBackendOptions(), |
|
171 | - $config->getMountOptions() |
|
172 | - ]; |
|
173 | - if (!$userId || $userId === self::ALL) { |
|
174 | - $values[] = $config->getApplicableUsers(); |
|
175 | - $values[] = $config->getApplicableGroups(); |
|
176 | - } |
|
177 | - if ($userId === self::ALL) { |
|
178 | - $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'admin' : 'personal'; |
|
179 | - } |
|
164 | + $pairs = array_map(function (StorageConfig $config) use ($keys, $userId) { |
|
165 | + $values = [ |
|
166 | + $config->getId(), |
|
167 | + $config->getMountPoint(), |
|
168 | + $config->getBackend()->getStorageClass(), |
|
169 | + $config->getAuthMechanism()->getIdentifier(), |
|
170 | + $config->getBackendOptions(), |
|
171 | + $config->getMountOptions() |
|
172 | + ]; |
|
173 | + if (!$userId || $userId === self::ALL) { |
|
174 | + $values[] = $config->getApplicableUsers(); |
|
175 | + $values[] = $config->getApplicableGroups(); |
|
176 | + } |
|
177 | + if ($userId === self::ALL) { |
|
178 | + $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'admin' : 'personal'; |
|
179 | + } |
|
180 | 180 | |
181 | - return array_combine($keys, $values); |
|
182 | - }, $mounts); |
|
183 | - if ($outputType === self::OUTPUT_FORMAT_JSON) { |
|
184 | - $output->writeln(json_encode(array_values($pairs))); |
|
185 | - } else { |
|
186 | - $output->writeln(json_encode(array_values($pairs), JSON_PRETTY_PRINT)); |
|
187 | - } |
|
188 | - } else { |
|
189 | - $full = $input->getOption('full'); |
|
190 | - $defaultMountOptions = [ |
|
191 | - 'encrypt' => true, |
|
192 | - 'previews' => true, |
|
193 | - 'filesystem_check_changes' => 1, |
|
194 | - 'enable_sharing' => false, |
|
195 | - 'encoding_compatibility' => false, |
|
196 | - 'readonly' => false, |
|
197 | - ]; |
|
198 | - $rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) { |
|
199 | - $storageConfig = $config->getBackendOptions(); |
|
200 | - $keys = array_keys($storageConfig); |
|
201 | - $values = array_values($storageConfig); |
|
181 | + return array_combine($keys, $values); |
|
182 | + }, $mounts); |
|
183 | + if ($outputType === self::OUTPUT_FORMAT_JSON) { |
|
184 | + $output->writeln(json_encode(array_values($pairs))); |
|
185 | + } else { |
|
186 | + $output->writeln(json_encode(array_values($pairs), JSON_PRETTY_PRINT)); |
|
187 | + } |
|
188 | + } else { |
|
189 | + $full = $input->getOption('full'); |
|
190 | + $defaultMountOptions = [ |
|
191 | + 'encrypt' => true, |
|
192 | + 'previews' => true, |
|
193 | + 'filesystem_check_changes' => 1, |
|
194 | + 'enable_sharing' => false, |
|
195 | + 'encoding_compatibility' => false, |
|
196 | + 'readonly' => false, |
|
197 | + ]; |
|
198 | + $rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) { |
|
199 | + $storageConfig = $config->getBackendOptions(); |
|
200 | + $keys = array_keys($storageConfig); |
|
201 | + $values = array_values($storageConfig); |
|
202 | 202 | |
203 | - if (!$full) { |
|
204 | - $values = array_map(function ($value) { |
|
205 | - if (is_string($value) && strlen($value) > 32) { |
|
206 | - return substr($value, 0, 6) . '...' . substr($value, -6, 6); |
|
207 | - } else { |
|
208 | - return $value; |
|
209 | - } |
|
210 | - }, $values); |
|
211 | - } |
|
203 | + if (!$full) { |
|
204 | + $values = array_map(function ($value) { |
|
205 | + if (is_string($value) && strlen($value) > 32) { |
|
206 | + return substr($value, 0, 6) . '...' . substr($value, -6, 6); |
|
207 | + } else { |
|
208 | + return $value; |
|
209 | + } |
|
210 | + }, $values); |
|
211 | + } |
|
212 | 212 | |
213 | - $configStrings = array_map(function ($key, $value) { |
|
214 | - return $key . ': ' . json_encode($value); |
|
215 | - }, $keys, $values); |
|
216 | - $configString = implode(', ', $configStrings); |
|
213 | + $configStrings = array_map(function ($key, $value) { |
|
214 | + return $key . ': ' . json_encode($value); |
|
215 | + }, $keys, $values); |
|
216 | + $configString = implode(', ', $configStrings); |
|
217 | 217 | |
218 | - $mountOptions = $config->getMountOptions(); |
|
219 | - // hide defaults |
|
220 | - foreach ($mountOptions as $key => $value) { |
|
221 | - if ($value === $defaultMountOptions[$key]) { |
|
222 | - unset($mountOptions[$key]); |
|
223 | - } |
|
224 | - } |
|
225 | - $keys = array_keys($mountOptions); |
|
226 | - $values = array_values($mountOptions); |
|
218 | + $mountOptions = $config->getMountOptions(); |
|
219 | + // hide defaults |
|
220 | + foreach ($mountOptions as $key => $value) { |
|
221 | + if ($value === $defaultMountOptions[$key]) { |
|
222 | + unset($mountOptions[$key]); |
|
223 | + } |
|
224 | + } |
|
225 | + $keys = array_keys($mountOptions); |
|
226 | + $values = array_values($mountOptions); |
|
227 | 227 | |
228 | - $optionsStrings = array_map(function ($key, $value) { |
|
229 | - return $key . ': ' . json_encode($value); |
|
230 | - }, $keys, $values); |
|
231 | - $optionsString = implode(', ', $optionsStrings); |
|
228 | + $optionsStrings = array_map(function ($key, $value) { |
|
229 | + return $key . ': ' . json_encode($value); |
|
230 | + }, $keys, $values); |
|
231 | + $optionsString = implode(', ', $optionsStrings); |
|
232 | 232 | |
233 | - $values = [ |
|
234 | - $config->getId(), |
|
235 | - $config->getMountPoint(), |
|
236 | - $config->getBackend()->getText(), |
|
237 | - $config->getAuthMechanism()->getText(), |
|
238 | - $configString, |
|
239 | - $optionsString |
|
240 | - ]; |
|
233 | + $values = [ |
|
234 | + $config->getId(), |
|
235 | + $config->getMountPoint(), |
|
236 | + $config->getBackend()->getText(), |
|
237 | + $config->getAuthMechanism()->getText(), |
|
238 | + $configString, |
|
239 | + $optionsString |
|
240 | + ]; |
|
241 | 241 | |
242 | - if (!$userId || $userId === self::ALL) { |
|
243 | - $applicableUsers = implode(', ', $config->getApplicableUsers()); |
|
244 | - $applicableGroups = implode(', ', $config->getApplicableGroups()); |
|
245 | - if ($applicableUsers === '' && $applicableGroups === '') { |
|
246 | - $applicableUsers = 'All'; |
|
247 | - } |
|
248 | - $values[] = $applicableUsers; |
|
249 | - $values[] = $applicableGroups; |
|
250 | - } |
|
251 | - if ($userId === self::ALL) { |
|
252 | - $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'Admin' : 'Personal'; |
|
253 | - } |
|
242 | + if (!$userId || $userId === self::ALL) { |
|
243 | + $applicableUsers = implode(', ', $config->getApplicableUsers()); |
|
244 | + $applicableGroups = implode(', ', $config->getApplicableGroups()); |
|
245 | + if ($applicableUsers === '' && $applicableGroups === '') { |
|
246 | + $applicableUsers = 'All'; |
|
247 | + } |
|
248 | + $values[] = $applicableUsers; |
|
249 | + $values[] = $applicableGroups; |
|
250 | + } |
|
251 | + if ($userId === self::ALL) { |
|
252 | + $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'Admin' : 'Personal'; |
|
253 | + } |
|
254 | 254 | |
255 | - return $values; |
|
256 | - }, $mounts); |
|
255 | + return $values; |
|
256 | + }, $mounts); |
|
257 | 257 | |
258 | - $table = new Table($output); |
|
259 | - $table->setHeaders($headers); |
|
260 | - $table->setRows($rows); |
|
261 | - $table->render(); |
|
262 | - } |
|
263 | - } |
|
258 | + $table = new Table($output); |
|
259 | + $table->setHeaders($headers); |
|
260 | + $table->setRows($rows); |
|
261 | + $table->render(); |
|
262 | + } |
|
263 | + } |
|
264 | 264 | |
265 | - protected function getStorageService($userId) { |
|
266 | - if (!empty($userId)) { |
|
267 | - $user = $this->userManager->get($userId); |
|
268 | - if (is_null($user)) { |
|
269 | - throw new NoUserException("user $userId not found"); |
|
270 | - } |
|
271 | - $this->userSession->setUser($user); |
|
272 | - return $this->userService; |
|
273 | - } else { |
|
274 | - return $this->globalService; |
|
275 | - } |
|
276 | - } |
|
265 | + protected function getStorageService($userId) { |
|
266 | + if (!empty($userId)) { |
|
267 | + $user = $this->userManager->get($userId); |
|
268 | + if (is_null($user)) { |
|
269 | + throw new NoUserException("user $userId not found"); |
|
270 | + } |
|
271 | + $this->userSession->setUser($user); |
|
272 | + return $this->userService; |
|
273 | + } else { |
|
274 | + return $this->globalService; |
|
275 | + } |
|
276 | + } |
|
277 | 277 | } |
@@ -34,55 +34,55 @@ |
||
34 | 34 | |
35 | 35 | class ProvisioningApiMiddleware extends Middleware { |
36 | 36 | |
37 | - /** @var IControllerMethodReflector */ |
|
38 | - private $reflector; |
|
37 | + /** @var IControllerMethodReflector */ |
|
38 | + private $reflector; |
|
39 | 39 | |
40 | - /** @var bool */ |
|
41 | - private $isAdmin; |
|
40 | + /** @var bool */ |
|
41 | + private $isAdmin; |
|
42 | 42 | |
43 | - /** @var bool */ |
|
44 | - private $isSubAdmin; |
|
43 | + /** @var bool */ |
|
44 | + private $isSubAdmin; |
|
45 | 45 | |
46 | - /** |
|
47 | - * ProvisioningApiMiddleware constructor. |
|
48 | - * |
|
49 | - * @param IControllerMethodReflector $reflector |
|
50 | - * @param bool $isAdmin |
|
51 | - * @param bool $isSubAdmin |
|
52 | - */ |
|
53 | - public function __construct( |
|
54 | - IControllerMethodReflector $reflector, |
|
55 | - bool $isAdmin, |
|
56 | - bool $isSubAdmin) { |
|
57 | - $this->reflector = $reflector; |
|
58 | - $this->isAdmin = $isAdmin; |
|
59 | - $this->isSubAdmin = $isSubAdmin; |
|
60 | - } |
|
46 | + /** |
|
47 | + * ProvisioningApiMiddleware constructor. |
|
48 | + * |
|
49 | + * @param IControllerMethodReflector $reflector |
|
50 | + * @param bool $isAdmin |
|
51 | + * @param bool $isSubAdmin |
|
52 | + */ |
|
53 | + public function __construct( |
|
54 | + IControllerMethodReflector $reflector, |
|
55 | + bool $isAdmin, |
|
56 | + bool $isSubAdmin) { |
|
57 | + $this->reflector = $reflector; |
|
58 | + $this->isAdmin = $isAdmin; |
|
59 | + $this->isSubAdmin = $isSubAdmin; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param Controller $controller |
|
64 | - * @param string $methodName |
|
65 | - * |
|
66 | - * @throws NotSubAdminException |
|
67 | - */ |
|
68 | - public function beforeController($controller, $methodName) { |
|
69 | - if (!$this->isAdmin && !$this->reflector->hasAnnotation('NoSubAdminRequired') && !$this->isSubAdmin) { |
|
70 | - throw new NotSubAdminException(); |
|
71 | - } |
|
72 | - } |
|
62 | + /** |
|
63 | + * @param Controller $controller |
|
64 | + * @param string $methodName |
|
65 | + * |
|
66 | + * @throws NotSubAdminException |
|
67 | + */ |
|
68 | + public function beforeController($controller, $methodName) { |
|
69 | + if (!$this->isAdmin && !$this->reflector->hasAnnotation('NoSubAdminRequired') && !$this->isSubAdmin) { |
|
70 | + throw new NotSubAdminException(); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param Controller $controller |
|
76 | - * @param string $methodName |
|
77 | - * @param \Exception $exception |
|
78 | - * @throws \Exception |
|
79 | - * @return Response |
|
80 | - */ |
|
81 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
82 | - if ($exception instanceof NotSubAdminException) { |
|
83 | - throw new OCSException($exception->getMessage(), \OCP\API::RESPOND_UNAUTHORISED); |
|
84 | - } |
|
74 | + /** |
|
75 | + * @param Controller $controller |
|
76 | + * @param string $methodName |
|
77 | + * @param \Exception $exception |
|
78 | + * @throws \Exception |
|
79 | + * @return Response |
|
80 | + */ |
|
81 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
82 | + if ($exception instanceof NotSubAdminException) { |
|
83 | + throw new OCSException($exception->getMessage(), \OCP\API::RESPOND_UNAUTHORISED); |
|
84 | + } |
|
85 | 85 | |
86 | - throw $exception; |
|
87 | - } |
|
86 | + throw $exception; |
|
87 | + } |
|
88 | 88 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $dir = $pathinfo['dirname']; |
59 | 59 | $i = 2; |
60 | 60 | while ($view->file_exists($path) || in_array($path, $excludeList)) { |
61 | - $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext); |
|
61 | + $path = Filesystem::normalizePath($dir.'/'.$name.' ('.$i.')'.$ext); |
|
62 | 62 | $i++; |
63 | 63 | } |
64 | 64 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $dir = ''; |
83 | 83 | $subdirs = explode('/', $shareFolder); |
84 | 84 | foreach ($subdirs as $subdir) { |
85 | - $dir = $dir . '/' . $subdir; |
|
85 | + $dir = $dir.'/'.$subdir; |
|
86 | 86 | if (!$view->is_dir($dir)) { |
87 | 87 | $view->mkdir($dir); |
88 | 88 | } |
@@ -31,68 +31,68 @@ |
||
31 | 31 | use OC\Files\View; |
32 | 32 | |
33 | 33 | class Helper { |
34 | - public static function registerHooks() { |
|
35 | - \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); |
|
36 | - \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); |
|
34 | + public static function registerHooks() { |
|
35 | + \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); |
|
36 | + \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); |
|
37 | 37 | |
38 | - \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); |
|
39 | - } |
|
38 | + \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * check if file name already exists and generate unique target |
|
43 | - * |
|
44 | - * @param string $path |
|
45 | - * @param array $excludeList |
|
46 | - * @param View $view |
|
47 | - * @return string $path |
|
48 | - */ |
|
49 | - public static function generateUniqueTarget($path, $excludeList, $view) { |
|
50 | - $pathinfo = pathinfo($path); |
|
51 | - $ext = isset($pathinfo['extension']) ? '.'.$pathinfo['extension'] : ''; |
|
52 | - $name = $pathinfo['filename']; |
|
53 | - $dir = $pathinfo['dirname']; |
|
54 | - $i = 2; |
|
55 | - while ($view->file_exists($path) || in_array($path, $excludeList)) { |
|
56 | - $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext); |
|
57 | - $i++; |
|
58 | - } |
|
41 | + /** |
|
42 | + * check if file name already exists and generate unique target |
|
43 | + * |
|
44 | + * @param string $path |
|
45 | + * @param array $excludeList |
|
46 | + * @param View $view |
|
47 | + * @return string $path |
|
48 | + */ |
|
49 | + public static function generateUniqueTarget($path, $excludeList, $view) { |
|
50 | + $pathinfo = pathinfo($path); |
|
51 | + $ext = isset($pathinfo['extension']) ? '.'.$pathinfo['extension'] : ''; |
|
52 | + $name = $pathinfo['filename']; |
|
53 | + $dir = $pathinfo['dirname']; |
|
54 | + $i = 2; |
|
55 | + while ($view->file_exists($path) || in_array($path, $excludeList)) { |
|
56 | + $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext); |
|
57 | + $i++; |
|
58 | + } |
|
59 | 59 | |
60 | - return $path; |
|
61 | - } |
|
60 | + return $path; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * get default share folder |
|
65 | - * |
|
66 | - * @param \OC\Files\View $view |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public static function getShareFolder($view = null) { |
|
70 | - if ($view === null) { |
|
71 | - $view = Filesystem::getView(); |
|
72 | - } |
|
73 | - $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/'); |
|
74 | - $shareFolder = Filesystem::normalizePath($shareFolder); |
|
63 | + /** |
|
64 | + * get default share folder |
|
65 | + * |
|
66 | + * @param \OC\Files\View $view |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public static function getShareFolder($view = null) { |
|
70 | + if ($view === null) { |
|
71 | + $view = Filesystem::getView(); |
|
72 | + } |
|
73 | + $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/'); |
|
74 | + $shareFolder = Filesystem::normalizePath($shareFolder); |
|
75 | 75 | |
76 | - if (!$view->file_exists($shareFolder)) { |
|
77 | - $dir = ''; |
|
78 | - $subdirs = explode('/', $shareFolder); |
|
79 | - foreach ($subdirs as $subdir) { |
|
80 | - $dir = $dir . '/' . $subdir; |
|
81 | - if (!$view->is_dir($dir)) { |
|
82 | - $view->mkdir($dir); |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
76 | + if (!$view->file_exists($shareFolder)) { |
|
77 | + $dir = ''; |
|
78 | + $subdirs = explode('/', $shareFolder); |
|
79 | + foreach ($subdirs as $subdir) { |
|
80 | + $dir = $dir . '/' . $subdir; |
|
81 | + if (!$view->is_dir($dir)) { |
|
82 | + $view->mkdir($dir); |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - return $shareFolder; |
|
88 | - } |
|
87 | + return $shareFolder; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * set default share folder |
|
92 | - * |
|
93 | - * @param string $shareFolder |
|
94 | - */ |
|
95 | - public static function setShareFolder($shareFolder) { |
|
96 | - \OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder); |
|
97 | - } |
|
90 | + /** |
|
91 | + * set default share folder |
|
92 | + * |
|
93 | + * @param string $shareFolder |
|
94 | + */ |
|
95 | + public static function setShareFolder($shareFolder) { |
|
96 | + \OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder); |
|
97 | + } |
|
98 | 98 | } |
@@ -22,11 +22,11 @@ |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | return [ |
25 | - 'routes' => [ |
|
26 | - ['name' => 'Admin#createCredentials', 'url' => '/credentials', 'verb' => 'GET'], |
|
27 | - ['name' => 'Admin#setChannel', 'url' => '/channel', 'verb' => 'POST'], |
|
28 | - ], |
|
29 | - 'ocs' => [ |
|
30 | - ['name' => 'API#getAppList', 'url' => '/api/{apiVersion}/applist/{newVersion}', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v1']], |
|
31 | - ], |
|
25 | + 'routes' => [ |
|
26 | + ['name' => 'Admin#createCredentials', 'url' => '/credentials', 'verb' => 'GET'], |
|
27 | + ['name' => 'Admin#setChannel', 'url' => '/channel', 'verb' => 'POST'], |
|
28 | + ], |
|
29 | + 'ocs' => [ |
|
30 | + ['name' => 'API#getAppList', 'url' => '/api/{apiVersion}/applist/{newVersion}', 'verb' => 'GET', 'requirements' => ['apiVersion' => 'v1']], |
|
31 | + ], |
|
32 | 32 | ]; |