Passed
Push — master ( 9348fd...7904dd )
by Roeland
11:27 queued 12s
created
apps/files_external/lib/Controller/UserStoragesController.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -43,185 +43,185 @@
 block discarded – undo
43 43
  * User storages controller
44 44
  */
45 45
 class UserStoragesController extends StoragesController {
46
-	/**
47
-	 * @var IUserSession
48
-	 */
49
-	private $userSession;
50
-
51
-	/**
52
-	 * Creates a new user storages controller.
53
-	 *
54
-	 * @param string $AppName application name
55
-	 * @param IRequest $request request object
56
-	 * @param IL10N $l10n l10n service
57
-	 * @param UserStoragesService $userStoragesService storage service
58
-	 * @param IUserSession $userSession
59
-	 * @param ILogger $logger
60
-	 */
61
-	public function __construct(
62
-		$AppName,
63
-		IRequest $request,
64
-		IL10N $l10n,
65
-		UserStoragesService $userStoragesService,
66
-		IUserSession $userSession,
67
-		ILogger $logger
68
-	) {
69
-		parent::__construct(
70
-			$AppName,
71
-			$request,
72
-			$l10n,
73
-			$userStoragesService,
74
-			$logger
75
-		);
76
-		$this->userSession = $userSession;
77
-	}
78
-
79
-	protected function manipulateStorageConfig(StorageConfig $storage) {
80
-		/** @var AuthMechanism */
81
-		$authMechanism = $storage->getAuthMechanism();
82
-		$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
83
-		/** @var Backend */
84
-		$backend = $storage->getBackend();
85
-		$backend->manipulateStorageConfig($storage, $this->userSession->getUser());
86
-	}
87
-
88
-	/**
89
-	 * Get all storage entries
90
-	 *
91
-	 * @NoAdminRequired
92
-	 *
93
-	 * @return DataResponse
94
-	 */
95
-	public function index() {
96
-		return parent::index();
97
-	}
98
-
99
-	/**
100
-	 * Return storage
101
-	 *
102
-	 * @NoAdminRequired
103
-	 *
104
-	 * {@inheritdoc}
105
-	 */
106
-	public function show($id, $testOnly = true) {
107
-		return parent::show($id, $testOnly);
108
-	}
109
-
110
-	/**
111
-	 * Create an external storage entry.
112
-	 *
113
-	 * @param string $mountPoint storage mount point
114
-	 * @param string $backend backend identifier
115
-	 * @param string $authMechanism authentication mechanism identifier
116
-	 * @param array $backendOptions backend-specific options
117
-	 * @param array $mountOptions backend-specific mount options
118
-	 *
119
-	 * @return DataResponse
120
-	 *
121
-	 * @NoAdminRequired
122
-	 */
123
-	public function create(
124
-		$mountPoint,
125
-		$backend,
126
-		$authMechanism,
127
-		$backendOptions,
128
-		$mountOptions
129
-	) {
130
-		$newStorage = $this->createStorage(
131
-			$mountPoint,
132
-			$backend,
133
-			$authMechanism,
134
-			$backendOptions,
135
-			$mountOptions
136
-		);
137
-		if ($newStorage instanceOf DataResponse) {
138
-			return $newStorage;
139
-		}
140
-
141
-		$response = $this->validate($newStorage);
142
-		if (!empty($response)) {
143
-			return $response;
144
-		}
145
-
146
-		$newStorage = $this->service->addStorage($newStorage);
147
-		$this->updateStorageStatus($newStorage);
148
-
149
-		return new DataResponse(
150
-			$newStorage,
151
-			Http::STATUS_CREATED
152
-		);
153
-	}
154
-
155
-	/**
156
-	 * Update an external storage entry.
157
-	 *
158
-	 * @param int $id storage id
159
-	 * @param string $mountPoint storage mount point
160
-	 * @param string $backend backend identifier
161
-	 * @param string $authMechanism authentication mechanism identifier
162
-	 * @param array $backendOptions backend-specific options
163
-	 * @param array $mountOptions backend-specific mount options
164
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
165
-	 *
166
-	 * @return DataResponse
167
-	 *
168
-	 * @NoAdminRequired
169
-	 */
170
-	public function update(
171
-		$id,
172
-		$mountPoint,
173
-		$backend,
174
-		$authMechanism,
175
-		$backendOptions,
176
-		$mountOptions,
177
-		$testOnly = true
178
-	) {
179
-		$storage = $this->createStorage(
180
-			$mountPoint,
181
-			$backend,
182
-			$authMechanism,
183
-			$backendOptions,
184
-			$mountOptions
185
-		);
186
-		if ($storage instanceOf DataResponse) {
187
-			return $storage;
188
-		}
189
-		$storage->setId($id);
190
-
191
-		$response = $this->validate($storage);
192
-		if (!empty($response)) {
193
-			return $response;
194
-		}
195
-
196
-		try {
197
-			$storage = $this->service->updateStorage($storage);
198
-		} catch (NotFoundException $e) {
199
-			return new DataResponse(
200
-				[
201
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
202
-				],
203
-				Http::STATUS_NOT_FOUND
204
-			);
205
-		}
206
-
207
-		$this->updateStorageStatus($storage, $testOnly);
208
-
209
-		return new DataResponse(
210
-			$storage,
211
-			Http::STATUS_OK
212
-		);
213
-
214
-	}
215
-
216
-	/**
217
-	 * Delete storage
218
-	 *
219
-	 * @NoAdminRequired
220
-	 *
221
-	 * {@inheritdoc}
222
-	 */
223
-	public function destroy($id) {
224
-		return parent::destroy($id);
225
-	}
46
+    /**
47
+     * @var IUserSession
48
+     */
49
+    private $userSession;
50
+
51
+    /**
52
+     * Creates a new user storages controller.
53
+     *
54
+     * @param string $AppName application name
55
+     * @param IRequest $request request object
56
+     * @param IL10N $l10n l10n service
57
+     * @param UserStoragesService $userStoragesService storage service
58
+     * @param IUserSession $userSession
59
+     * @param ILogger $logger
60
+     */
61
+    public function __construct(
62
+        $AppName,
63
+        IRequest $request,
64
+        IL10N $l10n,
65
+        UserStoragesService $userStoragesService,
66
+        IUserSession $userSession,
67
+        ILogger $logger
68
+    ) {
69
+        parent::__construct(
70
+            $AppName,
71
+            $request,
72
+            $l10n,
73
+            $userStoragesService,
74
+            $logger
75
+        );
76
+        $this->userSession = $userSession;
77
+    }
78
+
79
+    protected function manipulateStorageConfig(StorageConfig $storage) {
80
+        /** @var AuthMechanism */
81
+        $authMechanism = $storage->getAuthMechanism();
82
+        $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
83
+        /** @var Backend */
84
+        $backend = $storage->getBackend();
85
+        $backend->manipulateStorageConfig($storage, $this->userSession->getUser());
86
+    }
87
+
88
+    /**
89
+     * Get all storage entries
90
+     *
91
+     * @NoAdminRequired
92
+     *
93
+     * @return DataResponse
94
+     */
95
+    public function index() {
96
+        return parent::index();
97
+    }
98
+
99
+    /**
100
+     * Return storage
101
+     *
102
+     * @NoAdminRequired
103
+     *
104
+     * {@inheritdoc}
105
+     */
106
+    public function show($id, $testOnly = true) {
107
+        return parent::show($id, $testOnly);
108
+    }
109
+
110
+    /**
111
+     * Create an external storage entry.
112
+     *
113
+     * @param string $mountPoint storage mount point
114
+     * @param string $backend backend identifier
115
+     * @param string $authMechanism authentication mechanism identifier
116
+     * @param array $backendOptions backend-specific options
117
+     * @param array $mountOptions backend-specific mount options
118
+     *
119
+     * @return DataResponse
120
+     *
121
+     * @NoAdminRequired
122
+     */
123
+    public function create(
124
+        $mountPoint,
125
+        $backend,
126
+        $authMechanism,
127
+        $backendOptions,
128
+        $mountOptions
129
+    ) {
130
+        $newStorage = $this->createStorage(
131
+            $mountPoint,
132
+            $backend,
133
+            $authMechanism,
134
+            $backendOptions,
135
+            $mountOptions
136
+        );
137
+        if ($newStorage instanceOf DataResponse) {
138
+            return $newStorage;
139
+        }
140
+
141
+        $response = $this->validate($newStorage);
142
+        if (!empty($response)) {
143
+            return $response;
144
+        }
145
+
146
+        $newStorage = $this->service->addStorage($newStorage);
147
+        $this->updateStorageStatus($newStorage);
148
+
149
+        return new DataResponse(
150
+            $newStorage,
151
+            Http::STATUS_CREATED
152
+        );
153
+    }
154
+
155
+    /**
156
+     * Update an external storage entry.
157
+     *
158
+     * @param int $id storage id
159
+     * @param string $mountPoint storage mount point
160
+     * @param string $backend backend identifier
161
+     * @param string $authMechanism authentication mechanism identifier
162
+     * @param array $backendOptions backend-specific options
163
+     * @param array $mountOptions backend-specific mount options
164
+     * @param bool $testOnly whether to storage should only test the connection or do more things
165
+     *
166
+     * @return DataResponse
167
+     *
168
+     * @NoAdminRequired
169
+     */
170
+    public function update(
171
+        $id,
172
+        $mountPoint,
173
+        $backend,
174
+        $authMechanism,
175
+        $backendOptions,
176
+        $mountOptions,
177
+        $testOnly = true
178
+    ) {
179
+        $storage = $this->createStorage(
180
+            $mountPoint,
181
+            $backend,
182
+            $authMechanism,
183
+            $backendOptions,
184
+            $mountOptions
185
+        );
186
+        if ($storage instanceOf DataResponse) {
187
+            return $storage;
188
+        }
189
+        $storage->setId($id);
190
+
191
+        $response = $this->validate($storage);
192
+        if (!empty($response)) {
193
+            return $response;
194
+        }
195
+
196
+        try {
197
+            $storage = $this->service->updateStorage($storage);
198
+        } catch (NotFoundException $e) {
199
+            return new DataResponse(
200
+                [
201
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
202
+                ],
203
+                Http::STATUS_NOT_FOUND
204
+            );
205
+        }
206
+
207
+        $this->updateStorageStatus($storage, $testOnly);
208
+
209
+        return new DataResponse(
210
+            $storage,
211
+            Http::STATUS_OK
212
+        );
213
+
214
+    }
215
+
216
+    /**
217
+     * Delete storage
218
+     *
219
+     * @NoAdminRequired
220
+     *
221
+     * {@inheritdoc}
222
+     */
223
+    public function destroy($id) {
224
+        return parent::destroy($id);
225
+    }
226 226
 
227 227
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/GlobalStoragesController.php 1 patch
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -39,151 +39,151 @@
 block discarded – undo
39 39
  * Global storages controller
40 40
  */
41 41
 class GlobalStoragesController extends StoragesController {
42
-	/**
43
-	 * Creates a new global storages controller.
44
-	 *
45
-	 * @param string $AppName application name
46
-	 * @param IRequest $request request object
47
-	 * @param IL10N $l10n l10n service
48
-	 * @param GlobalStoragesService $globalStoragesService storage service
49
-	 * @param ILogger $logger
50
-	 */
51
-	public function __construct(
52
-		$AppName,
53
-		IRequest $request,
54
-		IL10N $l10n,
55
-		GlobalStoragesService $globalStoragesService,
56
-		ILogger $logger
57
-	) {
58
-		parent::__construct(
59
-			$AppName,
60
-			$request,
61
-			$l10n,
62
-			$globalStoragesService,
63
-			$logger
64
-		);
65
-	}
66
-
67
-	/**
68
-	 * Create an external storage entry.
69
-	 *
70
-	 * @param string $mountPoint storage mount point
71
-	 * @param string $backend backend identifier
72
-	 * @param string $authMechanism authentication mechanism identifier
73
-	 * @param array $backendOptions backend-specific options
74
-	 * @param array $mountOptions mount-specific options
75
-	 * @param array $applicableUsers users for which to mount the storage
76
-	 * @param array $applicableGroups groups for which to mount the storage
77
-	 * @param int $priority priority
78
-	 *
79
-	 * @return DataResponse
80
-	 */
81
-	public function create(
82
-		$mountPoint,
83
-		$backend,
84
-		$authMechanism,
85
-		$backendOptions,
86
-		$mountOptions,
87
-		$applicableUsers,
88
-		$applicableGroups,
89
-		$priority
90
-	) {
91
-		$newStorage = $this->createStorage(
92
-			$mountPoint,
93
-			$backend,
94
-			$authMechanism,
95
-			$backendOptions,
96
-			$mountOptions,
97
-			$applicableUsers,
98
-			$applicableGroups,
99
-			$priority
100
-		);
101
-		if ($newStorage instanceof DataResponse) {
102
-			return $newStorage;
103
-		}
104
-
105
-		$response = $this->validate($newStorage);
106
-		if (!empty($response)) {
107
-			return $response;
108
-		}
109
-
110
-		$newStorage = $this->service->addStorage($newStorage);
111
-
112
-		$this->updateStorageStatus($newStorage);
113
-
114
-		return new DataResponse(
115
-			$newStorage,
116
-			Http::STATUS_CREATED
117
-		);
118
-	}
119
-
120
-	/**
121
-	 * Update an external storage entry.
122
-	 *
123
-	 * @param int $id storage id
124
-	 * @param string $mountPoint storage mount point
125
-	 * @param string $backend backend identifier
126
-	 * @param string $authMechanism authentication mechansim identifier
127
-	 * @param array $backendOptions backend-specific options
128
-	 * @param array $mountOptions mount-specific options
129
-	 * @param array $applicableUsers users for which to mount the storage
130
-	 * @param array $applicableGroups groups for which to mount the storage
131
-	 * @param int $priority priority
132
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
133
-	 *
134
-	 * @return DataResponse
135
-	 */
136
-	public function update(
137
-		$id,
138
-		$mountPoint,
139
-		$backend,
140
-		$authMechanism,
141
-		$backendOptions,
142
-		$mountOptions,
143
-		$applicableUsers,
144
-		$applicableGroups,
145
-		$priority,
146
-		$testOnly = true
147
-	) {
148
-		$storage = $this->createStorage(
149
-			$mountPoint,
150
-			$backend,
151
-			$authMechanism,
152
-			$backendOptions,
153
-			$mountOptions,
154
-			$applicableUsers,
155
-			$applicableGroups,
156
-			$priority
157
-		);
158
-		if ($storage instanceof DataResponse) {
159
-			return $storage;
160
-		}
161
-		$storage->setId($id);
162
-
163
-		$response = $this->validate($storage);
164
-		if (!empty($response)) {
165
-			return $response;
166
-		}
167
-
168
-		try {
169
-			$storage = $this->service->updateStorage($storage);
170
-		} catch (NotFoundException $e) {
171
-			return new DataResponse(
172
-				[
173
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
174
-				],
175
-				Http::STATUS_NOT_FOUND
176
-			);
177
-		}
178
-
179
-		$this->updateStorageStatus($storage, $testOnly);
180
-
181
-		return new DataResponse(
182
-			$storage,
183
-			Http::STATUS_OK
184
-		);
185
-
186
-	}
42
+    /**
43
+     * Creates a new global storages controller.
44
+     *
45
+     * @param string $AppName application name
46
+     * @param IRequest $request request object
47
+     * @param IL10N $l10n l10n service
48
+     * @param GlobalStoragesService $globalStoragesService storage service
49
+     * @param ILogger $logger
50
+     */
51
+    public function __construct(
52
+        $AppName,
53
+        IRequest $request,
54
+        IL10N $l10n,
55
+        GlobalStoragesService $globalStoragesService,
56
+        ILogger $logger
57
+    ) {
58
+        parent::__construct(
59
+            $AppName,
60
+            $request,
61
+            $l10n,
62
+            $globalStoragesService,
63
+            $logger
64
+        );
65
+    }
66
+
67
+    /**
68
+     * Create an external storage entry.
69
+     *
70
+     * @param string $mountPoint storage mount point
71
+     * @param string $backend backend identifier
72
+     * @param string $authMechanism authentication mechanism identifier
73
+     * @param array $backendOptions backend-specific options
74
+     * @param array $mountOptions mount-specific options
75
+     * @param array $applicableUsers users for which to mount the storage
76
+     * @param array $applicableGroups groups for which to mount the storage
77
+     * @param int $priority priority
78
+     *
79
+     * @return DataResponse
80
+     */
81
+    public function create(
82
+        $mountPoint,
83
+        $backend,
84
+        $authMechanism,
85
+        $backendOptions,
86
+        $mountOptions,
87
+        $applicableUsers,
88
+        $applicableGroups,
89
+        $priority
90
+    ) {
91
+        $newStorage = $this->createStorage(
92
+            $mountPoint,
93
+            $backend,
94
+            $authMechanism,
95
+            $backendOptions,
96
+            $mountOptions,
97
+            $applicableUsers,
98
+            $applicableGroups,
99
+            $priority
100
+        );
101
+        if ($newStorage instanceof DataResponse) {
102
+            return $newStorage;
103
+        }
104
+
105
+        $response = $this->validate($newStorage);
106
+        if (!empty($response)) {
107
+            return $response;
108
+        }
109
+
110
+        $newStorage = $this->service->addStorage($newStorage);
111
+
112
+        $this->updateStorageStatus($newStorage);
113
+
114
+        return new DataResponse(
115
+            $newStorage,
116
+            Http::STATUS_CREATED
117
+        );
118
+    }
119
+
120
+    /**
121
+     * Update an external storage entry.
122
+     *
123
+     * @param int $id storage id
124
+     * @param string $mountPoint storage mount point
125
+     * @param string $backend backend identifier
126
+     * @param string $authMechanism authentication mechansim identifier
127
+     * @param array $backendOptions backend-specific options
128
+     * @param array $mountOptions mount-specific options
129
+     * @param array $applicableUsers users for which to mount the storage
130
+     * @param array $applicableGroups groups for which to mount the storage
131
+     * @param int $priority priority
132
+     * @param bool $testOnly whether to storage should only test the connection or do more things
133
+     *
134
+     * @return DataResponse
135
+     */
136
+    public function update(
137
+        $id,
138
+        $mountPoint,
139
+        $backend,
140
+        $authMechanism,
141
+        $backendOptions,
142
+        $mountOptions,
143
+        $applicableUsers,
144
+        $applicableGroups,
145
+        $priority,
146
+        $testOnly = true
147
+    ) {
148
+        $storage = $this->createStorage(
149
+            $mountPoint,
150
+            $backend,
151
+            $authMechanism,
152
+            $backendOptions,
153
+            $mountOptions,
154
+            $applicableUsers,
155
+            $applicableGroups,
156
+            $priority
157
+        );
158
+        if ($storage instanceof DataResponse) {
159
+            return $storage;
160
+        }
161
+        $storage->setId($id);
162
+
163
+        $response = $this->validate($storage);
164
+        if (!empty($response)) {
165
+            return $response;
166
+        }
167
+
168
+        try {
169
+            $storage = $this->service->updateStorage($storage);
170
+        } catch (NotFoundException $e) {
171
+            return new DataResponse(
172
+                [
173
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
174
+                ],
175
+                Http::STATUS_NOT_FOUND
176
+            );
177
+        }
178
+
179
+        $this->updateStorageStatus($storage, $testOnly);
180
+
181
+        return new DataResponse(
182
+            $storage,
183
+            Http::STATUS_OK
184
+        );
185
+
186
+    }
187 187
 
188 188
 
189 189
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/StoragesController.php 1 patch
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -47,298 +47,298 @@
 block discarded – undo
47 47
  */
48 48
 abstract class StoragesController extends Controller {
49 49
 
50
-	/**
51
-	 * L10N service
52
-	 *
53
-	 * @var IL10N
54
-	 */
55
-	protected $l10n;
50
+    /**
51
+     * L10N service
52
+     *
53
+     * @var IL10N
54
+     */
55
+    protected $l10n;
56 56
 
57
-	/**
58
-	 * Storages service
59
-	 *
60
-	 * @var StoragesService
61
-	 */
62
-	protected $service;
57
+    /**
58
+     * Storages service
59
+     *
60
+     * @var StoragesService
61
+     */
62
+    protected $service;
63 63
 
64
-	/**
65
-	 * @var ILogger
66
-	 */
67
-	protected $logger;
64
+    /**
65
+     * @var ILogger
66
+     */
67
+    protected $logger;
68 68
 
69
-	/**
70
-	 * Creates a new storages controller.
71
-	 *
72
-	 * @param string $AppName application name
73
-	 * @param IRequest $request request object
74
-	 * @param IL10N $l10n l10n service
75
-	 * @param StoragesService $storagesService storage service
76
-	 * @param ILogger $logger
77
-	 */
78
-	public function __construct(
79
-		$AppName,
80
-		IRequest $request,
81
-		IL10N $l10n,
82
-		StoragesService $storagesService,
83
-		ILogger $logger
84
-	) {
85
-		parent::__construct($AppName, $request);
86
-		$this->l10n = $l10n;
87
-		$this->service = $storagesService;
88
-		$this->logger = $logger;
89
-	}
69
+    /**
70
+     * Creates a new storages controller.
71
+     *
72
+     * @param string $AppName application name
73
+     * @param IRequest $request request object
74
+     * @param IL10N $l10n l10n service
75
+     * @param StoragesService $storagesService storage service
76
+     * @param ILogger $logger
77
+     */
78
+    public function __construct(
79
+        $AppName,
80
+        IRequest $request,
81
+        IL10N $l10n,
82
+        StoragesService $storagesService,
83
+        ILogger $logger
84
+    ) {
85
+        parent::__construct($AppName, $request);
86
+        $this->l10n = $l10n;
87
+        $this->service = $storagesService;
88
+        $this->logger = $logger;
89
+    }
90 90
 
91
-	/**
92
-	 * Create a storage from its parameters
93
-	 *
94
-	 * @param string $mountPoint storage mount point
95
-	 * @param string $backend backend identifier
96
-	 * @param string $authMechanism authentication mechanism identifier
97
-	 * @param array $backendOptions backend-specific options
98
-	 * @param array|null $mountOptions mount-specific options
99
-	 * @param array|null $applicableUsers users for which to mount the storage
100
-	 * @param array|null $applicableGroups groups for which to mount the storage
101
-	 * @param int|null $priority priority
102
-	 *
103
-	 * @return StorageConfig|DataResponse
104
-	 */
105
-	protected function createStorage(
106
-		$mountPoint,
107
-		$backend,
108
-		$authMechanism,
109
-		$backendOptions,
110
-		$mountOptions = null,
111
-		$applicableUsers = null,
112
-		$applicableGroups = null,
113
-		$priority = null
114
-	) {
115
-		try {
116
-			return $this->service->createStorage(
117
-				$mountPoint,
118
-				$backend,
119
-				$authMechanism,
120
-				$backendOptions,
121
-				$mountOptions,
122
-				$applicableUsers,
123
-				$applicableGroups,
124
-				$priority
125
-			);
126
-		} catch (\InvalidArgumentException $e) {
127
-			$this->logger->logException($e);
128
-			return new DataResponse(
129
-				[
130
-					'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class')
131
-				],
132
-				Http::STATUS_UNPROCESSABLE_ENTITY
133
-			);
134
-		}
135
-	}
91
+    /**
92
+     * Create a storage from its parameters
93
+     *
94
+     * @param string $mountPoint storage mount point
95
+     * @param string $backend backend identifier
96
+     * @param string $authMechanism authentication mechanism identifier
97
+     * @param array $backendOptions backend-specific options
98
+     * @param array|null $mountOptions mount-specific options
99
+     * @param array|null $applicableUsers users for which to mount the storage
100
+     * @param array|null $applicableGroups groups for which to mount the storage
101
+     * @param int|null $priority priority
102
+     *
103
+     * @return StorageConfig|DataResponse
104
+     */
105
+    protected function createStorage(
106
+        $mountPoint,
107
+        $backend,
108
+        $authMechanism,
109
+        $backendOptions,
110
+        $mountOptions = null,
111
+        $applicableUsers = null,
112
+        $applicableGroups = null,
113
+        $priority = null
114
+    ) {
115
+        try {
116
+            return $this->service->createStorage(
117
+                $mountPoint,
118
+                $backend,
119
+                $authMechanism,
120
+                $backendOptions,
121
+                $mountOptions,
122
+                $applicableUsers,
123
+                $applicableGroups,
124
+                $priority
125
+            );
126
+        } catch (\InvalidArgumentException $e) {
127
+            $this->logger->logException($e);
128
+            return new DataResponse(
129
+                [
130
+                    'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class')
131
+                ],
132
+                Http::STATUS_UNPROCESSABLE_ENTITY
133
+            );
134
+        }
135
+    }
136 136
 
137
-	/**
138
-	 * Validate storage config
139
-	 *
140
-	 * @param StorageConfig $storage storage config
141
-	 *1
142
-	 * @return DataResponse|null returns response in case of validation error
143
-	 */
144
-	protected function validate(StorageConfig $storage) {
145
-		$mountPoint = $storage->getMountPoint();
146
-		if ($mountPoint === '') {
147
-			return new DataResponse(
148
-				array(
149
-					'message' => (string)$this->l10n->t('Invalid mount point')
150
-				),
151
-				Http::STATUS_UNPROCESSABLE_ENTITY
152
-			);
153
-		}
137
+    /**
138
+     * Validate storage config
139
+     *
140
+     * @param StorageConfig $storage storage config
141
+     *1
142
+     * @return DataResponse|null returns response in case of validation error
143
+     */
144
+    protected function validate(StorageConfig $storage) {
145
+        $mountPoint = $storage->getMountPoint();
146
+        if ($mountPoint === '') {
147
+            return new DataResponse(
148
+                array(
149
+                    'message' => (string)$this->l10n->t('Invalid mount point')
150
+                ),
151
+                Http::STATUS_UNPROCESSABLE_ENTITY
152
+            );
153
+        }
154 154
 
155
-		if ($storage->getBackendOption('objectstore')) {
156
-			// objectstore must not be sent from client side
157
-			return new DataResponse(
158
-				array(
159
-					'message' => (string)$this->l10n->t('Objectstore forbidden')
160
-				),
161
-				Http::STATUS_UNPROCESSABLE_ENTITY
162
-			);
163
-		}
155
+        if ($storage->getBackendOption('objectstore')) {
156
+            // objectstore must not be sent from client side
157
+            return new DataResponse(
158
+                array(
159
+                    'message' => (string)$this->l10n->t('Objectstore forbidden')
160
+                ),
161
+                Http::STATUS_UNPROCESSABLE_ENTITY
162
+            );
163
+        }
164 164
 
165
-		/** @var Backend */
166
-		$backend = $storage->getBackend();
167
-		/** @var AuthMechanism */
168
-		$authMechanism = $storage->getAuthMechanism();
169
-		if ($backend->checkDependencies()) {
170
-			// invalid backend
171
-			return new DataResponse(
172
-				array(
173
-					'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [
174
-						$backend->getIdentifier()
175
-					])
176
-				),
177
-				Http::STATUS_UNPROCESSABLE_ENTITY
178
-			);
179
-		}
165
+        /** @var Backend */
166
+        $backend = $storage->getBackend();
167
+        /** @var AuthMechanism */
168
+        $authMechanism = $storage->getAuthMechanism();
169
+        if ($backend->checkDependencies()) {
170
+            // invalid backend
171
+            return new DataResponse(
172
+                array(
173
+                    'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [
174
+                        $backend->getIdentifier()
175
+                    ])
176
+                ),
177
+                Http::STATUS_UNPROCESSABLE_ENTITY
178
+            );
179
+        }
180 180
 
181
-		if (!$backend->isVisibleFor($this->service->getVisibilityType())) {
182
-			// not permitted to use backend
183
-			return new DataResponse(
184
-				array(
185
-					'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [
186
-						$backend->getIdentifier()
187
-					])
188
-				),
189
-				Http::STATUS_UNPROCESSABLE_ENTITY
190
-			);
191
-		}
192
-		if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) {
193
-			// not permitted to use auth mechanism
194
-			return new DataResponse(
195
-				array(
196
-					'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [
197
-						$authMechanism->getIdentifier()
198
-					])
199
-				),
200
-				Http::STATUS_UNPROCESSABLE_ENTITY
201
-			);
202
-		}
181
+        if (!$backend->isVisibleFor($this->service->getVisibilityType())) {
182
+            // not permitted to use backend
183
+            return new DataResponse(
184
+                array(
185
+                    'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [
186
+                        $backend->getIdentifier()
187
+                    ])
188
+                ),
189
+                Http::STATUS_UNPROCESSABLE_ENTITY
190
+            );
191
+        }
192
+        if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) {
193
+            // not permitted to use auth mechanism
194
+            return new DataResponse(
195
+                array(
196
+                    'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [
197
+                        $authMechanism->getIdentifier()
198
+                    ])
199
+                ),
200
+                Http::STATUS_UNPROCESSABLE_ENTITY
201
+            );
202
+        }
203 203
 
204
-		if (!$backend->validateStorage($storage)) {
205
-			// unsatisfied parameters
206
-			return new DataResponse(
207
-				array(
208
-					'message' => (string)$this->l10n->t('Unsatisfied backend parameters')
209
-				),
210
-				Http::STATUS_UNPROCESSABLE_ENTITY
211
-			);
212
-		}
213
-		if (!$authMechanism->validateStorage($storage)) {
214
-			// unsatisfied parameters
215
-			return new DataResponse(
216
-				[
217
-					'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters')
218
-				],
219
-				Http::STATUS_UNPROCESSABLE_ENTITY
220
-			);
221
-		}
204
+        if (!$backend->validateStorage($storage)) {
205
+            // unsatisfied parameters
206
+            return new DataResponse(
207
+                array(
208
+                    'message' => (string)$this->l10n->t('Unsatisfied backend parameters')
209
+                ),
210
+                Http::STATUS_UNPROCESSABLE_ENTITY
211
+            );
212
+        }
213
+        if (!$authMechanism->validateStorage($storage)) {
214
+            // unsatisfied parameters
215
+            return new DataResponse(
216
+                [
217
+                    'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters')
218
+                ],
219
+                Http::STATUS_UNPROCESSABLE_ENTITY
220
+            );
221
+        }
222 222
 
223
-		return null;
224
-	}
223
+        return null;
224
+    }
225 225
 
226
-	protected function manipulateStorageConfig(StorageConfig $storage) {
227
-		/** @var AuthMechanism */
228
-		$authMechanism = $storage->getAuthMechanism();
229
-		$authMechanism->manipulateStorageConfig($storage);
230
-		/** @var Backend */
231
-		$backend = $storage->getBackend();
232
-		$backend->manipulateStorageConfig($storage);
233
-	}
226
+    protected function manipulateStorageConfig(StorageConfig $storage) {
227
+        /** @var AuthMechanism */
228
+        $authMechanism = $storage->getAuthMechanism();
229
+        $authMechanism->manipulateStorageConfig($storage);
230
+        /** @var Backend */
231
+        $backend = $storage->getBackend();
232
+        $backend->manipulateStorageConfig($storage);
233
+    }
234 234
 
235
-	/**
236
-	 * Check whether the given storage is available / valid.
237
-	 *
238
-	 * Note that this operation can be time consuming depending
239
-	 * on whether the remote storage is available or not.
240
-	 *
241
-	 * @param StorageConfig $storage storage configuration
242
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
243
-	 */
244
-	protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) {
245
-		try {
246
-			$this->manipulateStorageConfig($storage);
235
+    /**
236
+     * Check whether the given storage is available / valid.
237
+     *
238
+     * Note that this operation can be time consuming depending
239
+     * on whether the remote storage is available or not.
240
+     *
241
+     * @param StorageConfig $storage storage configuration
242
+     * @param bool $testOnly whether to storage should only test the connection or do more things
243
+     */
244
+    protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) {
245
+        try {
246
+            $this->manipulateStorageConfig($storage);
247 247
 
248
-			/** @var Backend */
249
-			$backend = $storage->getBackend();
250
-			// update status (can be time-consuming)
251
-			$storage->setStatus(
252
-				\OC_Mount_Config::getBackendStatus(
253
-					$backend->getStorageClass(),
254
-					$storage->getBackendOptions(),
255
-					false,
256
-					$testOnly
257
-				)
258
-			);
259
-		} catch (InsufficientDataForMeaningfulAnswerException $e) {
260
-			$status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
261
-			$storage->setStatus(
262
-				$status,
263
-				$this->l10n->t('Insufficient data: %s', [$e->getMessage()])
264
-			);
265
-		} catch (StorageNotAvailableException $e) {
266
-			$storage->setStatus(
267
-				$e->getCode(),
268
-				$this->l10n->t('%s', [$e->getMessage()])
269
-			);
270
-		} catch (\Exception $e) {
271
-			// FIXME: convert storage exceptions to StorageNotAvailableException
272
-			$storage->setStatus(
273
-				StorageNotAvailableException::STATUS_ERROR,
274
-				get_class($e).': '.$e->getMessage()
275
-			);
276
-		}
277
-	}
248
+            /** @var Backend */
249
+            $backend = $storage->getBackend();
250
+            // update status (can be time-consuming)
251
+            $storage->setStatus(
252
+                \OC_Mount_Config::getBackendStatus(
253
+                    $backend->getStorageClass(),
254
+                    $storage->getBackendOptions(),
255
+                    false,
256
+                    $testOnly
257
+                )
258
+            );
259
+        } catch (InsufficientDataForMeaningfulAnswerException $e) {
260
+            $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
261
+            $storage->setStatus(
262
+                $status,
263
+                $this->l10n->t('Insufficient data: %s', [$e->getMessage()])
264
+            );
265
+        } catch (StorageNotAvailableException $e) {
266
+            $storage->setStatus(
267
+                $e->getCode(),
268
+                $this->l10n->t('%s', [$e->getMessage()])
269
+            );
270
+        } catch (\Exception $e) {
271
+            // FIXME: convert storage exceptions to StorageNotAvailableException
272
+            $storage->setStatus(
273
+                StorageNotAvailableException::STATUS_ERROR,
274
+                get_class($e).': '.$e->getMessage()
275
+            );
276
+        }
277
+    }
278 278
 
279
-	/**
280
-	 * Get all storage entries
281
-	 *
282
-	 * @return DataResponse
283
-	 */
284
-	public function index() {
285
-		$storages = $this->service->getStorages();
279
+    /**
280
+     * Get all storage entries
281
+     *
282
+     * @return DataResponse
283
+     */
284
+    public function index() {
285
+        $storages = $this->service->getStorages();
286 286
 
287
-		return new DataResponse(
288
-			$storages,
289
-			Http::STATUS_OK
290
-		);
291
-	}
287
+        return new DataResponse(
288
+            $storages,
289
+            Http::STATUS_OK
290
+        );
291
+    }
292 292
 
293
-	/**
294
-	 * Get an external storage entry.
295
-	 *
296
-	 * @param int $id storage id
297
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
298
-	 *
299
-	 * @return DataResponse
300
-	 */
301
-	public function show($id, $testOnly = true) {
302
-		try {
303
-			$storage = $this->service->getStorage($id);
293
+    /**
294
+     * Get an external storage entry.
295
+     *
296
+     * @param int $id storage id
297
+     * @param bool $testOnly whether to storage should only test the connection or do more things
298
+     *
299
+     * @return DataResponse
300
+     */
301
+    public function show($id, $testOnly = true) {
302
+        try {
303
+            $storage = $this->service->getStorage($id);
304 304
 
305
-			$this->updateStorageStatus($storage, $testOnly);
306
-		} catch (NotFoundException $e) {
307
-			return new DataResponse(
308
-				[
309
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
310
-				],
311
-				Http::STATUS_NOT_FOUND
312
-			);
313
-		}
305
+            $this->updateStorageStatus($storage, $testOnly);
306
+        } catch (NotFoundException $e) {
307
+            return new DataResponse(
308
+                [
309
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
310
+                ],
311
+                Http::STATUS_NOT_FOUND
312
+            );
313
+        }
314 314
 
315
-		return new DataResponse(
316
-			$storage,
317
-			Http::STATUS_OK
318
-		);
319
-	}
315
+        return new DataResponse(
316
+            $storage,
317
+            Http::STATUS_OK
318
+        );
319
+    }
320 320
 
321
-	/**
322
-	 * Deletes the storage with the given id.
323
-	 *
324
-	 * @param int $id storage id
325
-	 *
326
-	 * @return DataResponse
327
-	 */
328
-	public function destroy($id) {
329
-		try {
330
-			$this->service->removeStorage($id);
331
-		} catch (NotFoundException $e) {
332
-			return new DataResponse(
333
-				[
334
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
335
-				],
336
-				Http::STATUS_NOT_FOUND
337
-			);
338
-		}
321
+    /**
322
+     * Deletes the storage with the given id.
323
+     *
324
+     * @param int $id storage id
325
+     *
326
+     * @return DataResponse
327
+     */
328
+    public function destroy($id) {
329
+        try {
330
+            $this->service->removeStorage($id);
331
+        } catch (NotFoundException $e) {
332
+            return new DataResponse(
333
+                [
334
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id))
335
+                ],
336
+                Http::STATUS_NOT_FOUND
337
+            );
338
+        }
339 339
 
340
-		return new DataResponse([], Http::STATUS_NO_CONTENT);
341
-	}
340
+        return new DataResponse([], Http::STATUS_NO_CONTENT);
341
+    }
342 342
 
343 343
 }
344 344
 
Please login to merge, or discard this patch.
lib/private/Accounts/Hooks.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -27,73 +27,73 @@
 block discarded – undo
27 27
 
28 28
 class Hooks {
29 29
 
30
-	/** @var  AccountManager */
31
-	private $accountManager = null;
32
-
33
-	/** @var ILogger */
34
-	private $logger;
35
-
36
-	/**
37
-	 * Hooks constructor.
38
-	 *
39
-	 * @param ILogger $logger
40
-	 */
41
-	public function __construct(ILogger $logger) {
42
-		$this->logger = $logger;
43
-	}
44
-
45
-	/**
46
-	 * update accounts table if email address or display name was changed from outside
47
-	 *
48
-	 * @param array $params
49
-	 */
50
-	public function changeUserHook($params) {
51
-
52
-		$accountManager = $this->getAccountManager();
53
-
54
-		/** @var IUser $user */
55
-		$user = isset($params['user']) ? $params['user'] : null;
56
-		$feature = isset($params['feature']) ? $params['feature'] : null;
57
-		$newValue = isset($params['value']) ? $params['value'] : null;
58
-
59
-		if (is_null($user) || is_null($feature) || is_null($newValue)) {
60
-			$this->logger->warning('Missing expected parameters in change user hook');
61
-			return;
62
-		}
63
-
64
-		$accountData = $accountManager->getUser($user);
65
-
66
-		switch ($feature) {
67
-			case 'eMailAddress':
68
-				if ($accountData[AccountManager::PROPERTY_EMAIL]['value'] !== $newValue) {
69
-					$accountData[AccountManager::PROPERTY_EMAIL]['value'] = $newValue;
70
-					$accountManager->updateUser($user, $accountData);
71
-				}
72
-				break;
73
-			case 'displayName':
74
-				if ($accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $newValue) {
75
-					$accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $newValue;
76
-					$accountManager->updateUser($user, $accountData);
77
-				}
78
-				break;
79
-		}
80
-
81
-	}
82
-
83
-	/**
84
-	 * return instance of accountManager
85
-	 *
86
-	 * @return AccountManager
87
-	 */
88
-	protected function getAccountManager() {
89
-		if (is_null($this->accountManager)) {
90
-			$this->accountManager = new AccountManager(
91
-				\OC::$server->getDatabaseConnection(),
92
-				\OC::$server->getEventDispatcher(),
93
-				\OC::$server->getJobList()
94
-			);
95
-		}
96
-		return $this->accountManager;
97
-	}
30
+    /** @var  AccountManager */
31
+    private $accountManager = null;
32
+
33
+    /** @var ILogger */
34
+    private $logger;
35
+
36
+    /**
37
+     * Hooks constructor.
38
+     *
39
+     * @param ILogger $logger
40
+     */
41
+    public function __construct(ILogger $logger) {
42
+        $this->logger = $logger;
43
+    }
44
+
45
+    /**
46
+     * update accounts table if email address or display name was changed from outside
47
+     *
48
+     * @param array $params
49
+     */
50
+    public function changeUserHook($params) {
51
+
52
+        $accountManager = $this->getAccountManager();
53
+
54
+        /** @var IUser $user */
55
+        $user = isset($params['user']) ? $params['user'] : null;
56
+        $feature = isset($params['feature']) ? $params['feature'] : null;
57
+        $newValue = isset($params['value']) ? $params['value'] : null;
58
+
59
+        if (is_null($user) || is_null($feature) || is_null($newValue)) {
60
+            $this->logger->warning('Missing expected parameters in change user hook');
61
+            return;
62
+        }
63
+
64
+        $accountData = $accountManager->getUser($user);
65
+
66
+        switch ($feature) {
67
+            case 'eMailAddress':
68
+                if ($accountData[AccountManager::PROPERTY_EMAIL]['value'] !== $newValue) {
69
+                    $accountData[AccountManager::PROPERTY_EMAIL]['value'] = $newValue;
70
+                    $accountManager->updateUser($user, $accountData);
71
+                }
72
+                break;
73
+            case 'displayName':
74
+                if ($accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $newValue) {
75
+                    $accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $newValue;
76
+                    $accountManager->updateUser($user, $accountData);
77
+                }
78
+                break;
79
+        }
80
+
81
+    }
82
+
83
+    /**
84
+     * return instance of accountManager
85
+     *
86
+     * @return AccountManager
87
+     */
88
+    protected function getAccountManager() {
89
+        if (is_null($this->accountManager)) {
90
+            $this->accountManager = new AccountManager(
91
+                \OC::$server->getDatabaseConnection(),
92
+                \OC::$server->getEventDispatcher(),
93
+                \OC::$server->getJobList()
94
+            );
95
+        }
96
+        return $this->accountManager;
97
+    }
98 98
 
99 99
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagPlugin.php 1 patch
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -46,280 +46,280 @@
 block discarded – undo
46 46
  */
47 47
 class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
48 48
 
49
-	// namespace
50
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
51
-	const ID_PROPERTYNAME = '{http://owncloud.org/ns}id';
52
-	const DISPLAYNAME_PROPERTYNAME = '{http://owncloud.org/ns}display-name';
53
-	const USERVISIBLE_PROPERTYNAME = '{http://owncloud.org/ns}user-visible';
54
-	const USERASSIGNABLE_PROPERTYNAME = '{http://owncloud.org/ns}user-assignable';
55
-	const GROUPS_PROPERTYNAME = '{http://owncloud.org/ns}groups';
56
-	const CANASSIGN_PROPERTYNAME = '{http://owncloud.org/ns}can-assign';
57
-
58
-	/**
59
-	 * @var \Sabre\DAV\Server $server
60
-	 */
61
-	private $server;
62
-
63
-	/**
64
-	 * @var ISystemTagManager
65
-	 */
66
-	protected $tagManager;
67
-
68
-	/**
69
-	 * @var IUserSession
70
-	 */
71
-	protected $userSession;
72
-
73
-	/**
74
-	 * @var IGroupManager
75
-	 */
76
-	protected $groupManager;
77
-
78
-	/**
79
-	 * @param ISystemTagManager $tagManager tag manager
80
-	 * @param IGroupManager $groupManager
81
-	 * @param IUserSession $userSession
82
-	 */
83
-	public function __construct(ISystemTagManager $tagManager,
84
-								IGroupManager $groupManager,
85
-								IUserSession $userSession) {
86
-		$this->tagManager = $tagManager;
87
-		$this->userSession = $userSession;
88
-		$this->groupManager = $groupManager;
89
-	}
90
-
91
-	/**
92
-	 * This initializes the plugin.
93
-	 *
94
-	 * This function is called by \Sabre\DAV\Server, after
95
-	 * addPlugin is called.
96
-	 *
97
-	 * This method should set up the required event subscriptions.
98
-	 *
99
-	 * @param \Sabre\DAV\Server $server
100
-	 * @return void
101
-	 */
102
-	public function initialize(\Sabre\DAV\Server $server) {
103
-
104
-		$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
105
-
106
-		$server->protectedProperties[] = self::ID_PROPERTYNAME;
107
-
108
-		$server->on('propFind', array($this, 'handleGetProperties'));
109
-		$server->on('propPatch', array($this, 'handleUpdateProperties'));
110
-		$server->on('method:POST', [$this, 'httpPost']);
111
-
112
-		$this->server = $server;
113
-	}
114
-
115
-	/**
116
-	 * POST operation on system tag collections
117
-	 *
118
-	 * @param RequestInterface $request request object
119
-	 * @param ResponseInterface $response response object
120
-	 * @return null|false
121
-	 */
122
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
123
-		$path = $request->getPath();
124
-
125
-		// Making sure the node exists
126
-		$node = $this->server->tree->getNodeForPath($path);
127
-		if ($node instanceof SystemTagsByIdCollection || $node instanceof SystemTagsObjectMappingCollection) {
128
-			$data = $request->getBodyAsString();
129
-
130
-			$tag = $this->createTag($data, $request->getHeader('Content-Type'));
131
-
132
-			if ($node instanceof SystemTagsObjectMappingCollection) {
133
-				// also add to collection
134
-				$node->createFile($tag->getId());
135
-				$url = $request->getBaseUrl() . 'systemtags/';
136
-			} else {
137
-				$url = $request->getUrl();
138
-			}
139
-
140
-			if ($url[strlen($url) - 1] !== '/') {
141
-				$url .= '/';
142
-			}
143
-
144
-			$response->setHeader('Content-Location', $url . $tag->getId());
145
-
146
-			// created
147
-			$response->setStatus(201);
148
-			return false;
149
-		}
150
-	}
151
-
152
-	/**
153
-	 * Creates a new tag
154
-	 *
155
-	 * @param string $data JSON encoded string containing the properties of the tag to create
156
-	 * @param string $contentType content type of the data
157
-	 * @return ISystemTag newly created system tag
158
-	 *
159
-	 * @throws BadRequest if a field was missing
160
-	 * @throws Conflict if a tag with the same properties already exists
161
-	 * @throws UnsupportedMediaType if the content type is not supported
162
-	 */
163
-	private function createTag($data, $contentType = 'application/json') {
164
-		if (explode(';', $contentType)[0] === 'application/json') {
165
-			$data = json_decode($data, true);
166
-		} else {
167
-			throw new UnsupportedMediaType();
168
-		}
169
-
170
-		if (!isset($data['name'])) {
171
-			throw new BadRequest('Missing "name" attribute');
172
-		}
173
-
174
-		$tagName = $data['name'];
175
-		$userVisible = true;
176
-		$userAssignable = true;
177
-
178
-		if (isset($data['userVisible'])) {
179
-			$userVisible = (bool)$data['userVisible'];
180
-		}
181
-
182
-		if (isset($data['userAssignable'])) {
183
-			$userAssignable = (bool)$data['userAssignable'];
184
-		}
185
-
186
-		$groups = [];
187
-		if (isset($data['groups'])) {
188
-			$groups = $data['groups'];
189
-			if (is_string($groups)) {
190
-				$groups = explode('|', $groups);
191
-			}
192
-		}
193
-
194
-		if($userVisible === false || $userAssignable === false || !empty($groups)) {
195
-			if(!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
196
-				throw new BadRequest('Not sufficient permissions');
197
-			}
198
-		}
199
-
200
-		try {
201
-			$tag = $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
202
-			if (!empty($groups)) {
203
-				$this->tagManager->setTagGroups($tag, $groups);
204
-			}
205
-			return $tag;
206
-		} catch (TagAlreadyExistsException $e) {
207
-			throw new Conflict('Tag already exists', 0, $e);
208
-		}
209
-	}
210
-
211
-
212
-	/**
213
-	 * Retrieves system tag properties
214
-	 *
215
-	 * @param PropFind $propFind
216
-	 * @param \Sabre\DAV\INode $node
217
-	 */
218
-	public function handleGetProperties(
219
-		PropFind $propFind,
220
-		\Sabre\DAV\INode $node
221
-	) {
222
-		if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
223
-			return;
224
-		}
225
-
226
-		$propFind->handle(self::ID_PROPERTYNAME, function() use ($node) {
227
-			return $node->getSystemTag()->getId();
228
-		});
229
-
230
-		$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function() use ($node) {
231
-			return $node->getSystemTag()->getName();
232
-		});
233
-
234
-		$propFind->handle(self::USERVISIBLE_PROPERTYNAME, function() use ($node) {
235
-			return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
236
-		});
237
-
238
-		$propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function() use ($node) {
239
-			// this is the tag's inherent property "is user assignable"
240
-			return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
241
-		});
242
-
243
-		$propFind->handle(self::CANASSIGN_PROPERTYNAME, function() use ($node) {
244
-			// this is the effective permission for the current user
245
-			return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
246
-		});
247
-
248
-		$propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
249
-			if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
250
-				// property only available for admins
251
-				throw new Forbidden();
252
-			}
253
-			$groups = [];
254
-			// no need to retrieve groups for namespaces that don't qualify
255
-			if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
256
-				$groups = $this->tagManager->getTagGroups($node->getSystemTag());
257
-			}
258
-			return implode('|', $groups);
259
-		});
260
-	}
261
-
262
-	/**
263
-	 * Updates tag attributes
264
-	 *
265
-	 * @param string $path
266
-	 * @param PropPatch $propPatch
267
-	 *
268
-	 * @return void
269
-	 */
270
-	public function handleUpdateProperties($path, PropPatch $propPatch) {
271
-		$node = $this->server->tree->getNodeForPath($path);
272
-		if (!($node instanceof SystemTagNode)) {
273
-			return;
274
-		}
275
-
276
-		$propPatch->handle([
277
-			self::DISPLAYNAME_PROPERTYNAME,
278
-			self::USERVISIBLE_PROPERTYNAME,
279
-			self::USERASSIGNABLE_PROPERTYNAME,
280
-			self::GROUPS_PROPERTYNAME,
281
-		], function($props) use ($node) {
282
-			$tag = $node->getSystemTag();
283
-			$name = $tag->getName();
284
-			$userVisible = $tag->isUserVisible();
285
-			$userAssignable = $tag->isUserAssignable();
286
-
287
-			$updateTag = false;
288
-
289
-			if (isset($props[self::DISPLAYNAME_PROPERTYNAME])) {
290
-				$name = $props[self::DISPLAYNAME_PROPERTYNAME];
291
-				$updateTag = true;
292
-			}
293
-
294
-			if (isset($props[self::USERVISIBLE_PROPERTYNAME])) {
295
-				$propValue = $props[self::USERVISIBLE_PROPERTYNAME];
296
-				$userVisible = ($propValue !== 'false' && $propValue !== '0');
297
-				$updateTag = true;
298
-			}
299
-
300
-			if (isset($props[self::USERASSIGNABLE_PROPERTYNAME])) {
301
-				$propValue = $props[self::USERASSIGNABLE_PROPERTYNAME];
302
-				$userAssignable = ($propValue !== 'false' && $propValue !== '0');
303
-				$updateTag = true;
304
-			}
305
-
306
-			if (isset($props[self::GROUPS_PROPERTYNAME])) {
307
-				if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
308
-					// property only available for admins
309
-					throw new Forbidden();
310
-				}
311
-
312
-				$propValue = $props[self::GROUPS_PROPERTYNAME];
313
-				$groupIds = explode('|', $propValue);
314
-				$this->tagManager->setTagGroups($tag, $groupIds);
315
-			}
316
-
317
-			if ($updateTag) {
318
-				$node->update($name, $userVisible, $userAssignable);
319
-			}
320
-
321
-			return true;
322
-		});
323
-
324
-	}
49
+    // namespace
50
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
51
+    const ID_PROPERTYNAME = '{http://owncloud.org/ns}id';
52
+    const DISPLAYNAME_PROPERTYNAME = '{http://owncloud.org/ns}display-name';
53
+    const USERVISIBLE_PROPERTYNAME = '{http://owncloud.org/ns}user-visible';
54
+    const USERASSIGNABLE_PROPERTYNAME = '{http://owncloud.org/ns}user-assignable';
55
+    const GROUPS_PROPERTYNAME = '{http://owncloud.org/ns}groups';
56
+    const CANASSIGN_PROPERTYNAME = '{http://owncloud.org/ns}can-assign';
57
+
58
+    /**
59
+     * @var \Sabre\DAV\Server $server
60
+     */
61
+    private $server;
62
+
63
+    /**
64
+     * @var ISystemTagManager
65
+     */
66
+    protected $tagManager;
67
+
68
+    /**
69
+     * @var IUserSession
70
+     */
71
+    protected $userSession;
72
+
73
+    /**
74
+     * @var IGroupManager
75
+     */
76
+    protected $groupManager;
77
+
78
+    /**
79
+     * @param ISystemTagManager $tagManager tag manager
80
+     * @param IGroupManager $groupManager
81
+     * @param IUserSession $userSession
82
+     */
83
+    public function __construct(ISystemTagManager $tagManager,
84
+                                IGroupManager $groupManager,
85
+                                IUserSession $userSession) {
86
+        $this->tagManager = $tagManager;
87
+        $this->userSession = $userSession;
88
+        $this->groupManager = $groupManager;
89
+    }
90
+
91
+    /**
92
+     * This initializes the plugin.
93
+     *
94
+     * This function is called by \Sabre\DAV\Server, after
95
+     * addPlugin is called.
96
+     *
97
+     * This method should set up the required event subscriptions.
98
+     *
99
+     * @param \Sabre\DAV\Server $server
100
+     * @return void
101
+     */
102
+    public function initialize(\Sabre\DAV\Server $server) {
103
+
104
+        $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
105
+
106
+        $server->protectedProperties[] = self::ID_PROPERTYNAME;
107
+
108
+        $server->on('propFind', array($this, 'handleGetProperties'));
109
+        $server->on('propPatch', array($this, 'handleUpdateProperties'));
110
+        $server->on('method:POST', [$this, 'httpPost']);
111
+
112
+        $this->server = $server;
113
+    }
114
+
115
+    /**
116
+     * POST operation on system tag collections
117
+     *
118
+     * @param RequestInterface $request request object
119
+     * @param ResponseInterface $response response object
120
+     * @return null|false
121
+     */
122
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
123
+        $path = $request->getPath();
124
+
125
+        // Making sure the node exists
126
+        $node = $this->server->tree->getNodeForPath($path);
127
+        if ($node instanceof SystemTagsByIdCollection || $node instanceof SystemTagsObjectMappingCollection) {
128
+            $data = $request->getBodyAsString();
129
+
130
+            $tag = $this->createTag($data, $request->getHeader('Content-Type'));
131
+
132
+            if ($node instanceof SystemTagsObjectMappingCollection) {
133
+                // also add to collection
134
+                $node->createFile($tag->getId());
135
+                $url = $request->getBaseUrl() . 'systemtags/';
136
+            } else {
137
+                $url = $request->getUrl();
138
+            }
139
+
140
+            if ($url[strlen($url) - 1] !== '/') {
141
+                $url .= '/';
142
+            }
143
+
144
+            $response->setHeader('Content-Location', $url . $tag->getId());
145
+
146
+            // created
147
+            $response->setStatus(201);
148
+            return false;
149
+        }
150
+    }
151
+
152
+    /**
153
+     * Creates a new tag
154
+     *
155
+     * @param string $data JSON encoded string containing the properties of the tag to create
156
+     * @param string $contentType content type of the data
157
+     * @return ISystemTag newly created system tag
158
+     *
159
+     * @throws BadRequest if a field was missing
160
+     * @throws Conflict if a tag with the same properties already exists
161
+     * @throws UnsupportedMediaType if the content type is not supported
162
+     */
163
+    private function createTag($data, $contentType = 'application/json') {
164
+        if (explode(';', $contentType)[0] === 'application/json') {
165
+            $data = json_decode($data, true);
166
+        } else {
167
+            throw new UnsupportedMediaType();
168
+        }
169
+
170
+        if (!isset($data['name'])) {
171
+            throw new BadRequest('Missing "name" attribute');
172
+        }
173
+
174
+        $tagName = $data['name'];
175
+        $userVisible = true;
176
+        $userAssignable = true;
177
+
178
+        if (isset($data['userVisible'])) {
179
+            $userVisible = (bool)$data['userVisible'];
180
+        }
181
+
182
+        if (isset($data['userAssignable'])) {
183
+            $userAssignable = (bool)$data['userAssignable'];
184
+        }
185
+
186
+        $groups = [];
187
+        if (isset($data['groups'])) {
188
+            $groups = $data['groups'];
189
+            if (is_string($groups)) {
190
+                $groups = explode('|', $groups);
191
+            }
192
+        }
193
+
194
+        if($userVisible === false || $userAssignable === false || !empty($groups)) {
195
+            if(!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
196
+                throw new BadRequest('Not sufficient permissions');
197
+            }
198
+        }
199
+
200
+        try {
201
+            $tag = $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
202
+            if (!empty($groups)) {
203
+                $this->tagManager->setTagGroups($tag, $groups);
204
+            }
205
+            return $tag;
206
+        } catch (TagAlreadyExistsException $e) {
207
+            throw new Conflict('Tag already exists', 0, $e);
208
+        }
209
+    }
210
+
211
+
212
+    /**
213
+     * Retrieves system tag properties
214
+     *
215
+     * @param PropFind $propFind
216
+     * @param \Sabre\DAV\INode $node
217
+     */
218
+    public function handleGetProperties(
219
+        PropFind $propFind,
220
+        \Sabre\DAV\INode $node
221
+    ) {
222
+        if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
223
+            return;
224
+        }
225
+
226
+        $propFind->handle(self::ID_PROPERTYNAME, function() use ($node) {
227
+            return $node->getSystemTag()->getId();
228
+        });
229
+
230
+        $propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function() use ($node) {
231
+            return $node->getSystemTag()->getName();
232
+        });
233
+
234
+        $propFind->handle(self::USERVISIBLE_PROPERTYNAME, function() use ($node) {
235
+            return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
236
+        });
237
+
238
+        $propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function() use ($node) {
239
+            // this is the tag's inherent property "is user assignable"
240
+            return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
241
+        });
242
+
243
+        $propFind->handle(self::CANASSIGN_PROPERTYNAME, function() use ($node) {
244
+            // this is the effective permission for the current user
245
+            return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
246
+        });
247
+
248
+        $propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
249
+            if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
250
+                // property only available for admins
251
+                throw new Forbidden();
252
+            }
253
+            $groups = [];
254
+            // no need to retrieve groups for namespaces that don't qualify
255
+            if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
256
+                $groups = $this->tagManager->getTagGroups($node->getSystemTag());
257
+            }
258
+            return implode('|', $groups);
259
+        });
260
+    }
261
+
262
+    /**
263
+     * Updates tag attributes
264
+     *
265
+     * @param string $path
266
+     * @param PropPatch $propPatch
267
+     *
268
+     * @return void
269
+     */
270
+    public function handleUpdateProperties($path, PropPatch $propPatch) {
271
+        $node = $this->server->tree->getNodeForPath($path);
272
+        if (!($node instanceof SystemTagNode)) {
273
+            return;
274
+        }
275
+
276
+        $propPatch->handle([
277
+            self::DISPLAYNAME_PROPERTYNAME,
278
+            self::USERVISIBLE_PROPERTYNAME,
279
+            self::USERASSIGNABLE_PROPERTYNAME,
280
+            self::GROUPS_PROPERTYNAME,
281
+        ], function($props) use ($node) {
282
+            $tag = $node->getSystemTag();
283
+            $name = $tag->getName();
284
+            $userVisible = $tag->isUserVisible();
285
+            $userAssignable = $tag->isUserAssignable();
286
+
287
+            $updateTag = false;
288
+
289
+            if (isset($props[self::DISPLAYNAME_PROPERTYNAME])) {
290
+                $name = $props[self::DISPLAYNAME_PROPERTYNAME];
291
+                $updateTag = true;
292
+            }
293
+
294
+            if (isset($props[self::USERVISIBLE_PROPERTYNAME])) {
295
+                $propValue = $props[self::USERVISIBLE_PROPERTYNAME];
296
+                $userVisible = ($propValue !== 'false' && $propValue !== '0');
297
+                $updateTag = true;
298
+            }
299
+
300
+            if (isset($props[self::USERASSIGNABLE_PROPERTYNAME])) {
301
+                $propValue = $props[self::USERASSIGNABLE_PROPERTYNAME];
302
+                $userAssignable = ($propValue !== 'false' && $propValue !== '0');
303
+                $updateTag = true;
304
+            }
305
+
306
+            if (isset($props[self::GROUPS_PROPERTYNAME])) {
307
+                if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
308
+                    // property only available for admins
309
+                    throw new Forbidden();
310
+                }
311
+
312
+                $propValue = $props[self::GROUPS_PROPERTYNAME];
313
+                $groupIds = explode('|', $propValue);
314
+                $this->tagManager->setTagGroups($tag, $groupIds);
315
+            }
316
+
317
+            if ($updateTag) {
318
+                $node->update($name, $userVisible, $userAssignable);
319
+            }
320
+
321
+            return true;
322
+        });
323
+
324
+    }
325 325
 }
Please login to merge, or discard this patch.
lib/public/BackgroundJob/IJobList.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -32,100 +32,100 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -35,133 +35,133 @@
 block discarded – undo
35 35
  */
36 36
 class CalendarSearchReport implements XmlDeserializable {
37 37
 
38
-	/**
39
-	 * An array with requested properties.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $properties;
44
-
45
-	/**
46
-	 * List of property/component filters.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $filters;
51
-
52
-	/**
53
-	 * @var int
54
-	 */
55
-	public $limit;
56
-
57
-	/**
58
-	 * @var int
59
-	 */
60
-	public $offset;
61
-
62
-	/**
63
-	 * The deserialize method is called during xml parsing.
64
-	 *
65
-	 * This method is called statically, this is because in theory this method
66
-	 * may be used as a type of constructor, or factory method.
67
-	 *
68
-	 * Often you want to return an instance of the current class, but you are
69
-	 * free to return other data as well.
70
-	 *
71
-	 * You are responsible for advancing the reader to the next element. Not
72
-	 * doing anything will result in a never-ending loop.
73
-	 *
74
-	 * If you just want to skip parsing for this element altogether, you can
75
-	 * just call $reader->next();
76
-	 *
77
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
-	 * the next element.
79
-	 *
80
-	 * @param Reader $reader
81
-	 * @return mixed
82
-	 */
83
-	static function xmlDeserialize(Reader $reader) {
84
-		$elems = $reader->parseInnerTree([
85
-			'{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
-			'{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
-			'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
-			'{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
-			'{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
-			'{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
-			'{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
-		]);
93
-
94
-		$newProps = [
95
-			'filters'    => [],
96
-			'properties' => [],
97
-			'limit'      => null,
98
-			'offset'     => null
99
-		];
100
-
101
-		if (!is_array($elems)) {
102
-			$elems = [];
103
-		}
104
-
105
-		foreach ($elems as $elem) {
106
-			switch ($elem['name']) {
107
-				case '{DAV:}prop':
108
-					$newProps['properties'] = array_keys($elem['value']);
109
-					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
-					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
-							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
-								$newProps['filters']['comps'] = [];
115
-							}
116
-							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
-							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
-								$newProps['filters']['props'] = [];
120
-							}
121
-							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
-							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
-								$newProps['filters']['params'] = [];
125
-							}
126
-							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
-							$newProps['filters']['search-term'] = $subElem['value'];
129
-						}
130
-					}
131
-					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
-					$newProps['limit'] = $elem['value'];
134
-					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
-					$newProps['offset'] = $elem['value'];
137
-					break;
138
-
139
-			}
140
-		}
141
-
142
-		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
-		}
145
-
146
-		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
-		$noCompsDefined = empty($newProps['filters']['comps']);
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');
150
-		}
151
-
152
-		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
-		}
155
-
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');
158
-		}
159
-
160
-
161
-		$obj = new self();
162
-		foreach ($newProps as $key => $value) {
163
-			$obj->$key = $value;
164
-		}
165
-		return $obj;
166
-	}
38
+    /**
39
+     * An array with requested properties.
40
+     *
41
+     * @var array
42
+     */
43
+    public $properties;
44
+
45
+    /**
46
+     * List of property/component filters.
47
+     *
48
+     * @var array
49
+     */
50
+    public $filters;
51
+
52
+    /**
53
+     * @var int
54
+     */
55
+    public $limit;
56
+
57
+    /**
58
+     * @var int
59
+     */
60
+    public $offset;
61
+
62
+    /**
63
+     * The deserialize method is called during xml parsing.
64
+     *
65
+     * This method is called statically, this is because in theory this method
66
+     * may be used as a type of constructor, or factory method.
67
+     *
68
+     * Often you want to return an instance of the current class, but you are
69
+     * free to return other data as well.
70
+     *
71
+     * You are responsible for advancing the reader to the next element. Not
72
+     * doing anything will result in a never-ending loop.
73
+     *
74
+     * If you just want to skip parsing for this element altogether, you can
75
+     * just call $reader->next();
76
+     *
77
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
+     * the next element.
79
+     *
80
+     * @param Reader $reader
81
+     * @return mixed
82
+     */
83
+    static function xmlDeserialize(Reader $reader) {
84
+        $elems = $reader->parseInnerTree([
85
+            '{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
+            '{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
+            '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
+            '{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
+            '{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
+            '{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
+            '{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
+        ]);
93
+
94
+        $newProps = [
95
+            'filters'    => [],
96
+            'properties' => [],
97
+            'limit'      => null,
98
+            'offset'     => null
99
+        ];
100
+
101
+        if (!is_array($elems)) {
102
+            $elems = [];
103
+        }
104
+
105
+        foreach ($elems as $elem) {
106
+            switch ($elem['name']) {
107
+                case '{DAV:}prop':
108
+                    $newProps['properties'] = array_keys($elem['value']);
109
+                    break;
110
+                case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
+                    foreach ($elem['value'] as $subElem) {
112
+                        if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
+                            if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
+                                $newProps['filters']['comps'] = [];
115
+                            }
116
+                            $newProps['filters']['comps'][] = $subElem['value'];
117
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
+                            if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
+                                $newProps['filters']['props'] = [];
120
+                            }
121
+                            $newProps['filters']['props'][] = $subElem['value'];
122
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
+                            if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
+                                $newProps['filters']['params'] = [];
125
+                            }
126
+                            $newProps['filters']['params'][] = $subElem['value'];
127
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
+                            $newProps['filters']['search-term'] = $subElem['value'];
129
+                        }
130
+                    }
131
+                    break;
132
+                case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
+                    $newProps['limit'] = $elem['value'];
134
+                    break;
135
+                case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
+                    $newProps['offset'] = $elem['value'];
137
+                    break;
138
+
139
+            }
140
+        }
141
+
142
+        if (empty($newProps['filters'])) {
143
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
+        }
145
+
146
+        $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
+        $noCompsDefined = empty($newProps['filters']['comps']);
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');
150
+        }
151
+
152
+        if (!isset($newProps['filters']['search-term'])) {
153
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
+        }
155
+
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');
158
+        }
159
+
160
+
161
+        $obj = new self();
162
+        foreach ($newProps as $key => $value) {
163
+            $obj->$key = $value;
164
+        }
165
+        return $obj;
166
+    }
167 167
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/CoreBundle.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,20 +23,20 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/Bundle.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,36 +24,36 @@
 block discarded – undo
24 24
 use OCP\IL10N;
25 25
 
26 26
 abstract class Bundle {
27
-	/** @var IL10N */
28
-	protected $l10n;
27
+    /** @var IL10N */
28
+    protected $l10n;
29 29
 
30
-	/**
31
-	 * @param IL10N $l10n
32
-	 */
33
-	public function __construct(IL10N $l10n) {
34
-		$this->l10n = $l10n;
35
-	}
30
+    /**
31
+     * @param IL10N $l10n
32
+     */
33
+    public function __construct(IL10N $l10n) {
34
+        $this->l10n = $l10n;
35
+    }
36 36
 
37
-	/**
38
-	 * Get the identifier of the bundle
39
-	 *
40
-	 * @return string
41
-	 */
42
-	public final function getIdentifier() {
43
-		return substr(strrchr(get_class($this), '\\'), 1);
44
-	}
37
+    /**
38
+     * Get the identifier of the bundle
39
+     *
40
+     * @return string
41
+     */
42
+    public final function getIdentifier() {
43
+        return substr(strrchr(get_class($this), '\\'), 1);
44
+    }
45 45
 
46
-	/**
47
-	 * Get the name of the bundle
48
-	 *
49
-	 * @return string
50
-	 */
51
-	public abstract function getName();
46
+    /**
47
+     * Get the name of the bundle
48
+     *
49
+     * @return string
50
+     */
51
+    public abstract function getName();
52 52
 
53
-	/**
54
-	 * Get the list of app identifiers in the bundle
55
-	 *
56
-	 * @return array
57
-	 */
58
-	public abstract function getAppIdentifiers();
53
+    /**
54
+     * Get the list of app identifiers in the bundle
55
+     *
56
+     * @return array
57
+     */
58
+    public abstract function getAppIdentifiers();
59 59
 }
Please login to merge, or discard this patch.