|
1 | 1 | <?php |
| 2 | +use \OCA\Files_External\Lib\Auth\AuthMechanism; |
| 3 | +use \OCA\Files_External\Lib\Backend\Backend; |
2 | 4 | use \OCA\Files_External\Lib\DefinitionParameter; |
3 | 5 | use \OCA\Files_External\Service\BackendService; |
4 | 6 |
|
| 7 | +/** @var array $_ */ |
| 8 | + |
| 9 | +$canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; |
| 10 | + |
| 11 | +$l->t("Enable encryption"); |
| 12 | +$l->t("Enable previews"); |
| 13 | +$l->t("Enable sharing"); |
| 14 | +$l->t("Check for changes"); |
| 15 | +$l->t("Never"); |
| 16 | +$l->t("Once every direct access"); |
| 17 | +$l->t('Read only'); |
| 18 | + |
| 19 | +script('files_external', [ |
| 20 | + 'settings', |
| 21 | + 'templates' |
| 22 | +]); |
| 23 | +style('files_external', 'settings'); |
| 24 | + |
| 25 | +// load custom JS |
| 26 | +foreach ($_['backends'] as $backend) { |
| 27 | + /** @var Backend $backend */ |
| 28 | + $scripts = $backend->getCustomJs(); |
| 29 | + foreach ($scripts as $script) { |
| 30 | + script('files_external', $script); |
| 31 | + } |
| 32 | +} |
| 33 | +foreach ($_['authMechanisms'] as $authMechanism) { |
| 34 | + /** @var AuthMechanism $authMechanism */ |
| 35 | + $scripts = $authMechanism->getCustomJs(); |
| 36 | + foreach ($scripts as $script) { |
| 37 | + script('files_external', $script); |
| 38 | + } |
| 39 | +} |
| 40 | + |
5 | 41 | function writeParameterInput($parameter, $options, $classes = []) { |
6 | 42 | $value = ''; |
7 | 43 | if (isset($options[$parameter->getName()])) { |
@@ -61,10 +97,21 @@ function writeParameterInput($parameter, $options, $classes = []) { |
61 | 97 | } |
62 | 98 | ?> |
63 | 99 |
|
| 100 | +<div class="emptyfilelist emptycontent hidden"> |
| 101 | + <div class="icon-external"></div> |
| 102 | + <h2><?php p($l->t('No external storage configured or you don\'t have the permission to configure them')); ?></h2> |
| 103 | +</div> |
| 104 | + |
64 | 105 | <?php |
65 | 106 | $canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', true); |
66 | 107 | ?> |
67 | 108 | <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'; ?>"> |
| 109 | + <h2 class="inlineblock" data-anchor-name="external-storage"><?php p($l->t('External storage')); ?></h2> |
| 110 | + <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> |
| 111 | + <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> |
| 112 | + <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) { |
| 113 | + print_unescaped(''.$_['dependencies'].''); |
| 114 | + } ?> |
68 | 115 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
69 | 116 | <thead> |
70 | 117 | <tr> |
@@ -140,5 +187,54 @@ function writeParameterInput($parameter, $options, $classes = []) { |
140 | 187 | </tr> |
141 | 188 | </tbody> |
142 | 189 | </table> |
| 190 | + |
| 191 | + <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?> |
| 192 | + <input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox" |
| 193 | + value="1" <?php if ($_['allowUserMounting']) { |
| 194 | + print_unescaped(' checked="checked"'); |
| 195 | + } ?> /> |
| 196 | + <label for="allowUserMounting"><?php p($l->t('Allow people to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span> |
| 197 | + |
| 198 | + <p id="userMountingBackends"<?php if (!$_['allowUserMounting']): ?> class="hidden"<?php endif; ?>> |
| 199 | + <?php |
| 200 | + $userBackends = array_filter($_['backends'], function ($backend) { |
| 201 | + return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
| 202 | + }); |
| 203 | + ?> |
| 204 | + <?php $i = 0; |
| 205 | + foreach ($userBackends as $backend): ?> |
| 206 | + <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
| 207 | + <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
| 208 | + <?php else: ?> |
| 209 | + <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
| 210 | + print_unescaped(' checked="checked"'); |
| 211 | + } ?> /> |
| 212 | + <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br /> |
| 213 | + <?php endif; ?> |
| 214 | + <?php $i++; ?> |
| 215 | + <?php endforeach; ?> |
| 216 | + </p> |
| 217 | + <?php endif; ?> |
143 | 218 | </form> |
144 | 219 |
|
| 220 | +<div class="followupsection"> |
| 221 | + <form autocomplete="false" action="#" |
| 222 | + id="global_credentials" method="post" |
| 223 | + class="<?php if (isset($_['visibilityType']) && $_['visibilityType'] === BackendService::VISIBILITY_PERSONAL) { |
| 224 | + print_unescaped("global_credentials__personal"); |
| 225 | + } ?>"> |
| 226 | + <h2><?php p($l->t('Global credentials')); ?></h2> |
| 227 | + <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> |
| 228 | + <input type="text" name="username" |
| 229 | + autocomplete="false" |
| 230 | + value="<?php p($_['globalCredentials']['user']); ?>" |
| 231 | + placeholder="<?php p($l->t('Login')) ?>"/> |
| 232 | + <input type="password" name="password" |
| 233 | + autocomplete="false" |
| 234 | + value="<?php p($_['globalCredentials']['password']); ?>" |
| 235 | + placeholder="<?php p($l->t('Password')) ?>"/> |
| 236 | + <input type="hidden" name="uid" |
| 237 | + value="<?php p($_['globalCredentialsUid']); ?>"/> |
| 238 | + <input type="submit" value="<?php p($l->t('Save')) ?>"/> |
| 239 | + </form> |
| 240 | +</div> |
0 commit comments