@@ -31,35 +31,35 @@ |
||
| 31 | 31 | * @package OC\Hooks |
| 32 | 32 | */ |
| 33 | 33 | abstract class ForwardingEmitter extends BasicEmitter { |
| 34 | - /** |
|
| 35 | - * @var \OC\Hooks\Emitter[] array |
|
| 36 | - */ |
|
| 37 | - private $forwardEmitters = []; |
|
| 34 | + /** |
|
| 35 | + * @var \OC\Hooks\Emitter[] array |
|
| 36 | + */ |
|
| 37 | + private $forwardEmitters = []; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $scope |
|
| 41 | - * @param string $method |
|
| 42 | - * @param callable $callback |
|
| 43 | - */ |
|
| 44 | - public function listen($scope, $method, callable $callback) { |
|
| 45 | - parent::listen($scope, $method, $callback); |
|
| 46 | - foreach ($this->forwardEmitters as $emitter) { |
|
| 47 | - $emitter->listen($scope, $method, $callback); |
|
| 48 | - } |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $scope |
|
| 41 | + * @param string $method |
|
| 42 | + * @param callable $callback |
|
| 43 | + */ |
|
| 44 | + public function listen($scope, $method, callable $callback) { |
|
| 45 | + parent::listen($scope, $method, $callback); |
|
| 46 | + foreach ($this->forwardEmitters as $emitter) { |
|
| 47 | + $emitter->listen($scope, $method, $callback); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param \OC\Hooks\Emitter $emitter |
|
| 53 | - */ |
|
| 54 | - protected function forward(Emitter $emitter) { |
|
| 55 | - $this->forwardEmitters[] = $emitter; |
|
| 51 | + /** |
|
| 52 | + * @param \OC\Hooks\Emitter $emitter |
|
| 53 | + */ |
|
| 54 | + protected function forward(Emitter $emitter) { |
|
| 55 | + $this->forwardEmitters[] = $emitter; |
|
| 56 | 56 | |
| 57 | - //forward all previously connected hooks |
|
| 58 | - foreach ($this->listeners as $key => $listeners) { |
|
| 59 | - list($scope, $method) = explode('::', $key, 2); |
|
| 60 | - foreach ($listeners as $listener) { |
|
| 61 | - $emitter->listen($scope, $method, $listener); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 57 | + //forward all previously connected hooks |
|
| 58 | + foreach ($this->listeners as $key => $listeners) { |
|
| 59 | + list($scope, $method) = explode('::', $key, 2); |
|
| 60 | + foreach ($listeners as $listener) { |
|
| 61 | + $emitter->listen($scope, $method, $listener); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -24,15 +24,15 @@ |
||
| 24 | 24 | namespace OC\Hooks; |
| 25 | 25 | |
| 26 | 26 | abstract class LegacyEmitter extends BasicEmitter { |
| 27 | - /** |
|
| 28 | - * @param string $scope |
|
| 29 | - * @param string $method |
|
| 30 | - * @param array $arguments |
|
| 31 | - * |
|
| 32 | - * @suppress PhanAccessMethodProtected |
|
| 33 | - */ |
|
| 34 | - protected function emit($scope, $method, array $arguments = []) { |
|
| 35 | - \OC_Hook::emit($scope, $method, $arguments); |
|
| 36 | - parent::emit($scope, $method, $arguments); |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * @param string $scope |
|
| 29 | + * @param string $method |
|
| 30 | + * @param array $arguments |
|
| 31 | + * |
|
| 32 | + * @suppress PhanAccessMethodProtected |
|
| 33 | + */ |
|
| 34 | + protected function emit($scope, $method, array $arguments = []) { |
|
| 35 | + \OC_Hook::emit($scope, $method, $arguments); |
|
| 36 | + parent::emit($scope, $method, $arguments); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $this->doFind($resource); |
| 76 | 76 | } catch (ResourceNotFoundException $e) { |
| 77 | 77 | $resourceApp = substr($resource, 0, strpos($resource, '/')); |
| 78 | - $this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]); |
|
| 78 | + $this->logger->debug('Could not find resource file "'.$e->getResourcePath().'"', ['app' => $resourceApp]); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | if (!empty($this->theme)) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->doFindTheme($resource); |
| 85 | 85 | } catch (ResourceNotFoundException $e) { |
| 86 | 86 | $resourceApp = substr($resource, 0, strpos($resource, '/')); |
| 87 | - $this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]); |
|
| 87 | + $this->logger->debug('Could not find resource file in theme "'.$e->getResourcePath().'"', ['app' => $resourceApp]); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | $this->resources[] = [$root, $webRoot, $file]; |
| 160 | 160 | |
| 161 | - if ($throw && !is_file($root . '/' . $file)) { |
|
| 161 | + if ($throw && !is_file($root.'/'.$file)) { |
|
| 162 | 162 | throw new ResourceNotFoundException($file, $webRoot); |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -30,173 +30,173 @@ |
||
| 30 | 30 | namespace OC\Template; |
| 31 | 31 | |
| 32 | 32 | abstract class ResourceLocator { |
| 33 | - protected $theme; |
|
| 34 | - |
|
| 35 | - protected $mapping; |
|
| 36 | - protected $serverroot; |
|
| 37 | - protected $thirdpartyroot; |
|
| 38 | - protected $webroot; |
|
| 39 | - |
|
| 40 | - protected $resources = []; |
|
| 41 | - |
|
| 42 | - /** @var \OCP\ILogger */ |
|
| 43 | - protected $logger; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param \OCP\ILogger $logger |
|
| 47 | - * @param string $theme |
|
| 48 | - * @param array $core_map |
|
| 49 | - * @param array $party_map |
|
| 50 | - */ |
|
| 51 | - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) { |
|
| 52 | - $this->logger = $logger; |
|
| 53 | - $this->theme = $theme; |
|
| 54 | - $this->mapping = $core_map + $party_map; |
|
| 55 | - $this->serverroot = key($core_map); |
|
| 56 | - $this->thirdpartyroot = key($party_map); |
|
| 57 | - $this->webroot = $this->mapping[$this->serverroot]; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @param string $resource |
|
| 62 | - */ |
|
| 63 | - abstract public function doFind($resource); |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param string $resource |
|
| 67 | - */ |
|
| 68 | - abstract public function doFindTheme($resource); |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Finds the resources and adds them to the list |
|
| 72 | - * |
|
| 73 | - * @param array $resources |
|
| 74 | - */ |
|
| 75 | - public function find($resources) { |
|
| 76 | - foreach ($resources as $resource) { |
|
| 77 | - try { |
|
| 78 | - $this->doFind($resource); |
|
| 79 | - } catch (ResourceNotFoundException $e) { |
|
| 80 | - $resourceApp = substr($resource, 0, strpos($resource, '/')); |
|
| 81 | - $this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]); |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - if (!empty($this->theme)) { |
|
| 85 | - foreach ($resources as $resource) { |
|
| 86 | - try { |
|
| 87 | - $this->doFindTheme($resource); |
|
| 88 | - } catch (ResourceNotFoundException $e) { |
|
| 89 | - $resourceApp = substr($resource, 0, strpos($resource, '/')); |
|
| 90 | - $this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * append the $file resource if exist at $root |
|
| 98 | - * |
|
| 99 | - * @param string $root path to check |
|
| 100 | - * @param string $file the filename |
|
| 101 | - * @param string|null $webRoot base for path, default map $root to $webRoot |
|
| 102 | - * @return bool True if the resource was found, false otherwise |
|
| 103 | - */ |
|
| 104 | - protected function appendIfExist($root, $file, $webRoot = null) { |
|
| 105 | - if (is_file($root.'/'.$file)) { |
|
| 106 | - $this->append($root, $file, $webRoot, false); |
|
| 107 | - return true; |
|
| 108 | - } |
|
| 109 | - return false; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Attempt to find the webRoot |
|
| 114 | - * |
|
| 115 | - * traverse the potential web roots upwards in the path |
|
| 116 | - * |
|
| 117 | - * example: |
|
| 118 | - * - root: /srv/www/apps/myapp |
|
| 119 | - * - available mappings: ['/srv/www'] |
|
| 120 | - * |
|
| 121 | - * First we check if a mapping for /srv/www/apps/myapp is available, |
|
| 122 | - * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a |
|
| 123 | - * valid web root |
|
| 124 | - * |
|
| 125 | - * @param string $root |
|
| 126 | - * @return string|null The web root or null on failure |
|
| 127 | - */ |
|
| 128 | - protected function findWebRoot($root) { |
|
| 129 | - $webRoot = null; |
|
| 130 | - $tmpRoot = $root; |
|
| 131 | - |
|
| 132 | - while ($webRoot === null) { |
|
| 133 | - if (isset($this->mapping[$tmpRoot])) { |
|
| 134 | - $webRoot = $this->mapping[$tmpRoot]; |
|
| 135 | - break; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($tmpRoot === '/') { |
|
| 139 | - break; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $tmpRoot = dirname($tmpRoot); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if ($webRoot === null) { |
|
| 146 | - $realpath = realpath($root); |
|
| 147 | - |
|
| 148 | - if ($realpath && ($realpath !== $root)) { |
|
| 149 | - return $this->findWebRoot($realpath); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $webRoot; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * append the $file resource at $root |
|
| 158 | - * |
|
| 159 | - * @param string $root path to check |
|
| 160 | - * @param string $file the filename |
|
| 161 | - * @param string|null $webRoot base for path, default map $root to $webRoot |
|
| 162 | - * @param bool $throw Throw an exception, when the route does not exist |
|
| 163 | - * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing |
|
| 164 | - */ |
|
| 165 | - protected function append($root, $file, $webRoot = null, $throw = true) { |
|
| 166 | - |
|
| 167 | - if (!is_string($root)) { |
|
| 168 | - if ($throw) { |
|
| 169 | - throw new ResourceNotFoundException($file, $webRoot); |
|
| 170 | - } |
|
| 171 | - return; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - if (!$webRoot) { |
|
| 175 | - $webRoot = $this->findWebRoot($root); |
|
| 176 | - |
|
| 177 | - if ($webRoot === null) { |
|
| 178 | - $webRoot = ''; |
|
| 179 | - $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [ |
|
| 180 | - 'app' => 'lib', |
|
| 181 | - 'root' => $root, |
|
| 182 | - 'file' => $file, |
|
| 183 | - 'webRoot' => $webRoot, |
|
| 184 | - 'throw' => $throw ? 'true' : 'false' |
|
| 185 | - ]); |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - $this->resources[] = [$root, $webRoot, $file]; |
|
| 189 | - |
|
| 190 | - if ($throw && !is_file($root . '/' . $file)) { |
|
| 191 | - throw new ResourceNotFoundException($file, $webRoot); |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Returns the list of all resources that should be loaded |
|
| 197 | - * @return array |
|
| 198 | - */ |
|
| 199 | - public function getResources() { |
|
| 200 | - return $this->resources; |
|
| 201 | - } |
|
| 33 | + protected $theme; |
|
| 34 | + |
|
| 35 | + protected $mapping; |
|
| 36 | + protected $serverroot; |
|
| 37 | + protected $thirdpartyroot; |
|
| 38 | + protected $webroot; |
|
| 39 | + |
|
| 40 | + protected $resources = []; |
|
| 41 | + |
|
| 42 | + /** @var \OCP\ILogger */ |
|
| 43 | + protected $logger; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param \OCP\ILogger $logger |
|
| 47 | + * @param string $theme |
|
| 48 | + * @param array $core_map |
|
| 49 | + * @param array $party_map |
|
| 50 | + */ |
|
| 51 | + public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) { |
|
| 52 | + $this->logger = $logger; |
|
| 53 | + $this->theme = $theme; |
|
| 54 | + $this->mapping = $core_map + $party_map; |
|
| 55 | + $this->serverroot = key($core_map); |
|
| 56 | + $this->thirdpartyroot = key($party_map); |
|
| 57 | + $this->webroot = $this->mapping[$this->serverroot]; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param string $resource |
|
| 62 | + */ |
|
| 63 | + abstract public function doFind($resource); |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param string $resource |
|
| 67 | + */ |
|
| 68 | + abstract public function doFindTheme($resource); |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Finds the resources and adds them to the list |
|
| 72 | + * |
|
| 73 | + * @param array $resources |
|
| 74 | + */ |
|
| 75 | + public function find($resources) { |
|
| 76 | + foreach ($resources as $resource) { |
|
| 77 | + try { |
|
| 78 | + $this->doFind($resource); |
|
| 79 | + } catch (ResourceNotFoundException $e) { |
|
| 80 | + $resourceApp = substr($resource, 0, strpos($resource, '/')); |
|
| 81 | + $this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + if (!empty($this->theme)) { |
|
| 85 | + foreach ($resources as $resource) { |
|
| 86 | + try { |
|
| 87 | + $this->doFindTheme($resource); |
|
| 88 | + } catch (ResourceNotFoundException $e) { |
|
| 89 | + $resourceApp = substr($resource, 0, strpos($resource, '/')); |
|
| 90 | + $this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * append the $file resource if exist at $root |
|
| 98 | + * |
|
| 99 | + * @param string $root path to check |
|
| 100 | + * @param string $file the filename |
|
| 101 | + * @param string|null $webRoot base for path, default map $root to $webRoot |
|
| 102 | + * @return bool True if the resource was found, false otherwise |
|
| 103 | + */ |
|
| 104 | + protected function appendIfExist($root, $file, $webRoot = null) { |
|
| 105 | + if (is_file($root.'/'.$file)) { |
|
| 106 | + $this->append($root, $file, $webRoot, false); |
|
| 107 | + return true; |
|
| 108 | + } |
|
| 109 | + return false; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Attempt to find the webRoot |
|
| 114 | + * |
|
| 115 | + * traverse the potential web roots upwards in the path |
|
| 116 | + * |
|
| 117 | + * example: |
|
| 118 | + * - root: /srv/www/apps/myapp |
|
| 119 | + * - available mappings: ['/srv/www'] |
|
| 120 | + * |
|
| 121 | + * First we check if a mapping for /srv/www/apps/myapp is available, |
|
| 122 | + * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a |
|
| 123 | + * valid web root |
|
| 124 | + * |
|
| 125 | + * @param string $root |
|
| 126 | + * @return string|null The web root or null on failure |
|
| 127 | + */ |
|
| 128 | + protected function findWebRoot($root) { |
|
| 129 | + $webRoot = null; |
|
| 130 | + $tmpRoot = $root; |
|
| 131 | + |
|
| 132 | + while ($webRoot === null) { |
|
| 133 | + if (isset($this->mapping[$tmpRoot])) { |
|
| 134 | + $webRoot = $this->mapping[$tmpRoot]; |
|
| 135 | + break; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($tmpRoot === '/') { |
|
| 139 | + break; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $tmpRoot = dirname($tmpRoot); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if ($webRoot === null) { |
|
| 146 | + $realpath = realpath($root); |
|
| 147 | + |
|
| 148 | + if ($realpath && ($realpath !== $root)) { |
|
| 149 | + return $this->findWebRoot($realpath); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $webRoot; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * append the $file resource at $root |
|
| 158 | + * |
|
| 159 | + * @param string $root path to check |
|
| 160 | + * @param string $file the filename |
|
| 161 | + * @param string|null $webRoot base for path, default map $root to $webRoot |
|
| 162 | + * @param bool $throw Throw an exception, when the route does not exist |
|
| 163 | + * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing |
|
| 164 | + */ |
|
| 165 | + protected function append($root, $file, $webRoot = null, $throw = true) { |
|
| 166 | + |
|
| 167 | + if (!is_string($root)) { |
|
| 168 | + if ($throw) { |
|
| 169 | + throw new ResourceNotFoundException($file, $webRoot); |
|
| 170 | + } |
|
| 171 | + return; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + if (!$webRoot) { |
|
| 175 | + $webRoot = $this->findWebRoot($root); |
|
| 176 | + |
|
| 177 | + if ($webRoot === null) { |
|
| 178 | + $webRoot = ''; |
|
| 179 | + $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [ |
|
| 180 | + 'app' => 'lib', |
|
| 181 | + 'root' => $root, |
|
| 182 | + 'file' => $file, |
|
| 183 | + 'webRoot' => $webRoot, |
|
| 184 | + 'throw' => $throw ? 'true' : 'false' |
|
| 185 | + ]); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + $this->resources[] = [$root, $webRoot, $file]; |
|
| 189 | + |
|
| 190 | + if ($throw && !is_file($root . '/' . $file)) { |
|
| 191 | + throw new ResourceNotFoundException($file, $webRoot); |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Returns the list of all resources that should be loaded |
|
| 197 | + * @return array |
|
| 198 | + */ |
|
| 199 | + public function getResources() { |
|
| 200 | + return $this->resources; |
|
| 201 | + } |
|
| 202 | 202 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | // always add owner to the list of users with access to the file |
| 74 | 74 | $userIds = [$owner]; |
| 75 | 75 | |
| 76 | - if (!$this->util->isFile($owner . '/' . $ownerPath)) { |
|
| 76 | + if (!$this->util->isFile($owner.'/'.$ownerPath)) { |
|
| 77 | 77 | return ['users' => $userIds, 'public' => false]; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -33,95 +33,95 @@ |
||
| 33 | 33 | |
| 34 | 34 | class File implements \OCP\Encryption\IFile { |
| 35 | 35 | |
| 36 | - /** @var Util */ |
|
| 37 | - protected $util; |
|
| 38 | - |
|
| 39 | - /** @var IRootFolder */ |
|
| 40 | - private $rootFolder; |
|
| 41 | - |
|
| 42 | - /** @var IManager */ |
|
| 43 | - private $shareManager; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * cache results of already checked folders |
|
| 47 | - * |
|
| 48 | - * @var array |
|
| 49 | - */ |
|
| 50 | - protected $cache; |
|
| 51 | - |
|
| 52 | - public function __construct(Util $util, |
|
| 53 | - IRootFolder $rootFolder, |
|
| 54 | - IManager $shareManager) { |
|
| 55 | - $this->util = $util; |
|
| 56 | - $this->cache = new CappedMemoryCache(); |
|
| 57 | - $this->rootFolder = $rootFolder; |
|
| 58 | - $this->shareManager = $shareManager; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * get list of users with access to the file |
|
| 64 | - * |
|
| 65 | - * @param string $path to the file |
|
| 66 | - * @return array ['users' => $uniqueUserIds, 'public' => $public] |
|
| 67 | - */ |
|
| 68 | - public function getAccessList($path) { |
|
| 69 | - |
|
| 70 | - // Make sure that a share key is generated for the owner too |
|
| 71 | - list($owner, $ownerPath) = $this->util->getUidAndFilename($path); |
|
| 72 | - |
|
| 73 | - // always add owner to the list of users with access to the file |
|
| 74 | - $userIds = [$owner]; |
|
| 75 | - |
|
| 76 | - if (!$this->util->isFile($owner . '/' . $ownerPath)) { |
|
| 77 | - return ['users' => $userIds, 'public' => false]; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - $ownerPath = substr($ownerPath, strlen('/files')); |
|
| 81 | - $userFolder = $this->rootFolder->getUserFolder($owner); |
|
| 82 | - try { |
|
| 83 | - $file = $userFolder->get($ownerPath); |
|
| 84 | - } catch (NotFoundException $e) { |
|
| 85 | - $file = null; |
|
| 86 | - } |
|
| 87 | - $ownerPath = $this->util->stripPartialFileExtension($ownerPath); |
|
| 88 | - |
|
| 89 | - // first get the shares for the parent and cache the result so that we don't |
|
| 90 | - // need to check all parents for every file |
|
| 91 | - $parent = dirname($ownerPath); |
|
| 92 | - $parentNode = $userFolder->get($parent); |
|
| 93 | - if (isset($this->cache[$parent])) { |
|
| 94 | - $resultForParents = $this->cache[$parent]; |
|
| 95 | - } else { |
|
| 96 | - $resultForParents = $this->shareManager->getAccessList($parentNode); |
|
| 97 | - $this->cache[$parent] = $resultForParents; |
|
| 98 | - } |
|
| 99 | - $userIds = array_merge($userIds, $resultForParents['users']); |
|
| 100 | - $public = $resultForParents['public'] || $resultForParents['remote']; |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - // Find out who, if anyone, is sharing the file |
|
| 104 | - if ($file !== null) { |
|
| 105 | - $resultForFile = $this->shareManager->getAccessList($file, false); |
|
| 106 | - $userIds = array_merge($userIds, $resultForFile['users']); |
|
| 107 | - $public = $resultForFile['public'] || $resultForFile['remote'] || $public; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - // check if it is a group mount |
|
| 111 | - if (\OCP\App::isEnabled("files_external")) { |
|
| 112 | - $mounts = \OC_Mount_Config::getSystemMountPoints(); |
|
| 113 | - foreach ($mounts as $mount) { |
|
| 114 | - if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) { |
|
| 115 | - $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']); |
|
| 116 | - $userIds = array_merge($userIds, $mountedFor); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // Remove duplicate UIDs |
|
| 122 | - $uniqueUserIds = array_unique($userIds); |
|
| 123 | - |
|
| 124 | - return ['users' => $uniqueUserIds, 'public' => $public]; |
|
| 125 | - } |
|
| 36 | + /** @var Util */ |
|
| 37 | + protected $util; |
|
| 38 | + |
|
| 39 | + /** @var IRootFolder */ |
|
| 40 | + private $rootFolder; |
|
| 41 | + |
|
| 42 | + /** @var IManager */ |
|
| 43 | + private $shareManager; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * cache results of already checked folders |
|
| 47 | + * |
|
| 48 | + * @var array |
|
| 49 | + */ |
|
| 50 | + protected $cache; |
|
| 51 | + |
|
| 52 | + public function __construct(Util $util, |
|
| 53 | + IRootFolder $rootFolder, |
|
| 54 | + IManager $shareManager) { |
|
| 55 | + $this->util = $util; |
|
| 56 | + $this->cache = new CappedMemoryCache(); |
|
| 57 | + $this->rootFolder = $rootFolder; |
|
| 58 | + $this->shareManager = $shareManager; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * get list of users with access to the file |
|
| 64 | + * |
|
| 65 | + * @param string $path to the file |
|
| 66 | + * @return array ['users' => $uniqueUserIds, 'public' => $public] |
|
| 67 | + */ |
|
| 68 | + public function getAccessList($path) { |
|
| 69 | + |
|
| 70 | + // Make sure that a share key is generated for the owner too |
|
| 71 | + list($owner, $ownerPath) = $this->util->getUidAndFilename($path); |
|
| 72 | + |
|
| 73 | + // always add owner to the list of users with access to the file |
|
| 74 | + $userIds = [$owner]; |
|
| 75 | + |
|
| 76 | + if (!$this->util->isFile($owner . '/' . $ownerPath)) { |
|
| 77 | + return ['users' => $userIds, 'public' => false]; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + $ownerPath = substr($ownerPath, strlen('/files')); |
|
| 81 | + $userFolder = $this->rootFolder->getUserFolder($owner); |
|
| 82 | + try { |
|
| 83 | + $file = $userFolder->get($ownerPath); |
|
| 84 | + } catch (NotFoundException $e) { |
|
| 85 | + $file = null; |
|
| 86 | + } |
|
| 87 | + $ownerPath = $this->util->stripPartialFileExtension($ownerPath); |
|
| 88 | + |
|
| 89 | + // first get the shares for the parent and cache the result so that we don't |
|
| 90 | + // need to check all parents for every file |
|
| 91 | + $parent = dirname($ownerPath); |
|
| 92 | + $parentNode = $userFolder->get($parent); |
|
| 93 | + if (isset($this->cache[$parent])) { |
|
| 94 | + $resultForParents = $this->cache[$parent]; |
|
| 95 | + } else { |
|
| 96 | + $resultForParents = $this->shareManager->getAccessList($parentNode); |
|
| 97 | + $this->cache[$parent] = $resultForParents; |
|
| 98 | + } |
|
| 99 | + $userIds = array_merge($userIds, $resultForParents['users']); |
|
| 100 | + $public = $resultForParents['public'] || $resultForParents['remote']; |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + // Find out who, if anyone, is sharing the file |
|
| 104 | + if ($file !== null) { |
|
| 105 | + $resultForFile = $this->shareManager->getAccessList($file, false); |
|
| 106 | + $userIds = array_merge($userIds, $resultForFile['users']); |
|
| 107 | + $public = $resultForFile['public'] || $resultForFile['remote'] || $public; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + // check if it is a group mount |
|
| 111 | + if (\OCP\App::isEnabled("files_external")) { |
|
| 112 | + $mounts = \OC_Mount_Config::getSystemMountPoints(); |
|
| 113 | + foreach ($mounts as $mount) { |
|
| 114 | + if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) { |
|
| 115 | + $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']); |
|
| 116 | + $userIds = array_merge($userIds, $mountedFor); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // Remove duplicate UIDs |
|
| 122 | + $uniqueUserIds = array_unique($userIds); |
|
| 123 | + |
|
| 124 | + return ['users' => $uniqueUserIds, 'public' => $public]; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin(); |
| 61 | 61 | $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin(); |
| 62 | 62 | |
| 63 | -$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) { |
|
| 63 | +$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function(\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) { |
|
| 64 | 64 | $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'); |
| 65 | 65 | $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
| 66 | 66 | $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
| 78 | 78 | $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
| 79 | - \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { |
|
| 79 | + \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function($mountPoint, $storage) use ($share) { |
|
| 80 | 80 | return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]); |
| 81 | 81 | }); |
| 82 | 82 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | OC_Util::tearDownFS(); |
| 86 | 86 | OC_Util::setupFS($owner); |
| 87 | - $ownerView = new \OC\Files\View('/'. $owner . '/files'); |
|
| 87 | + $ownerView = new \OC\Files\View('/'.$owner.'/files'); |
|
| 88 | 88 | $path = $ownerView->getPath($fileId); |
| 89 | 89 | $fileInfo = $ownerView->getFileInfo($path); |
| 90 | 90 | $linkCheckPlugin->setFileInfo($fileInfo); |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // Backends |
| 41 | 41 | $authBackend = new OCA\DAV\Connector\PublicAuth( |
| 42 | - \OC::$server->getRequest(), |
|
| 43 | - \OC::$server->getShareManager(), |
|
| 44 | - \OC::$server->getSession() |
|
| 42 | + \OC::$server->getRequest(), |
|
| 43 | + \OC::$server->getShareManager(), |
|
| 44 | + \OC::$server->getSession() |
|
| 45 | 45 | ); |
| 46 | 46 | $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend); |
| 47 | 47 | |
| 48 | 48 | $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory( |
| 49 | - \OC::$server->getConfig(), |
|
| 50 | - \OC::$server->getLogger(), |
|
| 51 | - \OC::$server->getDatabaseConnection(), |
|
| 52 | - \OC::$server->getUserSession(), |
|
| 53 | - \OC::$server->getMountManager(), |
|
| 54 | - \OC::$server->getTagManager(), |
|
| 55 | - \OC::$server->getRequest(), |
|
| 56 | - \OC::$server->getPreviewManager(), |
|
| 57 | - \OC::$server->getEventDispatcher() |
|
| 49 | + \OC::$server->getConfig(), |
|
| 50 | + \OC::$server->getLogger(), |
|
| 51 | + \OC::$server->getDatabaseConnection(), |
|
| 52 | + \OC::$server->getUserSession(), |
|
| 53 | + \OC::$server->getMountManager(), |
|
| 54 | + \OC::$server->getTagManager(), |
|
| 55 | + \OC::$server->getRequest(), |
|
| 56 | + \OC::$server->getPreviewManager(), |
|
| 57 | + \OC::$server->getEventDispatcher() |
|
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
@@ -63,43 +63,43 @@ discard block |
||
| 63 | 63 | $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin(); |
| 64 | 64 | |
| 65 | 65 | $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) { |
| 66 | - $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'); |
|
| 67 | - $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
| 68 | - $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
|
| 69 | - if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) { |
|
| 70 | - // this is what is thrown when trying to access a non-existing share |
|
| 71 | - throw new \Sabre\DAV\Exception\NotAuthenticated(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - $share = $authBackend->getShare(); |
|
| 75 | - $owner = $share->getShareOwner(); |
|
| 76 | - $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ; |
|
| 77 | - $fileId = $share->getNodeId(); |
|
| 78 | - |
|
| 79 | - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
| 80 | - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
| 81 | - \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { |
|
| 82 | - return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]); |
|
| 83 | - }); |
|
| 84 | - |
|
| 85 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
| 86 | - |
|
| 87 | - OC_Util::tearDownFS(); |
|
| 88 | - OC_Util::setupFS($owner); |
|
| 89 | - $ownerView = new \OC\Files\View('/'. $owner . '/files'); |
|
| 90 | - $path = $ownerView->getPath($fileId); |
|
| 91 | - $fileInfo = $ownerView->getFileInfo($path); |
|
| 92 | - $linkCheckPlugin->setFileInfo($fileInfo); |
|
| 93 | - |
|
| 94 | - // If not readble (files_drop) enable the filesdrop plugin |
|
| 95 | - if (!$isReadable) { |
|
| 96 | - $filesDropPlugin->enable(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $view = new \OC\Files\View($ownerView->getAbsolutePath($path)); |
|
| 100 | - $filesDropPlugin->setView($view); |
|
| 101 | - |
|
| 102 | - return $view; |
|
| 66 | + $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'); |
|
| 67 | + $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
| 68 | + $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
|
| 69 | + if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) { |
|
| 70 | + // this is what is thrown when trying to access a non-existing share |
|
| 71 | + throw new \Sabre\DAV\Exception\NotAuthenticated(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + $share = $authBackend->getShare(); |
|
| 75 | + $owner = $share->getShareOwner(); |
|
| 76 | + $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ; |
|
| 77 | + $fileId = $share->getNodeId(); |
|
| 78 | + |
|
| 79 | + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
| 80 | + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
| 81 | + \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { |
|
| 82 | + return new \OC\Files\Storage\Wrapper\PermissionsMask(['storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE]); |
|
| 83 | + }); |
|
| 84 | + |
|
| 85 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
| 86 | + |
|
| 87 | + OC_Util::tearDownFS(); |
|
| 88 | + OC_Util::setupFS($owner); |
|
| 89 | + $ownerView = new \OC\Files\View('/'. $owner . '/files'); |
|
| 90 | + $path = $ownerView->getPath($fileId); |
|
| 91 | + $fileInfo = $ownerView->getFileInfo($path); |
|
| 92 | + $linkCheckPlugin->setFileInfo($fileInfo); |
|
| 93 | + |
|
| 94 | + // If not readble (files_drop) enable the filesdrop plugin |
|
| 95 | + if (!$isReadable) { |
|
| 96 | + $filesDropPlugin->enable(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $view = new \OC\Files\View($ownerView->getAbsolutePath($path)); |
|
| 100 | + $filesDropPlugin->setView($view); |
|
| 101 | + |
|
| 102 | + return $view; |
|
| 103 | 103 | }); |
| 104 | 104 | |
| 105 | 105 | $server->addPlugin($linkCheckPlugin); |
@@ -197,7 +197,7 @@ |
||
| 197 | 197 | } catch (NotFoundException $e) { |
| 198 | 198 | return new DataResponse( |
| 199 | 199 | [ |
| 200 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 200 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 201 | 201 | ], |
| 202 | 202 | Http::STATUS_NOT_FOUND |
| 203 | 203 | ); |
@@ -44,185 +44,185 @@ |
||
| 44 | 44 | * User storages controller |
| 45 | 45 | */ |
| 46 | 46 | class UserStoragesController extends StoragesController { |
| 47 | - /** |
|
| 48 | - * @var IUserSession |
|
| 49 | - */ |
|
| 50 | - private $userSession; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Creates a new user storages controller. |
|
| 54 | - * |
|
| 55 | - * @param string $AppName application name |
|
| 56 | - * @param IRequest $request request object |
|
| 57 | - * @param IL10N $l10n l10n service |
|
| 58 | - * @param UserStoragesService $userStoragesService storage service |
|
| 59 | - * @param IUserSession $userSession |
|
| 60 | - * @param ILogger $logger |
|
| 61 | - */ |
|
| 62 | - public function __construct( |
|
| 63 | - $AppName, |
|
| 64 | - IRequest $request, |
|
| 65 | - IL10N $l10n, |
|
| 66 | - UserStoragesService $userStoragesService, |
|
| 67 | - IUserSession $userSession, |
|
| 68 | - ILogger $logger |
|
| 69 | - ) { |
|
| 70 | - parent::__construct( |
|
| 71 | - $AppName, |
|
| 72 | - $request, |
|
| 73 | - $l10n, |
|
| 74 | - $userStoragesService, |
|
| 75 | - $logger |
|
| 76 | - ); |
|
| 77 | - $this->userSession = $userSession; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
| 81 | - /** @var AuthMechanism */ |
|
| 82 | - $authMechanism = $storage->getAuthMechanism(); |
|
| 83 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 84 | - /** @var Backend */ |
|
| 85 | - $backend = $storage->getBackend(); |
|
| 86 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Get all storage entries |
|
| 91 | - * |
|
| 92 | - * @NoAdminRequired |
|
| 93 | - * |
|
| 94 | - * @return DataResponse |
|
| 95 | - */ |
|
| 96 | - public function index() { |
|
| 97 | - return parent::index(); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Return storage |
|
| 102 | - * |
|
| 103 | - * @NoAdminRequired |
|
| 104 | - * |
|
| 105 | - * {@inheritdoc} |
|
| 106 | - */ |
|
| 107 | - public function show($id, $testOnly = true) { |
|
| 108 | - return parent::show($id, $testOnly); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Create an external storage entry. |
|
| 113 | - * |
|
| 114 | - * @param string $mountPoint storage mount point |
|
| 115 | - * @param string $backend backend identifier |
|
| 116 | - * @param string $authMechanism authentication mechanism identifier |
|
| 117 | - * @param array $backendOptions backend-specific options |
|
| 118 | - * @param array $mountOptions backend-specific mount options |
|
| 119 | - * |
|
| 120 | - * @return DataResponse |
|
| 121 | - * |
|
| 122 | - * @NoAdminRequired |
|
| 123 | - */ |
|
| 124 | - public function create( |
|
| 125 | - $mountPoint, |
|
| 126 | - $backend, |
|
| 127 | - $authMechanism, |
|
| 128 | - $backendOptions, |
|
| 129 | - $mountOptions |
|
| 130 | - ) { |
|
| 131 | - $newStorage = $this->createStorage( |
|
| 132 | - $mountPoint, |
|
| 133 | - $backend, |
|
| 134 | - $authMechanism, |
|
| 135 | - $backendOptions, |
|
| 136 | - $mountOptions |
|
| 137 | - ); |
|
| 138 | - if ($newStorage instanceOf DataResponse) { |
|
| 139 | - return $newStorage; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $response = $this->validate($newStorage); |
|
| 143 | - if (!empty($response)) { |
|
| 144 | - return $response; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - $newStorage = $this->service->addStorage($newStorage); |
|
| 148 | - $this->updateStorageStatus($newStorage); |
|
| 149 | - |
|
| 150 | - return new DataResponse( |
|
| 151 | - $this->formatStorageForUI($newStorage), |
|
| 152 | - Http::STATUS_CREATED |
|
| 153 | - ); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Update an external storage entry. |
|
| 158 | - * |
|
| 159 | - * @param int $id storage id |
|
| 160 | - * @param string $mountPoint storage mount point |
|
| 161 | - * @param string $backend backend identifier |
|
| 162 | - * @param string $authMechanism authentication mechanism identifier |
|
| 163 | - * @param array $backendOptions backend-specific options |
|
| 164 | - * @param array $mountOptions backend-specific mount options |
|
| 165 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 166 | - * |
|
| 167 | - * @return DataResponse |
|
| 168 | - * |
|
| 169 | - * @NoAdminRequired |
|
| 170 | - */ |
|
| 171 | - public function update( |
|
| 172 | - $id, |
|
| 173 | - $mountPoint, |
|
| 174 | - $backend, |
|
| 175 | - $authMechanism, |
|
| 176 | - $backendOptions, |
|
| 177 | - $mountOptions, |
|
| 178 | - $testOnly = true |
|
| 179 | - ) { |
|
| 180 | - $storage = $this->createStorage( |
|
| 181 | - $mountPoint, |
|
| 182 | - $backend, |
|
| 183 | - $authMechanism, |
|
| 184 | - $backendOptions, |
|
| 185 | - $mountOptions |
|
| 186 | - ); |
|
| 187 | - if ($storage instanceOf DataResponse) { |
|
| 188 | - return $storage; |
|
| 189 | - } |
|
| 190 | - $storage->setId($id); |
|
| 191 | - |
|
| 192 | - $response = $this->validate($storage); |
|
| 193 | - if (!empty($response)) { |
|
| 194 | - return $response; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - try { |
|
| 198 | - $storage = $this->service->updateStorage($storage); |
|
| 199 | - } catch (NotFoundException $e) { |
|
| 200 | - return new DataResponse( |
|
| 201 | - [ |
|
| 202 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 203 | - ], |
|
| 204 | - Http::STATUS_NOT_FOUND |
|
| 205 | - ); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $this->updateStorageStatus($storage, $testOnly); |
|
| 209 | - |
|
| 210 | - return new DataResponse( |
|
| 211 | - $this->formatStorageForUI($storage), |
|
| 212 | - Http::STATUS_OK |
|
| 213 | - ); |
|
| 214 | - |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * Delete storage |
|
| 219 | - * |
|
| 220 | - * @NoAdminRequired |
|
| 221 | - * |
|
| 222 | - * {@inheritdoc} |
|
| 223 | - */ |
|
| 224 | - public function destroy($id) { |
|
| 225 | - return parent::destroy($id); |
|
| 226 | - } |
|
| 47 | + /** |
|
| 48 | + * @var IUserSession |
|
| 49 | + */ |
|
| 50 | + private $userSession; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Creates a new user storages controller. |
|
| 54 | + * |
|
| 55 | + * @param string $AppName application name |
|
| 56 | + * @param IRequest $request request object |
|
| 57 | + * @param IL10N $l10n l10n service |
|
| 58 | + * @param UserStoragesService $userStoragesService storage service |
|
| 59 | + * @param IUserSession $userSession |
|
| 60 | + * @param ILogger $logger |
|
| 61 | + */ |
|
| 62 | + public function __construct( |
|
| 63 | + $AppName, |
|
| 64 | + IRequest $request, |
|
| 65 | + IL10N $l10n, |
|
| 66 | + UserStoragesService $userStoragesService, |
|
| 67 | + IUserSession $userSession, |
|
| 68 | + ILogger $logger |
|
| 69 | + ) { |
|
| 70 | + parent::__construct( |
|
| 71 | + $AppName, |
|
| 72 | + $request, |
|
| 73 | + $l10n, |
|
| 74 | + $userStoragesService, |
|
| 75 | + $logger |
|
| 76 | + ); |
|
| 77 | + $this->userSession = $userSession; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
| 81 | + /** @var AuthMechanism */ |
|
| 82 | + $authMechanism = $storage->getAuthMechanism(); |
|
| 83 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 84 | + /** @var Backend */ |
|
| 85 | + $backend = $storage->getBackend(); |
|
| 86 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Get all storage entries |
|
| 91 | + * |
|
| 92 | + * @NoAdminRequired |
|
| 93 | + * |
|
| 94 | + * @return DataResponse |
|
| 95 | + */ |
|
| 96 | + public function index() { |
|
| 97 | + return parent::index(); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Return storage |
|
| 102 | + * |
|
| 103 | + * @NoAdminRequired |
|
| 104 | + * |
|
| 105 | + * {@inheritdoc} |
|
| 106 | + */ |
|
| 107 | + public function show($id, $testOnly = true) { |
|
| 108 | + return parent::show($id, $testOnly); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Create an external storage entry. |
|
| 113 | + * |
|
| 114 | + * @param string $mountPoint storage mount point |
|
| 115 | + * @param string $backend backend identifier |
|
| 116 | + * @param string $authMechanism authentication mechanism identifier |
|
| 117 | + * @param array $backendOptions backend-specific options |
|
| 118 | + * @param array $mountOptions backend-specific mount options |
|
| 119 | + * |
|
| 120 | + * @return DataResponse |
|
| 121 | + * |
|
| 122 | + * @NoAdminRequired |
|
| 123 | + */ |
|
| 124 | + public function create( |
|
| 125 | + $mountPoint, |
|
| 126 | + $backend, |
|
| 127 | + $authMechanism, |
|
| 128 | + $backendOptions, |
|
| 129 | + $mountOptions |
|
| 130 | + ) { |
|
| 131 | + $newStorage = $this->createStorage( |
|
| 132 | + $mountPoint, |
|
| 133 | + $backend, |
|
| 134 | + $authMechanism, |
|
| 135 | + $backendOptions, |
|
| 136 | + $mountOptions |
|
| 137 | + ); |
|
| 138 | + if ($newStorage instanceOf DataResponse) { |
|
| 139 | + return $newStorage; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $response = $this->validate($newStorage); |
|
| 143 | + if (!empty($response)) { |
|
| 144 | + return $response; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + $newStorage = $this->service->addStorage($newStorage); |
|
| 148 | + $this->updateStorageStatus($newStorage); |
|
| 149 | + |
|
| 150 | + return new DataResponse( |
|
| 151 | + $this->formatStorageForUI($newStorage), |
|
| 152 | + Http::STATUS_CREATED |
|
| 153 | + ); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Update an external storage entry. |
|
| 158 | + * |
|
| 159 | + * @param int $id storage id |
|
| 160 | + * @param string $mountPoint storage mount point |
|
| 161 | + * @param string $backend backend identifier |
|
| 162 | + * @param string $authMechanism authentication mechanism identifier |
|
| 163 | + * @param array $backendOptions backend-specific options |
|
| 164 | + * @param array $mountOptions backend-specific mount options |
|
| 165 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 166 | + * |
|
| 167 | + * @return DataResponse |
|
| 168 | + * |
|
| 169 | + * @NoAdminRequired |
|
| 170 | + */ |
|
| 171 | + public function update( |
|
| 172 | + $id, |
|
| 173 | + $mountPoint, |
|
| 174 | + $backend, |
|
| 175 | + $authMechanism, |
|
| 176 | + $backendOptions, |
|
| 177 | + $mountOptions, |
|
| 178 | + $testOnly = true |
|
| 179 | + ) { |
|
| 180 | + $storage = $this->createStorage( |
|
| 181 | + $mountPoint, |
|
| 182 | + $backend, |
|
| 183 | + $authMechanism, |
|
| 184 | + $backendOptions, |
|
| 185 | + $mountOptions |
|
| 186 | + ); |
|
| 187 | + if ($storage instanceOf DataResponse) { |
|
| 188 | + return $storage; |
|
| 189 | + } |
|
| 190 | + $storage->setId($id); |
|
| 191 | + |
|
| 192 | + $response = $this->validate($storage); |
|
| 193 | + if (!empty($response)) { |
|
| 194 | + return $response; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + try { |
|
| 198 | + $storage = $this->service->updateStorage($storage); |
|
| 199 | + } catch (NotFoundException $e) { |
|
| 200 | + return new DataResponse( |
|
| 201 | + [ |
|
| 202 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 203 | + ], |
|
| 204 | + Http::STATUS_NOT_FOUND |
|
| 205 | + ); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $this->updateStorageStatus($storage, $testOnly); |
|
| 209 | + |
|
| 210 | + return new DataResponse( |
|
| 211 | + $this->formatStorageForUI($storage), |
|
| 212 | + Http::STATUS_OK |
|
| 213 | + ); |
|
| 214 | + |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * Delete storage |
|
| 219 | + * |
|
| 220 | + * @NoAdminRequired |
|
| 221 | + * |
|
| 222 | + * {@inheritdoc} |
|
| 223 | + */ |
|
| 224 | + public function destroy($id) { |
|
| 225 | + return parent::destroy($id); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } catch (NotFoundException $e) { |
| 123 | 123 | return new DataResponse( |
| 124 | 124 | [ |
| 125 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 125 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 126 | 126 | ], |
| 127 | 127 | Http::STATUS_NOT_FOUND |
| 128 | 128 | ); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } else { |
| 163 | 163 | return new DataResponse( |
| 164 | 164 | [ |
| 165 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
| 165 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
| 166 | 166 | ], |
| 167 | 167 | Http::STATUS_FORBIDDEN |
| 168 | 168 | ); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } catch (NotFoundException $e) { |
| 171 | 171 | return new DataResponse( |
| 172 | 172 | [ |
| 173 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 173 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 174 | 174 | ], |
| 175 | 175 | Http::STATUS_NOT_FOUND |
| 176 | 176 | ); |
@@ -45,165 +45,165 @@ |
||
| 45 | 45 | * User global storages controller |
| 46 | 46 | */ |
| 47 | 47 | class UserGlobalStoragesController extends StoragesController { |
| 48 | - /** |
|
| 49 | - * @var IUserSession |
|
| 50 | - */ |
|
| 51 | - private $userSession; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Creates a new user global storages controller. |
|
| 55 | - * |
|
| 56 | - * @param string $AppName application name |
|
| 57 | - * @param IRequest $request request object |
|
| 58 | - * @param IL10N $l10n l10n service |
|
| 59 | - * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
| 60 | - * @param IUserSession $userSession |
|
| 61 | - */ |
|
| 62 | - public function __construct( |
|
| 63 | - $AppName, |
|
| 64 | - IRequest $request, |
|
| 65 | - IL10N $l10n, |
|
| 66 | - UserGlobalStoragesService $userGlobalStoragesService, |
|
| 67 | - IUserSession $userSession, |
|
| 68 | - ILogger $logger |
|
| 69 | - ) { |
|
| 70 | - parent::__construct( |
|
| 71 | - $AppName, |
|
| 72 | - $request, |
|
| 73 | - $l10n, |
|
| 74 | - $userGlobalStoragesService, |
|
| 75 | - $logger |
|
| 76 | - ); |
|
| 77 | - $this->userSession = $userSession; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Get all storage entries |
|
| 82 | - * |
|
| 83 | - * @return DataResponse |
|
| 84 | - * |
|
| 85 | - * @NoAdminRequired |
|
| 86 | - */ |
|
| 87 | - public function index() { |
|
| 88 | - $storages = $this->formatStoragesForUI($this->service->getUniqueStorages()); |
|
| 89 | - |
|
| 90 | - // remove configuration data, this must be kept private |
|
| 91 | - foreach ($storages as $storage) { |
|
| 92 | - $this->sanitizeStorage($storage); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - return new DataResponse( |
|
| 96 | - $storages, |
|
| 97 | - Http::STATUS_OK |
|
| 98 | - ); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - protected function manipulateStorageConfig(StorageConfig $storage) { |
|
| 102 | - /** @var AuthMechanism */ |
|
| 103 | - $authMechanism = $storage->getAuthMechanism(); |
|
| 104 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 105 | - /** @var Backend */ |
|
| 106 | - $backend = $storage->getBackend(); |
|
| 107 | - $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Get an external storage entry. |
|
| 112 | - * |
|
| 113 | - * @param int $id storage id |
|
| 114 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 115 | - * @return DataResponse |
|
| 116 | - * |
|
| 117 | - * @NoAdminRequired |
|
| 118 | - */ |
|
| 119 | - public function show($id, $testOnly = true) { |
|
| 120 | - try { |
|
| 121 | - $storage = $this->service->getStorage($id); |
|
| 122 | - |
|
| 123 | - $this->updateStorageStatus($storage, $testOnly); |
|
| 124 | - } catch (NotFoundException $e) { |
|
| 125 | - return new DataResponse( |
|
| 126 | - [ |
|
| 127 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 128 | - ], |
|
| 129 | - Http::STATUS_NOT_FOUND |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $this->sanitizeStorage($storage); |
|
| 134 | - |
|
| 135 | - return new DataResponse( |
|
| 136 | - $this->formatStorageForUI($storage), |
|
| 137 | - Http::STATUS_OK |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Update an external storage entry. |
|
| 143 | - * Only allows setting user provided backend fields |
|
| 144 | - * |
|
| 145 | - * @param int $id storage id |
|
| 146 | - * @param array $backendOptions backend-specific options |
|
| 147 | - * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 148 | - * |
|
| 149 | - * @return DataResponse |
|
| 150 | - * |
|
| 151 | - * @NoAdminRequired |
|
| 152 | - */ |
|
| 153 | - public function update( |
|
| 154 | - $id, |
|
| 155 | - $backendOptions, |
|
| 156 | - $testOnly = true |
|
| 157 | - ) { |
|
| 158 | - try { |
|
| 159 | - $storage = $this->service->getStorage($id); |
|
| 160 | - $authMechanism = $storage->getAuthMechanism(); |
|
| 161 | - if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { |
|
| 162 | - $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
| 163 | - $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 164 | - } else { |
|
| 165 | - return new DataResponse( |
|
| 166 | - [ |
|
| 167 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
| 168 | - ], |
|
| 169 | - Http::STATUS_FORBIDDEN |
|
| 170 | - ); |
|
| 171 | - } |
|
| 172 | - } catch (NotFoundException $e) { |
|
| 173 | - return new DataResponse( |
|
| 174 | - [ |
|
| 175 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 176 | - ], |
|
| 177 | - Http::STATUS_NOT_FOUND |
|
| 178 | - ); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $this->updateStorageStatus($storage, $testOnly); |
|
| 182 | - $this->sanitizeStorage($storage); |
|
| 183 | - |
|
| 184 | - return new DataResponse( |
|
| 185 | - $this->formatStorageForUI($storage), |
|
| 186 | - Http::STATUS_OK |
|
| 187 | - ); |
|
| 188 | - |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Remove sensitive data from a StorageConfig before returning it to the user |
|
| 193 | - * |
|
| 194 | - * @param StorageConfig $storage |
|
| 195 | - */ |
|
| 196 | - protected function sanitizeStorage(StorageConfig $storage) { |
|
| 197 | - $storage->setBackendOptions([]); |
|
| 198 | - $storage->setMountOptions([]); |
|
| 199 | - |
|
| 200 | - if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
| 201 | - try { |
|
| 202 | - $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 203 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
| 204 | - // not configured yet |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - } |
|
| 48 | + /** |
|
| 49 | + * @var IUserSession |
|
| 50 | + */ |
|
| 51 | + private $userSession; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Creates a new user global storages controller. |
|
| 55 | + * |
|
| 56 | + * @param string $AppName application name |
|
| 57 | + * @param IRequest $request request object |
|
| 58 | + * @param IL10N $l10n l10n service |
|
| 59 | + * @param UserGlobalStoragesService $userGlobalStoragesService storage service |
|
| 60 | + * @param IUserSession $userSession |
|
| 61 | + */ |
|
| 62 | + public function __construct( |
|
| 63 | + $AppName, |
|
| 64 | + IRequest $request, |
|
| 65 | + IL10N $l10n, |
|
| 66 | + UserGlobalStoragesService $userGlobalStoragesService, |
|
| 67 | + IUserSession $userSession, |
|
| 68 | + ILogger $logger |
|
| 69 | + ) { |
|
| 70 | + parent::__construct( |
|
| 71 | + $AppName, |
|
| 72 | + $request, |
|
| 73 | + $l10n, |
|
| 74 | + $userGlobalStoragesService, |
|
| 75 | + $logger |
|
| 76 | + ); |
|
| 77 | + $this->userSession = $userSession; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Get all storage entries |
|
| 82 | + * |
|
| 83 | + * @return DataResponse |
|
| 84 | + * |
|
| 85 | + * @NoAdminRequired |
|
| 86 | + */ |
|
| 87 | + public function index() { |
|
| 88 | + $storages = $this->formatStoragesForUI($this->service->getUniqueStorages()); |
|
| 89 | + |
|
| 90 | + // remove configuration data, this must be kept private |
|
| 91 | + foreach ($storages as $storage) { |
|
| 92 | + $this->sanitizeStorage($storage); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + return new DataResponse( |
|
| 96 | + $storages, |
|
| 97 | + Http::STATUS_OK |
|
| 98 | + ); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + protected function manipulateStorageConfig(StorageConfig $storage) { |
|
| 102 | + /** @var AuthMechanism */ |
|
| 103 | + $authMechanism = $storage->getAuthMechanism(); |
|
| 104 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 105 | + /** @var Backend */ |
|
| 106 | + $backend = $storage->getBackend(); |
|
| 107 | + $backend->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Get an external storage entry. |
|
| 112 | + * |
|
| 113 | + * @param int $id storage id |
|
| 114 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 115 | + * @return DataResponse |
|
| 116 | + * |
|
| 117 | + * @NoAdminRequired |
|
| 118 | + */ |
|
| 119 | + public function show($id, $testOnly = true) { |
|
| 120 | + try { |
|
| 121 | + $storage = $this->service->getStorage($id); |
|
| 122 | + |
|
| 123 | + $this->updateStorageStatus($storage, $testOnly); |
|
| 124 | + } catch (NotFoundException $e) { |
|
| 125 | + return new DataResponse( |
|
| 126 | + [ |
|
| 127 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 128 | + ], |
|
| 129 | + Http::STATUS_NOT_FOUND |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $this->sanitizeStorage($storage); |
|
| 134 | + |
|
| 135 | + return new DataResponse( |
|
| 136 | + $this->formatStorageForUI($storage), |
|
| 137 | + Http::STATUS_OK |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Update an external storage entry. |
|
| 143 | + * Only allows setting user provided backend fields |
|
| 144 | + * |
|
| 145 | + * @param int $id storage id |
|
| 146 | + * @param array $backendOptions backend-specific options |
|
| 147 | + * @param bool $testOnly whether to storage should only test the connection or do more things |
|
| 148 | + * |
|
| 149 | + * @return DataResponse |
|
| 150 | + * |
|
| 151 | + * @NoAdminRequired |
|
| 152 | + */ |
|
| 153 | + public function update( |
|
| 154 | + $id, |
|
| 155 | + $backendOptions, |
|
| 156 | + $testOnly = true |
|
| 157 | + ) { |
|
| 158 | + try { |
|
| 159 | + $storage = $this->service->getStorage($id); |
|
| 160 | + $authMechanism = $storage->getAuthMechanism(); |
|
| 161 | + if ($authMechanism instanceof IUserProvided || $authMechanism instanceof UserGlobalAuth) { |
|
| 162 | + $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
| 163 | + $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 164 | + } else { |
|
| 165 | + return new DataResponse( |
|
| 166 | + [ |
|
| 167 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id]) |
|
| 168 | + ], |
|
| 169 | + Http::STATUS_FORBIDDEN |
|
| 170 | + ); |
|
| 171 | + } |
|
| 172 | + } catch (NotFoundException $e) { |
|
| 173 | + return new DataResponse( |
|
| 174 | + [ |
|
| 175 | + 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]) |
|
| 176 | + ], |
|
| 177 | + Http::STATUS_NOT_FOUND |
|
| 178 | + ); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $this->updateStorageStatus($storage, $testOnly); |
|
| 182 | + $this->sanitizeStorage($storage); |
|
| 183 | + |
|
| 184 | + return new DataResponse( |
|
| 185 | + $this->formatStorageForUI($storage), |
|
| 186 | + Http::STATUS_OK |
|
| 187 | + ); |
|
| 188 | + |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Remove sensitive data from a StorageConfig before returning it to the user |
|
| 193 | + * |
|
| 194 | + * @param StorageConfig $storage |
|
| 195 | + */ |
|
| 196 | + protected function sanitizeStorage(StorageConfig $storage) { |
|
| 197 | + $storage->setBackendOptions([]); |
|
| 198 | + $storage->setMountOptions([]); |
|
| 199 | + |
|
| 200 | + if ($storage->getAuthMechanism() instanceof IUserProvided) { |
|
| 201 | + try { |
|
| 202 | + $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 203 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
| 204 | + // not configured yet |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | } |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | <td width="20px"> </td> |
| 16 | 16 | <td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;"> |
| 17 | 17 | <?php |
| 18 | - print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']])); |
|
| 19 | - // TRANSLATORS term at the end of a mail |
|
| 20 | - p($l->t('Cheers!')); |
|
| 21 | - ?> |
|
| 18 | + print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']])); |
|
| 19 | + // TRANSLATORS term at the end of a mail |
|
| 20 | + p($l->t('Cheers!')); |
|
| 21 | + ?> |
|
| 22 | 22 | </td> |
| 23 | 23 | </tr> |
| 24 | 24 | <tr><td colspan="2"> </td></tr> |
@@ -28,23 +28,23 @@ |
||
| 28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 29 | |
| 30 | 30 | class Status extends Base { |
| 31 | - protected function configure() { |
|
| 32 | - parent::configure(); |
|
| 31 | + protected function configure() { |
|
| 32 | + parent::configure(); |
|
| 33 | 33 | |
| 34 | - $this |
|
| 35 | - ->setName('status') |
|
| 36 | - ->setDescription('show some status information') |
|
| 37 | - ; |
|
| 38 | - } |
|
| 34 | + $this |
|
| 35 | + ->setName('status') |
|
| 36 | + ->setDescription('show some status information') |
|
| 37 | + ; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 41 | - $values = [ |
|
| 42 | - 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), |
|
| 43 | - 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 44 | - 'versionstring' => \OC_Util::getVersionString(), |
|
| 45 | - 'edition' => '', |
|
| 46 | - ]; |
|
| 40 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 41 | + $values = [ |
|
| 42 | + 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), |
|
| 43 | + 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 44 | + 'versionstring' => \OC_Util::getVersionString(), |
|
| 45 | + 'edition' => '', |
|
| 46 | + ]; |
|
| 47 | 47 | |
| 48 | - $this->writeArrayInOutputFormat($input, $output, $values); |
|
| 49 | - } |
|
| 48 | + $this->writeArrayInOutputFormat($input, $output, $values); |
|
| 49 | + } |
|
| 50 | 50 | } |