@@ -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 | ] |
@@ -29,37 +29,37 @@ |
||
| 29 | 29 | |
| 30 | 30 | /** @var $this \OCP\Route\IRouter */ |
| 31 | 31 | $this->create('user_ldap_ajax_clearMappings', 'apps/user_ldap/ajax/clearMappings.php') |
| 32 | - ->actionInclude('user_ldap/ajax/clearMappings.php'); |
|
| 32 | + ->actionInclude('user_ldap/ajax/clearMappings.php'); |
|
| 33 | 33 | $this->create('user_ldap_ajax_deleteConfiguration', 'apps/user_ldap/ajax/deleteConfiguration.php') |
| 34 | - ->actionInclude('user_ldap/ajax/deleteConfiguration.php'); |
|
| 34 | + ->actionInclude('user_ldap/ajax/deleteConfiguration.php'); |
|
| 35 | 35 | $this->create('user_ldap_ajax_getConfiguration', 'apps/user_ldap/ajax/getConfiguration.php') |
| 36 | - ->actionInclude('user_ldap/ajax/getConfiguration.php'); |
|
| 36 | + ->actionInclude('user_ldap/ajax/getConfiguration.php'); |
|
| 37 | 37 | $this->create('user_ldap_ajax_getNewServerConfigPrefix', 'apps/user_ldap/ajax/getNewServerConfigPrefix.php') |
| 38 | - ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); |
|
| 38 | + ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); |
|
| 39 | 39 | $this->create('user_ldap_ajax_setConfiguration', 'apps/user_ldap/ajax/setConfiguration.php') |
| 40 | - ->actionInclude('user_ldap/ajax/setConfiguration.php'); |
|
| 40 | + ->actionInclude('user_ldap/ajax/setConfiguration.php'); |
|
| 41 | 41 | $this->create('user_ldap_ajax_testConfiguration', 'apps/user_ldap/ajax/testConfiguration.php') |
| 42 | - ->actionInclude('user_ldap/ajax/testConfiguration.php'); |
|
| 42 | + ->actionInclude('user_ldap/ajax/testConfiguration.php'); |
|
| 43 | 43 | $this->create('user_ldap_ajax_wizard', 'apps/user_ldap/ajax/wizard.php') |
| 44 | - ->actionInclude('user_ldap/ajax/wizard.php'); |
|
| 44 | + ->actionInclude('user_ldap/ajax/wizard.php'); |
|
| 45 | 45 | |
| 46 | 46 | $application = new \OCP\AppFramework\App('user_ldap'); |
| 47 | 47 | $application->registerRoutes($this, [ |
| 48 | - 'ocs' => [ |
|
| 49 | - ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
|
| 50 | - ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
| 51 | - ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
|
| 52 | - ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
|
| 53 | - ] |
|
| 48 | + 'ocs' => [ |
|
| 49 | + ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'], |
|
| 50 | + ['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'], |
|
| 51 | + ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'], |
|
| 52 | + ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'], |
|
| 53 | + ] |
|
| 54 | 54 | ]); |
| 55 | 55 | |
| 56 | 56 | /** @var \OCA\User_LDAP\AppInfo\Application $application */ |
| 57 | 57 | $application = \OC::$server->query(\OCA\User_LDAP\AppInfo\Application::class); |
| 58 | 58 | $application->registerRoutes($this, [ |
| 59 | - 'routes' => [ |
|
| 60 | - ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'], |
|
| 61 | - ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'], |
|
| 62 | - ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'], |
|
| 63 | - ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'], |
|
| 64 | - ] |
|
| 59 | + 'routes' => [ |
|
| 60 | + ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'], |
|
| 61 | + ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'], |
|
| 62 | + ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'], |
|
| 63 | + ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'], |
|
| 64 | + ] |
|
| 65 | 65 | ]); |
@@ -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 = []; |
@@ -32,23 +32,23 @@ |
||
| 32 | 32 | $limit = null; |
| 33 | 33 | $offset = null; |
| 34 | 34 | if (isset($_GET['pattern'])) { |
| 35 | - $pattern = (string)$_GET['pattern']; |
|
| 35 | + $pattern = (string)$_GET['pattern']; |
|
| 36 | 36 | } |
| 37 | 37 | if (isset($_GET['limit'])) { |
| 38 | - $limit = (int)$_GET['limit']; |
|
| 38 | + $limit = (int)$_GET['limit']; |
|
| 39 | 39 | } |
| 40 | 40 | if (isset($_GET['offset'])) { |
| 41 | - $offset = (int)$_GET['offset']; |
|
| 41 | + $offset = (int)$_GET['offset']; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $groups = []; |
| 45 | 45 | foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) { |
| 46 | - $groups[$group->getGID()] = $group->getDisplayName(); |
|
| 46 | + $groups[$group->getGID()] = $group->getDisplayName(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $users = []; |
| 50 | 50 | foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) { |
| 51 | - $users[$user->getUID()] = $user->getDisplayName(); |
|
| 51 | + $users[$user->getUID()] = $user->getDisplayName(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $results = ['groups' => $groups, 'users' => $users]; |
@@ -24,25 +24,25 @@ |
||
| 24 | 24 | namespace OCA\Files_External\Service; |
| 25 | 25 | |
| 26 | 26 | class ImportLegacyStoragesService extends LegacyStoragesService { |
| 27 | - private $data; |
|
| 27 | + private $data; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @param BackendService $backendService |
|
| 31 | - */ |
|
| 32 | - public function __construct(BackendService $backendService) { |
|
| 33 | - $this->backendService = $backendService; |
|
| 34 | - } |
|
| 29 | + /** |
|
| 30 | + * @param BackendService $backendService |
|
| 31 | + */ |
|
| 32 | + public function __construct(BackendService $backendService) { |
|
| 33 | + $this->backendService = $backendService; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public function setData($data) { |
|
| 37 | - $this->data = $data; |
|
| 38 | - } |
|
| 36 | + public function setData($data) { |
|
| 37 | + $this->data = $data; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Read legacy config data |
|
| 42 | - * |
|
| 43 | - * @return array list of mount configs |
|
| 44 | - */ |
|
| 45 | - protected function readLegacyConfig() { |
|
| 46 | - return $this->data; |
|
| 47 | - } |
|
| 40 | + /** |
|
| 41 | + * Read legacy config data |
|
| 42 | + * |
|
| 43 | + * @return array list of mount configs |
|
| 44 | + */ |
|
| 45 | + protected function readLegacyConfig() { |
|
| 46 | + return $this->data; |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -172,11 +172,11 @@ |
||
| 172 | 172 | public function getStorageForAllUsers() { |
| 173 | 173 | $mounts = $this->dbConfig->getAllMounts(); |
| 174 | 174 | $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
| 175 | - $configs = array_filter($configs, function ($config) { |
|
| 175 | + $configs = array_filter($configs, function($config) { |
|
| 176 | 176 | return $config instanceof StorageConfig; |
| 177 | 177 | }); |
| 178 | 178 | |
| 179 | - $keys = array_map(function (StorageConfig $config) { |
|
| 179 | + $keys = array_map(function(StorageConfig $config) { |
|
| 180 | 180 | return $config->getId(); |
| 181 | 181 | }, $configs); |
| 182 | 182 | |
@@ -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 | - \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, |
|
| 55 | - ['all'] |
|
| 56 | - ); |
|
| 57 | - return; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - $this->triggerApplicableHooks( |
|
| 61 | - $signal, |
|
| 62 | - $storage->getMountPoint(), |
|
| 63 | - \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, |
|
| 64 | - $applicableUsers |
|
| 65 | - ); |
|
| 66 | - $this->triggerApplicableHooks( |
|
| 67 | - $signal, |
|
| 68 | - $storage->getMountPoint(), |
|
| 69 | - \OCA\Files_External\MountConfig::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 | - \OCA\Files_External\MountConfig::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 | - \OCA\Files_External\MountConfig::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 | - \OCA\Files_External\MountConfig::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 | - \OCA\Files_External\MountConfig::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 | - \OCA\Files_External\MountConfig::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 | - \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, |
|
| 55 | + ['all'] |
|
| 56 | + ); |
|
| 57 | + return; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + $this->triggerApplicableHooks( |
|
| 61 | + $signal, |
|
| 62 | + $storage->getMountPoint(), |
|
| 63 | + \OCA\Files_External\MountConfig::MOUNT_TYPE_USER, |
|
| 64 | + $applicableUsers |
|
| 65 | + ); |
|
| 66 | + $this->triggerApplicableHooks( |
|
| 67 | + $signal, |
|
| 68 | + $storage->getMountPoint(), |
|
| 69 | + \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::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 | + \OCA\Files_External\MountConfig::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 | } |
@@ -30,46 +30,46 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | trait UserTrait { |
| 32 | 32 | |
| 33 | - /** @var IUserSession */ |
|
| 34 | - protected $userSession; |
|
| 33 | + /** @var IUserSession */ |
|
| 34 | + protected $userSession; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * User override |
|
| 38 | - * |
|
| 39 | - * @var IUser|null |
|
| 40 | - */ |
|
| 41 | - private $user = null; |
|
| 36 | + /** |
|
| 37 | + * User override |
|
| 38 | + * |
|
| 39 | + * @var IUser|null |
|
| 40 | + */ |
|
| 41 | + private $user = null; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return IUser|null |
|
| 45 | - */ |
|
| 46 | - protected function getUser() { |
|
| 47 | - if ($this->user) { |
|
| 48 | - return $this->user; |
|
| 49 | - } |
|
| 50 | - return $this->userSession->getUser(); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * @return IUser|null |
|
| 45 | + */ |
|
| 46 | + protected function getUser() { |
|
| 47 | + if ($this->user) { |
|
| 48 | + return $this->user; |
|
| 49 | + } |
|
| 50 | + return $this->userSession->getUser(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Override the user from the session |
|
| 55 | - * Unset with ->resetUser() when finished! |
|
| 56 | - * |
|
| 57 | - * @param IUser |
|
| 58 | - * @return self |
|
| 59 | - */ |
|
| 60 | - public function setUser(IUser $user) { |
|
| 61 | - $this->user = $user; |
|
| 62 | - return $this; |
|
| 63 | - } |
|
| 53 | + /** |
|
| 54 | + * Override the user from the session |
|
| 55 | + * Unset with ->resetUser() when finished! |
|
| 56 | + * |
|
| 57 | + * @param IUser |
|
| 58 | + * @return self |
|
| 59 | + */ |
|
| 60 | + public function setUser(IUser $user) { |
|
| 61 | + $this->user = $user; |
|
| 62 | + return $this; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Reset the user override |
|
| 67 | - * |
|
| 68 | - * @return self |
|
| 69 | - */ |
|
| 70 | - public function resetUser() { |
|
| 71 | - $this->user = null; |
|
| 72 | - return $this; |
|
| 73 | - } |
|
| 65 | + /** |
|
| 66 | + * Reset the user override |
|
| 67 | + * |
|
| 68 | + * @return self |
|
| 69 | + */ |
|
| 70 | + public function resetUser() { |
|
| 71 | + $this->user = null; |
|
| 72 | + return $this; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | try { |
| 104 | 104 | $mount = $this->globalService->getStorage($mountId); |
| 105 | 105 | } catch (NotFoundException $e) { |
| 106 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts</error>'); |
|
| 106 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts</error>'); |
|
| 107 | 107 | return 404; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | if ((count($addUsers) + count($removeUsers) + count($addGroups) + count($removeGroups) > 0) || $input->getOption('remove-all')) { |
| 124 | 124 | foreach ($addUsers as $addUser) { |
| 125 | 125 | if (!$this->userManager->userExists($addUser)) { |
| 126 | - $output->writeln('<error>User "' . $addUser . '" not found</error>'); |
|
| 126 | + $output->writeln('<error>User "'.$addUser.'" not found</error>'); |
|
| 127 | 127 | return 404; |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | foreach ($addGroups as $addGroup) { |
| 131 | 131 | if (!$this->groupManager->groupExists($addGroup)) { |
| 132 | - $output->writeln('<error>Group "' . $addGroup . '" not found</error>'); |
|
| 132 | + $output->writeln('<error>Group "'.$addGroup.'" not found</error>'); |
|
| 133 | 133 | return 404; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -37,123 +37,123 @@ |
||
| 37 | 37 | use Symfony\Component\Console\Output\OutputInterface; |
| 38 | 38 | |
| 39 | 39 | class Applicable extends Base { |
| 40 | - /** |
|
| 41 | - * @var GlobalStoragesService |
|
| 42 | - */ |
|
| 43 | - protected $globalService; |
|
| 40 | + /** |
|
| 41 | + * @var GlobalStoragesService |
|
| 42 | + */ |
|
| 43 | + protected $globalService; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var IUserManager |
|
| 47 | - */ |
|
| 48 | - private $userManager; |
|
| 45 | + /** |
|
| 46 | + * @var IUserManager |
|
| 47 | + */ |
|
| 48 | + private $userManager; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var IGroupManager |
|
| 52 | - */ |
|
| 53 | - private $groupManager; |
|
| 50 | + /** |
|
| 51 | + * @var IGroupManager |
|
| 52 | + */ |
|
| 53 | + private $groupManager; |
|
| 54 | 54 | |
| 55 | - public function __construct( |
|
| 56 | - GlobalStoragesService $globalService, |
|
| 57 | - IUserManager $userManager, |
|
| 58 | - IGroupManager $groupManager |
|
| 59 | - ) { |
|
| 60 | - parent::__construct(); |
|
| 61 | - $this->globalService = $globalService; |
|
| 62 | - $this->userManager = $userManager; |
|
| 63 | - $this->groupManager = $groupManager; |
|
| 64 | - } |
|
| 55 | + public function __construct( |
|
| 56 | + GlobalStoragesService $globalService, |
|
| 57 | + IUserManager $userManager, |
|
| 58 | + IGroupManager $groupManager |
|
| 59 | + ) { |
|
| 60 | + parent::__construct(); |
|
| 61 | + $this->globalService = $globalService; |
|
| 62 | + $this->userManager = $userManager; |
|
| 63 | + $this->groupManager = $groupManager; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - protected function configure() { |
|
| 67 | - $this |
|
| 68 | - ->setName('files_external:applicable') |
|
| 69 | - ->setDescription('Manage applicable users and groups for a mount') |
|
| 70 | - ->addArgument( |
|
| 71 | - 'mount_id', |
|
| 72 | - InputArgument::REQUIRED, |
|
| 73 | - 'The id of the mount to edit' |
|
| 74 | - )->addOption( |
|
| 75 | - 'add-user', |
|
| 76 | - '', |
|
| 77 | - InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 78 | - 'user to add as applicable' |
|
| 79 | - )->addOption( |
|
| 80 | - 'remove-user', |
|
| 81 | - '', |
|
| 82 | - InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 83 | - 'user to remove as applicable' |
|
| 84 | - )->addOption( |
|
| 85 | - 'add-group', |
|
| 86 | - '', |
|
| 87 | - InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 88 | - 'group to add as applicable' |
|
| 89 | - )->addOption( |
|
| 90 | - 'remove-group', |
|
| 91 | - '', |
|
| 92 | - InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 93 | - 'group to remove as applicable' |
|
| 94 | - )->addOption( |
|
| 95 | - 'remove-all', |
|
| 96 | - '', |
|
| 97 | - InputOption::VALUE_NONE, |
|
| 98 | - 'Set the mount to be globally applicable' |
|
| 99 | - ); |
|
| 100 | - parent::configure(); |
|
| 101 | - } |
|
| 66 | + protected function configure() { |
|
| 67 | + $this |
|
| 68 | + ->setName('files_external:applicable') |
|
| 69 | + ->setDescription('Manage applicable users and groups for a mount') |
|
| 70 | + ->addArgument( |
|
| 71 | + 'mount_id', |
|
| 72 | + InputArgument::REQUIRED, |
|
| 73 | + 'The id of the mount to edit' |
|
| 74 | + )->addOption( |
|
| 75 | + 'add-user', |
|
| 76 | + '', |
|
| 77 | + InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 78 | + 'user to add as applicable' |
|
| 79 | + )->addOption( |
|
| 80 | + 'remove-user', |
|
| 81 | + '', |
|
| 82 | + InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 83 | + 'user to remove as applicable' |
|
| 84 | + )->addOption( |
|
| 85 | + 'add-group', |
|
| 86 | + '', |
|
| 87 | + InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 88 | + 'group to add as applicable' |
|
| 89 | + )->addOption( |
|
| 90 | + 'remove-group', |
|
| 91 | + '', |
|
| 92 | + InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, |
|
| 93 | + 'group to remove as applicable' |
|
| 94 | + )->addOption( |
|
| 95 | + 'remove-all', |
|
| 96 | + '', |
|
| 97 | + InputOption::VALUE_NONE, |
|
| 98 | + 'Set the mount to be globally applicable' |
|
| 99 | + ); |
|
| 100 | + parent::configure(); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 104 | - $mountId = $input->getArgument('mount_id'); |
|
| 105 | - try { |
|
| 106 | - $mount = $this->globalService->getStorage($mountId); |
|
| 107 | - } catch (NotFoundException $e) { |
|
| 108 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts</error>'); |
|
| 109 | - return 404; |
|
| 110 | - } |
|
| 103 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 104 | + $mountId = $input->getArgument('mount_id'); |
|
| 105 | + try { |
|
| 106 | + $mount = $this->globalService->getStorage($mountId); |
|
| 107 | + } catch (NotFoundException $e) { |
|
| 108 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts</error>'); |
|
| 109 | + return 404; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) { |
|
| 113 | - $output->writeln('<error>Can\'t change applicables on personal mounts</error>'); |
|
| 114 | - return 1; |
|
| 115 | - } |
|
| 112 | + if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) { |
|
| 113 | + $output->writeln('<error>Can\'t change applicables on personal mounts</error>'); |
|
| 114 | + return 1; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $addUsers = $input->getOption('add-user'); |
|
| 118 | - $removeUsers = $input->getOption('remove-user'); |
|
| 119 | - $addGroups = $input->getOption('add-group'); |
|
| 120 | - $removeGroups = $input->getOption('remove-group'); |
|
| 117 | + $addUsers = $input->getOption('add-user'); |
|
| 118 | + $removeUsers = $input->getOption('remove-user'); |
|
| 119 | + $addGroups = $input->getOption('add-group'); |
|
| 120 | + $removeGroups = $input->getOption('remove-group'); |
|
| 121 | 121 | |
| 122 | - $applicableUsers = $mount->getApplicableUsers(); |
|
| 123 | - $applicableGroups = $mount->getApplicableGroups(); |
|
| 122 | + $applicableUsers = $mount->getApplicableUsers(); |
|
| 123 | + $applicableGroups = $mount->getApplicableGroups(); |
|
| 124 | 124 | |
| 125 | - if ((count($addUsers) + count($removeUsers) + count($addGroups) + count($removeGroups) > 0) || $input->getOption('remove-all')) { |
|
| 126 | - foreach ($addUsers as $addUser) { |
|
| 127 | - if (!$this->userManager->userExists($addUser)) { |
|
| 128 | - $output->writeln('<error>User "' . $addUser . '" not found</error>'); |
|
| 129 | - return 404; |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - foreach ($addGroups as $addGroup) { |
|
| 133 | - if (!$this->groupManager->groupExists($addGroup)) { |
|
| 134 | - $output->writeln('<error>Group "' . $addGroup . '" not found</error>'); |
|
| 135 | - return 404; |
|
| 136 | - } |
|
| 137 | - } |
|
| 125 | + if ((count($addUsers) + count($removeUsers) + count($addGroups) + count($removeGroups) > 0) || $input->getOption('remove-all')) { |
|
| 126 | + foreach ($addUsers as $addUser) { |
|
| 127 | + if (!$this->userManager->userExists($addUser)) { |
|
| 128 | + $output->writeln('<error>User "' . $addUser . '" not found</error>'); |
|
| 129 | + return 404; |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + foreach ($addGroups as $addGroup) { |
|
| 133 | + if (!$this->groupManager->groupExists($addGroup)) { |
|
| 134 | + $output->writeln('<error>Group "' . $addGroup . '" not found</error>'); |
|
| 135 | + return 404; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - if ($input->getOption('remove-all')) { |
|
| 140 | - $applicableUsers = []; |
|
| 141 | - $applicableGroups = []; |
|
| 142 | - } else { |
|
| 143 | - $applicableUsers = array_unique(array_merge($applicableUsers, $addUsers)); |
|
| 144 | - $applicableUsers = array_values(array_diff($applicableUsers, $removeUsers)); |
|
| 145 | - $applicableGroups = array_unique(array_merge($applicableGroups, $addGroups)); |
|
| 146 | - $applicableGroups = array_values(array_diff($applicableGroups, $removeGroups)); |
|
| 147 | - } |
|
| 148 | - $mount->setApplicableUsers($applicableUsers); |
|
| 149 | - $mount->setApplicableGroups($applicableGroups); |
|
| 150 | - $this->globalService->updateStorage($mount); |
|
| 151 | - } |
|
| 139 | + if ($input->getOption('remove-all')) { |
|
| 140 | + $applicableUsers = []; |
|
| 141 | + $applicableGroups = []; |
|
| 142 | + } else { |
|
| 143 | + $applicableUsers = array_unique(array_merge($applicableUsers, $addUsers)); |
|
| 144 | + $applicableUsers = array_values(array_diff($applicableUsers, $removeUsers)); |
|
| 145 | + $applicableGroups = array_unique(array_merge($applicableGroups, $addGroups)); |
|
| 146 | + $applicableGroups = array_values(array_diff($applicableGroups, $removeGroups)); |
|
| 147 | + } |
|
| 148 | + $mount->setApplicableUsers($applicableUsers); |
|
| 149 | + $mount->setApplicableGroups($applicableGroups); |
|
| 150 | + $this->globalService->updateStorage($mount); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - $this->writeArrayInOutputFormat($input, $output, [ |
|
| 154 | - 'users' => $applicableUsers, |
|
| 155 | - 'groups' => $applicableGroups |
|
| 156 | - ]); |
|
| 157 | - return 0; |
|
| 158 | - } |
|
| 153 | + $this->writeArrayInOutputFormat($input, $output, [ |
|
| 154 | + 'users' => $applicableUsers, |
|
| 155 | + 'groups' => $applicableGroups |
|
| 156 | + ]); |
|
| 157 | + return 0; |
|
| 158 | + } |
|
| 159 | 159 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | try { |
| 69 | 69 | $mount = $this->globalService->getStorage($mountId); |
| 70 | 70 | } catch (NotFoundException $e) { |
| 71 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 71 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 72 | 72 | return 404; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -34,88 +34,88 @@ |
||
| 34 | 34 | use Symfony\Component\Console\Output\OutputInterface; |
| 35 | 35 | |
| 36 | 36 | class Config extends Base { |
| 37 | - /** |
|
| 38 | - * @var GlobalStoragesService |
|
| 39 | - */ |
|
| 40 | - protected $globalService; |
|
| 37 | + /** |
|
| 38 | + * @var GlobalStoragesService |
|
| 39 | + */ |
|
| 40 | + protected $globalService; |
|
| 41 | 41 | |
| 42 | - public function __construct(GlobalStoragesService $globalService) { |
|
| 43 | - parent::__construct(); |
|
| 44 | - $this->globalService = $globalService; |
|
| 45 | - } |
|
| 42 | + public function __construct(GlobalStoragesService $globalService) { |
|
| 43 | + parent::__construct(); |
|
| 44 | + $this->globalService = $globalService; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - protected function configure() { |
|
| 48 | - $this |
|
| 49 | - ->setName('files_external:config') |
|
| 50 | - ->setDescription('Manage backend configuration for a mount') |
|
| 51 | - ->addArgument( |
|
| 52 | - 'mount_id', |
|
| 53 | - InputArgument::REQUIRED, |
|
| 54 | - 'The id of the mount to edit' |
|
| 55 | - )->addArgument( |
|
| 56 | - 'key', |
|
| 57 | - InputArgument::REQUIRED, |
|
| 58 | - 'key of the config option to set/get' |
|
| 59 | - )->addArgument( |
|
| 60 | - 'value', |
|
| 61 | - InputArgument::OPTIONAL, |
|
| 62 | - 'value to set the config option to, when no value is provided the existing value will be printed' |
|
| 63 | - ); |
|
| 64 | - parent::configure(); |
|
| 65 | - } |
|
| 47 | + protected function configure() { |
|
| 48 | + $this |
|
| 49 | + ->setName('files_external:config') |
|
| 50 | + ->setDescription('Manage backend configuration for a mount') |
|
| 51 | + ->addArgument( |
|
| 52 | + 'mount_id', |
|
| 53 | + InputArgument::REQUIRED, |
|
| 54 | + 'The id of the mount to edit' |
|
| 55 | + )->addArgument( |
|
| 56 | + 'key', |
|
| 57 | + InputArgument::REQUIRED, |
|
| 58 | + 'key of the config option to set/get' |
|
| 59 | + )->addArgument( |
|
| 60 | + 'value', |
|
| 61 | + InputArgument::OPTIONAL, |
|
| 62 | + 'value to set the config option to, when no value is provided the existing value will be printed' |
|
| 63 | + ); |
|
| 64 | + parent::configure(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 68 | - $mountId = $input->getArgument('mount_id'); |
|
| 69 | - $key = $input->getArgument('key'); |
|
| 70 | - try { |
|
| 71 | - $mount = $this->globalService->getStorage($mountId); |
|
| 72 | - } catch (NotFoundException $e) { |
|
| 73 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 74 | - return 404; |
|
| 75 | - } |
|
| 67 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 68 | + $mountId = $input->getArgument('mount_id'); |
|
| 69 | + $key = $input->getArgument('key'); |
|
| 70 | + try { |
|
| 71 | + $mount = $this->globalService->getStorage($mountId); |
|
| 72 | + } catch (NotFoundException $e) { |
|
| 73 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 74 | + return 404; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $value = $input->getArgument('value'); |
|
| 78 | - if ($value !== null) { |
|
| 79 | - $this->setOption($mount, $key, $value, $output); |
|
| 80 | - } else { |
|
| 81 | - $this->getOption($mount, $key, $output); |
|
| 82 | - } |
|
| 83 | - return 0; |
|
| 84 | - } |
|
| 77 | + $value = $input->getArgument('value'); |
|
| 78 | + if ($value !== null) { |
|
| 79 | + $this->setOption($mount, $key, $value, $output); |
|
| 80 | + } else { |
|
| 81 | + $this->getOption($mount, $key, $output); |
|
| 82 | + } |
|
| 83 | + return 0; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @param StorageConfig $mount |
|
| 88 | - * @param string $key |
|
| 89 | - * @param OutputInterface $output |
|
| 90 | - */ |
|
| 91 | - protected function getOption(StorageConfig $mount, $key, OutputInterface $output) { |
|
| 92 | - if ($key === 'mountpoint' || $key === 'mount_point') { |
|
| 93 | - $value = $mount->getMountPoint(); |
|
| 94 | - } else { |
|
| 95 | - $value = $mount->getBackendOption($key); |
|
| 96 | - } |
|
| 97 | - if (!is_string($value) && json_decode(json_encode($value)) === $value) { // show bools and objects correctly |
|
| 98 | - $value = json_encode($value); |
|
| 99 | - } |
|
| 100 | - $output->writeln($value); |
|
| 101 | - } |
|
| 86 | + /** |
|
| 87 | + * @param StorageConfig $mount |
|
| 88 | + * @param string $key |
|
| 89 | + * @param OutputInterface $output |
|
| 90 | + */ |
|
| 91 | + protected function getOption(StorageConfig $mount, $key, OutputInterface $output) { |
|
| 92 | + if ($key === 'mountpoint' || $key === 'mount_point') { |
|
| 93 | + $value = $mount->getMountPoint(); |
|
| 94 | + } else { |
|
| 95 | + $value = $mount->getBackendOption($key); |
|
| 96 | + } |
|
| 97 | + if (!is_string($value) && json_decode(json_encode($value)) === $value) { // show bools and objects correctly |
|
| 98 | + $value = json_encode($value); |
|
| 99 | + } |
|
| 100 | + $output->writeln($value); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param StorageConfig $mount |
|
| 105 | - * @param string $key |
|
| 106 | - * @param string $value |
|
| 107 | - * @param OutputInterface $output |
|
| 108 | - */ |
|
| 109 | - protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) { |
|
| 110 | - $decoded = json_decode($value, true); |
|
| 111 | - if (!is_null($decoded) && json_encode($decoded) === $value) { |
|
| 112 | - $value = $decoded; |
|
| 113 | - } |
|
| 114 | - if ($key === 'mountpoint' || $key === 'mount_point') { |
|
| 115 | - $mount->setMountPoint($value); |
|
| 116 | - } else { |
|
| 117 | - $mount->setBackendOption($key, $value); |
|
| 118 | - } |
|
| 119 | - $this->globalService->updateStorage($mount); |
|
| 120 | - } |
|
| 103 | + /** |
|
| 104 | + * @param StorageConfig $mount |
|
| 105 | + * @param string $key |
|
| 106 | + * @param string $value |
|
| 107 | + * @param OutputInterface $output |
|
| 108 | + */ |
|
| 109 | + protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) { |
|
| 110 | + $decoded = json_decode($value, true); |
|
| 111 | + if (!is_null($decoded) && json_encode($decoded) === $value) { |
|
| 112 | + $value = $decoded; |
|
| 113 | + } |
|
| 114 | + if ($key === 'mountpoint' || $key === 'mount_point') { |
|
| 115 | + $mount->setMountPoint($value); |
|
| 116 | + } else { |
|
| 117 | + $mount->setBackendOption($key, $value); |
|
| 118 | + } |
|
| 119 | + $this->globalService->updateStorage($mount); |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -28,50 +28,50 @@ |
||
| 28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 29 | |
| 30 | 30 | class Option extends Config { |
| 31 | - protected function configure() { |
|
| 32 | - $this |
|
| 33 | - ->setName('files_external:option') |
|
| 34 | - ->setDescription('Manage mount options for a mount') |
|
| 35 | - ->addArgument( |
|
| 36 | - 'mount_id', |
|
| 37 | - InputArgument::REQUIRED, |
|
| 38 | - 'The id of the mount to edit' |
|
| 39 | - )->addArgument( |
|
| 40 | - 'key', |
|
| 41 | - InputArgument::REQUIRED, |
|
| 42 | - 'key of the mount option to set/get' |
|
| 43 | - )->addArgument( |
|
| 44 | - 'value', |
|
| 45 | - InputArgument::OPTIONAL, |
|
| 46 | - 'value to set the mount option to, when no value is provided the existing value will be printed' |
|
| 47 | - ); |
|
| 48 | - } |
|
| 31 | + protected function configure() { |
|
| 32 | + $this |
|
| 33 | + ->setName('files_external:option') |
|
| 34 | + ->setDescription('Manage mount options for a mount') |
|
| 35 | + ->addArgument( |
|
| 36 | + 'mount_id', |
|
| 37 | + InputArgument::REQUIRED, |
|
| 38 | + 'The id of the mount to edit' |
|
| 39 | + )->addArgument( |
|
| 40 | + 'key', |
|
| 41 | + InputArgument::REQUIRED, |
|
| 42 | + 'key of the mount option to set/get' |
|
| 43 | + )->addArgument( |
|
| 44 | + 'value', |
|
| 45 | + InputArgument::OPTIONAL, |
|
| 46 | + 'value to set the mount option to, when no value is provided the existing value will be printed' |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param StorageConfig $mount |
|
| 52 | - * @param string $key |
|
| 53 | - * @param OutputInterface $output |
|
| 54 | - */ |
|
| 55 | - protected function getOption(StorageConfig $mount, $key, OutputInterface $output) { |
|
| 56 | - $value = $mount->getMountOption($key); |
|
| 57 | - if (!is_string($value)) { // show bools and objects correctly |
|
| 58 | - $value = json_encode($value); |
|
| 59 | - } |
|
| 60 | - $output->writeln($value); |
|
| 61 | - } |
|
| 50 | + /** |
|
| 51 | + * @param StorageConfig $mount |
|
| 52 | + * @param string $key |
|
| 53 | + * @param OutputInterface $output |
|
| 54 | + */ |
|
| 55 | + protected function getOption(StorageConfig $mount, $key, OutputInterface $output) { |
|
| 56 | + $value = $mount->getMountOption($key); |
|
| 57 | + if (!is_string($value)) { // show bools and objects correctly |
|
| 58 | + $value = json_encode($value); |
|
| 59 | + } |
|
| 60 | + $output->writeln($value); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param StorageConfig $mount |
|
| 65 | - * @param string $key |
|
| 66 | - * @param string $value |
|
| 67 | - * @param OutputInterface $output |
|
| 68 | - */ |
|
| 69 | - protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) { |
|
| 70 | - $decoded = json_decode($value, true); |
|
| 71 | - if (!is_null($decoded)) { |
|
| 72 | - $value = $decoded; |
|
| 73 | - } |
|
| 74 | - $mount->setMountOption($key, $value); |
|
| 75 | - $this->globalService->updateStorage($mount); |
|
| 76 | - } |
|
| 63 | + /** |
|
| 64 | + * @param StorageConfig $mount |
|
| 65 | + * @param string $key |
|
| 66 | + * @param string $value |
|
| 67 | + * @param OutputInterface $output |
|
| 68 | + */ |
|
| 69 | + protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) { |
|
| 70 | + $decoded = json_decode($value, true); |
|
| 71 | + if (!is_null($decoded)) { |
|
| 72 | + $value = $decoded; |
|
| 73 | + } |
|
| 74 | + $mount->setMountOption($key, $value); |
|
| 75 | + $this->globalService->updateStorage($mount); |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | $backend = $input->getArgument('backend'); |
| 72 | 72 | if ($type) { |
| 73 | 73 | if (!isset($data[$type])) { |
| 74 | - $output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>'); |
|
| 74 | + $output->writeln('<error>Invalid type "'.$type.'". Possible values are "authentication" or "storage"</error>'); |
|
| 75 | 75 | return 1; |
| 76 | 76 | } |
| 77 | 77 | $data = $data[$type]; |
| 78 | 78 | |
| 79 | 79 | if ($backend) { |
| 80 | 80 | if (!isset($data[$backend])) { |
| 81 | - $output->writeln('<error>Unknown backend "' . $backend . '" of type "' . $type . '"</error>'); |
|
| 81 | + $output->writeln('<error>Unknown backend "'.$backend.'" of type "'.$type.'"</error>'); |
|
| 82 | 82 | return 1; |
| 83 | 83 | } |
| 84 | 84 | $data = $data[$backend]; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $result['storage_class'] = $backend->getStorageClass(); |
| 100 | 100 | $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes())); |
| 101 | 101 | $result['supported_authentication_backends'] = array_keys($authBackends); |
| 102 | - $authConfig = array_map(function (AuthMechanism $auth) { |
|
| 102 | + $authConfig = array_map(function(AuthMechanism $auth) { |
|
| 103 | 103 | return $this->serializeAuthBackend($auth)['configuration']; |
| 104 | 104 | }, $authBackends); |
| 105 | 105 | $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig); |
@@ -112,10 +112,10 @@ discard block |
||
| 112 | 112 | * @return string[] |
| 113 | 113 | */ |
| 114 | 114 | private function formatConfiguration(array $parameters) { |
| 115 | - $configuration = array_filter($parameters, function (DefinitionParameter $parameter) { |
|
| 115 | + $configuration = array_filter($parameters, function(DefinitionParameter $parameter) { |
|
| 116 | 116 | return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN; |
| 117 | 117 | }); |
| 118 | - return array_map(function (DefinitionParameter $parameter) { |
|
| 118 | + return array_map(function(DefinitionParameter $parameter) { |
|
| 119 | 119 | return $parameter->getTypeName(); |
| 120 | 120 | }, $configuration); |
| 121 | 121 | } |
@@ -33,92 +33,92 @@ |
||
| 33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
| 34 | 34 | |
| 35 | 35 | class Backends extends Base { |
| 36 | - /** @var BackendService */ |
|
| 37 | - private $backendService; |
|
| 36 | + /** @var BackendService */ |
|
| 37 | + private $backendService; |
|
| 38 | 38 | |
| 39 | - public function __construct(BackendService $backendService |
|
| 40 | - ) { |
|
| 41 | - parent::__construct(); |
|
| 39 | + public function __construct(BackendService $backendService |
|
| 40 | + ) { |
|
| 41 | + parent::__construct(); |
|
| 42 | 42 | |
| 43 | - $this->backendService = $backendService; |
|
| 44 | - } |
|
| 43 | + $this->backendService = $backendService; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - protected function configure() { |
|
| 47 | - $this |
|
| 48 | - ->setName('files_external:backends') |
|
| 49 | - ->setDescription('Show available authentication and storage backends') |
|
| 50 | - ->addArgument( |
|
| 51 | - 'type', |
|
| 52 | - InputArgument::OPTIONAL, |
|
| 53 | - 'only show backends of a certain type. Possible values are "authentication" or "storage"' |
|
| 54 | - )->addArgument( |
|
| 55 | - 'backend', |
|
| 56 | - InputArgument::OPTIONAL, |
|
| 57 | - 'only show information of a specific backend' |
|
| 58 | - ); |
|
| 59 | - parent::configure(); |
|
| 60 | - } |
|
| 46 | + protected function configure() { |
|
| 47 | + $this |
|
| 48 | + ->setName('files_external:backends') |
|
| 49 | + ->setDescription('Show available authentication and storage backends') |
|
| 50 | + ->addArgument( |
|
| 51 | + 'type', |
|
| 52 | + InputArgument::OPTIONAL, |
|
| 53 | + 'only show backends of a certain type. Possible values are "authentication" or "storage"' |
|
| 54 | + )->addArgument( |
|
| 55 | + 'backend', |
|
| 56 | + InputArgument::OPTIONAL, |
|
| 57 | + 'only show information of a specific backend' |
|
| 58 | + ); |
|
| 59 | + parent::configure(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 63 | - $authBackends = $this->backendService->getAuthMechanisms(); |
|
| 64 | - $storageBackends = $this->backendService->getBackends(); |
|
| 62 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 63 | + $authBackends = $this->backendService->getAuthMechanisms(); |
|
| 64 | + $storageBackends = $this->backendService->getBackends(); |
|
| 65 | 65 | |
| 66 | - $data = [ |
|
| 67 | - 'authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends), |
|
| 68 | - 'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends) |
|
| 69 | - ]; |
|
| 66 | + $data = [ |
|
| 67 | + 'authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends), |
|
| 68 | + 'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends) |
|
| 69 | + ]; |
|
| 70 | 70 | |
| 71 | - $type = $input->getArgument('type'); |
|
| 72 | - $backend = $input->getArgument('backend'); |
|
| 73 | - if ($type) { |
|
| 74 | - if (!isset($data[$type])) { |
|
| 75 | - $output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>'); |
|
| 76 | - return 1; |
|
| 77 | - } |
|
| 78 | - $data = $data[$type]; |
|
| 71 | + $type = $input->getArgument('type'); |
|
| 72 | + $backend = $input->getArgument('backend'); |
|
| 73 | + if ($type) { |
|
| 74 | + if (!isset($data[$type])) { |
|
| 75 | + $output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>'); |
|
| 76 | + return 1; |
|
| 77 | + } |
|
| 78 | + $data = $data[$type]; |
|
| 79 | 79 | |
| 80 | - if ($backend) { |
|
| 81 | - if (!isset($data[$backend])) { |
|
| 82 | - $output->writeln('<error>Unknown backend "' . $backend . '" of type "' . $type . '"</error>'); |
|
| 83 | - return 1; |
|
| 84 | - } |
|
| 85 | - $data = $data[$backend]; |
|
| 86 | - } |
|
| 87 | - } |
|
| 80 | + if ($backend) { |
|
| 81 | + if (!isset($data[$backend])) { |
|
| 82 | + $output->writeln('<error>Unknown backend "' . $backend . '" of type "' . $type . '"</error>'); |
|
| 83 | + return 1; |
|
| 84 | + } |
|
| 85 | + $data = $data[$backend]; |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $this->writeArrayInOutputFormat($input, $output, $data); |
|
| 90 | - return 0; |
|
| 91 | - } |
|
| 89 | + $this->writeArrayInOutputFormat($input, $output, $data); |
|
| 90 | + return 0; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - private function serializeAuthBackend(\JsonSerializable $backend) { |
|
| 94 | - $data = $backend->jsonSerialize(); |
|
| 95 | - $result = [ |
|
| 96 | - 'name' => $data['name'], |
|
| 97 | - 'identifier' => $data['identifier'], |
|
| 98 | - 'configuration' => $this->formatConfiguration($data['configuration']) |
|
| 99 | - ]; |
|
| 100 | - if ($backend instanceof Backend) { |
|
| 101 | - $result['storage_class'] = $backend->getStorageClass(); |
|
| 102 | - $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes())); |
|
| 103 | - $result['supported_authentication_backends'] = array_keys($authBackends); |
|
| 104 | - $authConfig = array_map(function (AuthMechanism $auth) { |
|
| 105 | - return $this->serializeAuthBackend($auth)['configuration']; |
|
| 106 | - }, $authBackends); |
|
| 107 | - $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig); |
|
| 108 | - } |
|
| 109 | - return $result; |
|
| 110 | - } |
|
| 93 | + private function serializeAuthBackend(\JsonSerializable $backend) { |
|
| 94 | + $data = $backend->jsonSerialize(); |
|
| 95 | + $result = [ |
|
| 96 | + 'name' => $data['name'], |
|
| 97 | + 'identifier' => $data['identifier'], |
|
| 98 | + 'configuration' => $this->formatConfiguration($data['configuration']) |
|
| 99 | + ]; |
|
| 100 | + if ($backend instanceof Backend) { |
|
| 101 | + $result['storage_class'] = $backend->getStorageClass(); |
|
| 102 | + $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes())); |
|
| 103 | + $result['supported_authentication_backends'] = array_keys($authBackends); |
|
| 104 | + $authConfig = array_map(function (AuthMechanism $auth) { |
|
| 105 | + return $this->serializeAuthBackend($auth)['configuration']; |
|
| 106 | + }, $authBackends); |
|
| 107 | + $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig); |
|
| 108 | + } |
|
| 109 | + return $result; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * @param DefinitionParameter[] $parameters |
|
| 114 | - * @return string[] |
|
| 115 | - */ |
|
| 116 | - private function formatConfiguration(array $parameters) { |
|
| 117 | - $configuration = array_filter($parameters, function (DefinitionParameter $parameter) { |
|
| 118 | - return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN; |
|
| 119 | - }); |
|
| 120 | - return array_map(function (DefinitionParameter $parameter) { |
|
| 121 | - return $parameter->getTypeName(); |
|
| 122 | - }, $configuration); |
|
| 123 | - } |
|
| 112 | + /** |
|
| 113 | + * @param DefinitionParameter[] $parameters |
|
| 114 | + * @return string[] |
|
| 115 | + */ |
|
| 116 | + private function formatConfiguration(array $parameters) { |
|
| 117 | + $configuration = array_filter($parameters, function (DefinitionParameter $parameter) { |
|
| 118 | + return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN; |
|
| 119 | + }); |
|
| 120 | + return array_map(function (DefinitionParameter $parameter) { |
|
| 121 | + return $parameter->getTypeName(); |
|
| 122 | + }, $configuration); |
|
| 123 | + } |
|
| 124 | 124 | } |