@@ -29,19 +29,19 @@ |
||
29 | 29 | */ |
30 | 30 | class FilesystemHelper { |
31 | 31 | |
32 | - /** |
|
33 | - * @brief states whether the filesystem was loaded |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function isLoaded() { |
|
37 | - return \OC\Files\Filesystem::$loaded; |
|
38 | - } |
|
32 | + /** |
|
33 | + * @brief states whether the filesystem was loaded |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function isLoaded() { |
|
37 | + return \OC\Files\Filesystem::$loaded; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @brief initializes the filesystem for the given user |
|
42 | - * @param string $uid the Nextcloud username of the user |
|
43 | - */ |
|
44 | - public function setup($uid) { |
|
45 | - \OC_Util::setupFS($uid); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @brief initializes the filesystem for the given user |
|
42 | + * @param string $uid the Nextcloud username of the user |
|
43 | + */ |
|
44 | + public function setup($uid) { |
|
45 | + \OC_Util::setupFS($uid); |
|
46 | + } |
|
47 | 47 | } |
@@ -42,97 +42,97 @@ |
||
42 | 42 | * Migrate mount config from mount.json to the database |
43 | 43 | */ |
44 | 44 | class StorageMigrator { |
45 | - /** |
|
46 | - * @var BackendService |
|
47 | - */ |
|
48 | - private $backendService; |
|
45 | + /** |
|
46 | + * @var BackendService |
|
47 | + */ |
|
48 | + private $backendService; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var DBConfigService |
|
52 | - */ |
|
53 | - private $dbConfig; |
|
50 | + /** |
|
51 | + * @var DBConfigService |
|
52 | + */ |
|
53 | + private $dbConfig; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var IConfig |
|
57 | - */ |
|
58 | - private $config; |
|
55 | + /** |
|
56 | + * @var IConfig |
|
57 | + */ |
|
58 | + private $config; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var IDBConnection |
|
62 | - */ |
|
63 | - private $connection; |
|
60 | + /** |
|
61 | + * @var IDBConnection |
|
62 | + */ |
|
63 | + private $connection; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var ILogger |
|
67 | - */ |
|
68 | - private $logger; |
|
65 | + /** |
|
66 | + * @var ILogger |
|
67 | + */ |
|
68 | + private $logger; |
|
69 | 69 | |
70 | - /** @var IUserMountCache */ |
|
71 | - private $userMountCache; |
|
70 | + /** @var IUserMountCache */ |
|
71 | + private $userMountCache; |
|
72 | 72 | |
73 | - /** |
|
74 | - * StorageMigrator constructor. |
|
75 | - * |
|
76 | - * @param BackendService $backendService |
|
77 | - * @param DBConfigService $dbConfig |
|
78 | - * @param IConfig $config |
|
79 | - * @param IDBConnection $connection |
|
80 | - * @param ILogger $logger |
|
81 | - * @param IUserMountCache $userMountCache |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - BackendService $backendService, |
|
85 | - DBConfigService $dbConfig, |
|
86 | - IConfig $config, |
|
87 | - IDBConnection $connection, |
|
88 | - ILogger $logger, |
|
89 | - IUserMountCache $userMountCache |
|
90 | - ) { |
|
91 | - $this->backendService = $backendService; |
|
92 | - $this->dbConfig = $dbConfig; |
|
93 | - $this->config = $config; |
|
94 | - $this->connection = $connection; |
|
95 | - $this->logger = $logger; |
|
96 | - $this->userMountCache = $userMountCache; |
|
97 | - } |
|
73 | + /** |
|
74 | + * StorageMigrator constructor. |
|
75 | + * |
|
76 | + * @param BackendService $backendService |
|
77 | + * @param DBConfigService $dbConfig |
|
78 | + * @param IConfig $config |
|
79 | + * @param IDBConnection $connection |
|
80 | + * @param ILogger $logger |
|
81 | + * @param IUserMountCache $userMountCache |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + BackendService $backendService, |
|
85 | + DBConfigService $dbConfig, |
|
86 | + IConfig $config, |
|
87 | + IDBConnection $connection, |
|
88 | + ILogger $logger, |
|
89 | + IUserMountCache $userMountCache |
|
90 | + ) { |
|
91 | + $this->backendService = $backendService; |
|
92 | + $this->dbConfig = $dbConfig; |
|
93 | + $this->config = $config; |
|
94 | + $this->connection = $connection; |
|
95 | + $this->logger = $logger; |
|
96 | + $this->userMountCache = $userMountCache; |
|
97 | + } |
|
98 | 98 | |
99 | - private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { |
|
100 | - $existingStorage = $legacyService->getAllStorages(); |
|
99 | + private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { |
|
100 | + $existingStorage = $legacyService->getAllStorages(); |
|
101 | 101 | |
102 | - $this->connection->beginTransaction(); |
|
103 | - try { |
|
104 | - foreach ($existingStorage as $storage) { |
|
105 | - $mountOptions = $storage->getMountOptions(); |
|
106 | - if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { |
|
107 | - // existing mounts must have sharing enabled by default to avoid surprises |
|
108 | - $mountOptions['enable_sharing'] = true; |
|
109 | - $storage->setMountOptions($mountOptions); |
|
110 | - } |
|
111 | - $storageService->addStorage($storage); |
|
112 | - } |
|
113 | - $this->connection->commit(); |
|
114 | - } catch (\Exception $e) { |
|
115 | - $this->logger->logException($e); |
|
116 | - $this->connection->rollBack(); |
|
117 | - } |
|
118 | - } |
|
102 | + $this->connection->beginTransaction(); |
|
103 | + try { |
|
104 | + foreach ($existingStorage as $storage) { |
|
105 | + $mountOptions = $storage->getMountOptions(); |
|
106 | + if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { |
|
107 | + // existing mounts must have sharing enabled by default to avoid surprises |
|
108 | + $mountOptions['enable_sharing'] = true; |
|
109 | + $storage->setMountOptions($mountOptions); |
|
110 | + } |
|
111 | + $storageService->addStorage($storage); |
|
112 | + } |
|
113 | + $this->connection->commit(); |
|
114 | + } catch (\Exception $e) { |
|
115 | + $this->logger->logException($e); |
|
116 | + $this->connection->rollBack(); |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Migrate personal storages configured by the current user |
|
122 | - * |
|
123 | - * @param IUser $user |
|
124 | - */ |
|
125 | - public function migrateUser(IUser $user) { |
|
126 | - $dummySession = new DummyUserSession(); |
|
127 | - $dummySession->setUser($user); |
|
128 | - $userId = $user->getUID(); |
|
129 | - $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0'); |
|
130 | - if (version_compare($userVersion, '0.5.0', '<')) { |
|
131 | - $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0'); |
|
132 | - $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession); |
|
133 | - $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache); |
|
120 | + /** |
|
121 | + * Migrate personal storages configured by the current user |
|
122 | + * |
|
123 | + * @param IUser $user |
|
124 | + */ |
|
125 | + public function migrateUser(IUser $user) { |
|
126 | + $dummySession = new DummyUserSession(); |
|
127 | + $dummySession->setUser($user); |
|
128 | + $userId = $user->getUID(); |
|
129 | + $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0'); |
|
130 | + if (version_compare($userVersion, '0.5.0', '<')) { |
|
131 | + $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0'); |
|
132 | + $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession); |
|
133 | + $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache); |
|
134 | 134 | |
135 | - $this->migrate($legacyService, $storageService); |
|
136 | - } |
|
137 | - } |
|
135 | + $this->migrate($legacyService, $storageService); |
|
136 | + } |
|
137 | + } |
|
138 | 138 | } |
@@ -25,28 +25,28 @@ |
||
25 | 25 | use OCP\AppFramework\Http\JSONResponse; |
26 | 26 | |
27 | 27 | class RateLimitTestController extends Controller { |
28 | - /** |
|
29 | - * @PublicPage |
|
30 | - * @NoCSRFRequired |
|
31 | - * |
|
32 | - * @UserRateThrottle(limit=5, period=100) |
|
33 | - * @AnonRateThrottle(limit=1, period=100) |
|
34 | - * |
|
35 | - * @return JSONResponse |
|
36 | - */ |
|
37 | - public function userAndAnonProtected() { |
|
38 | - return new JSONResponse(); |
|
39 | - } |
|
28 | + /** |
|
29 | + * @PublicPage |
|
30 | + * @NoCSRFRequired |
|
31 | + * |
|
32 | + * @UserRateThrottle(limit=5, period=100) |
|
33 | + * @AnonRateThrottle(limit=1, period=100) |
|
34 | + * |
|
35 | + * @return JSONResponse |
|
36 | + */ |
|
37 | + public function userAndAnonProtected() { |
|
38 | + return new JSONResponse(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @PublicPage |
|
43 | - * @NoCSRFRequired |
|
44 | - * |
|
45 | - * @AnonRateThrottle(limit=1, period=10) |
|
46 | - * |
|
47 | - * @return JSONResponse |
|
48 | - */ |
|
49 | - public function onlyAnonProtected() { |
|
50 | - return new JSONResponse(); |
|
51 | - } |
|
41 | + /** |
|
42 | + * @PublicPage |
|
43 | + * @NoCSRFRequired |
|
44 | + * |
|
45 | + * @AnonRateThrottle(limit=1, period=10) |
|
46 | + * |
|
47 | + * @return JSONResponse |
|
48 | + */ |
|
49 | + public function onlyAnonProtected() { |
|
50 | + return new JSONResponse(); |
|
51 | + } |
|
52 | 52 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCP\AppFramework\Http; |
26 | 26 | |
27 | 27 | class RateLimitExceededException extends SecurityException { |
28 | - public function __construct() { |
|
29 | - parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | - } |
|
28 | + public function __construct() { |
|
29 | + parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | + } |
|
31 | 31 | } |
@@ -32,100 +32,100 @@ |
||
32 | 32 | * @since 7.0.0 |
33 | 33 | */ |
34 | 34 | interface IJobList { |
35 | - /** |
|
36 | - * Add a job to the list |
|
37 | - * |
|
38 | - * @param \OCP\BackgroundJob\IJob|string $job |
|
39 | - * @param mixed $argument The argument to be passed to $job->run() when the job is exectured |
|
40 | - * @since 7.0.0 |
|
41 | - */ |
|
42 | - public function add($job, $argument = null); |
|
35 | + /** |
|
36 | + * Add a job to the list |
|
37 | + * |
|
38 | + * @param \OCP\BackgroundJob\IJob|string $job |
|
39 | + * @param mixed $argument The argument to be passed to $job->run() when the job is exectured |
|
40 | + * @since 7.0.0 |
|
41 | + */ |
|
42 | + public function add($job, $argument = null); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Remove a job from the list |
|
46 | - * |
|
47 | - * @param \OCP\BackgroundJob\IJob|string $job |
|
48 | - * @param mixed $argument |
|
49 | - * @since 7.0.0 |
|
50 | - */ |
|
51 | - public function remove($job, $argument = null); |
|
44 | + /** |
|
45 | + * Remove a job from the list |
|
46 | + * |
|
47 | + * @param \OCP\BackgroundJob\IJob|string $job |
|
48 | + * @param mixed $argument |
|
49 | + * @since 7.0.0 |
|
50 | + */ |
|
51 | + public function remove($job, $argument = null); |
|
52 | 52 | |
53 | - /** |
|
54 | - * check if a job is in the list |
|
55 | - * |
|
56 | - * @param \OCP\BackgroundJob\IJob|string $job |
|
57 | - * @param mixed $argument |
|
58 | - * @return bool |
|
59 | - * @since 7.0.0 |
|
60 | - */ |
|
61 | - public function has($job, $argument); |
|
53 | + /** |
|
54 | + * check if a job is in the list |
|
55 | + * |
|
56 | + * @param \OCP\BackgroundJob\IJob|string $job |
|
57 | + * @param mixed $argument |
|
58 | + * @return bool |
|
59 | + * @since 7.0.0 |
|
60 | + */ |
|
61 | + public function has($job, $argument); |
|
62 | 62 | |
63 | - /** |
|
64 | - * get all jobs in the list |
|
65 | - * |
|
66 | - * @return \OCP\BackgroundJob\IJob[] |
|
67 | - * @since 7.0.0 |
|
68 | - * @deprecated 9.0.0 - This method is dangerous since it can cause load and |
|
69 | - * memory problems when creating too many instances. |
|
70 | - */ |
|
71 | - public function getAll(); |
|
63 | + /** |
|
64 | + * get all jobs in the list |
|
65 | + * |
|
66 | + * @return \OCP\BackgroundJob\IJob[] |
|
67 | + * @since 7.0.0 |
|
68 | + * @deprecated 9.0.0 - This method is dangerous since it can cause load and |
|
69 | + * memory problems when creating too many instances. |
|
70 | + */ |
|
71 | + public function getAll(); |
|
72 | 72 | |
73 | - /** |
|
74 | - * get the next job in the list |
|
75 | - * |
|
76 | - * @return \OCP\BackgroundJob\IJob|null |
|
77 | - * @since 7.0.0 |
|
78 | - */ |
|
79 | - public function getNext(); |
|
73 | + /** |
|
74 | + * get the next job in the list |
|
75 | + * |
|
76 | + * @return \OCP\BackgroundJob\IJob|null |
|
77 | + * @since 7.0.0 |
|
78 | + */ |
|
79 | + public function getNext(); |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param int $id |
|
83 | - * @return \OCP\BackgroundJob\IJob|null |
|
84 | - * @since 7.0.0 |
|
85 | - */ |
|
86 | - public function getById($id); |
|
81 | + /** |
|
82 | + * @param int $id |
|
83 | + * @return \OCP\BackgroundJob\IJob|null |
|
84 | + * @since 7.0.0 |
|
85 | + */ |
|
86 | + public function getById($id); |
|
87 | 87 | |
88 | - /** |
|
89 | - * set the job that was last ran to the current time |
|
90 | - * |
|
91 | - * @param \OCP\BackgroundJob\IJob $job |
|
92 | - * @since 7.0.0 |
|
93 | - */ |
|
94 | - public function setLastJob(IJob $job); |
|
88 | + /** |
|
89 | + * set the job that was last ran to the current time |
|
90 | + * |
|
91 | + * @param \OCP\BackgroundJob\IJob $job |
|
92 | + * @since 7.0.0 |
|
93 | + */ |
|
94 | + public function setLastJob(IJob $job); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Remove the reservation for a job |
|
98 | - * |
|
99 | - * @param IJob $job |
|
100 | - * @since 9.1.0 |
|
101 | - */ |
|
102 | - public function unlockJob(IJob $job); |
|
96 | + /** |
|
97 | + * Remove the reservation for a job |
|
98 | + * |
|
99 | + * @param IJob $job |
|
100 | + * @since 9.1.0 |
|
101 | + */ |
|
102 | + public function unlockJob(IJob $job); |
|
103 | 103 | |
104 | - /** |
|
105 | - * get the id of the last ran job |
|
106 | - * |
|
107 | - * @return int |
|
108 | - * @since 7.0.0 |
|
109 | - * @deprecated 9.1.0 - The functionality behind the value is deprecated, it |
|
110 | - * only tells you which job finished last, but since we now allow multiple |
|
111 | - * executors to run in parallel, it's not used to calculate the next job. |
|
112 | - */ |
|
113 | - public function getLastJob(); |
|
104 | + /** |
|
105 | + * get the id of the last ran job |
|
106 | + * |
|
107 | + * @return int |
|
108 | + * @since 7.0.0 |
|
109 | + * @deprecated 9.1.0 - The functionality behind the value is deprecated, it |
|
110 | + * only tells you which job finished last, but since we now allow multiple |
|
111 | + * executors to run in parallel, it's not used to calculate the next job. |
|
112 | + */ |
|
113 | + public function getLastJob(); |
|
114 | 114 | |
115 | - /** |
|
116 | - * set the lastRun of $job to now |
|
117 | - * |
|
118 | - * @param IJob $job |
|
119 | - * @since 7.0.0 |
|
120 | - */ |
|
121 | - public function setLastRun(IJob $job); |
|
115 | + /** |
|
116 | + * set the lastRun of $job to now |
|
117 | + * |
|
118 | + * @param IJob $job |
|
119 | + * @since 7.0.0 |
|
120 | + */ |
|
121 | + public function setLastRun(IJob $job); |
|
122 | 122 | |
123 | - /** |
|
124 | - * set the run duration of $job |
|
125 | - * |
|
126 | - * @param IJob $job |
|
127 | - * @param $timeTaken |
|
128 | - * @since 12.0.0 |
|
129 | - */ |
|
130 | - public function setExecutionTime(IJob $job, $timeTaken); |
|
123 | + /** |
|
124 | + * set the run duration of $job |
|
125 | + * |
|
126 | + * @param IJob $job |
|
127 | + * @param $timeTaken |
|
128 | + * @since 12.0.0 |
|
129 | + */ |
|
130 | + public function setExecutionTime(IJob $job, $timeTaken); |
|
131 | 131 | } |
@@ -107,32 +107,32 @@ discard block |
||
107 | 107 | case '{DAV:}prop': |
108 | 108 | $newProps['properties'] = array_keys($elem['value']); |
109 | 109 | break; |
110 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
110 | + case '{'.SearchPlugin::NS_Nextcloud.'}filter': |
|
111 | 111 | foreach ($elem['value'] as $subElem) { |
112 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
112 | + if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') { |
|
113 | 113 | if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
114 | 114 | $newProps['filters']['comps'] = []; |
115 | 115 | } |
116 | 116 | $newProps['filters']['comps'][] = $subElem['value']; |
117 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
117 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') { |
|
118 | 118 | if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
119 | 119 | $newProps['filters']['props'] = []; |
120 | 120 | } |
121 | 121 | $newProps['filters']['props'][] = $subElem['value']; |
122 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
122 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') { |
|
123 | 123 | if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
124 | 124 | $newProps['filters']['params'] = []; |
125 | 125 | } |
126 | 126 | $newProps['filters']['params'][] = $subElem['value']; |
127 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
127 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') { |
|
128 | 128 | $newProps['filters']['search-term'] = $subElem['value']; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | break; |
132 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
132 | + case '{'.SearchPlugin::NS_Nextcloud.'}limit': |
|
133 | 133 | $newProps['limit'] = $elem['value']; |
134 | 134 | break; |
135 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
135 | + case '{'.SearchPlugin::NS_Nextcloud.'}offset': |
|
136 | 136 | $newProps['offset'] = $elem['value']; |
137 | 137 | break; |
138 | 138 | |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | if (empty($newProps['filters'])) { |
143 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
143 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
147 | 147 | $noCompsDefined = empty($newProps['filters']['comps']); |
148 | 148 | if ($propsOrParamsDefined && $noCompsDefined) { |
149 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
149 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | if (!isset($newProps['filters']['search-term'])) { |
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
153 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
157 | - throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
157 | + throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 |
@@ -39,133 +39,133 @@ |
||
39 | 39 | */ |
40 | 40 | class CalendarSearchReport implements XmlDeserializable { |
41 | 41 | |
42 | - /** |
|
43 | - * An array with requested properties. |
|
44 | - * |
|
45 | - * @var array |
|
46 | - */ |
|
47 | - public $properties; |
|
48 | - |
|
49 | - /** |
|
50 | - * List of property/component filters. |
|
51 | - * |
|
52 | - * @var array |
|
53 | - */ |
|
54 | - public $filters; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var int |
|
58 | - */ |
|
59 | - public $limit; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var int |
|
63 | - */ |
|
64 | - public $offset; |
|
65 | - |
|
66 | - /** |
|
67 | - * The deserialize method is called during xml parsing. |
|
68 | - * |
|
69 | - * This method is called statically, this is because in theory this method |
|
70 | - * may be used as a type of constructor, or factory method. |
|
71 | - * |
|
72 | - * Often you want to return an instance of the current class, but you are |
|
73 | - * free to return other data as well. |
|
74 | - * |
|
75 | - * You are responsible for advancing the reader to the next element. Not |
|
76 | - * doing anything will result in a never-ending loop. |
|
77 | - * |
|
78 | - * If you just want to skip parsing for this element altogether, you can |
|
79 | - * just call $reader->next(); |
|
80 | - * |
|
81 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
82 | - * the next element. |
|
83 | - * |
|
84 | - * @param Reader $reader |
|
85 | - * @return mixed |
|
86 | - */ |
|
87 | - public static function xmlDeserialize(Reader $reader) { |
|
88 | - $elems = $reader->parseInnerTree([ |
|
89 | - '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
90 | - '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
91 | - '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
92 | - '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
93 | - '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
94 | - '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
95 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
96 | - ]); |
|
97 | - |
|
98 | - $newProps = [ |
|
99 | - 'filters' => [], |
|
100 | - 'properties' => [], |
|
101 | - 'limit' => null, |
|
102 | - 'offset' => null |
|
103 | - ]; |
|
104 | - |
|
105 | - if (!is_array($elems)) { |
|
106 | - $elems = []; |
|
107 | - } |
|
108 | - |
|
109 | - foreach ($elems as $elem) { |
|
110 | - switch ($elem['name']) { |
|
111 | - case '{DAV:}prop': |
|
112 | - $newProps['properties'] = array_keys($elem['value']); |
|
113 | - break; |
|
114 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
115 | - foreach ($elem['value'] as $subElem) { |
|
116 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
117 | - if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
|
118 | - $newProps['filters']['comps'] = []; |
|
119 | - } |
|
120 | - $newProps['filters']['comps'][] = $subElem['value']; |
|
121 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
122 | - if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
|
123 | - $newProps['filters']['props'] = []; |
|
124 | - } |
|
125 | - $newProps['filters']['props'][] = $subElem['value']; |
|
126 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
127 | - if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
|
128 | - $newProps['filters']['params'] = []; |
|
129 | - } |
|
130 | - $newProps['filters']['params'][] = $subElem['value']; |
|
131 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
132 | - $newProps['filters']['search-term'] = $subElem['value']; |
|
133 | - } |
|
134 | - } |
|
135 | - break; |
|
136 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
137 | - $newProps['limit'] = $elem['value']; |
|
138 | - break; |
|
139 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
140 | - $newProps['offset'] = $elem['value']; |
|
141 | - break; |
|
142 | - |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - if (empty($newProps['filters'])) { |
|
147 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
148 | - } |
|
149 | - |
|
150 | - $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
|
151 | - $noCompsDefined = empty($newProps['filters']['comps']); |
|
152 | - if ($propsOrParamsDefined && $noCompsDefined) { |
|
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
154 | - } |
|
155 | - |
|
156 | - if (!isset($newProps['filters']['search-term'])) { |
|
157 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
158 | - } |
|
159 | - |
|
160 | - if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
|
161 | - throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - $obj = new self(); |
|
166 | - foreach ($newProps as $key => $value) { |
|
167 | - $obj->$key = $value; |
|
168 | - } |
|
169 | - return $obj; |
|
170 | - } |
|
42 | + /** |
|
43 | + * An array with requested properties. |
|
44 | + * |
|
45 | + * @var array |
|
46 | + */ |
|
47 | + public $properties; |
|
48 | + |
|
49 | + /** |
|
50 | + * List of property/component filters. |
|
51 | + * |
|
52 | + * @var array |
|
53 | + */ |
|
54 | + public $filters; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var int |
|
58 | + */ |
|
59 | + public $limit; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var int |
|
63 | + */ |
|
64 | + public $offset; |
|
65 | + |
|
66 | + /** |
|
67 | + * The deserialize method is called during xml parsing. |
|
68 | + * |
|
69 | + * This method is called statically, this is because in theory this method |
|
70 | + * may be used as a type of constructor, or factory method. |
|
71 | + * |
|
72 | + * Often you want to return an instance of the current class, but you are |
|
73 | + * free to return other data as well. |
|
74 | + * |
|
75 | + * You are responsible for advancing the reader to the next element. Not |
|
76 | + * doing anything will result in a never-ending loop. |
|
77 | + * |
|
78 | + * If you just want to skip parsing for this element altogether, you can |
|
79 | + * just call $reader->next(); |
|
80 | + * |
|
81 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
82 | + * the next element. |
|
83 | + * |
|
84 | + * @param Reader $reader |
|
85 | + * @return mixed |
|
86 | + */ |
|
87 | + public static function xmlDeserialize(Reader $reader) { |
|
88 | + $elems = $reader->parseInnerTree([ |
|
89 | + '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
90 | + '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
91 | + '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
92 | + '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
93 | + '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
94 | + '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
95 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
96 | + ]); |
|
97 | + |
|
98 | + $newProps = [ |
|
99 | + 'filters' => [], |
|
100 | + 'properties' => [], |
|
101 | + 'limit' => null, |
|
102 | + 'offset' => null |
|
103 | + ]; |
|
104 | + |
|
105 | + if (!is_array($elems)) { |
|
106 | + $elems = []; |
|
107 | + } |
|
108 | + |
|
109 | + foreach ($elems as $elem) { |
|
110 | + switch ($elem['name']) { |
|
111 | + case '{DAV:}prop': |
|
112 | + $newProps['properties'] = array_keys($elem['value']); |
|
113 | + break; |
|
114 | + case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
115 | + foreach ($elem['value'] as $subElem) { |
|
116 | + if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
117 | + if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) { |
|
118 | + $newProps['filters']['comps'] = []; |
|
119 | + } |
|
120 | + $newProps['filters']['comps'][] = $subElem['value']; |
|
121 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
122 | + if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) { |
|
123 | + $newProps['filters']['props'] = []; |
|
124 | + } |
|
125 | + $newProps['filters']['props'][] = $subElem['value']; |
|
126 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
127 | + if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) { |
|
128 | + $newProps['filters']['params'] = []; |
|
129 | + } |
|
130 | + $newProps['filters']['params'][] = $subElem['value']; |
|
131 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
132 | + $newProps['filters']['search-term'] = $subElem['value']; |
|
133 | + } |
|
134 | + } |
|
135 | + break; |
|
136 | + case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
137 | + $newProps['limit'] = $elem['value']; |
|
138 | + break; |
|
139 | + case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
140 | + $newProps['offset'] = $elem['value']; |
|
141 | + break; |
|
142 | + |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + if (empty($newProps['filters'])) { |
|
147 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
148 | + } |
|
149 | + |
|
150 | + $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params'])); |
|
151 | + $noCompsDefined = empty($newProps['filters']['comps']); |
|
152 | + if ($propsOrParamsDefined && $noCompsDefined) { |
|
153 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
154 | + } |
|
155 | + |
|
156 | + if (!isset($newProps['filters']['search-term'])) { |
|
157 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request'); |
|
158 | + } |
|
159 | + |
|
160 | + if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) { |
|
161 | + throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request'); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + $obj = new self(); |
|
166 | + foreach ($newProps as $key => $value) { |
|
167 | + $obj->$key = $value; |
|
168 | + } |
|
169 | + return $obj; |
|
170 | + } |
|
171 | 171 | } |
@@ -23,20 +23,20 @@ |
||
23 | 23 | |
24 | 24 | class CoreBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return 'Core bundle'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return 'Core bundle'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'bruteforcesettings', |
|
39 | - ]; |
|
40 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'bruteforcesettings', |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Groupware bundle'); |
|
30 | + return (string) $this->l10n->t('Groupware bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -25,23 +25,23 @@ |
||
25 | 25 | |
26 | 26 | class GroupwareBundle extends Bundle { |
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getName() { |
|
32 | - return (string)$this->l10n->t('Groupware bundle'); |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getName() { |
|
32 | + return (string)$this->l10n->t('Groupware bundle'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritDoc} |
|
37 | - */ |
|
38 | - public function getAppIdentifiers() { |
|
39 | - return [ |
|
40 | - 'calendar', |
|
41 | - 'contacts', |
|
42 | - 'deck', |
|
43 | - 'mail' |
|
44 | - ]; |
|
45 | - } |
|
35 | + /** |
|
36 | + * {@inheritDoc} |
|
37 | + */ |
|
38 | + public function getAppIdentifiers() { |
|
39 | + return [ |
|
40 | + 'calendar', |
|
41 | + 'contacts', |
|
42 | + 'deck', |
|
43 | + 'mail' |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -35,55 +35,55 @@ |
||
35 | 35 | * @since 8.0.0 |
36 | 36 | */ |
37 | 37 | interface IEventLogger { |
38 | - /** |
|
39 | - * Mark the start of an event setting its ID $id and providing event description $description. |
|
40 | - * |
|
41 | - * @param string $id |
|
42 | - * @param string $description |
|
43 | - * @since 8.0.0 |
|
44 | - */ |
|
45 | - public function start($id, $description); |
|
38 | + /** |
|
39 | + * Mark the start of an event setting its ID $id and providing event description $description. |
|
40 | + * |
|
41 | + * @param string $id |
|
42 | + * @param string $description |
|
43 | + * @since 8.0.0 |
|
44 | + */ |
|
45 | + public function start($id, $description); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Mark the end of an event with specific ID $id, marked by start() method. |
|
49 | - * Ending event should store \OCP\Diagnostics\IEvent to |
|
50 | - * be returned with getEvents() method. |
|
51 | - * |
|
52 | - * @param string $id |
|
53 | - * @since 8.0.0 |
|
54 | - */ |
|
55 | - public function end($id); |
|
47 | + /** |
|
48 | + * Mark the end of an event with specific ID $id, marked by start() method. |
|
49 | + * Ending event should store \OCP\Diagnostics\IEvent to |
|
50 | + * be returned with getEvents() method. |
|
51 | + * |
|
52 | + * @param string $id |
|
53 | + * @since 8.0.0 |
|
54 | + */ |
|
55 | + public function end($id); |
|
56 | 56 | |
57 | - /** |
|
58 | - * Mark the start and the end of an event with specific ID $id and description $description, |
|
59 | - * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
60 | - * Logging event should store \OCP\Diagnostics\IEvent to |
|
61 | - * be returned with getEvents() method. |
|
62 | - * |
|
63 | - * @param string $id |
|
64 | - * @param string $description |
|
65 | - * @param float $start |
|
66 | - * @param float $end |
|
67 | - * @since 8.0.0 |
|
68 | - */ |
|
69 | - public function log($id, $description, $start, $end); |
|
57 | + /** |
|
58 | + * Mark the start and the end of an event with specific ID $id and description $description, |
|
59 | + * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
60 | + * Logging event should store \OCP\Diagnostics\IEvent to |
|
61 | + * be returned with getEvents() method. |
|
62 | + * |
|
63 | + * @param string $id |
|
64 | + * @param string $description |
|
65 | + * @param float $start |
|
66 | + * @param float $end |
|
67 | + * @since 8.0.0 |
|
68 | + */ |
|
69 | + public function log($id, $description, $start, $end); |
|
70 | 70 | |
71 | - /** |
|
72 | - * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
73 | - * start()/end() or log() methods |
|
74 | - * |
|
75 | - * @return \OCP\Diagnostics\IEvent[] |
|
76 | - * @since 8.0.0 |
|
77 | - */ |
|
78 | - public function getEvents(); |
|
71 | + /** |
|
72 | + * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
73 | + * start()/end() or log() methods |
|
74 | + * |
|
75 | + * @return \OCP\Diagnostics\IEvent[] |
|
76 | + * @since 8.0.0 |
|
77 | + */ |
|
78 | + public function getEvents(); |
|
79 | 79 | |
80 | - /** |
|
81 | - * Activate the module for the duration of the request. Deactivated module |
|
82 | - * does not create and store \OCP\Diagnostics\IEvent objects. |
|
83 | - * Only activated module should create and store objects to be |
|
84 | - * returned with getEvents() call. |
|
85 | - * |
|
86 | - * @since 12.0.0 |
|
87 | - */ |
|
88 | - public function activate(); |
|
80 | + /** |
|
81 | + * Activate the module for the duration of the request. Deactivated module |
|
82 | + * does not create and store \OCP\Diagnostics\IEvent objects. |
|
83 | + * Only activated module should create and store objects to be |
|
84 | + * returned with getEvents() call. |
|
85 | + * |
|
86 | + * @since 12.0.0 |
|
87 | + */ |
|
88 | + public function activate(); |
|
89 | 89 | } |