@@ -9,74 +9,74 @@ |
||
9 | 9 | use OCA\Files_External\Lib\DefinitionParameter as Param; |
10 | 10 | |
11 | 11 | class DefinitionParameterTest extends \Test\TestCase { |
12 | - public function testJsonSerialization(): void { |
|
13 | - $param = new Param('foo', 'bar'); |
|
14 | - $this->assertEquals([ |
|
15 | - 'value' => 'bar', |
|
16 | - 'flags' => 0, |
|
17 | - 'type' => 0, |
|
18 | - 'tooltip' => '', |
|
19 | - ], $param->jsonSerialize()); |
|
12 | + public function testJsonSerialization(): void { |
|
13 | + $param = new Param('foo', 'bar'); |
|
14 | + $this->assertEquals([ |
|
15 | + 'value' => 'bar', |
|
16 | + 'flags' => 0, |
|
17 | + 'type' => 0, |
|
18 | + 'tooltip' => '', |
|
19 | + ], $param->jsonSerialize()); |
|
20 | 20 | |
21 | - $param->setType(Param::VALUE_BOOLEAN); |
|
22 | - $param->setDefaultValue(true); |
|
23 | - $this->assertEquals([ |
|
24 | - 'value' => 'bar', |
|
25 | - 'flags' => 0, |
|
26 | - 'type' => Param::VALUE_BOOLEAN, |
|
27 | - 'tooltip' => '', |
|
28 | - 'defaultValue' => true, |
|
29 | - ], $param->jsonSerialize()); |
|
21 | + $param->setType(Param::VALUE_BOOLEAN); |
|
22 | + $param->setDefaultValue(true); |
|
23 | + $this->assertEquals([ |
|
24 | + 'value' => 'bar', |
|
25 | + 'flags' => 0, |
|
26 | + 'type' => Param::VALUE_BOOLEAN, |
|
27 | + 'tooltip' => '', |
|
28 | + 'defaultValue' => true, |
|
29 | + ], $param->jsonSerialize()); |
|
30 | 30 | |
31 | - $param->setType(Param::VALUE_PASSWORD); |
|
32 | - $param->setFlag(Param::FLAG_OPTIONAL); |
|
33 | - $param->setDefaultValue(null); |
|
34 | - $this->assertEquals([ |
|
35 | - 'value' => 'bar', |
|
36 | - 'flags' => Param::FLAG_OPTIONAL, |
|
37 | - 'type' => Param::VALUE_PASSWORD, |
|
38 | - 'tooltip' => '', |
|
39 | - ], $param->jsonSerialize()); |
|
31 | + $param->setType(Param::VALUE_PASSWORD); |
|
32 | + $param->setFlag(Param::FLAG_OPTIONAL); |
|
33 | + $param->setDefaultValue(null); |
|
34 | + $this->assertEquals([ |
|
35 | + 'value' => 'bar', |
|
36 | + 'flags' => Param::FLAG_OPTIONAL, |
|
37 | + 'type' => Param::VALUE_PASSWORD, |
|
38 | + 'tooltip' => '', |
|
39 | + ], $param->jsonSerialize()); |
|
40 | 40 | |
41 | - $param->setType(Param::VALUE_TEXT); |
|
42 | - $param->setFlags(Param::FLAG_HIDDEN); |
|
43 | - $this->assertEquals([ |
|
44 | - 'value' => 'bar', |
|
45 | - 'flags' => Param::FLAG_HIDDEN, |
|
46 | - 'type' => Param::VALUE_TEXT, |
|
47 | - 'tooltip' => '', |
|
48 | - ], $param->jsonSerialize()); |
|
49 | - } |
|
41 | + $param->setType(Param::VALUE_TEXT); |
|
42 | + $param->setFlags(Param::FLAG_HIDDEN); |
|
43 | + $this->assertEquals([ |
|
44 | + 'value' => 'bar', |
|
45 | + 'flags' => Param::FLAG_HIDDEN, |
|
46 | + 'type' => Param::VALUE_TEXT, |
|
47 | + 'tooltip' => '', |
|
48 | + ], $param->jsonSerialize()); |
|
49 | + } |
|
50 | 50 | |
51 | - public function validateValueProvider() { |
|
52 | - return [ |
|
53 | - [Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true], |
|
54 | - [Param::VALUE_TEXT, Param::FLAG_NONE, '', false], |
|
55 | - [Param::VALUE_TEXT, Param::FLAG_OPTIONAL, '', true], |
|
56 | - [Param::VALUE_TEXT, Param::FLAG_HIDDEN, '', false], |
|
51 | + public function validateValueProvider() { |
|
52 | + return [ |
|
53 | + [Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true], |
|
54 | + [Param::VALUE_TEXT, Param::FLAG_NONE, '', false], |
|
55 | + [Param::VALUE_TEXT, Param::FLAG_OPTIONAL, '', true], |
|
56 | + [Param::VALUE_TEXT, Param::FLAG_HIDDEN, '', false], |
|
57 | 57 | |
58 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true], |
|
59 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false], |
|
60 | - // conversion from string to boolean |
|
61 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'false', true, false], |
|
62 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'true', true, true], |
|
58 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true], |
|
59 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false], |
|
60 | + // conversion from string to boolean |
|
61 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'false', true, false], |
|
62 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'true', true, true], |
|
63 | 63 | |
64 | - [Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true], |
|
65 | - [Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false], |
|
66 | - ]; |
|
67 | - } |
|
64 | + [Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true], |
|
65 | + [Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false], |
|
66 | + ]; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @dataProvider validateValueProvider |
|
71 | - */ |
|
72 | - public function testValidateValue($type, $flags, $value, $success, $expectedValue = null): void { |
|
73 | - $param = new Param('foo', 'bar'); |
|
74 | - $param->setType($type); |
|
75 | - $param->setFlags($flags); |
|
69 | + /** |
|
70 | + * @dataProvider validateValueProvider |
|
71 | + */ |
|
72 | + public function testValidateValue($type, $flags, $value, $success, $expectedValue = null): void { |
|
73 | + $param = new Param('foo', 'bar'); |
|
74 | + $param->setType($type); |
|
75 | + $param->setFlags($flags); |
|
76 | 76 | |
77 | - $this->assertEquals($success, $param->validateValue($value)); |
|
78 | - if (isset($expectedValue)) { |
|
79 | - $this->assertEquals($expectedValue, $value); |
|
80 | - } |
|
81 | - } |
|
77 | + $this->assertEquals($success, $param->validateValue($value)); |
|
78 | + if (isset($expectedValue)) { |
|
79 | + $this->assertEquals($expectedValue, $value); |
|
80 | + } |
|
81 | + } |
|
82 | 82 | } |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | |
28 | 28 | // load custom JS |
29 | 29 | foreach ($_['backends'] as $backend) { |
30 | - /** @var Backend $backend */ |
|
31 | - $scripts = $backend->getCustomJs(); |
|
32 | - foreach ($scripts as $script) { |
|
33 | - script('files_external', $script); |
|
34 | - } |
|
30 | + /** @var Backend $backend */ |
|
31 | + $scripts = $backend->getCustomJs(); |
|
32 | + foreach ($scripts as $script) { |
|
33 | + script('files_external', $script); |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | foreach ($_['authMechanisms'] as $authMechanism) { |
37 | - /** @var AuthMechanism $authMechanism */ |
|
38 | - $scripts = $authMechanism->getCustomJs(); |
|
39 | - foreach ($scripts as $script) { |
|
40 | - script('files_external', $script); |
|
41 | - } |
|
37 | + /** @var AuthMechanism $authMechanism */ |
|
38 | + $scripts = $authMechanism->getCustomJs(); |
|
39 | + foreach ($scripts as $script) { |
|
40 | + script('files_external', $script); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | ?> |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | </div> |
50 | 50 | |
51 | 51 | <?php |
52 | - $canCreateNewLocalStorage = \OCP\Server::get(\OCP\IConfig::class)->getSystemValue('files_external_allow_create_new_local', true); |
|
52 | + $canCreateNewLocalStorage = \OCP\Server::get(\OCP\IConfig::class)->getSystemValue('files_external_allow_create_new_local', true); |
|
53 | 53 | ?> |
54 | 54 | <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" data-can-create-local="<?php echo $canCreateNewLocalStorage?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
55 | 55 | <h2 class="inlineblock" data-anchor-name="external-storage"><?php p($l->t('External storage')); ?></h2> |
56 | 56 | <a target="_blank" rel="noreferrer" class="icon-info" title="<?php p($l->t('Open documentation'));?>" href="<?php p(link_to_docs('admin-external-storage')); ?>"></a> |
57 | 57 | <p class="settings-hint"><?php p($l->t('External storage enables you to mount external storage services and devices as secondary Nextcloud storage devices. You may also allow people to mount their own external storage services.')); ?></p> |
58 | 58 | <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) { |
59 | - print_unescaped('' . $_['dependencies'] . ''); |
|
60 | - } ?> |
|
59 | + print_unescaped('' . $_['dependencies'] . ''); |
|
60 | + } ?> |
|
61 | 61 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
62 | 62 | <thead> |
63 | 63 | <tr> |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | <th><?php p($l->t('Authentication')); ?></th> |
68 | 68 | <th><?php p($l->t('Configuration')); ?></th> |
69 | 69 | <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) { |
70 | - print_unescaped('<th>' . $l->t('Available for') . '</th>'); |
|
71 | - } ?> |
|
70 | + print_unescaped('<th>' . $l->t('Available for') . '</th>'); |
|
71 | + } ?> |
|
72 | 72 | <th> </th> |
73 | 73 | <th> </th> |
74 | 74 | <th> </th> |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | <?php p($l->t('Add storage')); ?> |
99 | 99 | </option> |
100 | 100 | <?php |
101 | - $sortedBackends = array_filter($_['backends'], function ($backend) use ($_) { |
|
102 | - return $backend->isVisibleFor($_['visibilityType']); |
|
103 | - }); |
|
101 | + $sortedBackends = array_filter($_['backends'], function ($backend) use ($_) { |
|
102 | + return $backend->isVisibleFor($_['visibilityType']); |
|
103 | + }); |
|
104 | 104 | uasort($sortedBackends, function ($a, $b) { |
105 | - return strcasecmp($a->getText(), $b->getText()); |
|
105 | + return strcasecmp($a->getText(), $b->getText()); |
|
106 | 106 | }); |
107 | 107 | ?> |
108 | 108 | <?php foreach ($sortedBackends as $backend): ?> |
109 | 109 | <?php if ($backend->getDeprecateTo() || (!$canCreateNewLocalStorage && $backend->getIdentifier() == 'local')) { |
110 | - continue; |
|
111 | - } // ignore deprecated backends?> |
|
110 | + continue; |
|
111 | + } // ignore deprecated backends?> |
|
112 | 112 | <option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option> |
113 | 113 | <?php endforeach; ?> |
114 | 114 | </select> |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?> |
138 | 138 | <input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox" |
139 | 139 | value="1" <?php if ($_['allowUserMounting']) { |
140 | - print_unescaped(' checked="checked"'); |
|
141 | - } ?> /> |
|
140 | + print_unescaped(' checked="checked"'); |
|
141 | + } ?> /> |
|
142 | 142 | <label for="allowUserMounting"><?php p($l->t('Allow people to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span> |
143 | 143 | |
144 | 144 | <p id="userMountingBackends"<?php if (!$_['allowUserMounting']): ?> class="hidden"<?php endif; ?>> |
145 | 145 | <?php |
146 | - $userBackends = array_filter($_['backends'], function ($backend) { |
|
147 | - return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
148 | - }); |
|
149 | - ?> |
|
146 | + $userBackends = array_filter($_['backends'], function ($backend) { |
|
147 | + return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
148 | + }); |
|
149 | + ?> |
|
150 | 150 | <?php $i = 0; |
151 | - foreach ($userBackends as $backend): ?> |
|
151 | + foreach ($userBackends as $backend): ?> |
|
152 | 152 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
153 | 153 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
154 | 154 | <?php else: ?> |
155 | 155 | <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
156 | - print_unescaped(' checked="checked"'); |
|
157 | - } ?> /> |
|
156 | + print_unescaped(' checked="checked"'); |
|
157 | + } ?> /> |
|
158 | 158 | <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br /> |
159 | 159 | <?php endif; ?> |
160 | 160 | <?php $i++; ?> |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | <form autocomplete="false" action="#" |
168 | 168 | id="global_credentials" method="post" |
169 | 169 | class="<?php if (isset($_['visibilityType']) && $_['visibilityType'] === BackendService::VISIBILITY_PERSONAL) { |
170 | - print_unescaped('global_credentials__personal'); |
|
171 | - } ?>"> |
|
170 | + print_unescaped('global_credentials__personal'); |
|
171 | + } ?>"> |
|
172 | 172 | <h2><?php p($l->t('Global credentials')); ?></h2> |
173 | 173 | <p class="settings-hint"><?php p($l->t('Global credentials can be used to authenticate with multiple external storages that have the same credentials.')); ?></p> |
174 | 174 | <input type="text" name="username" |