@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | $tag = $this->tagManager->getTagsByIds([$name]); |
105 | 105 | $tag = current($tag); |
106 | 106 | if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
107 | - throw new NotFound('Tag with id ' . $name . ' not found'); |
|
107 | + throw new NotFound('Tag with id '.$name.' not found'); |
|
108 | 108 | } |
109 | 109 | return $this->makeNode($tag); |
110 | 110 | } catch (\InvalidArgumentException $e) { |
111 | 111 | throw new BadRequest('Invalid tag id', 0, $e); |
112 | 112 | } catch (TagNotFoundException $e) { |
113 | - throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
113 | + throw new NotFound('Tag with id '.$name.' not found', 0, $e); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $tags = $this->tagManager->getAllTags($visibilityFilter); |
124 | - return array_map(function ($tag) { |
|
124 | + return array_map(function($tag) { |
|
125 | 125 | return $this->makeNode($tag); |
126 | 126 | }, $tags); |
127 | 127 | } |
@@ -36,144 +36,144 @@ |
||
36 | 36 | |
37 | 37 | class SystemTagsByIdCollection implements ICollection { |
38 | 38 | |
39 | - /** |
|
40 | - * @var ISystemTagManager |
|
41 | - */ |
|
42 | - private $tagManager; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var IGroupManager |
|
46 | - */ |
|
47 | - private $groupManager; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var IUserSession |
|
51 | - */ |
|
52 | - private $userSession; |
|
53 | - |
|
54 | - /** |
|
55 | - * SystemTagsByIdCollection constructor. |
|
56 | - * |
|
57 | - * @param ISystemTagManager $tagManager |
|
58 | - * @param IUserSession $userSession |
|
59 | - * @param IGroupManager $groupManager |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - ISystemTagManager $tagManager, |
|
63 | - IUserSession $userSession, |
|
64 | - IGroupManager $groupManager |
|
65 | - ) { |
|
66 | - $this->tagManager = $tagManager; |
|
67 | - $this->userSession = $userSession; |
|
68 | - $this->groupManager = $groupManager; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Returns whether the currently logged in user is an administrator |
|
73 | - * |
|
74 | - * @return bool true if the user is an admin |
|
75 | - */ |
|
76 | - private function isAdmin() { |
|
77 | - $user = $this->userSession->getUser(); |
|
78 | - if ($user !== null) { |
|
79 | - return $this->groupManager->isAdmin($user->getUID()); |
|
80 | - } |
|
81 | - return false; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $name |
|
86 | - * @param resource|string $data Initial payload |
|
87 | - * @throws Forbidden |
|
88 | - */ |
|
89 | - function createFile($name, $data = null) { |
|
90 | - throw new Forbidden('Cannot create tags by id'); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string $name |
|
95 | - */ |
|
96 | - function createDirectory($name) { |
|
97 | - throw new Forbidden('Permission denied to create collections'); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @param string $name |
|
102 | - */ |
|
103 | - function getChild($name) { |
|
104 | - try { |
|
105 | - $tag = $this->tagManager->getTagsByIds([$name]); |
|
106 | - $tag = current($tag); |
|
107 | - if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
108 | - throw new NotFound('Tag with id ' . $name . ' not found'); |
|
109 | - } |
|
110 | - return $this->makeNode($tag); |
|
111 | - } catch (\InvalidArgumentException $e) { |
|
112 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
113 | - } catch (TagNotFoundException $e) { |
|
114 | - throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - function getChildren() { |
|
119 | - $visibilityFilter = true; |
|
120 | - if ($this->isAdmin()) { |
|
121 | - $visibilityFilter = null; |
|
122 | - } |
|
123 | - |
|
124 | - $tags = $this->tagManager->getAllTags($visibilityFilter); |
|
125 | - return array_map(function ($tag) { |
|
126 | - return $this->makeNode($tag); |
|
127 | - }, $tags); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @param string $name |
|
132 | - */ |
|
133 | - function childExists($name) { |
|
134 | - try { |
|
135 | - $tag = $this->tagManager->getTagsByIds([$name]); |
|
136 | - $tag = current($tag); |
|
137 | - if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
138 | - return false; |
|
139 | - } |
|
140 | - return true; |
|
141 | - } catch (\InvalidArgumentException $e) { |
|
142 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
143 | - } catch (TagNotFoundException $e) { |
|
144 | - return false; |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - function delete() { |
|
149 | - throw new Forbidden('Permission denied to delete this collection'); |
|
150 | - } |
|
151 | - |
|
152 | - function getName() { |
|
153 | - return 'systemtags'; |
|
154 | - } |
|
155 | - |
|
156 | - function setName($name) { |
|
157 | - throw new Forbidden('Permission denied to rename this collection'); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Returns the last modification time, as a unix timestamp |
|
162 | - * |
|
163 | - * @return int |
|
164 | - */ |
|
165 | - function getLastModified() { |
|
166 | - return null; |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Create a sabre node for the given system tag |
|
171 | - * |
|
172 | - * @param ISystemTag $tag |
|
173 | - * |
|
174 | - * @return SystemTagNode |
|
175 | - */ |
|
176 | - private function makeNode(ISystemTag $tag) { |
|
177 | - return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager); |
|
178 | - } |
|
39 | + /** |
|
40 | + * @var ISystemTagManager |
|
41 | + */ |
|
42 | + private $tagManager; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var IGroupManager |
|
46 | + */ |
|
47 | + private $groupManager; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var IUserSession |
|
51 | + */ |
|
52 | + private $userSession; |
|
53 | + |
|
54 | + /** |
|
55 | + * SystemTagsByIdCollection constructor. |
|
56 | + * |
|
57 | + * @param ISystemTagManager $tagManager |
|
58 | + * @param IUserSession $userSession |
|
59 | + * @param IGroupManager $groupManager |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + ISystemTagManager $tagManager, |
|
63 | + IUserSession $userSession, |
|
64 | + IGroupManager $groupManager |
|
65 | + ) { |
|
66 | + $this->tagManager = $tagManager; |
|
67 | + $this->userSession = $userSession; |
|
68 | + $this->groupManager = $groupManager; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Returns whether the currently logged in user is an administrator |
|
73 | + * |
|
74 | + * @return bool true if the user is an admin |
|
75 | + */ |
|
76 | + private function isAdmin() { |
|
77 | + $user = $this->userSession->getUser(); |
|
78 | + if ($user !== null) { |
|
79 | + return $this->groupManager->isAdmin($user->getUID()); |
|
80 | + } |
|
81 | + return false; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $name |
|
86 | + * @param resource|string $data Initial payload |
|
87 | + * @throws Forbidden |
|
88 | + */ |
|
89 | + function createFile($name, $data = null) { |
|
90 | + throw new Forbidden('Cannot create tags by id'); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string $name |
|
95 | + */ |
|
96 | + function createDirectory($name) { |
|
97 | + throw new Forbidden('Permission denied to create collections'); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @param string $name |
|
102 | + */ |
|
103 | + function getChild($name) { |
|
104 | + try { |
|
105 | + $tag = $this->tagManager->getTagsByIds([$name]); |
|
106 | + $tag = current($tag); |
|
107 | + if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
108 | + throw new NotFound('Tag with id ' . $name . ' not found'); |
|
109 | + } |
|
110 | + return $this->makeNode($tag); |
|
111 | + } catch (\InvalidArgumentException $e) { |
|
112 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
113 | + } catch (TagNotFoundException $e) { |
|
114 | + throw new NotFound('Tag with id ' . $name . ' not found', 0, $e); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + function getChildren() { |
|
119 | + $visibilityFilter = true; |
|
120 | + if ($this->isAdmin()) { |
|
121 | + $visibilityFilter = null; |
|
122 | + } |
|
123 | + |
|
124 | + $tags = $this->tagManager->getAllTags($visibilityFilter); |
|
125 | + return array_map(function ($tag) { |
|
126 | + return $this->makeNode($tag); |
|
127 | + }, $tags); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @param string $name |
|
132 | + */ |
|
133 | + function childExists($name) { |
|
134 | + try { |
|
135 | + $tag = $this->tagManager->getTagsByIds([$name]); |
|
136 | + $tag = current($tag); |
|
137 | + if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) { |
|
138 | + return false; |
|
139 | + } |
|
140 | + return true; |
|
141 | + } catch (\InvalidArgumentException $e) { |
|
142 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
143 | + } catch (TagNotFoundException $e) { |
|
144 | + return false; |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + function delete() { |
|
149 | + throw new Forbidden('Permission denied to delete this collection'); |
|
150 | + } |
|
151 | + |
|
152 | + function getName() { |
|
153 | + return 'systemtags'; |
|
154 | + } |
|
155 | + |
|
156 | + function setName($name) { |
|
157 | + throw new Forbidden('Permission denied to rename this collection'); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Returns the last modification time, as a unix timestamp |
|
162 | + * |
|
163 | + * @return int |
|
164 | + */ |
|
165 | + function getLastModified() { |
|
166 | + return null; |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Create a sabre node for the given system tag |
|
171 | + * |
|
172 | + * @param ISystemTag $tag |
|
173 | + * |
|
174 | + * @return SystemTagNode |
|
175 | + */ |
|
176 | + private function makeNode(ISystemTag $tag) { |
|
177 | + return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager); |
|
178 | + } |
|
179 | 179 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
64 | 64 | |
65 | -$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () { |
|
65 | +$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function() { |
|
66 | 66 | // use the view for the logged in user |
67 | 67 | return \OC\Files\Filesystem::getView(); |
68 | 68 | }); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // no php execution timeout for webdav |
32 | 32 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
33 | - @set_time_limit(0); |
|
33 | + @set_time_limit(0); |
|
34 | 34 | } |
35 | 35 | ignore_user_abort(true); |
36 | 36 | |
@@ -38,39 +38,39 @@ discard block |
||
38 | 38 | \OC_Util::obEnd(); |
39 | 39 | |
40 | 40 | $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory( |
41 | - \OC::$server->getConfig(), |
|
42 | - \OC::$server->getLogger(), |
|
43 | - \OC::$server->getDatabaseConnection(), |
|
44 | - \OC::$server->getUserSession(), |
|
45 | - \OC::$server->getMountManager(), |
|
46 | - \OC::$server->getTagManager(), |
|
47 | - \OC::$server->getRequest(), |
|
48 | - \OC::$server->getPreviewManager(), |
|
49 | - \OC::$server->getEventDispatcher() |
|
41 | + \OC::$server->getConfig(), |
|
42 | + \OC::$server->getLogger(), |
|
43 | + \OC::$server->getDatabaseConnection(), |
|
44 | + \OC::$server->getUserSession(), |
|
45 | + \OC::$server->getMountManager(), |
|
46 | + \OC::$server->getTagManager(), |
|
47 | + \OC::$server->getRequest(), |
|
48 | + \OC::$server->getPreviewManager(), |
|
49 | + \OC::$server->getEventDispatcher() |
|
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Backends |
53 | 53 | $authBackend = new \OCA\DAV\Connector\Sabre\Auth( |
54 | - \OC::$server->getSession(), |
|
55 | - \OC::$server->getUserSession(), |
|
56 | - \OC::$server->getRequest(), |
|
57 | - \OC::$server->getTwoFactorAuthManager(), |
|
58 | - \OC::$server->getBruteForceThrottler(), |
|
59 | - 'principals/' |
|
54 | + \OC::$server->getSession(), |
|
55 | + \OC::$server->getUserSession(), |
|
56 | + \OC::$server->getRequest(), |
|
57 | + \OC::$server->getTwoFactorAuthManager(), |
|
58 | + \OC::$server->getBruteForceThrottler(), |
|
59 | + 'principals/' |
|
60 | 60 | ); |
61 | 61 | $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend); |
62 | 62 | $bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth( |
63 | - \OC::$server->getUserSession(), |
|
64 | - \OC::$server->getSession(), |
|
65 | - \OC::$server->getRequest() |
|
63 | + \OC::$server->getUserSession(), |
|
64 | + \OC::$server->getSession(), |
|
65 | + \OC::$server->getRequest() |
|
66 | 66 | ); |
67 | 67 | $authPlugin->addBackend($bearerAuthPlugin); |
68 | 68 | |
69 | 69 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
70 | 70 | |
71 | 71 | $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () { |
72 | - // use the view for the logged in user |
|
73 | - return \OC\Files\Filesystem::getView(); |
|
72 | + // use the view for the logged in user |
|
73 | + return \OC\Files\Filesystem::getView(); |
|
74 | 74 | }); |
75 | 75 | |
76 | 76 | $dispatcher = \OC::$server->getEventDispatcher(); |
@@ -31,35 +31,35 @@ |
||
31 | 31 | */ |
32 | 32 | class DeleteOrphanedSharesJob extends TimedJob { |
33 | 33 | |
34 | - /** |
|
35 | - * Default interval in minutes |
|
36 | - * |
|
37 | - * @var int $defaultIntervalMin |
|
38 | - **/ |
|
39 | - protected $defaultIntervalMin = 15; |
|
34 | + /** |
|
35 | + * Default interval in minutes |
|
36 | + * |
|
37 | + * @var int $defaultIntervalMin |
|
38 | + **/ |
|
39 | + protected $defaultIntervalMin = 15; |
|
40 | 40 | |
41 | - /** |
|
42 | - * sets the correct interval for this timed job |
|
43 | - */ |
|
44 | - public function __construct() { |
|
45 | - $this->interval = $this->defaultIntervalMin * 60; |
|
46 | - } |
|
41 | + /** |
|
42 | + * sets the correct interval for this timed job |
|
43 | + */ |
|
44 | + public function __construct() { |
|
45 | + $this->interval = $this->defaultIntervalMin * 60; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Makes the background job do its work |
|
50 | - * |
|
51 | - * @param array $argument unused argument |
|
52 | - */ |
|
53 | - public function run($argument) { |
|
54 | - $connection = \OC::$server->getDatabaseConnection(); |
|
55 | - $logger = \OC::$server->getLogger(); |
|
48 | + /** |
|
49 | + * Makes the background job do its work |
|
50 | + * |
|
51 | + * @param array $argument unused argument |
|
52 | + */ |
|
53 | + public function run($argument) { |
|
54 | + $connection = \OC::$server->getDatabaseConnection(); |
|
55 | + $logger = \OC::$server->getLogger(); |
|
56 | 56 | |
57 | - $sql = |
|
58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
60 | - 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
57 | + $sql = |
|
58 | + 'DELETE FROM `*PREFIX*share` ' . |
|
59 | + 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
60 | + 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
|
61 | 61 | |
62 | - $deletedEntries = $connection->executeUpdate($sql); |
|
63 | - $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
64 | - } |
|
62 | + $deletedEntries = $connection->executeUpdate($sql); |
|
63 | + $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']); |
|
64 | + } |
|
65 | 65 | } |
@@ -55,8 +55,8 @@ |
||
55 | 55 | $logger = \OC::$server->getLogger(); |
56 | 56 | |
57 | 57 | $sql = |
58 | - 'DELETE FROM `*PREFIX*share` ' . |
|
59 | - 'WHERE `item_type` in (\'file\', \'folder\') ' . |
|
58 | + 'DELETE FROM `*PREFIX*share` '. |
|
59 | + 'WHERE `item_type` in (\'file\', \'folder\') '. |
|
60 | 60 | 'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)'; |
61 | 61 | |
62 | 62 | $deletedEntries = $connection->executeUpdate($sql); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
51 | 51 | ]) |
52 | 52 | ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
53 | - ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
53 | + ->setLegacyAuthMechanismCallback(function(array $params) use ($openstackAuth, $rackspaceAuth) { |
|
54 | 54 | if (isset($params['options']['key']) && $params['options']['key']) { |
55 | 55 | return $rackspaceAuth; |
56 | 56 | } |
@@ -34,31 +34,31 @@ |
||
34 | 34 | |
35 | 35 | class Swift extends Backend { |
36 | 36 | |
37 | - use LegacyDependencyCheckPolyfill; |
|
37 | + use LegacyDependencyCheckPolyfill; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rackspaceAuth) { |
|
40 | - $this |
|
41 | - ->setIdentifier('swift') |
|
42 | - ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat |
|
43 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') |
|
44 | - ->setText($l->t('OpenStack Object Storage')) |
|
45 | - ->addParameters([ |
|
46 | - (new DefinitionParameter('service_name', $l->t('Service name'))) |
|
47 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
48 | - (new DefinitionParameter('region', $l->t('Region'))) |
|
49 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
50 | - new DefinitionParameter('bucket', $l->t('Bucket')), |
|
51 | - (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)'))) |
|
52 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
53 | - ]) |
|
54 | - ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
|
55 | - ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
56 | - if (isset($params['options']['key']) && $params['options']['key']) { |
|
57 | - return $rackspaceAuth; |
|
58 | - } |
|
59 | - return $openstackAuth; |
|
60 | - }) |
|
61 | - ; |
|
62 | - } |
|
39 | + public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rackspaceAuth) { |
|
40 | + $this |
|
41 | + ->setIdentifier('swift') |
|
42 | + ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat |
|
43 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') |
|
44 | + ->setText($l->t('OpenStack Object Storage')) |
|
45 | + ->addParameters([ |
|
46 | + (new DefinitionParameter('service_name', $l->t('Service name'))) |
|
47 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
48 | + (new DefinitionParameter('region', $l->t('Region'))) |
|
49 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
50 | + new DefinitionParameter('bucket', $l->t('Bucket')), |
|
51 | + (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)'))) |
|
52 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
53 | + ]) |
|
54 | + ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK) |
|
55 | + ->setLegacyAuthMechanismCallback(function (array $params) use ($openstackAuth, $rackspaceAuth) { |
|
56 | + if (isset($params['options']['key']) && $params['options']['key']) { |
|
57 | + return $rackspaceAuth; |
|
58 | + } |
|
59 | + return $openstackAuth; |
|
60 | + }) |
|
61 | + ; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } else { |
91 | 91 | $p = new ProgressBar($output); |
92 | 92 | $p->start(); |
93 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
93 | + $this->userManager->callForSeenUsers(function(IUser $user) use ($p) { |
|
94 | 94 | $p->advance(); |
95 | 95 | $this->expireTrashForUser($user); |
96 | 96 | }); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | \OC_Util::setupFS($user); |
119 | 119 | |
120 | 120 | // Check if this user has a trashbin directory |
121 | - $view = new \OC\Files\View('/' . $user); |
|
121 | + $view = new \OC\Files\View('/'.$user); |
|
122 | 122 | if (!$view->is_dir('/files_trashbin/files')) { |
123 | 123 | return false; |
124 | 124 | } |
@@ -37,94 +37,94 @@ |
||
37 | 37 | |
38 | 38 | class ExpireTrash extends Command { |
39 | 39 | |
40 | - /** |
|
41 | - * @var Expiration |
|
42 | - */ |
|
43 | - private $expiration; |
|
40 | + /** |
|
41 | + * @var Expiration |
|
42 | + */ |
|
43 | + private $expiration; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var IUserManager |
|
47 | - */ |
|
48 | - private $userManager; |
|
45 | + /** |
|
46 | + * @var IUserManager |
|
47 | + */ |
|
48 | + private $userManager; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param IUserManager|null $userManager |
|
52 | - * @param Expiration|null $expiration |
|
53 | - */ |
|
54 | - public function __construct(IUserManager $userManager = null, |
|
55 | - Expiration $expiration = null) { |
|
56 | - parent::__construct(); |
|
50 | + /** |
|
51 | + * @param IUserManager|null $userManager |
|
52 | + * @param Expiration|null $expiration |
|
53 | + */ |
|
54 | + public function __construct(IUserManager $userManager = null, |
|
55 | + Expiration $expiration = null) { |
|
56 | + parent::__construct(); |
|
57 | 57 | |
58 | - $this->userManager = $userManager; |
|
59 | - $this->expiration = $expiration; |
|
60 | - } |
|
58 | + $this->userManager = $userManager; |
|
59 | + $this->expiration = $expiration; |
|
60 | + } |
|
61 | 61 | |
62 | - protected function configure() { |
|
63 | - $this |
|
64 | - ->setName('trashbin:expire') |
|
65 | - ->setDescription('Expires the users trashbin') |
|
66 | - ->addArgument( |
|
67 | - 'user_id', |
|
68 | - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
69 | - 'expires the trashbin of the given user(s), if no user is given the trash for all users will be expired' |
|
70 | - ); |
|
71 | - } |
|
62 | + protected function configure() { |
|
63 | + $this |
|
64 | + ->setName('trashbin:expire') |
|
65 | + ->setDescription('Expires the users trashbin') |
|
66 | + ->addArgument( |
|
67 | + 'user_id', |
|
68 | + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
69 | + 'expires the trashbin of the given user(s), if no user is given the trash for all users will be expired' |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | |
73 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
73 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
74 | 74 | |
75 | - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
76 | - if (!$maxAge) { |
|
77 | - $output->writeln("No expiry configured."); |
|
78 | - return; |
|
79 | - } |
|
75 | + $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
76 | + if (!$maxAge) { |
|
77 | + $output->writeln("No expiry configured."); |
|
78 | + return; |
|
79 | + } |
|
80 | 80 | |
81 | - $users = $input->getArgument('user_id'); |
|
82 | - if (!empty($users)) { |
|
83 | - foreach ($users as $user) { |
|
84 | - if ($this->userManager->userExists($user)) { |
|
85 | - $output->writeln("Remove deleted files of <info>$user</info>"); |
|
86 | - $userObject = $this->userManager->get($user); |
|
87 | - $this->expireTrashForUser($userObject); |
|
88 | - } else { |
|
89 | - $output->writeln("<error>Unknown user $user</error>"); |
|
90 | - } |
|
91 | - } |
|
92 | - } else { |
|
93 | - $p = new ProgressBar($output); |
|
94 | - $p->start(); |
|
95 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
96 | - $p->advance(); |
|
97 | - $this->expireTrashForUser($user); |
|
98 | - }); |
|
99 | - $p->finish(); |
|
100 | - $output->writeln(''); |
|
101 | - } |
|
102 | - } |
|
81 | + $users = $input->getArgument('user_id'); |
|
82 | + if (!empty($users)) { |
|
83 | + foreach ($users as $user) { |
|
84 | + if ($this->userManager->userExists($user)) { |
|
85 | + $output->writeln("Remove deleted files of <info>$user</info>"); |
|
86 | + $userObject = $this->userManager->get($user); |
|
87 | + $this->expireTrashForUser($userObject); |
|
88 | + } else { |
|
89 | + $output->writeln("<error>Unknown user $user</error>"); |
|
90 | + } |
|
91 | + } |
|
92 | + } else { |
|
93 | + $p = new ProgressBar($output); |
|
94 | + $p->start(); |
|
95 | + $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
96 | + $p->advance(); |
|
97 | + $this->expireTrashForUser($user); |
|
98 | + }); |
|
99 | + $p->finish(); |
|
100 | + $output->writeln(''); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - function expireTrashForUser(IUser $user) { |
|
105 | - $uid = $user->getUID(); |
|
106 | - if (!$this->setupFS($uid)) { |
|
107 | - return; |
|
108 | - } |
|
109 | - $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); |
|
110 | - Trashbin::deleteExpiredFiles($dirContent, $uid); |
|
111 | - } |
|
104 | + function expireTrashForUser(IUser $user) { |
|
105 | + $uid = $user->getUID(); |
|
106 | + if (!$this->setupFS($uid)) { |
|
107 | + return; |
|
108 | + } |
|
109 | + $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); |
|
110 | + Trashbin::deleteExpiredFiles($dirContent, $uid); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Act on behalf on trash item owner |
|
115 | - * @param string $user |
|
116 | - * @return boolean |
|
117 | - */ |
|
118 | - protected function setupFS($user) { |
|
119 | - \OC_Util::tearDownFS(); |
|
120 | - \OC_Util::setupFS($user); |
|
113 | + /** |
|
114 | + * Act on behalf on trash item owner |
|
115 | + * @param string $user |
|
116 | + * @return boolean |
|
117 | + */ |
|
118 | + protected function setupFS($user) { |
|
119 | + \OC_Util::tearDownFS(); |
|
120 | + \OC_Util::setupFS($user); |
|
121 | 121 | |
122 | - // Check if this user has a trashbin directory |
|
123 | - $view = new \OC\Files\View('/' . $user); |
|
124 | - if (!$view->is_dir('/files_trashbin/files')) { |
|
125 | - return false; |
|
126 | - } |
|
122 | + // Check if this user has a trashbin directory |
|
123 | + $view = new \OC\Files\View('/' . $user); |
|
124 | + if (!$view->is_dir('/files_trashbin/files')) { |
|
125 | + return false; |
|
126 | + } |
|
127 | 127 | |
128 | - return true; |
|
129 | - } |
|
128 | + return true; |
|
129 | + } |
|
130 | 130 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
81 | + $this->userManager->callForSeenUsers(function(IUser $user) { |
|
82 | 82 | $uid = $user->getUID(); |
83 | 83 | if (!$this->setupFS($uid)) { |
84 | 84 | return; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | \OC_Util::setupFS($user); |
101 | 101 | |
102 | 102 | // Check if this user has a trashbin directory |
103 | - $view = new \OC\Files\View('/' . $user); |
|
103 | + $view = new \OC\Files\View('/'.$user); |
|
104 | 104 | if (!$view->is_dir('/files_trashbin/files')) { |
105 | 105 | return false; |
106 | 106 | } |
@@ -36,77 +36,77 @@ |
||
36 | 36 | |
37 | 37 | class ExpireTrash extends \OC\BackgroundJob\TimedJob { |
38 | 38 | |
39 | - /** |
|
40 | - * @var Expiration |
|
41 | - */ |
|
42 | - private $expiration; |
|
39 | + /** |
|
40 | + * @var Expiration |
|
41 | + */ |
|
42 | + private $expiration; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var IUserManager |
|
46 | - */ |
|
47 | - private $userManager; |
|
44 | + /** |
|
45 | + * @var IUserManager |
|
46 | + */ |
|
47 | + private $userManager; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param IUserManager|null $userManager |
|
51 | - * @param Expiration|null $expiration |
|
52 | - */ |
|
53 | - public function __construct(IUserManager $userManager = null, |
|
54 | - Expiration $expiration = null) { |
|
55 | - // Run once per 30 minutes |
|
56 | - $this->setInterval(60 * 30); |
|
49 | + /** |
|
50 | + * @param IUserManager|null $userManager |
|
51 | + * @param Expiration|null $expiration |
|
52 | + */ |
|
53 | + public function __construct(IUserManager $userManager = null, |
|
54 | + Expiration $expiration = null) { |
|
55 | + // Run once per 30 minutes |
|
56 | + $this->setInterval(60 * 30); |
|
57 | 57 | |
58 | - if (is_null($expiration) || is_null($userManager)) { |
|
59 | - $this->fixDIForJobs(); |
|
60 | - } else { |
|
61 | - $this->userManager = $userManager; |
|
62 | - $this->expiration = $expiration; |
|
63 | - } |
|
64 | - } |
|
58 | + if (is_null($expiration) || is_null($userManager)) { |
|
59 | + $this->fixDIForJobs(); |
|
60 | + } else { |
|
61 | + $this->userManager = $userManager; |
|
62 | + $this->expiration = $expiration; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - protected function fixDIForJobs() { |
|
67 | - /** @var Application $application */ |
|
68 | - $application = \OC::$server->query(Application::class); |
|
69 | - $this->userManager = \OC::$server->getUserManager(); |
|
70 | - $this->expiration = $application->getContainer()->query('Expiration'); |
|
71 | - } |
|
66 | + protected function fixDIForJobs() { |
|
67 | + /** @var Application $application */ |
|
68 | + $application = \OC::$server->query(Application::class); |
|
69 | + $this->userManager = \OC::$server->getUserManager(); |
|
70 | + $this->expiration = $application->getContainer()->query('Expiration'); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param $argument |
|
75 | - * @throws \Exception |
|
76 | - */ |
|
77 | - protected function run($argument) { |
|
78 | - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
79 | - if (!$maxAge) { |
|
80 | - return; |
|
81 | - } |
|
73 | + /** |
|
74 | + * @param $argument |
|
75 | + * @throws \Exception |
|
76 | + */ |
|
77 | + protected function run($argument) { |
|
78 | + $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
79 | + if (!$maxAge) { |
|
80 | + return; |
|
81 | + } |
|
82 | 82 | |
83 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
84 | - $uid = $user->getUID(); |
|
85 | - if (!$this->setupFS($uid)) { |
|
86 | - return; |
|
87 | - } |
|
88 | - $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); |
|
89 | - Trashbin::deleteExpiredFiles($dirContent, $uid); |
|
90 | - }); |
|
83 | + $this->userManager->callForSeenUsers(function (IUser $user) { |
|
84 | + $uid = $user->getUID(); |
|
85 | + if (!$this->setupFS($uid)) { |
|
86 | + return; |
|
87 | + } |
|
88 | + $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); |
|
89 | + Trashbin::deleteExpiredFiles($dirContent, $uid); |
|
90 | + }); |
|
91 | 91 | |
92 | - \OC_Util::tearDownFS(); |
|
93 | - } |
|
92 | + \OC_Util::tearDownFS(); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Act on behalf on trash item owner |
|
97 | - * @param string $user |
|
98 | - * @return boolean |
|
99 | - */ |
|
100 | - protected function setupFS($user) { |
|
101 | - \OC_Util::tearDownFS(); |
|
102 | - \OC_Util::setupFS($user); |
|
95 | + /** |
|
96 | + * Act on behalf on trash item owner |
|
97 | + * @param string $user |
|
98 | + * @return boolean |
|
99 | + */ |
|
100 | + protected function setupFS($user) { |
|
101 | + \OC_Util::tearDownFS(); |
|
102 | + \OC_Util::setupFS($user); |
|
103 | 103 | |
104 | - // Check if this user has a trashbin directory |
|
105 | - $view = new \OC\Files\View('/' . $user); |
|
106 | - if (!$view->is_dir('/files_trashbin/files')) { |
|
107 | - return false; |
|
108 | - } |
|
104 | + // Check if this user has a trashbin directory |
|
105 | + $view = new \OC\Files\View('/' . $user); |
|
106 | + if (!$view->is_dir('/files_trashbin/files')) { |
|
107 | + return false; |
|
108 | + } |
|
109 | 109 | |
110 | - return true; |
|
111 | - } |
|
110 | + return true; |
|
111 | + } |
|
112 | 112 | } |
@@ -26,66 +26,66 @@ |
||
26 | 26 | |
27 | 27 | class RequestURL extends AbstractStringCheck { |
28 | 28 | |
29 | - /** @var string */ |
|
30 | - protected $url; |
|
29 | + /** @var string */ |
|
30 | + protected $url; |
|
31 | 31 | |
32 | - /** @var IRequest */ |
|
33 | - protected $request; |
|
32 | + /** @var IRequest */ |
|
33 | + protected $request; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param IL10N $l |
|
37 | - * @param IRequest $request |
|
38 | - */ |
|
39 | - public function __construct(IL10N $l, IRequest $request) { |
|
40 | - parent::__construct($l); |
|
41 | - $this->request = $request; |
|
42 | - } |
|
35 | + /** |
|
36 | + * @param IL10N $l |
|
37 | + * @param IRequest $request |
|
38 | + */ |
|
39 | + public function __construct(IL10N $l, IRequest $request) { |
|
40 | + parent::__construct($l); |
|
41 | + $this->request = $request; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string $operator |
|
46 | - * @param string $value |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public function executeCheck($operator, $value) { |
|
50 | - $actualValue = $this->getActualValue(); |
|
51 | - if (in_array($operator, ['is', '!is'])) { |
|
52 | - switch ($value) { |
|
53 | - case 'webdav': |
|
54 | - if ($operator === 'is') { |
|
55 | - return $this->isWebDAVRequest(); |
|
56 | - } else { |
|
57 | - return !$this->isWebDAVRequest(); |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
61 | - return $this->executeStringCheck($operator, $value, $actualValue); |
|
62 | - } |
|
44 | + /** |
|
45 | + * @param string $operator |
|
46 | + * @param string $value |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public function executeCheck($operator, $value) { |
|
50 | + $actualValue = $this->getActualValue(); |
|
51 | + if (in_array($operator, ['is', '!is'])) { |
|
52 | + switch ($value) { |
|
53 | + case 'webdav': |
|
54 | + if ($operator === 'is') { |
|
55 | + return $this->isWebDAVRequest(); |
|
56 | + } else { |
|
57 | + return !$this->isWebDAVRequest(); |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | + return $this->executeStringCheck($operator, $value, $actualValue); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - protected function getActualValue() { |
|
68 | - if ($this->url !== null) { |
|
69 | - return $this->url; |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + protected function getActualValue() { |
|
68 | + if ($this->url !== null) { |
|
69 | + return $this->url; |
|
70 | + } |
|
71 | 71 | |
72 | - $this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + :// |
|
73 | - $this->url .= $this->request->getServerHost();// E.g. localhost |
|
74 | - $this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php |
|
75 | - $this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile |
|
72 | + $this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + :// |
|
73 | + $this->url .= $this->request->getServerHost();// E.g. localhost |
|
74 | + $this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php |
|
75 | + $this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile |
|
76 | 76 | |
77 | - return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile |
|
78 | - } |
|
77 | + return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - protected function isWebDAVRequest() { |
|
84 | - return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
85 | - $this->request->getPathInfo() === '/webdav' || |
|
86 | - strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
87 | - $this->request->getPathInfo() === '/dav/files' || |
|
88 | - strpos($this->request->getPathInfo(), '/dav/files/') === 0 |
|
89 | - ); |
|
90 | - } |
|
80 | + /** |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + protected function isWebDAVRequest() { |
|
84 | + return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
85 | + $this->request->getPathInfo() === '/webdav' || |
|
86 | + strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
87 | + $this->request->getPathInfo() === '/dav/files' || |
|
88 | + strpos($this->request->getPathInfo(), '/dav/files/') === 0 |
|
89 | + ); |
|
90 | + } |
|
91 | 91 | } |
@@ -69,10 +69,10 @@ |
||
69 | 69 | return $this->url; |
70 | 70 | } |
71 | 71 | |
72 | - $this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + :// |
|
73 | - $this->url .= $this->request->getServerHost();// E.g. localhost |
|
74 | - $this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php |
|
75 | - $this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile |
|
72 | + $this->url = $this->request->getServerProtocol().'://'; // E.g. http(s) + :// |
|
73 | + $this->url .= $this->request->getServerHost(); // E.g. localhost |
|
74 | + $this->url .= $this->request->getScriptName(); // E.g. /nextcloud/index.php |
|
75 | + $this->url .= $this->request->getPathInfo(); // E.g. /apps/files_texteditor/ajax/loadfile |
|
76 | 76 | |
77 | 77 | return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile |
78 | 78 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $container = $this->getContainer(); |
18 | 18 | $server = $container->getServer(); |
19 | 19 | |
20 | - $container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { |
|
20 | + $container->registerService(NewUserMailHelper::class, function(SimpleContainer $c) use ($server) { |
|
21 | 21 | return new NewUserMailHelper( |
22 | 22 | $server->query(Defaults::class), |
23 | 23 | $server->getURLGenerator(), |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | Util::getDefaultEmailAddress('no-reply') |
31 | 31 | ); |
32 | 32 | }); |
33 | - $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { |
|
33 | + $container->registerService('ProvisioningApiMiddleware', function(SimpleContainer $c) use ($server) { |
|
34 | 34 | $user = $server->getUserManager()->get($c['UserId']); |
35 | 35 | $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; |
36 | 36 | $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; |
@@ -37,35 +37,35 @@ |
||
37 | 37 | use OCP\Util; |
38 | 38 | |
39 | 39 | class Application extends App { |
40 | - public function __construct(array $urlParams = []) { |
|
41 | - parent::__construct('provisioning_api', $urlParams); |
|
40 | + public function __construct(array $urlParams = []) { |
|
41 | + parent::__construct('provisioning_api', $urlParams); |
|
42 | 42 | |
43 | - $container = $this->getContainer(); |
|
44 | - $server = $container->getServer(); |
|
43 | + $container = $this->getContainer(); |
|
44 | + $server = $container->getServer(); |
|
45 | 45 | |
46 | - $container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { |
|
47 | - return new NewUserMailHelper( |
|
48 | - $server->query(Defaults::class), |
|
49 | - $server->getURLGenerator(), |
|
50 | - $server->getL10NFactory(), |
|
51 | - $server->getMailer(), |
|
52 | - $server->getSecureRandom(), |
|
53 | - new TimeFactory(), |
|
54 | - $server->getConfig(), |
|
55 | - $server->getCrypto(), |
|
56 | - Util::getDefaultEmailAddress('no-reply') |
|
57 | - ); |
|
58 | - }); |
|
59 | - $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { |
|
60 | - $user = $server->getUserManager()->get($c['UserId']); |
|
61 | - $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; |
|
62 | - $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; |
|
63 | - return new ProvisioningApiMiddleware( |
|
64 | - $c->query(IControllerMethodReflector::class), |
|
65 | - $isAdmin, |
|
66 | - $isSubAdmin |
|
67 | - ); |
|
68 | - }); |
|
69 | - $container->registerMiddleWare('ProvisioningApiMiddleware'); |
|
70 | - } |
|
46 | + $container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { |
|
47 | + return new NewUserMailHelper( |
|
48 | + $server->query(Defaults::class), |
|
49 | + $server->getURLGenerator(), |
|
50 | + $server->getL10NFactory(), |
|
51 | + $server->getMailer(), |
|
52 | + $server->getSecureRandom(), |
|
53 | + new TimeFactory(), |
|
54 | + $server->getConfig(), |
|
55 | + $server->getCrypto(), |
|
56 | + Util::getDefaultEmailAddress('no-reply') |
|
57 | + ); |
|
58 | + }); |
|
59 | + $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { |
|
60 | + $user = $server->getUserManager()->get($c['UserId']); |
|
61 | + $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; |
|
62 | + $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; |
|
63 | + return new ProvisioningApiMiddleware( |
|
64 | + $c->query(IControllerMethodReflector::class), |
|
65 | + $isAdmin, |
|
66 | + $isSubAdmin |
|
67 | + ); |
|
68 | + }); |
|
69 | + $container->registerMiddleWare('ProvisioningApiMiddleware'); |
|
70 | + } |
|
71 | 71 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } else { |
90 | 90 | $p = new ProgressBar($output); |
91 | 91 | $p->start(); |
92 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
92 | + $this->userManager->callForSeenUsers(function(IUser $user) use ($p) { |
|
93 | 93 | $p->advance(); |
94 | 94 | $this->expireVersionsForUser($user); |
95 | 95 | }); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | \OC_Util::setupFS($user); |
117 | 117 | |
118 | 118 | // Check if this user has a version directory |
119 | - $view = new \OC\Files\View('/' . $user); |
|
119 | + $view = new \OC\Files\View('/'.$user); |
|
120 | 120 | if (!$view->is_dir('/files_versions')) { |
121 | 121 | return false; |
122 | 122 | } |
@@ -36,93 +36,93 @@ |
||
36 | 36 | |
37 | 37 | class ExpireVersions extends Command { |
38 | 38 | |
39 | - /** |
|
40 | - * @var Expiration |
|
41 | - */ |
|
42 | - private $expiration; |
|
39 | + /** |
|
40 | + * @var Expiration |
|
41 | + */ |
|
42 | + private $expiration; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var IUserManager |
|
46 | - */ |
|
47 | - private $userManager; |
|
44 | + /** |
|
45 | + * @var IUserManager |
|
46 | + */ |
|
47 | + private $userManager; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param IUserManager $userManager |
|
51 | - * @param Expiration $expiration |
|
52 | - */ |
|
53 | - public function __construct(IUserManager $userManager, |
|
54 | - Expiration $expiration) { |
|
55 | - parent::__construct(); |
|
49 | + /** |
|
50 | + * @param IUserManager $userManager |
|
51 | + * @param Expiration $expiration |
|
52 | + */ |
|
53 | + public function __construct(IUserManager $userManager, |
|
54 | + Expiration $expiration) { |
|
55 | + parent::__construct(); |
|
56 | 56 | |
57 | - $this->userManager = $userManager; |
|
58 | - $this->expiration = $expiration; |
|
59 | - } |
|
57 | + $this->userManager = $userManager; |
|
58 | + $this->expiration = $expiration; |
|
59 | + } |
|
60 | 60 | |
61 | - protected function configure() { |
|
62 | - $this |
|
63 | - ->setName('versions:expire') |
|
64 | - ->setDescription('Expires the users file versions') |
|
65 | - ->addArgument( |
|
66 | - 'user_id', |
|
67 | - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
68 | - 'expire file versions of the given user(s), if no user is given file versions for all users will be expired.' |
|
69 | - ); |
|
70 | - } |
|
61 | + protected function configure() { |
|
62 | + $this |
|
63 | + ->setName('versions:expire') |
|
64 | + ->setDescription('Expires the users file versions') |
|
65 | + ->addArgument( |
|
66 | + 'user_id', |
|
67 | + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
68 | + 'expire file versions of the given user(s), if no user is given file versions for all users will be expired.' |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
72 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
73 | 73 | |
74 | - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
75 | - if (!$maxAge) { |
|
76 | - $output->writeln("No expiry configured."); |
|
77 | - return; |
|
78 | - } |
|
74 | + $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
75 | + if (!$maxAge) { |
|
76 | + $output->writeln("No expiry configured."); |
|
77 | + return; |
|
78 | + } |
|
79 | 79 | |
80 | - $users = $input->getArgument('user_id'); |
|
81 | - if (!empty($users)) { |
|
82 | - foreach ($users as $user) { |
|
83 | - if ($this->userManager->userExists($user)) { |
|
84 | - $output->writeln("Remove deleted files of <info>$user</info>"); |
|
85 | - $userObject = $this->userManager->get($user); |
|
86 | - $this->expireVersionsForUser($userObject); |
|
87 | - } else { |
|
88 | - $output->writeln("<error>Unknown user $user</error>"); |
|
89 | - } |
|
90 | - } |
|
91 | - } else { |
|
92 | - $p = new ProgressBar($output); |
|
93 | - $p->start(); |
|
94 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
95 | - $p->advance(); |
|
96 | - $this->expireVersionsForUser($user); |
|
97 | - }); |
|
98 | - $p->finish(); |
|
99 | - $output->writeln(''); |
|
100 | - } |
|
101 | - } |
|
80 | + $users = $input->getArgument('user_id'); |
|
81 | + if (!empty($users)) { |
|
82 | + foreach ($users as $user) { |
|
83 | + if ($this->userManager->userExists($user)) { |
|
84 | + $output->writeln("Remove deleted files of <info>$user</info>"); |
|
85 | + $userObject = $this->userManager->get($user); |
|
86 | + $this->expireVersionsForUser($userObject); |
|
87 | + } else { |
|
88 | + $output->writeln("<error>Unknown user $user</error>"); |
|
89 | + } |
|
90 | + } |
|
91 | + } else { |
|
92 | + $p = new ProgressBar($output); |
|
93 | + $p->start(); |
|
94 | + $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
95 | + $p->advance(); |
|
96 | + $this->expireVersionsForUser($user); |
|
97 | + }); |
|
98 | + $p->finish(); |
|
99 | + $output->writeln(''); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - function expireVersionsForUser(IUser $user) { |
|
104 | - $uid = $user->getUID(); |
|
105 | - if (!$this->setupFS($uid)) { |
|
106 | - return; |
|
107 | - } |
|
108 | - Storage::expireOlderThanMaxForUser($uid); |
|
109 | - } |
|
103 | + function expireVersionsForUser(IUser $user) { |
|
104 | + $uid = $user->getUID(); |
|
105 | + if (!$this->setupFS($uid)) { |
|
106 | + return; |
|
107 | + } |
|
108 | + Storage::expireOlderThanMaxForUser($uid); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Act on behalf on versions item owner |
|
113 | - * @param string $user |
|
114 | - * @return boolean |
|
115 | - */ |
|
116 | - protected function setupFS($user) { |
|
117 | - \OC_Util::tearDownFS(); |
|
118 | - \OC_Util::setupFS($user); |
|
111 | + /** |
|
112 | + * Act on behalf on versions item owner |
|
113 | + * @param string $user |
|
114 | + * @return boolean |
|
115 | + */ |
|
116 | + protected function setupFS($user) { |
|
117 | + \OC_Util::tearDownFS(); |
|
118 | + \OC_Util::setupFS($user); |
|
119 | 119 | |
120 | - // Check if this user has a version directory |
|
121 | - $view = new \OC\Files\View('/' . $user); |
|
122 | - if (!$view->is_dir('/files_versions')) { |
|
123 | - return false; |
|
124 | - } |
|
120 | + // Check if this user has a version directory |
|
121 | + $view = new \OC\Files\View('/' . $user); |
|
122 | + if (!$view->is_dir('/files_versions')) { |
|
123 | + return false; |
|
124 | + } |
|
125 | 125 | |
126 | - return true; |
|
127 | - } |
|
126 | + return true; |
|
127 | + } |
|
128 | 128 | } |