@@ -28,55 +28,55 @@ |
||
28 | 28 | use OCP\Settings\IIconSection; |
29 | 29 | |
30 | 30 | class Section implements IIconSection { |
31 | - /** @var IL10N */ |
|
32 | - private $l; |
|
33 | - /** @var IURLGenerator */ |
|
34 | - private $url; |
|
31 | + /** @var IL10N */ |
|
32 | + private $l; |
|
33 | + /** @var IURLGenerator */ |
|
34 | + private $url; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param IURLGenerator $url |
|
38 | - * @param IL10N $l |
|
39 | - */ |
|
40 | - public function __construct(IURLGenerator $url, IL10N $l) { |
|
41 | - $this->url = $url; |
|
42 | - $this->l = $l; |
|
43 | - } |
|
36 | + /** |
|
37 | + * @param IURLGenerator $url |
|
38 | + * @param IL10N $l |
|
39 | + */ |
|
40 | + public function __construct(IURLGenerator $url, IL10N $l) { |
|
41 | + $this->url = $url; |
|
42 | + $this->l = $l; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
47 | - * e.g. 'ldap' |
|
48 | - * |
|
49 | - * @returns string |
|
50 | - */ |
|
51 | - public function getID() { |
|
52 | - return 'ldap'; |
|
53 | - } |
|
45 | + /** |
|
46 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
47 | + * e.g. 'ldap' |
|
48 | + * |
|
49 | + * @returns string |
|
50 | + */ |
|
51 | + public function getID() { |
|
52 | + return 'ldap'; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
57 | - * integration'. Use the L10N service to translate it. |
|
58 | - * |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getName() { |
|
62 | - return $this->l->t('LDAP / AD integration'); |
|
63 | - } |
|
55 | + /** |
|
56 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
57 | + * integration'. Use the L10N service to translate it. |
|
58 | + * |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getName() { |
|
62 | + return $this->l->t('LDAP / AD integration'); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return int whether the form should be rather on the top or bottom of |
|
67 | - * the settings navigation. The sections are arranged in ascending order of |
|
68 | - * the priority values. It is required to return a value between 0 and 99. |
|
69 | - * |
|
70 | - * E.g.: 70 |
|
71 | - */ |
|
72 | - public function getPriority() { |
|
73 | - return 25; |
|
74 | - } |
|
65 | + /** |
|
66 | + * @return int whether the form should be rather on the top or bottom of |
|
67 | + * the settings navigation. The sections are arranged in ascending order of |
|
68 | + * the priority values. It is required to return a value between 0 and 99. |
|
69 | + * |
|
70 | + * E.g.: 70 |
|
71 | + */ |
|
72 | + public function getPriority() { |
|
73 | + return 25; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * {@inheritdoc} |
|
78 | - */ |
|
79 | - public function getIcon() { |
|
80 | - return $this->url->imagePath('user_ldap', 'app-dark.svg'); |
|
81 | - } |
|
76 | + /** |
|
77 | + * {@inheritdoc} |
|
78 | + */ |
|
79 | + public function getIcon() { |
|
80 | + return $this->url->imagePath('user_ldap', 'app-dark.svg'); |
|
81 | + } |
|
82 | 82 | } |
@@ -28,32 +28,32 @@ |
||
28 | 28 | use OCA\User_LDAP\Mapping\UserMapping; |
29 | 29 | |
30 | 30 | class LDAPProviderFactory implements ILDAPProviderFactory { |
31 | - /** |
|
32 | - * Server container |
|
33 | - * |
|
34 | - * @var IServerContainer |
|
35 | - */ |
|
36 | - private $serverContainer; |
|
31 | + /** |
|
32 | + * Server container |
|
33 | + * |
|
34 | + * @var IServerContainer |
|
35 | + */ |
|
36 | + private $serverContainer; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor for the LDAP provider factory |
|
40 | - * |
|
41 | - * @param IServerContainer $serverContainer server container |
|
42 | - */ |
|
43 | - public function __construct(IServerContainer $serverContainer) { |
|
44 | - $this->serverContainer = $serverContainer; |
|
45 | - } |
|
38 | + /** |
|
39 | + * Constructor for the LDAP provider factory |
|
40 | + * |
|
41 | + * @param IServerContainer $serverContainer server container |
|
42 | + */ |
|
43 | + public function __construct(IServerContainer $serverContainer) { |
|
44 | + $this->serverContainer = $serverContainer; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * creates and returns an instance of the ILDAPProvider |
|
49 | - * |
|
50 | - * @return OCP\LDAP\ILDAPProvider |
|
51 | - */ |
|
52 | - public function getLDAPProvider() { |
|
53 | - $dbConnection = $this->serverContainer->getDatabaseConnection(); |
|
54 | - $userMapping = new UserMapping($dbConnection); |
|
55 | - return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()), |
|
56 | - new DeletedUsersIndex($this->serverContainer->getConfig(), |
|
57 | - $dbConnection, $userMapping)); |
|
58 | - } |
|
47 | + /** |
|
48 | + * creates and returns an instance of the ILDAPProvider |
|
49 | + * |
|
50 | + * @return OCP\LDAP\ILDAPProvider |
|
51 | + */ |
|
52 | + public function getLDAPProvider() { |
|
53 | + $dbConnection = $this->serverContainer->getDatabaseConnection(); |
|
54 | + $userMapping = new UserMapping($dbConnection); |
|
55 | + return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()), |
|
56 | + new DeletedUsersIndex($this->serverContainer->getConfig(), |
|
57 | + $dbConnection, $userMapping)); |
|
58 | + } |
|
59 | 59 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | $application->registerRoutes($this, [ |
42 | 42 | 'ocs' => [ |
43 | 43 | ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
44 | - ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
44 | + ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
45 | 45 | ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
46 | 46 | ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
47 | 47 | ] |
@@ -23,36 +23,36 @@ |
||
23 | 23 | |
24 | 24 | /** @var $this \OCP\Route\IRouter */ |
25 | 25 | $this->create('user_ldap_ajax_clearMappings', 'ajax/clearMappings.php') |
26 | - ->actionInclude('user_ldap/ajax/clearMappings.php'); |
|
26 | + ->actionInclude('user_ldap/ajax/clearMappings.php'); |
|
27 | 27 | $this->create('user_ldap_ajax_deleteConfiguration', 'ajax/deleteConfiguration.php') |
28 | - ->actionInclude('user_ldap/ajax/deleteConfiguration.php'); |
|
28 | + ->actionInclude('user_ldap/ajax/deleteConfiguration.php'); |
|
29 | 29 | $this->create('user_ldap_ajax_getConfiguration', 'ajax/getConfiguration.php') |
30 | - ->actionInclude('user_ldap/ajax/getConfiguration.php'); |
|
30 | + ->actionInclude('user_ldap/ajax/getConfiguration.php'); |
|
31 | 31 | $this->create('user_ldap_ajax_getNewServerConfigPrefix', 'ajax/getNewServerConfigPrefix.php') |
32 | - ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); |
|
32 | + ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); |
|
33 | 33 | $this->create('user_ldap_ajax_setConfiguration', 'ajax/setConfiguration.php') |
34 | - ->actionInclude('user_ldap/ajax/setConfiguration.php'); |
|
34 | + ->actionInclude('user_ldap/ajax/setConfiguration.php'); |
|
35 | 35 | $this->create('user_ldap_ajax_testConfiguration', 'ajax/testConfiguration.php') |
36 | - ->actionInclude('user_ldap/ajax/testConfiguration.php'); |
|
36 | + ->actionInclude('user_ldap/ajax/testConfiguration.php'); |
|
37 | 37 | $this->create('user_ldap_ajax_wizard', 'ajax/wizard.php') |
38 | - ->actionInclude('user_ldap/ajax/wizard.php'); |
|
38 | + ->actionInclude('user_ldap/ajax/wizard.php'); |
|
39 | 39 | |
40 | 40 | $application = new \OCP\AppFramework\App('user_ldap'); |
41 | 41 | $application->registerRoutes($this, [ |
42 | - 'ocs' => [ |
|
43 | - ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
|
44 | - ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
45 | - ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
|
46 | - ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
|
47 | - ] |
|
42 | + 'ocs' => [ |
|
43 | + ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
|
44 | + ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
45 | + ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
|
46 | + ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
|
47 | + ] |
|
48 | 48 | ]); |
49 | 49 | |
50 | 50 | $application = new OCA\User_LDAP\AppInfo\Application(); |
51 | 51 | $application->registerRoutes($this, [ |
52 | - 'routes' => [ |
|
53 | - ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'], |
|
54 | - ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'], |
|
55 | - ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'], |
|
56 | - ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'], |
|
57 | - ] |
|
52 | + 'routes' => [ |
|
53 | + ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'], |
|
54 | + ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'], |
|
55 | + ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'], |
|
56 | + ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'], |
|
57 | + ] |
|
58 | 58 | ]); |
@@ -41,44 +41,44 @@ |
||
41 | 41 | $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
42 | 42 | |
43 | 43 | switch ($parameter->getType()) { |
44 | - case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | - <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
46 | - <input type="password" |
|
44 | + case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | + <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
46 | + <input type="password" |
|
47 | 47 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
48 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
48 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
49 | 49 | value="<?php p($value); ?>" |
50 | 50 | placeholder="<?php p($placeholder); ?>" |
51 | 51 | /> |
52 | 52 | <?php |
53 | - break; |
|
54 | - case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
55 | - <?php $checkboxId = uniqid("checkbox_"); ?> |
|
53 | + break; |
|
54 | + case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
55 | + <?php $checkboxId = uniqid("checkbox_"); ?> |
|
56 | 56 | <div> |
57 | 57 | <label> |
58 | 58 | <input type="checkbox" |
59 | 59 | id="<?php p($checkboxId); ?>" |
60 | 60 | <?php if (!empty($classes)): ?> class="checkbox <?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
61 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
61 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
62 | 62 | <?php if ($value === true): ?> checked="checked"<?php endif; ?> |
63 | - /> |
|
63 | + /> |
|
64 | 64 | <?php p($placeholder); ?> |
65 | 65 | </label> |
66 | 66 | </div> |
67 | 67 | <?php |
68 | - break; |
|
69 | - case DefinitionParameter::VALUE_HIDDEN: ?> |
|
70 | - <input type="hidden" |
|
68 | + break; |
|
69 | + case DefinitionParameter::VALUE_HIDDEN: ?> |
|
70 | + <input type="hidden" |
|
71 | 71 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
72 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
72 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
73 | 73 | value="<?php p($value); ?>" |
74 | 74 | /> |
75 | 75 | <?php |
76 | - break; |
|
77 | - default: ?> |
|
78 | - <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
79 | - <input type="text" |
|
76 | + break; |
|
77 | + default: ?> |
|
78 | + <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
79 | + <input type="text" |
|
80 | 80 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
81 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
81 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
82 | 82 | value="<?php p($value); ?>" |
83 | 83 | placeholder="<?php p($placeholder); ?>" |
84 | 84 | /> |
@@ -89,7 +89,10 @@ discard block |
||
89 | 89 | |
90 | 90 | <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
91 | 91 | <h2 data-anchor-name="external-storage"><?php p($l->t('External storages')); ?></h2> |
92 | - <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> |
|
92 | + <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) { |
|
93 | + print_unescaped(''.$_['dependencies'].''); |
|
94 | +} |
|
95 | +?> |
|
93 | 96 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
94 | 97 | <thead> |
95 | 98 | <tr> |
@@ -98,7 +101,10 @@ discard block |
||
98 | 101 | <th><?php p($l->t('External storage')); ?></th> |
99 | 102 | <th><?php p($l->t('Authentication')); ?></th> |
100 | 103 | <th><?php p($l->t('Configuration')); ?></th> |
101 | - <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) print_unescaped('<th>'.$l->t('Available for').'</th>'); ?> |
|
104 | + <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) { |
|
105 | + print_unescaped('<th>'.$l->t('Available for').'</th>'); |
|
106 | +} |
|
107 | +?> |
|
102 | 108 | <th> </th> |
103 | 109 | <th> </th> |
104 | 110 | </tr> |
@@ -130,7 +136,10 @@ discard block |
||
130 | 136 | }); |
131 | 137 | ?> |
132 | 138 | <?php foreach ($sortedBackends as $backend): ?> |
133 | - <?php if ($backend->getDeprecateTo()) continue; // ignore deprecated backends ?> |
|
139 | + <?php if ($backend->getDeprecateTo()) { |
|
140 | + continue; |
|
141 | +} |
|
142 | +// ignore deprecated backends ?> |
|
134 | 143 | <option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option> |
135 | 144 | <?php endforeach; ?> |
136 | 145 | </select> |
@@ -169,7 +178,10 @@ discard block |
||
169 | 178 | |
170 | 179 | <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?> |
171 | 180 | <input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox" |
172 | - value="1" <?php if ($_['allowUserMounting']) print_unescaped(' checked="checked"'); ?> /> |
|
181 | + value="1" <?php if ($_['allowUserMounting']) { |
|
182 | + print_unescaped(' checked="checked"'); |
|
183 | +} |
|
184 | +?> /> |
|
173 | 185 | <label for="allowUserMounting"><?php p($l->t('Allow users to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span> |
174 | 186 | |
175 | 187 | <p id="userMountingBackends"<?php if (!$_['allowUserMounting']): ?> class="hidden"<?php endif; ?>> |
@@ -182,8 +194,14 @@ discard block |
||
182 | 194 | <?php $i = 0; foreach ($userBackends as $backend): ?> |
183 | 195 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
184 | 196 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
185 | - <?php else: ?> |
|
186 | - <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) print_unescaped(' checked="checked"'); ?> /> |
|
197 | + <?php else { |
|
198 | + : ?> |
|
199 | + <input type="checkbox" id="allowUserMountingBackends<?php p($i); |
|
200 | +} |
|
201 | +?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
|
202 | + print_unescaped(' checked="checked"'); |
|
203 | +} |
|
204 | +?> /> |
|
187 | 205 | <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br /> |
188 | 206 | <?php endif; ?> |
189 | 207 | <?php $i++; ?> |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | - use \OCA\Files_External\Lib\Backend\Backend; |
|
3 | - use \OCA\Files_External\Lib\Auth\AuthMechanism; |
|
4 | - use \OCA\Files_External\Lib\DefinitionParameter; |
|
5 | - use \OCA\Files_External\Service\BackendService; |
|
2 | + use \OCA\Files_External\Lib\Backend\Backend; |
|
3 | + use \OCA\Files_External\Lib\Auth\AuthMechanism; |
|
4 | + use \OCA\Files_External\Lib\DefinitionParameter; |
|
5 | + use \OCA\Files_External\Service\BackendService; |
|
6 | 6 | |
7 | - $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; |
|
7 | + $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; |
|
8 | 8 | |
9 | - $l->t("Enable encryption"); |
|
10 | - $l->t("Enable previews"); |
|
11 | - $l->t("Enable sharing"); |
|
12 | - $l->t("Check for changes"); |
|
13 | - $l->t("Never"); |
|
14 | - $l->t("Once every direct access"); |
|
9 | + $l->t("Enable encryption"); |
|
10 | + $l->t("Enable previews"); |
|
11 | + $l->t("Enable sharing"); |
|
12 | + $l->t("Check for changes"); |
|
13 | + $l->t("Never"); |
|
14 | + $l->t("Once every direct access"); |
|
15 | 15 | |
16 | - script('files_external', 'settings'); |
|
17 | - style('files_external', 'settings'); |
|
16 | + script('files_external', 'settings'); |
|
17 | + style('files_external', 'settings'); |
|
18 | 18 | |
19 | - // load custom JS |
|
20 | - foreach ($_['backends'] as $backend) { |
|
21 | - /** @var Backend $backend */ |
|
22 | - $scripts = $backend->getCustomJs(); |
|
23 | - foreach ($scripts as $script) { |
|
24 | - script('files_external', $script); |
|
25 | - } |
|
26 | - } |
|
27 | - foreach ($_['authMechanisms'] as $authMechanism) { |
|
28 | - /** @var AuthMechanism $authMechanism */ |
|
29 | - $scripts = $authMechanism->getCustomJs(); |
|
30 | - foreach ($scripts as $script) { |
|
31 | - script('files_external', $script); |
|
32 | - } |
|
33 | - } |
|
19 | + // load custom JS |
|
20 | + foreach ($_['backends'] as $backend) { |
|
21 | + /** @var Backend $backend */ |
|
22 | + $scripts = $backend->getCustomJs(); |
|
23 | + foreach ($scripts as $script) { |
|
24 | + script('files_external', $script); |
|
25 | + } |
|
26 | + } |
|
27 | + foreach ($_['authMechanisms'] as $authMechanism) { |
|
28 | + /** @var AuthMechanism $authMechanism */ |
|
29 | + $scripts = $authMechanism->getCustomJs(); |
|
30 | + foreach ($scripts as $script) { |
|
31 | + script('files_external', $script); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - function writeParameterInput($parameter, $options, $classes = []) { |
|
36 | - $value = ''; |
|
37 | - if (isset($options[$parameter->getName()])) { |
|
38 | - $value = $options[$parameter->getName()]; |
|
39 | - } |
|
40 | - $placeholder = $parameter->getText(); |
|
41 | - $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
|
35 | + function writeParameterInput($parameter, $options, $classes = []) { |
|
36 | + $value = ''; |
|
37 | + if (isset($options[$parameter->getName()])) { |
|
38 | + $value = $options[$parameter->getName()]; |
|
39 | + } |
|
40 | + $placeholder = $parameter->getText(); |
|
41 | + $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
|
42 | 42 | |
43 | - switch ($parameter->getType()) { |
|
44 | - case DefinitionParameter::VALUE_PASSWORD: ?> |
|
43 | + switch ($parameter->getType()) { |
|
44 | + case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | 45 | <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
46 | 46 | <input type="password" |
47 | 47 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | placeholder="<?php p($placeholder); ?>" |
51 | 51 | /> |
52 | 52 | <?php |
53 | - break; |
|
54 | - case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
53 | + break; |
|
54 | + case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
55 | 55 | <?php $checkboxId = uniqid("checkbox_"); ?> |
56 | 56 | <div> |
57 | 57 | <label> |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | </label> |
66 | 66 | </div> |
67 | 67 | <?php |
68 | - break; |
|
69 | - case DefinitionParameter::VALUE_HIDDEN: ?> |
|
68 | + break; |
|
69 | + case DefinitionParameter::VALUE_HIDDEN: ?> |
|
70 | 70 | <input type="hidden" |
71 | 71 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
72 | 72 | data-parameter="<?php p($parameter->getName()); ?>" |
73 | 73 | value="<?php p($value); ?>" |
74 | 74 | /> |
75 | 75 | <?php |
76 | - break; |
|
77 | - default: ?> |
|
76 | + break; |
|
77 | + default: ?> |
|
78 | 78 | <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
79 | 79 | <input type="text" |
80 | 80 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | placeholder="<?php p($placeholder); ?>" |
84 | 84 | /> |
85 | 85 | <?php |
86 | - } |
|
87 | - } |
|
86 | + } |
|
87 | + } |
|
88 | 88 | ?> |
89 | 89 | |
90 | 90 | <div id="emptycontent" class="hidden"> |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | <?php p($l->t('Add storage')); ?> |
129 | 129 | </option> |
130 | 130 | <?php |
131 | - $sortedBackends = array_filter($_['backends'], function($backend) use ($_) { |
|
132 | - return $backend->isVisibleFor($_['visibilityType']); |
|
133 | - }); |
|
134 | - uasort($sortedBackends, function($a, $b) { |
|
135 | - return strcasecmp($a->getText(), $b->getText()); |
|
136 | - }); |
|
137 | - ?> |
|
131 | + $sortedBackends = array_filter($_['backends'], function($backend) use ($_) { |
|
132 | + return $backend->isVisibleFor($_['visibilityType']); |
|
133 | + }); |
|
134 | + uasort($sortedBackends, function($a, $b) { |
|
135 | + return strcasecmp($a->getText(), $b->getText()); |
|
136 | + }); |
|
137 | + ?> |
|
138 | 138 | <?php foreach ($sortedBackends as $backend): ?> |
139 | 139 | <?php if ($backend->getDeprecateTo()) continue; // ignore deprecated backends ?> |
140 | 140 | <option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option> |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | <p id="userMountingBackends"<?php if (!$_['allowUserMounting']): ?> class="hidden"<?php endif; ?>> |
182 | 182 | <?php p($l->t('Allow users to mount the following external storage')); ?><br /> |
183 | 183 | <?php |
184 | - $userBackends = array_filter($_['backends'], function($backend) { |
|
185 | - return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
186 | - }); |
|
187 | - ?> |
|
184 | + $userBackends = array_filter($_['backends'], function($backend) { |
|
185 | + return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
186 | + }); |
|
187 | + ?> |
|
188 | 188 | <?php $i = 0; foreach ($userBackends as $backend): ?> |
189 | 189 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
190 | 190 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
@@ -92,7 +92,7 @@ |
||
92 | 92 | <h2><?php p($l->t('No external storage configured or you don\'t have the permission to configure them')); ?></h2> |
93 | 93 | </div> |
94 | 94 | |
95 | -<form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
|
95 | +<form data-can-create="<?php echo $canCreateMounts ? 'true' : 'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled'] ? 'true' : 'false'; ?>"> |
|
96 | 96 | <h2 data-anchor-name="external-storage"><?php p($l->t('External storages')); ?></h2> |
97 | 97 | <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> |
98 | 98 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
@@ -30,23 +30,23 @@ |
||
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 = []; |
43 | 43 | foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) { |
44 | - $groups[$group->getGID()] = $group->getGID(); |
|
44 | + $groups[$group->getGID()] = $group->getGID(); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $users = []; |
48 | 48 | foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) { |
49 | - $users[$user->getUID()] = $user->getDisplayName(); |
|
49 | + $users[$user->getUID()] = $user->getDisplayName(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $results = array('groups' => $groups, 'users' => $users); |
@@ -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 = []; |
@@ -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 | } |
@@ -34,167 +34,167 @@ |
||
34 | 34 | */ |
35 | 35 | class UserGlobalStoragesService extends GlobalStoragesService { |
36 | 36 | |
37 | - use UserTrait; |
|
38 | - |
|
39 | - /** @var IGroupManager */ |
|
40 | - protected $groupManager; |
|
41 | - |
|
42 | - /** |
|
43 | - * @param BackendService $backendService |
|
44 | - * @param DBConfigService $dbConfig |
|
45 | - * @param IUserSession $userSession |
|
46 | - * @param IGroupManager $groupManager |
|
47 | - * @param IUserMountCache $userMountCache |
|
48 | - */ |
|
49 | - public function __construct( |
|
50 | - BackendService $backendService, |
|
51 | - DBConfigService $dbConfig, |
|
52 | - IUserSession $userSession, |
|
53 | - IGroupManager $groupManager, |
|
54 | - IUserMountCache $userMountCache |
|
55 | - ) { |
|
56 | - parent::__construct($backendService, $dbConfig, $userMountCache); |
|
57 | - $this->userSession = $userSession; |
|
58 | - $this->groupManager = $groupManager; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Replace config hash ID with real IDs, for migrating legacy storages |
|
63 | - * |
|
64 | - * @param StorageConfig[] $storages Storages with real IDs |
|
65 | - * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs |
|
66 | - */ |
|
67 | - protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) { |
|
68 | - // as a read-only view, storage IDs don't need to be real |
|
69 | - foreach ($storagesWithConfigHash as $storage) { |
|
70 | - $storages[$storage->getId()] = $storage; |
|
71 | - } |
|
72 | - } |
|
73 | - |
|
74 | - protected function readDBConfig() { |
|
75 | - $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID()); |
|
76 | - $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null); |
|
77 | - $groups = $this->groupManager->getUserGroupIds($this->getUser()); |
|
78 | - if (is_array($groups) && count($groups) !== 0) { |
|
79 | - $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups); |
|
80 | - } else { |
|
81 | - $groupMounts = []; |
|
82 | - } |
|
83 | - return array_merge($userMounts, $groupMounts, $globalMounts); |
|
84 | - } |
|
85 | - |
|
86 | - public function addStorage(StorageConfig $newStorage) { |
|
87 | - throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
88 | - } |
|
89 | - |
|
90 | - public function updateStorage(StorageConfig $updatedStorage) { |
|
91 | - throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param integer $id |
|
96 | - */ |
|
97 | - public function removeStorage($id) { |
|
98 | - throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Get unique storages, in case two are defined with the same mountpoint |
|
103 | - * Higher priority storages take precedence |
|
104 | - * |
|
105 | - * @return StorageConfig[] |
|
106 | - */ |
|
107 | - public function getUniqueStorages() { |
|
108 | - $storages = $this->getStorages(); |
|
109 | - |
|
110 | - $storagesByMountpoint = []; |
|
111 | - foreach ($storages as $storage) { |
|
112 | - $storagesByMountpoint[$storage->getMountPoint()][] = $storage; |
|
113 | - } |
|
114 | - |
|
115 | - $result = []; |
|
116 | - foreach ($storagesByMountpoint as $storageList) { |
|
117 | - $storage = array_reduce($storageList, function ($carry, $item) { |
|
118 | - if (isset($carry)) { |
|
119 | - $carryPriorityType = $this->getPriorityType($carry); |
|
120 | - $itemPriorityType = $this->getPriorityType($item); |
|
121 | - if ($carryPriorityType > $itemPriorityType) { |
|
122 | - return $carry; |
|
123 | - } elseif ($carryPriorityType === $itemPriorityType) { |
|
124 | - if ($carry->getPriority() > $item->getPriority()) { |
|
125 | - return $carry; |
|
126 | - } |
|
127 | - } |
|
128 | - } |
|
129 | - return $item; |
|
130 | - }); |
|
131 | - $result[$storage->getID()] = $storage; |
|
132 | - } |
|
133 | - |
|
134 | - return $result; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Get a priority 'type', where a bigger number means higher priority |
|
139 | - * user applicable > group applicable > 'all' |
|
140 | - * |
|
141 | - * @param StorageConfig $storage |
|
142 | - * @return int |
|
143 | - */ |
|
144 | - protected function getPriorityType(StorageConfig $storage) { |
|
145 | - $applicableUsers = $storage->getApplicableUsers(); |
|
146 | - $applicableGroups = $storage->getApplicableGroups(); |
|
147 | - |
|
148 | - if ($applicableUsers && $applicableUsers[0] !== 'all') { |
|
149 | - return 2; |
|
150 | - } |
|
151 | - if ($applicableGroups) { |
|
152 | - return 1; |
|
153 | - } |
|
154 | - return 0; |
|
155 | - } |
|
156 | - |
|
157 | - protected function isApplicable(StorageConfig $config) { |
|
158 | - $applicableUsers = $config->getApplicableUsers(); |
|
159 | - $applicableGroups = $config->getApplicableGroups(); |
|
160 | - |
|
161 | - if (count($applicableUsers) === 0 && count($applicableGroups) === 0) { |
|
162 | - return true; |
|
163 | - } |
|
164 | - if (in_array($this->getUser()->getUID(), $applicableUsers, true)) { |
|
165 | - return true; |
|
166 | - } |
|
167 | - $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
168 | - foreach ($groupIds as $groupId) { |
|
169 | - if (in_array($groupId, $applicableGroups, true)) { |
|
170 | - return true; |
|
171 | - } |
|
172 | - } |
|
173 | - return false; |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * Gets all storages for the user, admin, personal, global, etc |
|
179 | - * |
|
180 | - * @return StorageConfig[] array of storage configs |
|
181 | - */ |
|
182 | - public function getAllStoragesForUser() { |
|
183 | - if (is_null($this->getUser())) { |
|
184 | - return []; |
|
185 | - } |
|
186 | - $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
187 | - $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds); |
|
188 | - $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
189 | - $configs = array_filter($configs, function ($config) { |
|
190 | - return $config instanceof StorageConfig; |
|
191 | - }); |
|
192 | - |
|
193 | - $keys = array_map(function (StorageConfig $config) { |
|
194 | - return $config->getId(); |
|
195 | - }, $configs); |
|
196 | - |
|
197 | - $storages = array_combine($keys, $configs); |
|
198 | - return array_filter($storages, [$this, 'validateStorage']); |
|
199 | - } |
|
37 | + use UserTrait; |
|
38 | + |
|
39 | + /** @var IGroupManager */ |
|
40 | + protected $groupManager; |
|
41 | + |
|
42 | + /** |
|
43 | + * @param BackendService $backendService |
|
44 | + * @param DBConfigService $dbConfig |
|
45 | + * @param IUserSession $userSession |
|
46 | + * @param IGroupManager $groupManager |
|
47 | + * @param IUserMountCache $userMountCache |
|
48 | + */ |
|
49 | + public function __construct( |
|
50 | + BackendService $backendService, |
|
51 | + DBConfigService $dbConfig, |
|
52 | + IUserSession $userSession, |
|
53 | + IGroupManager $groupManager, |
|
54 | + IUserMountCache $userMountCache |
|
55 | + ) { |
|
56 | + parent::__construct($backendService, $dbConfig, $userMountCache); |
|
57 | + $this->userSession = $userSession; |
|
58 | + $this->groupManager = $groupManager; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Replace config hash ID with real IDs, for migrating legacy storages |
|
63 | + * |
|
64 | + * @param StorageConfig[] $storages Storages with real IDs |
|
65 | + * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs |
|
66 | + */ |
|
67 | + protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) { |
|
68 | + // as a read-only view, storage IDs don't need to be real |
|
69 | + foreach ($storagesWithConfigHash as $storage) { |
|
70 | + $storages[$storage->getId()] = $storage; |
|
71 | + } |
|
72 | + } |
|
73 | + |
|
74 | + protected function readDBConfig() { |
|
75 | + $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID()); |
|
76 | + $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null); |
|
77 | + $groups = $this->groupManager->getUserGroupIds($this->getUser()); |
|
78 | + if (is_array($groups) && count($groups) !== 0) { |
|
79 | + $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups); |
|
80 | + } else { |
|
81 | + $groupMounts = []; |
|
82 | + } |
|
83 | + return array_merge($userMounts, $groupMounts, $globalMounts); |
|
84 | + } |
|
85 | + |
|
86 | + public function addStorage(StorageConfig $newStorage) { |
|
87 | + throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
88 | + } |
|
89 | + |
|
90 | + public function updateStorage(StorageConfig $updatedStorage) { |
|
91 | + throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param integer $id |
|
96 | + */ |
|
97 | + public function removeStorage($id) { |
|
98 | + throw new \DomainException('UserGlobalStoragesService writing disallowed'); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Get unique storages, in case two are defined with the same mountpoint |
|
103 | + * Higher priority storages take precedence |
|
104 | + * |
|
105 | + * @return StorageConfig[] |
|
106 | + */ |
|
107 | + public function getUniqueStorages() { |
|
108 | + $storages = $this->getStorages(); |
|
109 | + |
|
110 | + $storagesByMountpoint = []; |
|
111 | + foreach ($storages as $storage) { |
|
112 | + $storagesByMountpoint[$storage->getMountPoint()][] = $storage; |
|
113 | + } |
|
114 | + |
|
115 | + $result = []; |
|
116 | + foreach ($storagesByMountpoint as $storageList) { |
|
117 | + $storage = array_reduce($storageList, function ($carry, $item) { |
|
118 | + if (isset($carry)) { |
|
119 | + $carryPriorityType = $this->getPriorityType($carry); |
|
120 | + $itemPriorityType = $this->getPriorityType($item); |
|
121 | + if ($carryPriorityType > $itemPriorityType) { |
|
122 | + return $carry; |
|
123 | + } elseif ($carryPriorityType === $itemPriorityType) { |
|
124 | + if ($carry->getPriority() > $item->getPriority()) { |
|
125 | + return $carry; |
|
126 | + } |
|
127 | + } |
|
128 | + } |
|
129 | + return $item; |
|
130 | + }); |
|
131 | + $result[$storage->getID()] = $storage; |
|
132 | + } |
|
133 | + |
|
134 | + return $result; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Get a priority 'type', where a bigger number means higher priority |
|
139 | + * user applicable > group applicable > 'all' |
|
140 | + * |
|
141 | + * @param StorageConfig $storage |
|
142 | + * @return int |
|
143 | + */ |
|
144 | + protected function getPriorityType(StorageConfig $storage) { |
|
145 | + $applicableUsers = $storage->getApplicableUsers(); |
|
146 | + $applicableGroups = $storage->getApplicableGroups(); |
|
147 | + |
|
148 | + if ($applicableUsers && $applicableUsers[0] !== 'all') { |
|
149 | + return 2; |
|
150 | + } |
|
151 | + if ($applicableGroups) { |
|
152 | + return 1; |
|
153 | + } |
|
154 | + return 0; |
|
155 | + } |
|
156 | + |
|
157 | + protected function isApplicable(StorageConfig $config) { |
|
158 | + $applicableUsers = $config->getApplicableUsers(); |
|
159 | + $applicableGroups = $config->getApplicableGroups(); |
|
160 | + |
|
161 | + if (count($applicableUsers) === 0 && count($applicableGroups) === 0) { |
|
162 | + return true; |
|
163 | + } |
|
164 | + if (in_array($this->getUser()->getUID(), $applicableUsers, true)) { |
|
165 | + return true; |
|
166 | + } |
|
167 | + $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
168 | + foreach ($groupIds as $groupId) { |
|
169 | + if (in_array($groupId, $applicableGroups, true)) { |
|
170 | + return true; |
|
171 | + } |
|
172 | + } |
|
173 | + return false; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * Gets all storages for the user, admin, personal, global, etc |
|
179 | + * |
|
180 | + * @return StorageConfig[] array of storage configs |
|
181 | + */ |
|
182 | + public function getAllStoragesForUser() { |
|
183 | + if (is_null($this->getUser())) { |
|
184 | + return []; |
|
185 | + } |
|
186 | + $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
|
187 | + $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds); |
|
188 | + $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
189 | + $configs = array_filter($configs, function ($config) { |
|
190 | + return $config instanceof StorageConfig; |
|
191 | + }); |
|
192 | + |
|
193 | + $keys = array_map(function (StorageConfig $config) { |
|
194 | + return $config->getId(); |
|
195 | + }, $configs); |
|
196 | + |
|
197 | + $storages = array_combine($keys, $configs); |
|
198 | + return array_filter($storages, [$this, 'validateStorage']); |
|
199 | + } |
|
200 | 200 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | $result = []; |
116 | 116 | foreach ($storagesByMountpoint as $storageList) { |
117 | - $storage = array_reduce($storageList, function ($carry, $item) { |
|
117 | + $storage = array_reduce($storageList, function($carry, $item) { |
|
118 | 118 | if (isset($carry)) { |
119 | 119 | $carryPriorityType = $this->getPriorityType($carry); |
120 | 120 | $itemPriorityType = $this->getPriorityType($item); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | $groupIds = $this->groupManager->getUserGroupIds($this->getUser()); |
187 | 187 | $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds); |
188 | 188 | $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
189 | - $configs = array_filter($configs, function ($config) { |
|
189 | + $configs = array_filter($configs, function($config) { |
|
190 | 190 | return $config instanceof StorageConfig; |
191 | 191 | }); |
192 | 192 | |
193 | - $keys = array_map(function (StorageConfig $config) { |
|
193 | + $keys = array_map(function(StorageConfig $config) { |
|
194 | 194 | return $config->getId(); |
195 | 195 | }, $configs); |
196 | 196 |
@@ -35,249 +35,249 @@ |
||
35 | 35 | */ |
36 | 36 | class BackendService { |
37 | 37 | |
38 | - /** Visibility constants for VisibilityTrait */ |
|
39 | - const VISIBILITY_NONE = 0; |
|
40 | - const VISIBILITY_PERSONAL = 1; |
|
41 | - const VISIBILITY_ADMIN = 2; |
|
42 | - //const VISIBILITY_ALIENS = 4; |
|
43 | - |
|
44 | - const VISIBILITY_DEFAULT = 3; // PERSONAL | ADMIN |
|
45 | - |
|
46 | - /** Priority constants for PriorityTrait */ |
|
47 | - const PRIORITY_DEFAULT = 100; |
|
48 | - |
|
49 | - /** @var IConfig */ |
|
50 | - protected $config; |
|
51 | - |
|
52 | - /** @var bool */ |
|
53 | - private $userMountingAllowed = true; |
|
54 | - |
|
55 | - /** @var string[] */ |
|
56 | - private $userMountingBackends = []; |
|
57 | - |
|
58 | - /** @var Backend[] */ |
|
59 | - private $backends = []; |
|
60 | - |
|
61 | - /** @var IBackendProvider[] */ |
|
62 | - private $backendProviders = []; |
|
63 | - |
|
64 | - /** @var AuthMechanism[] */ |
|
65 | - private $authMechanisms = []; |
|
66 | - |
|
67 | - /** @var IAuthMechanismProvider[] */ |
|
68 | - private $authMechanismProviders = []; |
|
69 | - |
|
70 | - /** |
|
71 | - * @param IConfig $config |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - IConfig $config |
|
75 | - ) { |
|
76 | - $this->config = $config; |
|
77 | - |
|
78 | - // Load config values |
|
79 | - if ($this->config->getAppValue('files_external', 'allow_user_mounting', 'yes') !== 'yes') { |
|
80 | - $this->userMountingAllowed = false; |
|
81 | - } |
|
82 | - $this->userMountingBackends = explode(',', |
|
83 | - $this->config->getAppValue('files_external', 'user_mounting_backends', '') |
|
84 | - ); |
|
85 | - |
|
86 | - // if no backend is in the list an empty string is in the array and user mounting is disabled |
|
87 | - if ($this->userMountingBackends === ['']) { |
|
88 | - $this->userMountingAllowed = false; |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Register a backend provider |
|
94 | - * |
|
95 | - * @since 9.1.0 |
|
96 | - * @param IBackendProvider $provider |
|
97 | - */ |
|
98 | - public function registerBackendProvider(IBackendProvider $provider) { |
|
99 | - $this->backendProviders[] = $provider; |
|
100 | - } |
|
101 | - |
|
102 | - private function loadBackendProviders() { |
|
103 | - foreach ($this->backendProviders as $provider) { |
|
104 | - $this->registerBackends($provider->getBackends()); |
|
105 | - } |
|
106 | - $this->backendProviders = []; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Register an auth mechanism provider |
|
111 | - * |
|
112 | - * @since 9.1.0 |
|
113 | - * @param IAuthMechanismProvider $provider |
|
114 | - */ |
|
115 | - public function registerAuthMechanismProvider(IAuthMechanismProvider $provider) { |
|
116 | - $this->authMechanismProviders[] = $provider; |
|
117 | - } |
|
118 | - |
|
119 | - private function loadAuthMechanismProviders() { |
|
120 | - foreach ($this->authMechanismProviders as $provider) { |
|
121 | - $this->registerAuthMechanisms($provider->getAuthMechanisms()); |
|
122 | - } |
|
123 | - $this->authMechanismProviders = []; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Register a backend |
|
128 | - * |
|
129 | - * @deprecated 9.1.0 use registerBackendProvider() |
|
130 | - * @param Backend $backend |
|
131 | - */ |
|
132 | - public function registerBackend(Backend $backend) { |
|
133 | - if (!$this->isAllowedUserBackend($backend)) { |
|
134 | - $backend->removeVisibility(BackendService::VISIBILITY_PERSONAL); |
|
135 | - } |
|
136 | - foreach ($backend->getIdentifierAliases() as $alias) { |
|
137 | - $this->backends[$alias] = $backend; |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @deprecated 9.1.0 use registerBackendProvider() |
|
143 | - * @param Backend[] $backends |
|
144 | - */ |
|
145 | - public function registerBackends(array $backends) { |
|
146 | - foreach ($backends as $backend) { |
|
147 | - $this->registerBackend($backend); |
|
148 | - } |
|
149 | - } |
|
150 | - /** |
|
151 | - * Register an authentication mechanism |
|
152 | - * |
|
153 | - * @deprecated 9.1.0 use registerAuthMechanismProvider() |
|
154 | - * @param AuthMechanism $authMech |
|
155 | - */ |
|
156 | - public function registerAuthMechanism(AuthMechanism $authMech) { |
|
157 | - if (!$this->isAllowedAuthMechanism($authMech)) { |
|
158 | - $authMech->removeVisibility(BackendService::VISIBILITY_PERSONAL); |
|
159 | - } |
|
160 | - foreach ($authMech->getIdentifierAliases() as $alias) { |
|
161 | - $this->authMechanisms[$alias] = $authMech; |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @deprecated 9.1.0 use registerAuthMechanismProvider() |
|
167 | - * @param AuthMechanism[] $mechanisms |
|
168 | - */ |
|
169 | - public function registerAuthMechanisms(array $mechanisms) { |
|
170 | - foreach ($mechanisms as $mechanism) { |
|
171 | - $this->registerAuthMechanism($mechanism); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Get all backends |
|
177 | - * |
|
178 | - * @return Backend[] |
|
179 | - */ |
|
180 | - public function getBackends() { |
|
181 | - $this->loadBackendProviders(); |
|
182 | - // only return real identifiers, no aliases |
|
183 | - $backends = []; |
|
184 | - foreach ($this->backends as $backend) { |
|
185 | - $backends[$backend->getIdentifier()] = $backend; |
|
186 | - } |
|
187 | - return $backends; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Get all available backends |
|
192 | - * |
|
193 | - * @return Backend[] |
|
194 | - */ |
|
195 | - public function getAvailableBackends() { |
|
196 | - return array_filter($this->getBackends(), function($backend) { |
|
197 | - return !($backend->checkDependencies()); |
|
198 | - }); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * @param string $identifier |
|
203 | - * @return Backend|null |
|
204 | - */ |
|
205 | - public function getBackend($identifier) { |
|
206 | - $this->loadBackendProviders(); |
|
207 | - if (isset($this->backends[$identifier])) { |
|
208 | - return $this->backends[$identifier]; |
|
209 | - } |
|
210 | - return null; |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Get all authentication mechanisms |
|
215 | - * |
|
216 | - * @return AuthMechanism[] |
|
217 | - */ |
|
218 | - public function getAuthMechanisms() { |
|
219 | - $this->loadAuthMechanismProviders(); |
|
220 | - // only return real identifiers, no aliases |
|
221 | - $mechanisms = []; |
|
222 | - foreach ($this->authMechanisms as $mechanism) { |
|
223 | - $mechanisms[$mechanism->getIdentifier()] = $mechanism; |
|
224 | - } |
|
225 | - return $mechanisms; |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Get all authentication mechanisms for schemes |
|
230 | - * |
|
231 | - * @param string[] $schemes |
|
232 | - * @return AuthMechanism[] |
|
233 | - */ |
|
234 | - public function getAuthMechanismsByScheme(array $schemes) { |
|
235 | - return array_filter($this->getAuthMechanisms(), function($authMech) use ($schemes) { |
|
236 | - return in_array($authMech->getScheme(), $schemes, true); |
|
237 | - }); |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * @param string $identifier |
|
242 | - * @return AuthMechanism|null |
|
243 | - */ |
|
244 | - public function getAuthMechanism($identifier) { |
|
245 | - $this->loadAuthMechanismProviders(); |
|
246 | - if (isset($this->authMechanisms[$identifier])) { |
|
247 | - return $this->authMechanisms[$identifier]; |
|
248 | - } |
|
249 | - return null; |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * @return bool |
|
254 | - */ |
|
255 | - public function isUserMountingAllowed() { |
|
256 | - return $this->userMountingAllowed; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Check a backend if a user is allowed to mount it |
|
261 | - * |
|
262 | - * @param Backend $backend |
|
263 | - * @return bool |
|
264 | - */ |
|
265 | - protected function isAllowedUserBackend(Backend $backend) { |
|
266 | - if ($this->userMountingAllowed && |
|
267 | - array_intersect($backend->getIdentifierAliases(), $this->userMountingBackends) |
|
268 | - ) { |
|
269 | - return true; |
|
270 | - } |
|
271 | - return false; |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Check an authentication mechanism if a user is allowed to use it |
|
276 | - * |
|
277 | - * @param AuthMechanism $authMechanism |
|
278 | - * @return bool |
|
279 | - */ |
|
280 | - protected function isAllowedAuthMechanism(AuthMechanism $authMechanism) { |
|
281 | - return true; // not implemented |
|
282 | - } |
|
38 | + /** Visibility constants for VisibilityTrait */ |
|
39 | + const VISIBILITY_NONE = 0; |
|
40 | + const VISIBILITY_PERSONAL = 1; |
|
41 | + const VISIBILITY_ADMIN = 2; |
|
42 | + //const VISIBILITY_ALIENS = 4; |
|
43 | + |
|
44 | + const VISIBILITY_DEFAULT = 3; // PERSONAL | ADMIN |
|
45 | + |
|
46 | + /** Priority constants for PriorityTrait */ |
|
47 | + const PRIORITY_DEFAULT = 100; |
|
48 | + |
|
49 | + /** @var IConfig */ |
|
50 | + protected $config; |
|
51 | + |
|
52 | + /** @var bool */ |
|
53 | + private $userMountingAllowed = true; |
|
54 | + |
|
55 | + /** @var string[] */ |
|
56 | + private $userMountingBackends = []; |
|
57 | + |
|
58 | + /** @var Backend[] */ |
|
59 | + private $backends = []; |
|
60 | + |
|
61 | + /** @var IBackendProvider[] */ |
|
62 | + private $backendProviders = []; |
|
63 | + |
|
64 | + /** @var AuthMechanism[] */ |
|
65 | + private $authMechanisms = []; |
|
66 | + |
|
67 | + /** @var IAuthMechanismProvider[] */ |
|
68 | + private $authMechanismProviders = []; |
|
69 | + |
|
70 | + /** |
|
71 | + * @param IConfig $config |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + IConfig $config |
|
75 | + ) { |
|
76 | + $this->config = $config; |
|
77 | + |
|
78 | + // Load config values |
|
79 | + if ($this->config->getAppValue('files_external', 'allow_user_mounting', 'yes') !== 'yes') { |
|
80 | + $this->userMountingAllowed = false; |
|
81 | + } |
|
82 | + $this->userMountingBackends = explode(',', |
|
83 | + $this->config->getAppValue('files_external', 'user_mounting_backends', '') |
|
84 | + ); |
|
85 | + |
|
86 | + // if no backend is in the list an empty string is in the array and user mounting is disabled |
|
87 | + if ($this->userMountingBackends === ['']) { |
|
88 | + $this->userMountingAllowed = false; |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Register a backend provider |
|
94 | + * |
|
95 | + * @since 9.1.0 |
|
96 | + * @param IBackendProvider $provider |
|
97 | + */ |
|
98 | + public function registerBackendProvider(IBackendProvider $provider) { |
|
99 | + $this->backendProviders[] = $provider; |
|
100 | + } |
|
101 | + |
|
102 | + private function loadBackendProviders() { |
|
103 | + foreach ($this->backendProviders as $provider) { |
|
104 | + $this->registerBackends($provider->getBackends()); |
|
105 | + } |
|
106 | + $this->backendProviders = []; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Register an auth mechanism provider |
|
111 | + * |
|
112 | + * @since 9.1.0 |
|
113 | + * @param IAuthMechanismProvider $provider |
|
114 | + */ |
|
115 | + public function registerAuthMechanismProvider(IAuthMechanismProvider $provider) { |
|
116 | + $this->authMechanismProviders[] = $provider; |
|
117 | + } |
|
118 | + |
|
119 | + private function loadAuthMechanismProviders() { |
|
120 | + foreach ($this->authMechanismProviders as $provider) { |
|
121 | + $this->registerAuthMechanisms($provider->getAuthMechanisms()); |
|
122 | + } |
|
123 | + $this->authMechanismProviders = []; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Register a backend |
|
128 | + * |
|
129 | + * @deprecated 9.1.0 use registerBackendProvider() |
|
130 | + * @param Backend $backend |
|
131 | + */ |
|
132 | + public function registerBackend(Backend $backend) { |
|
133 | + if (!$this->isAllowedUserBackend($backend)) { |
|
134 | + $backend->removeVisibility(BackendService::VISIBILITY_PERSONAL); |
|
135 | + } |
|
136 | + foreach ($backend->getIdentifierAliases() as $alias) { |
|
137 | + $this->backends[$alias] = $backend; |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @deprecated 9.1.0 use registerBackendProvider() |
|
143 | + * @param Backend[] $backends |
|
144 | + */ |
|
145 | + public function registerBackends(array $backends) { |
|
146 | + foreach ($backends as $backend) { |
|
147 | + $this->registerBackend($backend); |
|
148 | + } |
|
149 | + } |
|
150 | + /** |
|
151 | + * Register an authentication mechanism |
|
152 | + * |
|
153 | + * @deprecated 9.1.0 use registerAuthMechanismProvider() |
|
154 | + * @param AuthMechanism $authMech |
|
155 | + */ |
|
156 | + public function registerAuthMechanism(AuthMechanism $authMech) { |
|
157 | + if (!$this->isAllowedAuthMechanism($authMech)) { |
|
158 | + $authMech->removeVisibility(BackendService::VISIBILITY_PERSONAL); |
|
159 | + } |
|
160 | + foreach ($authMech->getIdentifierAliases() as $alias) { |
|
161 | + $this->authMechanisms[$alias] = $authMech; |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @deprecated 9.1.0 use registerAuthMechanismProvider() |
|
167 | + * @param AuthMechanism[] $mechanisms |
|
168 | + */ |
|
169 | + public function registerAuthMechanisms(array $mechanisms) { |
|
170 | + foreach ($mechanisms as $mechanism) { |
|
171 | + $this->registerAuthMechanism($mechanism); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Get all backends |
|
177 | + * |
|
178 | + * @return Backend[] |
|
179 | + */ |
|
180 | + public function getBackends() { |
|
181 | + $this->loadBackendProviders(); |
|
182 | + // only return real identifiers, no aliases |
|
183 | + $backends = []; |
|
184 | + foreach ($this->backends as $backend) { |
|
185 | + $backends[$backend->getIdentifier()] = $backend; |
|
186 | + } |
|
187 | + return $backends; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Get all available backends |
|
192 | + * |
|
193 | + * @return Backend[] |
|
194 | + */ |
|
195 | + public function getAvailableBackends() { |
|
196 | + return array_filter($this->getBackends(), function($backend) { |
|
197 | + return !($backend->checkDependencies()); |
|
198 | + }); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * @param string $identifier |
|
203 | + * @return Backend|null |
|
204 | + */ |
|
205 | + public function getBackend($identifier) { |
|
206 | + $this->loadBackendProviders(); |
|
207 | + if (isset($this->backends[$identifier])) { |
|
208 | + return $this->backends[$identifier]; |
|
209 | + } |
|
210 | + return null; |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Get all authentication mechanisms |
|
215 | + * |
|
216 | + * @return AuthMechanism[] |
|
217 | + */ |
|
218 | + public function getAuthMechanisms() { |
|
219 | + $this->loadAuthMechanismProviders(); |
|
220 | + // only return real identifiers, no aliases |
|
221 | + $mechanisms = []; |
|
222 | + foreach ($this->authMechanisms as $mechanism) { |
|
223 | + $mechanisms[$mechanism->getIdentifier()] = $mechanism; |
|
224 | + } |
|
225 | + return $mechanisms; |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Get all authentication mechanisms for schemes |
|
230 | + * |
|
231 | + * @param string[] $schemes |
|
232 | + * @return AuthMechanism[] |
|
233 | + */ |
|
234 | + public function getAuthMechanismsByScheme(array $schemes) { |
|
235 | + return array_filter($this->getAuthMechanisms(), function($authMech) use ($schemes) { |
|
236 | + return in_array($authMech->getScheme(), $schemes, true); |
|
237 | + }); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * @param string $identifier |
|
242 | + * @return AuthMechanism|null |
|
243 | + */ |
|
244 | + public function getAuthMechanism($identifier) { |
|
245 | + $this->loadAuthMechanismProviders(); |
|
246 | + if (isset($this->authMechanisms[$identifier])) { |
|
247 | + return $this->authMechanisms[$identifier]; |
|
248 | + } |
|
249 | + return null; |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * @return bool |
|
254 | + */ |
|
255 | + public function isUserMountingAllowed() { |
|
256 | + return $this->userMountingAllowed; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Check a backend if a user is allowed to mount it |
|
261 | + * |
|
262 | + * @param Backend $backend |
|
263 | + * @return bool |
|
264 | + */ |
|
265 | + protected function isAllowedUserBackend(Backend $backend) { |
|
266 | + if ($this->userMountingAllowed && |
|
267 | + array_intersect($backend->getIdentifierAliases(), $this->userMountingBackends) |
|
268 | + ) { |
|
269 | + return true; |
|
270 | + } |
|
271 | + return false; |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Check an authentication mechanism if a user is allowed to use it |
|
276 | + * |
|
277 | + * @param AuthMechanism $authMechanism |
|
278 | + * @return bool |
|
279 | + */ |
|
280 | + protected function isAllowedAuthMechanism(AuthMechanism $authMechanism) { |
|
281 | + return true; // not implemented |
|
282 | + } |
|
283 | 283 | } |
@@ -35,151 +35,151 @@ |
||
35 | 35 | * Service class to manage global external storages |
36 | 36 | */ |
37 | 37 | class GlobalStoragesService extends StoragesService { |
38 | - /** |
|
39 | - * Triggers $signal for all applicable users of the given |
|
40 | - * storage |
|
41 | - * |
|
42 | - * @param StorageConfig $storage storage data |
|
43 | - * @param string $signal signal to trigger |
|
44 | - */ |
|
45 | - protected function triggerHooks(StorageConfig $storage, $signal) { |
|
46 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
47 | - $applicableUsers = $storage->getApplicableUsers(); |
|
48 | - $applicableGroups = $storage->getApplicableGroups(); |
|
49 | - if (empty($applicableUsers) && empty($applicableGroups)) { |
|
50 | - // raise for user "all" |
|
51 | - $this->triggerApplicableHooks( |
|
52 | - $signal, |
|
53 | - $storage->getMountPoint(), |
|
54 | - \OC_Mount_Config::MOUNT_TYPE_USER, |
|
55 | - ['all'] |
|
56 | - ); |
|
57 | - return; |
|
58 | - } |
|
59 | - |
|
60 | - $this->triggerApplicableHooks( |
|
61 | - $signal, |
|
62 | - $storage->getMountPoint(), |
|
63 | - \OC_Mount_Config::MOUNT_TYPE_USER, |
|
64 | - $applicableUsers |
|
65 | - ); |
|
66 | - $this->triggerApplicableHooks( |
|
67 | - $signal, |
|
68 | - $storage->getMountPoint(), |
|
69 | - \OC_Mount_Config::MOUNT_TYPE_GROUP, |
|
70 | - $applicableGroups |
|
71 | - ); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Triggers signal_create_mount or signal_delete_mount to |
|
76 | - * accommodate for additions/deletions in applicableUsers |
|
77 | - * and applicableGroups fields. |
|
78 | - * |
|
79 | - * @param StorageConfig $oldStorage old storage config |
|
80 | - * @param StorageConfig $newStorage new storage config |
|
81 | - */ |
|
82 | - protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) { |
|
83 | - // if mount point changed, it's like a deletion + creation |
|
84 | - if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) { |
|
85 | - $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount); |
|
86 | - $this->triggerHooks($newStorage, Filesystem::signal_create_mount); |
|
87 | - return; |
|
88 | - } |
|
89 | - |
|
90 | - $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers()); |
|
91 | - $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers()); |
|
92 | - $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); |
|
93 | - $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); |
|
94 | - |
|
95 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
96 | - // if no applicable were set, raise a signal for "all" |
|
97 | - $oldApplicableUsers = $oldStorage->getApplicableUsers(); |
|
98 | - $oldApplicableGroups = $oldStorage->getApplicableGroups(); |
|
99 | - if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { |
|
100 | - $this->triggerApplicableHooks( |
|
101 | - Filesystem::signal_delete_mount, |
|
102 | - $oldStorage->getMountPoint(), |
|
103 | - \OC_Mount_Config::MOUNT_TYPE_USER, |
|
104 | - ['all'] |
|
105 | - ); |
|
106 | - } |
|
107 | - |
|
108 | - // trigger delete for removed users |
|
109 | - $this->triggerApplicableHooks( |
|
110 | - Filesystem::signal_delete_mount, |
|
111 | - $oldStorage->getMountPoint(), |
|
112 | - \OC_Mount_Config::MOUNT_TYPE_USER, |
|
113 | - $userDeletions |
|
114 | - ); |
|
115 | - |
|
116 | - // trigger delete for removed groups |
|
117 | - $this->triggerApplicableHooks( |
|
118 | - Filesystem::signal_delete_mount, |
|
119 | - $oldStorage->getMountPoint(), |
|
120 | - \OC_Mount_Config::MOUNT_TYPE_GROUP, |
|
121 | - $groupDeletions |
|
122 | - ); |
|
123 | - |
|
124 | - // and now add the new users |
|
125 | - $this->triggerApplicableHooks( |
|
126 | - Filesystem::signal_create_mount, |
|
127 | - $newStorage->getMountPoint(), |
|
128 | - \OC_Mount_Config::MOUNT_TYPE_USER, |
|
129 | - $userAdditions |
|
130 | - ); |
|
131 | - |
|
132 | - // and now add the new groups |
|
133 | - $this->triggerApplicableHooks( |
|
134 | - Filesystem::signal_create_mount, |
|
135 | - $newStorage->getMountPoint(), |
|
136 | - \OC_Mount_Config::MOUNT_TYPE_GROUP, |
|
137 | - $groupAdditions |
|
138 | - ); |
|
139 | - |
|
140 | - // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
141 | - // if no applicable, raise a signal for "all" |
|
142 | - $newApplicableUsers = $newStorage->getApplicableUsers(); |
|
143 | - $newApplicableGroups = $newStorage->getApplicableGroups(); |
|
144 | - if (empty($newApplicableUsers) && empty($newApplicableGroups)) { |
|
145 | - $this->triggerApplicableHooks( |
|
146 | - Filesystem::signal_create_mount, |
|
147 | - $newStorage->getMountPoint(), |
|
148 | - \OC_Mount_Config::MOUNT_TYPE_USER, |
|
149 | - ['all'] |
|
150 | - ); |
|
151 | - } |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Get the visibility type for this controller, used in validation |
|
156 | - * |
|
157 | - * @return string BackendService::VISIBILITY_* constants |
|
158 | - */ |
|
159 | - public function getVisibilityType() { |
|
160 | - return BackendService::VISIBILITY_ADMIN; |
|
161 | - } |
|
162 | - |
|
163 | - protected function isApplicable(StorageConfig $config) { |
|
164 | - return true; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Get all configured admin and personal mounts |
|
169 | - * |
|
170 | - * @return array map of storage id to storage config |
|
171 | - */ |
|
172 | - public function getStorageForAllUsers() { |
|
173 | - $mounts = $this->dbConfig->getAllMounts(); |
|
174 | - $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
175 | - $configs = array_filter($configs, function ($config) { |
|
176 | - return $config instanceof StorageConfig; |
|
177 | - }); |
|
178 | - |
|
179 | - $keys = array_map(function (StorageConfig $config) { |
|
180 | - return $config->getId(); |
|
181 | - }, $configs); |
|
182 | - |
|
183 | - return array_combine($keys, $configs); |
|
184 | - } |
|
38 | + /** |
|
39 | + * Triggers $signal for all applicable users of the given |
|
40 | + * storage |
|
41 | + * |
|
42 | + * @param StorageConfig $storage storage data |
|
43 | + * @param string $signal signal to trigger |
|
44 | + */ |
|
45 | + protected function triggerHooks(StorageConfig $storage, $signal) { |
|
46 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
47 | + $applicableUsers = $storage->getApplicableUsers(); |
|
48 | + $applicableGroups = $storage->getApplicableGroups(); |
|
49 | + if (empty($applicableUsers) && empty($applicableGroups)) { |
|
50 | + // raise for user "all" |
|
51 | + $this->triggerApplicableHooks( |
|
52 | + $signal, |
|
53 | + $storage->getMountPoint(), |
|
54 | + \OC_Mount_Config::MOUNT_TYPE_USER, |
|
55 | + ['all'] |
|
56 | + ); |
|
57 | + return; |
|
58 | + } |
|
59 | + |
|
60 | + $this->triggerApplicableHooks( |
|
61 | + $signal, |
|
62 | + $storage->getMountPoint(), |
|
63 | + \OC_Mount_Config::MOUNT_TYPE_USER, |
|
64 | + $applicableUsers |
|
65 | + ); |
|
66 | + $this->triggerApplicableHooks( |
|
67 | + $signal, |
|
68 | + $storage->getMountPoint(), |
|
69 | + \OC_Mount_Config::MOUNT_TYPE_GROUP, |
|
70 | + $applicableGroups |
|
71 | + ); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Triggers signal_create_mount or signal_delete_mount to |
|
76 | + * accommodate for additions/deletions in applicableUsers |
|
77 | + * and applicableGroups fields. |
|
78 | + * |
|
79 | + * @param StorageConfig $oldStorage old storage config |
|
80 | + * @param StorageConfig $newStorage new storage config |
|
81 | + */ |
|
82 | + protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage) { |
|
83 | + // if mount point changed, it's like a deletion + creation |
|
84 | + if ($oldStorage->getMountPoint() !== $newStorage->getMountPoint()) { |
|
85 | + $this->triggerHooks($oldStorage, Filesystem::signal_delete_mount); |
|
86 | + $this->triggerHooks($newStorage, Filesystem::signal_create_mount); |
|
87 | + return; |
|
88 | + } |
|
89 | + |
|
90 | + $userAdditions = array_diff($newStorage->getApplicableUsers(), $oldStorage->getApplicableUsers()); |
|
91 | + $userDeletions = array_diff($oldStorage->getApplicableUsers(), $newStorage->getApplicableUsers()); |
|
92 | + $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); |
|
93 | + $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); |
|
94 | + |
|
95 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
96 | + // if no applicable were set, raise a signal for "all" |
|
97 | + $oldApplicableUsers = $oldStorage->getApplicableUsers(); |
|
98 | + $oldApplicableGroups = $oldStorage->getApplicableGroups(); |
|
99 | + if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { |
|
100 | + $this->triggerApplicableHooks( |
|
101 | + Filesystem::signal_delete_mount, |
|
102 | + $oldStorage->getMountPoint(), |
|
103 | + \OC_Mount_Config::MOUNT_TYPE_USER, |
|
104 | + ['all'] |
|
105 | + ); |
|
106 | + } |
|
107 | + |
|
108 | + // trigger delete for removed users |
|
109 | + $this->triggerApplicableHooks( |
|
110 | + Filesystem::signal_delete_mount, |
|
111 | + $oldStorage->getMountPoint(), |
|
112 | + \OC_Mount_Config::MOUNT_TYPE_USER, |
|
113 | + $userDeletions |
|
114 | + ); |
|
115 | + |
|
116 | + // trigger delete for removed groups |
|
117 | + $this->triggerApplicableHooks( |
|
118 | + Filesystem::signal_delete_mount, |
|
119 | + $oldStorage->getMountPoint(), |
|
120 | + \OC_Mount_Config::MOUNT_TYPE_GROUP, |
|
121 | + $groupDeletions |
|
122 | + ); |
|
123 | + |
|
124 | + // and now add the new users |
|
125 | + $this->triggerApplicableHooks( |
|
126 | + Filesystem::signal_create_mount, |
|
127 | + $newStorage->getMountPoint(), |
|
128 | + \OC_Mount_Config::MOUNT_TYPE_USER, |
|
129 | + $userAdditions |
|
130 | + ); |
|
131 | + |
|
132 | + // and now add the new groups |
|
133 | + $this->triggerApplicableHooks( |
|
134 | + Filesystem::signal_create_mount, |
|
135 | + $newStorage->getMountPoint(), |
|
136 | + \OC_Mount_Config::MOUNT_TYPE_GROUP, |
|
137 | + $groupAdditions |
|
138 | + ); |
|
139 | + |
|
140 | + // FIXME: Use as expression in empty once PHP 5.4 support is dropped |
|
141 | + // if no applicable, raise a signal for "all" |
|
142 | + $newApplicableUsers = $newStorage->getApplicableUsers(); |
|
143 | + $newApplicableGroups = $newStorage->getApplicableGroups(); |
|
144 | + if (empty($newApplicableUsers) && empty($newApplicableGroups)) { |
|
145 | + $this->triggerApplicableHooks( |
|
146 | + Filesystem::signal_create_mount, |
|
147 | + $newStorage->getMountPoint(), |
|
148 | + \OC_Mount_Config::MOUNT_TYPE_USER, |
|
149 | + ['all'] |
|
150 | + ); |
|
151 | + } |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Get the visibility type for this controller, used in validation |
|
156 | + * |
|
157 | + * @return string BackendService::VISIBILITY_* constants |
|
158 | + */ |
|
159 | + public function getVisibilityType() { |
|
160 | + return BackendService::VISIBILITY_ADMIN; |
|
161 | + } |
|
162 | + |
|
163 | + protected function isApplicable(StorageConfig $config) { |
|
164 | + return true; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Get all configured admin and personal mounts |
|
169 | + * |
|
170 | + * @return array map of storage id to storage config |
|
171 | + */ |
|
172 | + public function getStorageForAllUsers() { |
|
173 | + $mounts = $this->dbConfig->getAllMounts(); |
|
174 | + $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
|
175 | + $configs = array_filter($configs, function ($config) { |
|
176 | + return $config instanceof StorageConfig; |
|
177 | + }); |
|
178 | + |
|
179 | + $keys = array_map(function (StorageConfig $config) { |
|
180 | + return $config->getId(); |
|
181 | + }, $configs); |
|
182 | + |
|
183 | + return array_combine($keys, $configs); |
|
184 | + } |
|
185 | 185 | } |
@@ -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 |