Passed
Push — master ( 873501...d2df81 )
by Maxence
14:59 queued 12s
created
lib/private/Repair/RemoveLinkShares.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$subQuery = $this->connection->getQueryBuilder();
114 114
 		$subQuery->select('s1.id')
115
-			->from($subQuery->createFunction('(' . $subSubQuery->getSQL() . ')'), 's1')
115
+			->from($subQuery->createFunction('('.$subSubQuery->getSQL().')'), 's1')
116 116
 			->join(
117 117
 				's1', 'share', 's2',
118 118
 				$subQuery->expr()->eq('s1.parent', 's2.id')
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		$query = $this->connection->getQueryBuilder();
127 127
 		$query->select($query->func()->count('*', 'total'))
128 128
 			->from('share')
129
-			->where($query->expr()->in('id', $query->createFunction('(' . $subQuery->getSQL() . ')')));
129
+			->where($query->expr()->in('id', $query->createFunction('('.$subQuery->getSQL().')')));
130 130
 
131 131
 		$result = $query->execute();
132 132
 		$data = $result->fetch();
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 		$query = $this->connection->getQueryBuilder();
151 151
 		$query->select('s1.id', 's1.uid_owner', 's1.uid_initiator')
152
-			->from($query->createFunction('(' . $subQuery->getSQL() . ')'), 's1')
152
+			->from($query->createFunction('('.$subQuery->getSQL().')'), 's1')
153 153
 			->join(
154 154
 				's1', 'share', 's2',
155 155
 				$query->expr()->eq('s1.parent', 's2.id')
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		$this->addToNotify($data['uid_owner']);
174 174
 		$this->addToNotify($data['uid_initiator']);
175 175
 
176
-		$this->deleteShare((int)$id);
176
+		$this->deleteShare((int) $id);
177 177
 	}
178 178
 
179 179
 	/**
Please login to merge, or discard this patch.
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -40,202 +40,202 @@
 block discarded – undo
40 40
 use OCP\Notification\IManager;
41 41
 
42 42
 class RemoveLinkShares implements IRepairStep {
43
-	/** @var IDBConnection */
44
-	private $connection;
45
-	/** @var IConfig */
46
-	private $config;
47
-	/** @var string[] */
48
-	private $userToNotify = [];
49
-	/** @var IGroupManager */
50
-	private $groupManager;
51
-	/** @var IManager */
52
-	private $notificationManager;
53
-	/** @var ITimeFactory */
54
-	private $timeFactory;
55
-
56
-	public function __construct(IDBConnection $connection,
57
-								IConfig $config,
58
-								IGroupManager $groupManager,
59
-								IManager $notificationManager,
60
-								ITimeFactory $timeFactory) {
61
-		$this->connection = $connection;
62
-		$this->config = $config;
63
-		$this->groupManager = $groupManager;
64
-		$this->notificationManager = $notificationManager;
65
-		$this->timeFactory = $timeFactory;
66
-	}
67
-
68
-
69
-	public function getName(): string {
70
-		return 'Remove potentially over exposing share links';
71
-	}
72
-
73
-	private function shouldRun(): bool {
74
-		$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
75
-
76
-		if (version_compare($versionFromBeforeUpdate, '14.0.11', '<')) {
77
-			return true;
78
-		}
79
-		if (version_compare($versionFromBeforeUpdate, '15.0.8', '<')) {
80
-			return true;
81
-		}
82
-		if (version_compare($versionFromBeforeUpdate, '16.0.0', '<=')) {
83
-			return true;
84
-		}
85
-
86
-		return false;
87
-	}
88
-
89
-	/**
90
-	 * Delete the share
91
-	 *
92
-	 * @param int $id
93
-	 */
94
-	private function deleteShare(int $id): void {
95
-		$qb = $this->connection->getQueryBuilder();
96
-		$qb->delete('share')
97
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
98
-		$qb->execute();
99
-	}
100
-
101
-	/**
102
-	 * Get the total of affected shares
103
-	 *
104
-	 * @return int
105
-	 */
106
-	private function getTotal(): int {
107
-		$subSubQuery = $this->connection->getQueryBuilder();
108
-		$subSubQuery->select('*')
109
-			->from('share')
110
-			->where($subSubQuery->expr()->isNotNull('parent'))
111
-			->andWhere($subSubQuery->expr()->eq('share_type', $subSubQuery->expr()->literal(3, IQueryBuilder::PARAM_INT)));
112
-
113
-		$subQuery = $this->connection->getQueryBuilder();
114
-		$subQuery->select('s1.id')
115
-			->from($subQuery->createFunction('(' . $subSubQuery->getSQL() . ')'), 's1')
116
-			->join(
117
-				's1', 'share', 's2',
118
-				$subQuery->expr()->eq('s1.parent', 's2.id')
119
-			)
120
-			->where($subQuery->expr()->orX(
121
-				$subQuery->expr()->eq('s2.share_type', $subQuery->expr()->literal(1, IQueryBuilder::PARAM_INT)),
122
-				$subQuery->expr()->eq('s2.share_type', $subQuery->expr()->literal(2, IQueryBuilder::PARAM_INT))
123
-			))
124
-			->andWhere($subQuery->expr()->eq('s1.item_source', 's2.item_source'));
125
-
126
-		$query = $this->connection->getQueryBuilder();
127
-		$query->select($query->func()->count('*', 'total'))
128
-			->from('share')
129
-			->where($query->expr()->in('id', $query->createFunction('(' . $subQuery->getSQL() . ')')));
130
-
131
-		$result = $query->execute();
132
-		$data = $result->fetch();
133
-		$result->closeCursor();
134
-
135
-		return (int) $data['total'];
136
-	}
137
-
138
-	/**
139
-	 * Get the cursor to fetch all the shares
140
-	 */
141
-	private function getShares(): IResult {
142
-		$subQuery = $this->connection->getQueryBuilder();
143
-		$subQuery->select('*')
144
-			->from('share')
145
-			->where($subQuery->expr()->isNotNull('parent'))
146
-			->andWhere($subQuery->expr()->eq('share_type', $subQuery->expr()->literal(3, IQueryBuilder::PARAM_INT)));
147
-
148
-		$query = $this->connection->getQueryBuilder();
149
-		$query->select('s1.id', 's1.uid_owner', 's1.uid_initiator')
150
-			->from($query->createFunction('(' . $subQuery->getSQL() . ')'), 's1')
151
-			->join(
152
-				's1', 'share', 's2',
153
-				$query->expr()->eq('s1.parent', 's2.id')
154
-			)
155
-			->where($query->expr()->orX(
156
-				$query->expr()->eq('s2.share_type', $query->expr()->literal(1, IQueryBuilder::PARAM_INT)),
157
-				$query->expr()->eq('s2.share_type', $query->expr()->literal(2, IQueryBuilder::PARAM_INT))
158
-			))
159
-			->andWhere($query->expr()->eq('s1.item_source', 's2.item_source'));
160
-		/** @var IResult $result */
161
-		$result = $query->execute();
162
-		return $result;
163
-	}
164
-
165
-	/**
166
-	 * Process a single share
167
-	 *
168
-	 * @param array $data
169
-	 */
170
-	private function processShare(array $data): void {
171
-		$id = $data['id'];
172
-
173
-		$this->addToNotify($data['uid_owner']);
174
-		$this->addToNotify($data['uid_initiator']);
175
-
176
-		$this->deleteShare((int)$id);
177
-	}
178
-
179
-	/**
180
-	 * Update list of users to notify
181
-	 *
182
-	 * @param string $uid
183
-	 */
184
-	private function addToNotify(string $uid): void {
185
-		if (!isset($this->userToNotify[$uid])) {
186
-			$this->userToNotify[$uid] = true;
187
-		}
188
-	}
189
-
190
-	/**
191
-	 * Send all notifications
192
-	 */
193
-	private function sendNotification(): void {
194
-		$time = $this->timeFactory->getDateTime();
195
-
196
-		$notification = $this->notificationManager->createNotification();
197
-		$notification->setApp('core')
198
-			->setDateTime($time)
199
-			->setObject('repair', 'exposing_links')
200
-			->setSubject('repair_exposing_links');
201
-
202
-		$users = array_keys($this->userToNotify);
203
-		foreach ($users as $user) {
204
-			$notification->setUser((string) $user);
205
-			$this->notificationManager->notify($notification);
206
-		}
207
-	}
208
-
209
-	private function repair(IOutput $output, int $total): void {
210
-		$output->startProgress($total);
211
-
212
-		$shareResult = $this->getShares();
213
-		while ($data = $shareResult->fetch()) {
214
-			$this->processShare($data);
215
-			$output->advance();
216
-		}
217
-		$output->finishProgress();
218
-		$shareResult->closeCursor();
219
-
220
-		// Notify all admins
221
-		$adminGroup = $this->groupManager->get('admin');
222
-		$adminUsers = $adminGroup->getUsers();
223
-		foreach ($adminUsers as $user) {
224
-			$this->addToNotify($user->getUID());
225
-		}
226
-
227
-		$output->info('Sending notifications to admins and affected users');
228
-		$this->sendNotification();
229
-	}
230
-
231
-	public function run(IOutput $output): void {
232
-		if ($this->shouldRun() === false || ($total = $this->getTotal()) === 0) {
233
-			$output->info('No need to remove link shares.');
234
-			return;
235
-		}
236
-
237
-		$output->info('Removing potentially over exposing link shares');
238
-		$this->repair($output, $total);
239
-		$output->info('Removed potentially over exposing link shares');
240
-	}
43
+    /** @var IDBConnection */
44
+    private $connection;
45
+    /** @var IConfig */
46
+    private $config;
47
+    /** @var string[] */
48
+    private $userToNotify = [];
49
+    /** @var IGroupManager */
50
+    private $groupManager;
51
+    /** @var IManager */
52
+    private $notificationManager;
53
+    /** @var ITimeFactory */
54
+    private $timeFactory;
55
+
56
+    public function __construct(IDBConnection $connection,
57
+                                IConfig $config,
58
+                                IGroupManager $groupManager,
59
+                                IManager $notificationManager,
60
+                                ITimeFactory $timeFactory) {
61
+        $this->connection = $connection;
62
+        $this->config = $config;
63
+        $this->groupManager = $groupManager;
64
+        $this->notificationManager = $notificationManager;
65
+        $this->timeFactory = $timeFactory;
66
+    }
67
+
68
+
69
+    public function getName(): string {
70
+        return 'Remove potentially over exposing share links';
71
+    }
72
+
73
+    private function shouldRun(): bool {
74
+        $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
75
+
76
+        if (version_compare($versionFromBeforeUpdate, '14.0.11', '<')) {
77
+            return true;
78
+        }
79
+        if (version_compare($versionFromBeforeUpdate, '15.0.8', '<')) {
80
+            return true;
81
+        }
82
+        if (version_compare($versionFromBeforeUpdate, '16.0.0', '<=')) {
83
+            return true;
84
+        }
85
+
86
+        return false;
87
+    }
88
+
89
+    /**
90
+     * Delete the share
91
+     *
92
+     * @param int $id
93
+     */
94
+    private function deleteShare(int $id): void {
95
+        $qb = $this->connection->getQueryBuilder();
96
+        $qb->delete('share')
97
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
98
+        $qb->execute();
99
+    }
100
+
101
+    /**
102
+     * Get the total of affected shares
103
+     *
104
+     * @return int
105
+     */
106
+    private function getTotal(): int {
107
+        $subSubQuery = $this->connection->getQueryBuilder();
108
+        $subSubQuery->select('*')
109
+            ->from('share')
110
+            ->where($subSubQuery->expr()->isNotNull('parent'))
111
+            ->andWhere($subSubQuery->expr()->eq('share_type', $subSubQuery->expr()->literal(3, IQueryBuilder::PARAM_INT)));
112
+
113
+        $subQuery = $this->connection->getQueryBuilder();
114
+        $subQuery->select('s1.id')
115
+            ->from($subQuery->createFunction('(' . $subSubQuery->getSQL() . ')'), 's1')
116
+            ->join(
117
+                's1', 'share', 's2',
118
+                $subQuery->expr()->eq('s1.parent', 's2.id')
119
+            )
120
+            ->where($subQuery->expr()->orX(
121
+                $subQuery->expr()->eq('s2.share_type', $subQuery->expr()->literal(1, IQueryBuilder::PARAM_INT)),
122
+                $subQuery->expr()->eq('s2.share_type', $subQuery->expr()->literal(2, IQueryBuilder::PARAM_INT))
123
+            ))
124
+            ->andWhere($subQuery->expr()->eq('s1.item_source', 's2.item_source'));
125
+
126
+        $query = $this->connection->getQueryBuilder();
127
+        $query->select($query->func()->count('*', 'total'))
128
+            ->from('share')
129
+            ->where($query->expr()->in('id', $query->createFunction('(' . $subQuery->getSQL() . ')')));
130
+
131
+        $result = $query->execute();
132
+        $data = $result->fetch();
133
+        $result->closeCursor();
134
+
135
+        return (int) $data['total'];
136
+    }
137
+
138
+    /**
139
+     * Get the cursor to fetch all the shares
140
+     */
141
+    private function getShares(): IResult {
142
+        $subQuery = $this->connection->getQueryBuilder();
143
+        $subQuery->select('*')
144
+            ->from('share')
145
+            ->where($subQuery->expr()->isNotNull('parent'))
146
+            ->andWhere($subQuery->expr()->eq('share_type', $subQuery->expr()->literal(3, IQueryBuilder::PARAM_INT)));
147
+
148
+        $query = $this->connection->getQueryBuilder();
149
+        $query->select('s1.id', 's1.uid_owner', 's1.uid_initiator')
150
+            ->from($query->createFunction('(' . $subQuery->getSQL() . ')'), 's1')
151
+            ->join(
152
+                's1', 'share', 's2',
153
+                $query->expr()->eq('s1.parent', 's2.id')
154
+            )
155
+            ->where($query->expr()->orX(
156
+                $query->expr()->eq('s2.share_type', $query->expr()->literal(1, IQueryBuilder::PARAM_INT)),
157
+                $query->expr()->eq('s2.share_type', $query->expr()->literal(2, IQueryBuilder::PARAM_INT))
158
+            ))
159
+            ->andWhere($query->expr()->eq('s1.item_source', 's2.item_source'));
160
+        /** @var IResult $result */
161
+        $result = $query->execute();
162
+        return $result;
163
+    }
164
+
165
+    /**
166
+     * Process a single share
167
+     *
168
+     * @param array $data
169
+     */
170
+    private function processShare(array $data): void {
171
+        $id = $data['id'];
172
+
173
+        $this->addToNotify($data['uid_owner']);
174
+        $this->addToNotify($data['uid_initiator']);
175
+
176
+        $this->deleteShare((int)$id);
177
+    }
178
+
179
+    /**
180
+     * Update list of users to notify
181
+     *
182
+     * @param string $uid
183
+     */
184
+    private function addToNotify(string $uid): void {
185
+        if (!isset($this->userToNotify[$uid])) {
186
+            $this->userToNotify[$uid] = true;
187
+        }
188
+    }
189
+
190
+    /**
191
+     * Send all notifications
192
+     */
193
+    private function sendNotification(): void {
194
+        $time = $this->timeFactory->getDateTime();
195
+
196
+        $notification = $this->notificationManager->createNotification();
197
+        $notification->setApp('core')
198
+            ->setDateTime($time)
199
+            ->setObject('repair', 'exposing_links')
200
+            ->setSubject('repair_exposing_links');
201
+
202
+        $users = array_keys($this->userToNotify);
203
+        foreach ($users as $user) {
204
+            $notification->setUser((string) $user);
205
+            $this->notificationManager->notify($notification);
206
+        }
207
+    }
208
+
209
+    private function repair(IOutput $output, int $total): void {
210
+        $output->startProgress($total);
211
+
212
+        $shareResult = $this->getShares();
213
+        while ($data = $shareResult->fetch()) {
214
+            $this->processShare($data);
215
+            $output->advance();
216
+        }
217
+        $output->finishProgress();
218
+        $shareResult->closeCursor();
219
+
220
+        // Notify all admins
221
+        $adminGroup = $this->groupManager->get('admin');
222
+        $adminUsers = $adminGroup->getUsers();
223
+        foreach ($adminUsers as $user) {
224
+            $this->addToNotify($user->getUID());
225
+        }
226
+
227
+        $output->info('Sending notifications to admins and affected users');
228
+        $this->sendNotification();
229
+    }
230
+
231
+    public function run(IOutput $output): void {
232
+        if ($this->shouldRun() === false || ($total = $this->getTotal()) === 0) {
233
+            $output->info('No need to remove link shares.');
234
+            return;
235
+        }
236
+
237
+        $output->info('Removing potentially over exposing link shares');
238
+        $this->repair($output, $total);
239
+        $output->info('Removed potentially over exposing link shares');
240
+    }
241 241
 }
Please login to merge, or discard this patch.
lib/private/legacy/OC_Response.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 				\OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
41 41
 				\OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
42 42
 			])) {
43
-			header('Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode($filename) . '"');
43
+			header('Content-Disposition: '.rawurlencode($type).'; filename="'.rawurlencode($filename).'"');
44 44
 		} else {
45
-			header('Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode($filename)
46
-												 . '; filename="' . rawurlencode($filename) . '"');
45
+			header('Content-Disposition: '.rawurlencode($type).'; filename*=UTF-8\'\''.rawurlencode($filename)
46
+												 . '; filename="'.rawurlencode($filename).'"');
47 47
 		}
48 48
 	}
49 49
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			. 'connect-src *; '
91 91
 			. 'object-src \'none\'; '
92 92
 			. 'base-uri \'self\'; ';
93
-		header('Content-Security-Policy:' . $policy);
93
+		header('Content-Security-Policy:'.$policy);
94 94
 
95 95
 		// Send fallback headers for installations that don't have the possibility to send
96 96
 		// custom headers on the webserver side
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -28,66 +28,66 @@
 block discarded – undo
28 28
  *
29 29
  */
30 30
 class OC_Response {
31
-	/**
32
-	 * Sets the content disposition header (with possible workarounds)
33
-	 * @param string $filename file name
34
-	 * @param string $type disposition type, either 'attachment' or 'inline'
35
-	 */
36
-	public static function setContentDispositionHeader($filename, $type = 'attachment') {
37
-		if (\OC::$server->getRequest()->isUserAgent(
38
-			[
39
-				\OC\AppFramework\Http\Request::USER_AGENT_IE,
40
-				\OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
41
-				\OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
42
-			])) {
43
-			header('Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode($filename) . '"');
44
-		} else {
45
-			header('Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode($filename)
46
-												 . '; filename="' . rawurlencode($filename) . '"');
47
-		}
48
-	}
31
+    /**
32
+     * Sets the content disposition header (with possible workarounds)
33
+     * @param string $filename file name
34
+     * @param string $type disposition type, either 'attachment' or 'inline'
35
+     */
36
+    public static function setContentDispositionHeader($filename, $type = 'attachment') {
37
+        if (\OC::$server->getRequest()->isUserAgent(
38
+            [
39
+                \OC\AppFramework\Http\Request::USER_AGENT_IE,
40
+                \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
41
+                \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
42
+            ])) {
43
+            header('Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode($filename) . '"');
44
+        } else {
45
+            header('Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode($filename)
46
+                                                    . '; filename="' . rawurlencode($filename) . '"');
47
+        }
48
+    }
49 49
 
50
-	/**
51
-	 * Sets the content length header (with possible workarounds)
52
-	 * @param string|int|float $length Length to be sent
53
-	 */
54
-	public static function setContentLengthHeader($length) {
55
-		header('Content-Length: '.$length);
56
-	}
50
+    /**
51
+     * Sets the content length header (with possible workarounds)
52
+     * @param string|int|float $length Length to be sent
53
+     */
54
+    public static function setContentLengthHeader($length) {
55
+        header('Content-Length: '.$length);
56
+    }
57 57
 
58
-	/**
59
-	 * This function adds some security related headers to all requests served via base.php
60
-	 * The implementation of this function has to happen here to ensure that all third-party
61
-	 * components (e.g. SabreDAV) also benefit from this headers.
62
-	 */
63
-	public static function addSecurityHeaders() {
64
-		/**
65
-		 * FIXME: Content Security Policy for legacy ownCloud components. This
66
-		 * can be removed once \OCP\AppFramework\Http\Response from the AppFramework
67
-		 * is used everywhere.
68
-		 * @see \OCP\AppFramework\Http\Response::getHeaders
69
-		 */
70
-		$policy = 'default-src \'self\'; '
71
-			. 'script-src \'self\' \'nonce-'.\OC::$server->getContentSecurityPolicyNonceManager()->getNonce().'\'; '
72
-			. 'style-src \'self\' \'unsafe-inline\'; '
73
-			. 'frame-src *; '
74
-			. 'img-src * data: blob:; '
75
-			. 'font-src \'self\' data:; '
76
-			. 'media-src *; '
77
-			. 'connect-src *; '
78
-			. 'object-src \'none\'; '
79
-			. 'base-uri \'self\'; ';
80
-		header('Content-Security-Policy:' . $policy);
58
+    /**
59
+     * This function adds some security related headers to all requests served via base.php
60
+     * The implementation of this function has to happen here to ensure that all third-party
61
+     * components (e.g. SabreDAV) also benefit from this headers.
62
+     */
63
+    public static function addSecurityHeaders() {
64
+        /**
65
+         * FIXME: Content Security Policy for legacy ownCloud components. This
66
+         * can be removed once \OCP\AppFramework\Http\Response from the AppFramework
67
+         * is used everywhere.
68
+         * @see \OCP\AppFramework\Http\Response::getHeaders
69
+         */
70
+        $policy = 'default-src \'self\'; '
71
+            . 'script-src \'self\' \'nonce-'.\OC::$server->getContentSecurityPolicyNonceManager()->getNonce().'\'; '
72
+            . 'style-src \'self\' \'unsafe-inline\'; '
73
+            . 'frame-src *; '
74
+            . 'img-src * data: blob:; '
75
+            . 'font-src \'self\' data:; '
76
+            . 'media-src *; '
77
+            . 'connect-src *; '
78
+            . 'object-src \'none\'; '
79
+            . 'base-uri \'self\'; ';
80
+        header('Content-Security-Policy:' . $policy);
81 81
 
82
-		// Send fallback headers for installations that don't have the possibility to send
83
-		// custom headers on the webserver side
84
-		if (getenv('modHeadersAvailable') !== 'true') {
85
-			header('Referrer-Policy: no-referrer'); // https://www.w3.org/TR/referrer-policy/
86
-			header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
87
-			header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains
88
-			header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
89
-			header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag
90
-			header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
91
-		}
92
-	}
82
+        // Send fallback headers for installations that don't have the possibility to send
83
+        // custom headers on the webserver side
84
+        if (getenv('modHeadersAvailable') !== 'true') {
85
+            header('Referrer-Policy: no-referrer'); // https://www.w3.org/TR/referrer-policy/
86
+            header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
87
+            header('X-Frame-Options: SAMEORIGIN'); // Disallow iFraming from other domains
88
+            header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
89
+            header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag
90
+            header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
91
+        }
92
+    }
93 93
 }
Please login to merge, or discard this patch.
lib/private/legacy/OC_EventSource.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		header('X-Accel-Buffering: no');
61 61
 		$this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
62 62
 		if ($this->fallback) {
63
-			$this->fallBackId = (int)$_GET['fallback_id'];
63
+			$this->fallBackId = (int) $_GET['fallback_id'];
64 64
 			/**
65 65
 			 * FIXME: The default content-security-policy of ownCloud forbids inline
66 66
 			 * JavaScript for security reasons. IE starting on Windows 10 will
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			 */
74 74
 			header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
75 75
 			header("Content-Type: text/html");
76
-			echo str_repeat('<span></span>' . PHP_EOL, 10); //dummy data to keep IE happy
76
+			echo str_repeat('<span></span>'.PHP_EOL, 10); //dummy data to keep IE happy
77 77
 		} else {
78 78
 			header("Content-Type: text/event-stream");
79 79
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function send($type, $data = null) {
103 103
 		if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
104
-			throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
104
+			throw new BadMethodCallException('Type needs to be alphanumeric ('.$type.')');
105 105
 		}
106 106
 		$this->init();
107 107
 		if (is_null($data)) {
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 		if ($this->fallback) {
112 112
 			$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
113
-				. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
113
+				. $this->fallBackId.',"'.$type.'",'.OC_JSON::encode($data).')</script>'.PHP_EOL;
114 114
 			echo $response;
115 115
 		} else {
116 116
 			if ($type) {
117
-				echo 'event: ' . $type . PHP_EOL;
117
+				echo 'event: '.$type.PHP_EOL;
118 118
 			}
119
-			echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
119
+			echo 'data: '.OC_JSON::encode($data).PHP_EOL;
120 120
 		}
121 121
 		echo PHP_EOL;
122 122
 		flush();
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -27,99 +27,99 @@
 block discarded – undo
27 27
  *
28 28
  */
29 29
 class OC_EventSource implements \OCP\IEventSource {
30
-	/**
31
-	 * @var bool
32
-	 */
33
-	private $fallback;
30
+    /**
31
+     * @var bool
32
+     */
33
+    private $fallback;
34 34
 
35
-	/**
36
-	 * @var int
37
-	 */
38
-	private $fallBackId = 0;
35
+    /**
36
+     * @var int
37
+     */
38
+    private $fallBackId = 0;
39 39
 
40
-	/**
41
-	 * @var bool
42
-	 */
43
-	private $started = false;
40
+    /**
41
+     * @var bool
42
+     */
43
+    private $started = false;
44 44
 
45
-	protected function init() {
46
-		if ($this->started) {
47
-			return;
48
-		}
49
-		$this->started = true;
45
+    protected function init() {
46
+        if ($this->started) {
47
+            return;
48
+        }
49
+        $this->started = true;
50 50
 
51
-		// prevent php output buffering, caching and nginx buffering
52
-		OC_Util::obEnd();
53
-		header('Cache-Control: no-cache');
54
-		header('X-Accel-Buffering: no');
55
-		$this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
56
-		if ($this->fallback) {
57
-			$this->fallBackId = (int)$_GET['fallback_id'];
58
-			/**
59
-			 * FIXME: The default content-security-policy of ownCloud forbids inline
60
-			 * JavaScript for security reasons. IE starting on Windows 10 will
61
-			 * however also obey the CSP which will break the event source fallback.
62
-			 *
63
-			 * As a workaround thus we set a custom policy which allows the execution
64
-			 * of inline JavaScript.
65
-			 *
66
-			 * @link https://github.com/owncloud/core/issues/14286
67
-			 */
68
-			header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
69
-			header("Content-Type: text/html");
70
-			echo str_repeat('<span></span>' . PHP_EOL, 10); //dummy data to keep IE happy
71
-		} else {
72
-			header("Content-Type: text/event-stream");
73
-		}
74
-		if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
75
-			header('Location: '.\OC::$WEBROOT);
76
-			exit();
77
-		}
78
-		if (!\OC::$server->getRequest()->passesCSRFCheck()) {
79
-			$this->send('error', 'Possible CSRF attack. Connection will be closed.');
80
-			$this->close();
81
-			exit();
82
-		}
83
-		flush();
84
-	}
51
+        // prevent php output buffering, caching and nginx buffering
52
+        OC_Util::obEnd();
53
+        header('Cache-Control: no-cache');
54
+        header('X-Accel-Buffering: no');
55
+        $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
56
+        if ($this->fallback) {
57
+            $this->fallBackId = (int)$_GET['fallback_id'];
58
+            /**
59
+             * FIXME: The default content-security-policy of ownCloud forbids inline
60
+             * JavaScript for security reasons. IE starting on Windows 10 will
61
+             * however also obey the CSP which will break the event source fallback.
62
+             *
63
+             * As a workaround thus we set a custom policy which allows the execution
64
+             * of inline JavaScript.
65
+             *
66
+             * @link https://github.com/owncloud/core/issues/14286
67
+             */
68
+            header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
69
+            header("Content-Type: text/html");
70
+            echo str_repeat('<span></span>' . PHP_EOL, 10); //dummy data to keep IE happy
71
+        } else {
72
+            header("Content-Type: text/event-stream");
73
+        }
74
+        if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
75
+            header('Location: '.\OC::$WEBROOT);
76
+            exit();
77
+        }
78
+        if (!\OC::$server->getRequest()->passesCSRFCheck()) {
79
+            $this->send('error', 'Possible CSRF attack. Connection will be closed.');
80
+            $this->close();
81
+            exit();
82
+        }
83
+        flush();
84
+    }
85 85
 
86
-	/**
87
-	 * send a message to the client
88
-	 *
89
-	 * @param string $type
90
-	 * @param mixed $data
91
-	 *
92
-	 * @throws \BadMethodCallException
93
-	 * if only one parameter is given, a typeless message will be send with that parameter as data
94
-	 * @suppress PhanDeprecatedFunction
95
-	 */
96
-	public function send($type, $data = null) {
97
-		if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
98
-			throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
99
-		}
100
-		$this->init();
101
-		if (is_null($data)) {
102
-			$data = $type;
103
-			$type = null;
104
-		}
105
-		if ($this->fallback) {
106
-			$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
107
-				. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
108
-			echo $response;
109
-		} else {
110
-			if ($type) {
111
-				echo 'event: ' . $type . PHP_EOL;
112
-			}
113
-			echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
114
-		}
115
-		echo PHP_EOL;
116
-		flush();
117
-	}
86
+    /**
87
+     * send a message to the client
88
+     *
89
+     * @param string $type
90
+     * @param mixed $data
91
+     *
92
+     * @throws \BadMethodCallException
93
+     * if only one parameter is given, a typeless message will be send with that parameter as data
94
+     * @suppress PhanDeprecatedFunction
95
+     */
96
+    public function send($type, $data = null) {
97
+        if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
98
+            throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
99
+        }
100
+        $this->init();
101
+        if (is_null($data)) {
102
+            $data = $type;
103
+            $type = null;
104
+        }
105
+        if ($this->fallback) {
106
+            $response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
107
+                . $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
108
+            echo $response;
109
+        } else {
110
+            if ($type) {
111
+                echo 'event: ' . $type . PHP_EOL;
112
+            }
113
+            echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
114
+        }
115
+        echo PHP_EOL;
116
+        flush();
117
+    }
118 118
 
119
-	/**
120
-	 * close the connection of the event source
121
-	 */
122
-	public function close() {
123
-		$this->send('__internal__', 'close'); //server side closing can be an issue, let the client do it
124
-	}
119
+    /**
120
+     * close the connection of the event source
121
+     */
122
+    public function close() {
123
+        $this->send('__internal__', 'close'); //server side closing can be an issue, let the client do it
124
+    }
125 125
 }
Please login to merge, or discard this patch.
lib/private/legacy/OC_JSON.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	public static function checkAppEnabled($app) {
45 45
 		if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
46 46
 			$l = \OC::$server->getL10N('lib');
47
-			self::error([ 'data' => [ 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ]]);
47
+			self::error(['data' => ['message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled']]);
48 48
 			exit();
49 49
 		}
50 50
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
61 61
 			$l = \OC::$server->getL10N('lib');
62 62
 			http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
63
-			self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
63
+			self::error(['data' => ['message' => $l->t('Authentication error'), 'error' => 'authentication_error']]);
64 64
 			exit();
65 65
 		}
66 66
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		if (!\OC::$server->getRequest()->passesCSRFCheck()) {
80 80
 			$l = \OC::$server->getL10N('lib');
81
-			self::error([ 'data' => [ 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ]]);
81
+			self::error(['data' => ['message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired']]);
82 82
 			exit();
83 83
 		}
84 84
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	public static function checkAdminUser() {
92 92
 		if (!OC_User::isAdminUser(OC_User::getUser())) {
93 93
 			$l = \OC::$server->getL10N('lib');
94
-			self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
94
+			self::error(['data' => ['message' => $l->t('Authentication error'), 'error' => 'authentication_error']]);
95 95
 			exit();
96 96
 		}
97 97
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	protected static function to_string(&$value) {
125 125
 		if ($value instanceof \OC\L10N\L10NString) {
126
-			$value = (string)$value;
126
+			$value = (string) $value;
127 127
 		}
128 128
 	}
129 129
 
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -28,108 +28,108 @@
 block discarded – undo
28 28
  *
29 29
  */
30 30
 class OC_JSON {
31
-	/**
32
-	 * Check if the app is enabled, send json error msg if not
33
-	 * @param string $app
34
-	 * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
35
-	 * @suppress PhanDeprecatedFunction
36
-	 */
37
-	public static function checkAppEnabled($app) {
38
-		if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
39
-			$l = \OC::$server->getL10N('lib');
40
-			self::error([ 'data' => [ 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ]]);
41
-			exit();
42
-		}
43
-	}
31
+    /**
32
+     * Check if the app is enabled, send json error msg if not
33
+     * @param string $app
34
+     * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
35
+     * @suppress PhanDeprecatedFunction
36
+     */
37
+    public static function checkAppEnabled($app) {
38
+        if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
39
+            $l = \OC::$server->getL10N('lib');
40
+            self::error([ 'data' => [ 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ]]);
41
+            exit();
42
+        }
43
+    }
44 44
 
45
-	/**
46
-	 * Check if the user is logged in, send json error msg if not
47
-	 * @deprecated Use annotation based ACLs from the AppFramework instead
48
-	 * @suppress PhanDeprecatedFunction
49
-	 */
50
-	public static function checkLoggedIn() {
51
-		$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
52
-		if (!\OC::$server->getUserSession()->isLoggedIn()
53
-			|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
54
-			$l = \OC::$server->getL10N('lib');
55
-			http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
56
-			self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
57
-			exit();
58
-		}
59
-	}
45
+    /**
46
+     * Check if the user is logged in, send json error msg if not
47
+     * @deprecated Use annotation based ACLs from the AppFramework instead
48
+     * @suppress PhanDeprecatedFunction
49
+     */
50
+    public static function checkLoggedIn() {
51
+        $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
52
+        if (!\OC::$server->getUserSession()->isLoggedIn()
53
+            || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
54
+            $l = \OC::$server->getL10N('lib');
55
+            http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
56
+            self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
57
+            exit();
58
+        }
59
+    }
60 60
 
61
-	/**
62
-	 * Check an ajax get/post call if the request token is valid, send json error msg if not.
63
-	 * @deprecated Use annotation based CSRF checks from the AppFramework instead
64
-	 * @suppress PhanDeprecatedFunction
65
-	 */
66
-	public static function callCheck() {
67
-		if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
68
-			header('Location: '.\OC::$WEBROOT);
69
-			exit();
70
-		}
61
+    /**
62
+     * Check an ajax get/post call if the request token is valid, send json error msg if not.
63
+     * @deprecated Use annotation based CSRF checks from the AppFramework instead
64
+     * @suppress PhanDeprecatedFunction
65
+     */
66
+    public static function callCheck() {
67
+        if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
68
+            header('Location: '.\OC::$WEBROOT);
69
+            exit();
70
+        }
71 71
 
72
-		if (!\OC::$server->getRequest()->passesCSRFCheck()) {
73
-			$l = \OC::$server->getL10N('lib');
74
-			self::error([ 'data' => [ 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ]]);
75
-			exit();
76
-		}
77
-	}
72
+        if (!\OC::$server->getRequest()->passesCSRFCheck()) {
73
+            $l = \OC::$server->getL10N('lib');
74
+            self::error([ 'data' => [ 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ]]);
75
+            exit();
76
+        }
77
+    }
78 78
 
79
-	/**
80
-	 * Check if the user is a admin, send json error msg if not.
81
-	 * @deprecated Use annotation based ACLs from the AppFramework instead
82
-	 * @suppress PhanDeprecatedFunction
83
-	 */
84
-	public static function checkAdminUser() {
85
-		if (!OC_User::isAdminUser(OC_User::getUser())) {
86
-			$l = \OC::$server->getL10N('lib');
87
-			self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
88
-			exit();
89
-		}
90
-	}
79
+    /**
80
+     * Check if the user is a admin, send json error msg if not.
81
+     * @deprecated Use annotation based ACLs from the AppFramework instead
82
+     * @suppress PhanDeprecatedFunction
83
+     */
84
+    public static function checkAdminUser() {
85
+        if (!OC_User::isAdminUser(OC_User::getUser())) {
86
+            $l = \OC::$server->getL10N('lib');
87
+            self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
88
+            exit();
89
+        }
90
+    }
91 91
 
92
-	/**
93
-	 * Send json error msg
94
-	 * @deprecated Use a AppFramework JSONResponse instead
95
-	 * @suppress PhanDeprecatedFunction
96
-	 * @psalm-taint-escape html
97
-	 */
98
-	public static function error($data = []) {
99
-		$data['status'] = 'error';
100
-		header('Content-Type: application/json; charset=utf-8');
101
-		echo self::encode($data);
102
-	}
92
+    /**
93
+     * Send json error msg
94
+     * @deprecated Use a AppFramework JSONResponse instead
95
+     * @suppress PhanDeprecatedFunction
96
+     * @psalm-taint-escape html
97
+     */
98
+    public static function error($data = []) {
99
+        $data['status'] = 'error';
100
+        header('Content-Type: application/json; charset=utf-8');
101
+        echo self::encode($data);
102
+    }
103 103
 
104
-	/**
105
-	 * Send json success msg
106
-	 * @deprecated Use a AppFramework JSONResponse instead
107
-	 * @suppress PhanDeprecatedFunction
108
-	 * @psalm-taint-escape html
109
-	 */
110
-	public static function success($data = []) {
111
-		$data['status'] = 'success';
112
-		header('Content-Type: application/json; charset=utf-8');
113
-		echo self::encode($data);
114
-	}
104
+    /**
105
+     * Send json success msg
106
+     * @deprecated Use a AppFramework JSONResponse instead
107
+     * @suppress PhanDeprecatedFunction
108
+     * @psalm-taint-escape html
109
+     */
110
+    public static function success($data = []) {
111
+        $data['status'] = 'success';
112
+        header('Content-Type: application/json; charset=utf-8');
113
+        echo self::encode($data);
114
+    }
115 115
 
116
-	/**
117
-	 * Convert OC_L10N_String to string, for use in json encodings
118
-	 */
119
-	protected static function to_string(&$value) {
120
-		if ($value instanceof \OC\L10N\L10NString) {
121
-			$value = (string)$value;
122
-		}
123
-	}
116
+    /**
117
+     * Convert OC_L10N_String to string, for use in json encodings
118
+     */
119
+    protected static function to_string(&$value) {
120
+        if ($value instanceof \OC\L10N\L10NString) {
121
+            $value = (string)$value;
122
+        }
123
+    }
124 124
 
125
-	/**
126
-	 * Encode JSON
127
-	 * @deprecated Use a AppFramework JSONResponse instead
128
-	 */
129
-	public static function encode($data) {
130
-		if (is_array($data)) {
131
-			array_walk_recursive($data, ['OC_JSON', 'to_string']);
132
-		}
133
-		return json_encode($data, JSON_HEX_TAG);
134
-	}
125
+    /**
126
+     * Encode JSON
127
+     * @deprecated Use a AppFramework JSONResponse instead
128
+     */
129
+    public static function encode($data) {
130
+        if (is_array($data)) {
131
+            array_walk_recursive($data, ['OC_JSON', 'to_string']);
132
+        }
133
+        return json_encode($data, JSON_HEX_TAG);
134
+    }
135 135
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Notification/Notifier.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -31,72 +31,72 @@
 block discarded – undo
31 31
 
32 32
 class Notifier implements INotifier {
33 33
 
34
-	/** @var IFactory */
35
-	protected $l10nFactory;
34
+    /** @var IFactory */
35
+    protected $l10nFactory;
36 36
 
37
-	/**
38
-	 * @param IFactory $l10nFactory
39
-	 */
40
-	public function __construct(\OCP\L10N\IFactory $l10nFactory) {
41
-		$this->l10nFactory = $l10nFactory;
42
-	}
37
+    /**
38
+     * @param IFactory $l10nFactory
39
+     */
40
+    public function __construct(\OCP\L10N\IFactory $l10nFactory) {
41
+        $this->l10nFactory = $l10nFactory;
42
+    }
43 43
 
44
-	/**
45
-	 * Identifier of the notifier, only use [a-z0-9_]
46
-	 *
47
-	 * @return string
48
-	 * @since 17.0.0
49
-	 */
50
-	public function getID(): string {
51
-		return 'user_ldap';
52
-	}
44
+    /**
45
+     * Identifier of the notifier, only use [a-z0-9_]
46
+     *
47
+     * @return string
48
+     * @since 17.0.0
49
+     */
50
+    public function getID(): string {
51
+        return 'user_ldap';
52
+    }
53 53
 
54
-	/**
55
-	 * Human readable name describing the notifier
56
-	 *
57
-	 * @return string
58
-	 * @since 17.0.0
59
-	 */
60
-	public function getName(): string {
61
-		return $this->l10nFactory->get('user_ldap')->t('LDAP User backend');
62
-	}
54
+    /**
55
+     * Human readable name describing the notifier
56
+     *
57
+     * @return string
58
+     * @since 17.0.0
59
+     */
60
+    public function getName(): string {
61
+        return $this->l10nFactory->get('user_ldap')->t('LDAP User backend');
62
+    }
63 63
 
64
-	/**
65
-	 * @param INotification $notification
66
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
67
-	 * @return INotification
68
-	 * @throws \InvalidArgumentException When the notification was not prepared by a notifier
69
-	 */
70
-	public function prepare(INotification $notification, string $languageCode): INotification {
71
-		if ($notification->getApp() !== 'user_ldap') {
72
-			// Not my app => throw
73
-			throw new \InvalidArgumentException();
74
-		}
64
+    /**
65
+     * @param INotification $notification
66
+     * @param string $languageCode The code of the language that should be used to prepare the notification
67
+     * @return INotification
68
+     * @throws \InvalidArgumentException When the notification was not prepared by a notifier
69
+     */
70
+    public function prepare(INotification $notification, string $languageCode): INotification {
71
+        if ($notification->getApp() !== 'user_ldap') {
72
+            // Not my app => throw
73
+            throw new \InvalidArgumentException();
74
+        }
75 75
 
76
-		// Read the language from the notification
77
-		$l = $this->l10nFactory->get('user_ldap', $languageCode);
76
+        // Read the language from the notification
77
+        $l = $this->l10nFactory->get('user_ldap', $languageCode);
78 78
 
79
-		switch ($notification->getSubject()) {
80
-			// Deal with known subjects
81
-			case 'pwd_exp_warn_days':
82
-				$params = $notification->getSubjectParameters();
83
-				$days = (int) $params[0];
84
-				if ($days === 2) {
85
-					$notification->setParsedSubject($l->t('Your password will expire tomorrow.'));
86
-				} elseif ($days === 1) {
87
-					$notification->setParsedSubject($l->t('Your password will expire today.'));
88
-				} else {
89
-					$notification->setParsedSubject($l->n(
90
-						'Your password will expire within %n day.',
91
-						'Your password will expire within %n days.',
92
-						$days
93
-					));
94
-				}
95
-				return $notification;
79
+        switch ($notification->getSubject()) {
80
+            // Deal with known subjects
81
+            case 'pwd_exp_warn_days':
82
+                $params = $notification->getSubjectParameters();
83
+                $days = (int) $params[0];
84
+                if ($days === 2) {
85
+                    $notification->setParsedSubject($l->t('Your password will expire tomorrow.'));
86
+                } elseif ($days === 1) {
87
+                    $notification->setParsedSubject($l->t('Your password will expire today.'));
88
+                } else {
89
+                    $notification->setParsedSubject($l->n(
90
+                        'Your password will expire within %n day.',
91
+                        'Your password will expire within %n days.',
92
+                        $days
93
+                    ));
94
+                }
95
+                return $notification;
96 96
 
97
-			default:
98
-				// Unknown subject => Unknown notification => throw
99
-				throw new \InvalidArgumentException();
100
-		}
101
-	}
97
+            default:
98
+                // Unknown subject => Unknown notification => throw
99
+                throw new \InvalidArgumentException();
100
+        }
101
+    }
102 102
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/GroupPluginManager.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$this->respondToActions |= $respondToActions;
55 55
 
56 56
 		foreach ($this->which as $action => $v) {
57
-			if ((bool)($respondToActions & $action)) {
57
+			if ((bool) ($respondToActions & $action)) {
58 58
 				$this->which[$action] = $plugin;
59 59
 				\OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
60 60
 			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		$plugin = $this->which[GroupInterface::COUNT_USERS];
148 148
 
149 149
 		if ($plugin) {
150
-			return $plugin->countUsersInGroup($gid,$search);
150
+			return $plugin->countUsersInGroup($gid, $search);
151 151
 		}
152 152
 		throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
153 153
 	}
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -26,161 +26,161 @@
 block discarded – undo
26 26
 use OCP\GroupInterface;
27 27
 
28 28
 class GroupPluginManager {
29
-	private int $respondToActions = 0;
30
-
31
-	/** @var array<int, ?ILDAPGroupPlugin> */
32
-	private array $which = [
33
-		GroupInterface::CREATE_GROUP => null,
34
-		GroupInterface::DELETE_GROUP => null,
35
-		GroupInterface::ADD_TO_GROUP => null,
36
-		GroupInterface::REMOVE_FROM_GROUP => null,
37
-		GroupInterface::COUNT_USERS => null,
38
-		GroupInterface::GROUP_DETAILS => null
39
-	];
40
-
41
-	private bool $suppressDeletion = false;
42
-
43
-	/**
44
-	 * @return int All implemented actions
45
-	 */
46
-	public function getImplementedActions() {
47
-		return $this->respondToActions;
48
-	}
49
-
50
-	/**
51
-	 * Registers a group plugin that may implement some actions, overriding User_LDAP's group actions.
52
-	 * @param ILDAPGroupPlugin $plugin
53
-	 */
54
-	public function register(ILDAPGroupPlugin $plugin) {
55
-		$respondToActions = $plugin->respondToActions();
56
-		$this->respondToActions |= $respondToActions;
57
-
58
-		foreach ($this->which as $action => $v) {
59
-			if ((bool)($respondToActions & $action)) {
60
-				$this->which[$action] = $plugin;
61
-				\OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
62
-			}
63
-		}
64
-	}
65
-
66
-	/**
67
-	 * Signal if there is a registered plugin that implements some given actions
68
-	 * @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP
69
-	 * @return bool
70
-	 */
71
-	public function implementsActions($actions) {
72
-		return ($actions & $this->respondToActions) == $actions;
73
-	}
74
-
75
-	/**
76
-	 * Create a group
77
-	 * @param string $gid Group Id
78
-	 * @return string | null The group DN if group creation was successful.
79
-	 * @throws \Exception
80
-	 */
81
-	public function createGroup($gid) {
82
-		$plugin = $this->which[GroupInterface::CREATE_GROUP];
83
-
84
-		if ($plugin) {
85
-			return $plugin->createGroup($gid);
86
-		}
87
-		throw new \Exception('No plugin implements createGroup in this LDAP Backend.');
88
-	}
89
-
90
-	public function canDeleteGroup(): bool {
91
-		return !$this->suppressDeletion && $this->implementsActions(GroupInterface::DELETE_GROUP);
92
-	}
93
-
94
-	/**
95
-	 * @return bool – the value before the change
96
-	 */
97
-	public function setSuppressDeletion(bool $value): bool {
98
-		$old = $this->suppressDeletion;
99
-		$this->suppressDeletion = $value;
100
-		return $old;
101
-	}
102
-
103
-	/**
104
-	 * Delete a group
105
-	 *
106
-	 * @throws \Exception
107
-	 */
108
-	public function deleteGroup(string $gid): bool {
109
-		$plugin = $this->which[GroupInterface::DELETE_GROUP];
110
-
111
-		if ($plugin) {
112
-			if ($this->suppressDeletion) {
113
-				return false;
114
-			}
115
-			return $plugin->deleteGroup($gid);
116
-		}
117
-		throw new \Exception('No plugin implements deleteGroup in this LDAP Backend.');
118
-	}
119
-
120
-	/**
121
-	 * Add a user to a group
122
-	 * @param string $uid ID of the user to add to group
123
-	 * @param string $gid ID of the group in which add the user
124
-	 * @return bool
125
-	 * @throws \Exception
126
-	 *
127
-	 * Adds a user to a group.
128
-	 */
129
-	public function addToGroup($uid, $gid) {
130
-		$plugin = $this->which[GroupInterface::ADD_TO_GROUP];
131
-
132
-		if ($plugin) {
133
-			return $plugin->addToGroup($uid, $gid);
134
-		}
135
-		throw new \Exception('No plugin implements addToGroup in this LDAP Backend.');
136
-	}
137
-
138
-	/**
139
-	 * Removes a user from a group
140
-	 * @param string $uid ID of the user to remove from group
141
-	 * @param string $gid ID of the group from which remove the user
142
-	 * @return bool
143
-	 * @throws \Exception
144
-	 *
145
-	 * removes the user from a group.
146
-	 */
147
-	public function removeFromGroup($uid, $gid) {
148
-		$plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP];
149
-
150
-		if ($plugin) {
151
-			return $plugin->removeFromGroup($uid, $gid);
152
-		}
153
-		throw new \Exception('No plugin implements removeFromGroup in this LDAP Backend.');
154
-	}
155
-
156
-	/**
157
-	 * get the number of all users matching the search string in a group
158
-	 * @param string $gid ID of the group
159
-	 * @param string $search query string
160
-	 * @return int|false
161
-	 * @throws \Exception
162
-	 */
163
-	public function countUsersInGroup($gid, $search = '') {
164
-		$plugin = $this->which[GroupInterface::COUNT_USERS];
165
-
166
-		if ($plugin) {
167
-			return $plugin->countUsersInGroup($gid,$search);
168
-		}
169
-		throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
170
-	}
171
-
172
-	/**
173
-	 * get an array with group details
174
-	 * @param string $gid
175
-	 * @return array|false
176
-	 * @throws \Exception
177
-	 */
178
-	public function getGroupDetails($gid) {
179
-		$plugin = $this->which[GroupInterface::GROUP_DETAILS];
180
-
181
-		if ($plugin) {
182
-			return $plugin->getGroupDetails($gid);
183
-		}
184
-		throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.');
185
-	}
29
+    private int $respondToActions = 0;
30
+
31
+    /** @var array<int, ?ILDAPGroupPlugin> */
32
+    private array $which = [
33
+        GroupInterface::CREATE_GROUP => null,
34
+        GroupInterface::DELETE_GROUP => null,
35
+        GroupInterface::ADD_TO_GROUP => null,
36
+        GroupInterface::REMOVE_FROM_GROUP => null,
37
+        GroupInterface::COUNT_USERS => null,
38
+        GroupInterface::GROUP_DETAILS => null
39
+    ];
40
+
41
+    private bool $suppressDeletion = false;
42
+
43
+    /**
44
+     * @return int All implemented actions
45
+     */
46
+    public function getImplementedActions() {
47
+        return $this->respondToActions;
48
+    }
49
+
50
+    /**
51
+     * Registers a group plugin that may implement some actions, overriding User_LDAP's group actions.
52
+     * @param ILDAPGroupPlugin $plugin
53
+     */
54
+    public function register(ILDAPGroupPlugin $plugin) {
55
+        $respondToActions = $plugin->respondToActions();
56
+        $this->respondToActions |= $respondToActions;
57
+
58
+        foreach ($this->which as $action => $v) {
59
+            if ((bool)($respondToActions & $action)) {
60
+                $this->which[$action] = $plugin;
61
+                \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
62
+            }
63
+        }
64
+    }
65
+
66
+    /**
67
+     * Signal if there is a registered plugin that implements some given actions
68
+     * @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP
69
+     * @return bool
70
+     */
71
+    public function implementsActions($actions) {
72
+        return ($actions & $this->respondToActions) == $actions;
73
+    }
74
+
75
+    /**
76
+     * Create a group
77
+     * @param string $gid Group Id
78
+     * @return string | null The group DN if group creation was successful.
79
+     * @throws \Exception
80
+     */
81
+    public function createGroup($gid) {
82
+        $plugin = $this->which[GroupInterface::CREATE_GROUP];
83
+
84
+        if ($plugin) {
85
+            return $plugin->createGroup($gid);
86
+        }
87
+        throw new \Exception('No plugin implements createGroup in this LDAP Backend.');
88
+    }
89
+
90
+    public function canDeleteGroup(): bool {
91
+        return !$this->suppressDeletion && $this->implementsActions(GroupInterface::DELETE_GROUP);
92
+    }
93
+
94
+    /**
95
+     * @return bool – the value before the change
96
+     */
97
+    public function setSuppressDeletion(bool $value): bool {
98
+        $old = $this->suppressDeletion;
99
+        $this->suppressDeletion = $value;
100
+        return $old;
101
+    }
102
+
103
+    /**
104
+     * Delete a group
105
+     *
106
+     * @throws \Exception
107
+     */
108
+    public function deleteGroup(string $gid): bool {
109
+        $plugin = $this->which[GroupInterface::DELETE_GROUP];
110
+
111
+        if ($plugin) {
112
+            if ($this->suppressDeletion) {
113
+                return false;
114
+            }
115
+            return $plugin->deleteGroup($gid);
116
+        }
117
+        throw new \Exception('No plugin implements deleteGroup in this LDAP Backend.');
118
+    }
119
+
120
+    /**
121
+     * Add a user to a group
122
+     * @param string $uid ID of the user to add to group
123
+     * @param string $gid ID of the group in which add the user
124
+     * @return bool
125
+     * @throws \Exception
126
+     *
127
+     * Adds a user to a group.
128
+     */
129
+    public function addToGroup($uid, $gid) {
130
+        $plugin = $this->which[GroupInterface::ADD_TO_GROUP];
131
+
132
+        if ($plugin) {
133
+            return $plugin->addToGroup($uid, $gid);
134
+        }
135
+        throw new \Exception('No plugin implements addToGroup in this LDAP Backend.');
136
+    }
137
+
138
+    /**
139
+     * Removes a user from a group
140
+     * @param string $uid ID of the user to remove from group
141
+     * @param string $gid ID of the group from which remove the user
142
+     * @return bool
143
+     * @throws \Exception
144
+     *
145
+     * removes the user from a group.
146
+     */
147
+    public function removeFromGroup($uid, $gid) {
148
+        $plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP];
149
+
150
+        if ($plugin) {
151
+            return $plugin->removeFromGroup($uid, $gid);
152
+        }
153
+        throw new \Exception('No plugin implements removeFromGroup in this LDAP Backend.');
154
+    }
155
+
156
+    /**
157
+     * get the number of all users matching the search string in a group
158
+     * @param string $gid ID of the group
159
+     * @param string $search query string
160
+     * @return int|false
161
+     * @throws \Exception
162
+     */
163
+    public function countUsersInGroup($gid, $search = '') {
164
+        $plugin = $this->which[GroupInterface::COUNT_USERS];
165
+
166
+        if ($plugin) {
167
+            return $plugin->countUsersInGroup($gid,$search);
168
+        }
169
+        throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
170
+    }
171
+
172
+    /**
173
+     * get an array with group details
174
+     * @param string $gid
175
+     * @return array|false
176
+     * @throws \Exception
177
+     */
178
+    public function getGroupDetails($gid) {
179
+        $plugin = $this->which[GroupInterface::GROUP_DETAILS];
180
+
181
+        if ($plugin) {
182
+            return $plugin->getGroupDetails($gid);
183
+        }
184
+        throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.');
185
+    }
186 186
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Handler/ExtStorageConfigHandler.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -30,40 +30,40 @@
 block discarded – undo
30 30
 use OCA\User_LDAP\User_Proxy;
31 31
 
32 32
 class ExtStorageConfigHandler extends UserContext implements IConfigHandler {
33
-	use SimpleSubstitutionTrait;
33
+    use SimpleSubstitutionTrait;
34 34
 
35
-	/**
36
-	 * @param mixed $optionValue
37
-	 * @return mixed the same type as $optionValue
38
-	 * @since 16.0.0
39
-	 * @throws \Exception
40
-	 */
41
-	public function handle($optionValue) {
42
-		$this->placeholder = 'home';
43
-		$user = $this->getUser();
35
+    /**
36
+     * @param mixed $optionValue
37
+     * @return mixed the same type as $optionValue
38
+     * @since 16.0.0
39
+     * @throws \Exception
40
+     */
41
+    public function handle($optionValue) {
42
+        $this->placeholder = 'home';
43
+        $user = $this->getUser();
44 44
 
45
-		if ($user === null) {
46
-			return $optionValue;
47
-		}
45
+        if ($user === null) {
46
+            return $optionValue;
47
+        }
48 48
 
49
-		$backend = $user->getBackend();
50
-		if (!$backend instanceof User_Proxy) {
51
-			return $optionValue;
52
-		}
49
+        $backend = $user->getBackend();
50
+        if (!$backend instanceof User_Proxy) {
51
+            return $optionValue;
52
+        }
53 53
 
54
-		$access = $backend->getLDAPAccess($user->getUID());
55
-		if (!$access) {
56
-			return $optionValue;
57
-		}
54
+        $access = $backend->getLDAPAccess($user->getUID());
55
+        if (!$access) {
56
+            return $optionValue;
57
+        }
58 58
 
59
-		$attribute = $access->connection->ldapExtStorageHomeAttribute;
60
-		if (empty($attribute)) {
61
-			return $optionValue;
62
-		}
59
+        $attribute = $access->connection->ldapExtStorageHomeAttribute;
60
+        if (empty($attribute)) {
61
+            return $optionValue;
62
+        }
63 63
 
64
-		$ldapUser = $access->userManager->get($user->getUID());
65
-		$extHome = $ldapUser->getExtStorageHome();
64
+        $ldapUser = $access->userManager->get($user->getUID());
65
+        $extHome = $ldapUser->getExtStorageHome();
66 66
 
67
-		return $this->processInput($optionValue, $extHome);
68
-	}
67
+        return $this->processInput($optionValue, $extHome);
68
+    }
69 69
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/User/DeletedUsersIndex.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
114 114
 			return;
115 115
 		}
116 116
 		$this->config->setUserValue($ocName, 'user_ldap', 'isDeleted', '1');
117
-		$this->config->setUserValue($ocName, 'user_ldap', 'foundDeleted', (string)time());
117
+		$this->config->setUserValue($ocName, 'user_ldap', 'foundDeleted', (string) time());
118 118
 		$this->deletedUsers = null;
119 119
 	}
120 120
 }
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -33,82 +33,82 @@
 block discarded – undo
33 33
  * @package OCA\User_LDAP
34 34
  */
35 35
 class DeletedUsersIndex {
36
-	/**
37
-	 * @var \OCP\IConfig $config
38
-	 */
39
-	protected $config;
36
+    /**
37
+     * @var \OCP\IConfig $config
38
+     */
39
+    protected $config;
40 40
 
41
-	/**
42
-	 * @var \OCA\User_LDAP\Mapping\UserMapping $mapping
43
-	 */
44
-	protected $mapping;
41
+    /**
42
+     * @var \OCA\User_LDAP\Mapping\UserMapping $mapping
43
+     */
44
+    protected $mapping;
45 45
 
46
-	/**
47
-	 * @var array $deletedUsers
48
-	 */
49
-	protected $deletedUsers;
50
-	/** @var IManager */
51
-	private $shareManager;
46
+    /**
47
+     * @var array $deletedUsers
48
+     */
49
+    protected $deletedUsers;
50
+    /** @var IManager */
51
+    private $shareManager;
52 52
 
53
-	public function __construct(\OCP\IConfig $config, UserMapping $mapping, IManager $shareManager) {
54
-		$this->config = $config;
55
-		$this->mapping = $mapping;
56
-		$this->shareManager = $shareManager;
57
-	}
53
+    public function __construct(\OCP\IConfig $config, UserMapping $mapping, IManager $shareManager) {
54
+        $this->config = $config;
55
+        $this->mapping = $mapping;
56
+        $this->shareManager = $shareManager;
57
+    }
58 58
 
59
-	/**
60
-	 * reads LDAP users marked as deleted from the database
61
-	 * @return \OCA\User_LDAP\User\OfflineUser[]
62
-	 */
63
-	private function fetchDeletedUsers() {
64
-		$deletedUsers = $this->config->getUsersForUserValue(
65
-			'user_ldap', 'isDeleted', '1');
59
+    /**
60
+     * reads LDAP users marked as deleted from the database
61
+     * @return \OCA\User_LDAP\User\OfflineUser[]
62
+     */
63
+    private function fetchDeletedUsers() {
64
+        $deletedUsers = $this->config->getUsersForUserValue(
65
+            'user_ldap', 'isDeleted', '1');
66 66
 
67
-		$userObjects = [];
68
-		foreach ($deletedUsers as $user) {
69
-			$userObjects[] = new OfflineUser($user, $this->config, $this->mapping, $this->shareManager);
70
-		}
71
-		$this->deletedUsers = $userObjects;
67
+        $userObjects = [];
68
+        foreach ($deletedUsers as $user) {
69
+            $userObjects[] = new OfflineUser($user, $this->config, $this->mapping, $this->shareManager);
70
+        }
71
+        $this->deletedUsers = $userObjects;
72 72
 
73
-		return $this->deletedUsers;
74
-	}
73
+        return $this->deletedUsers;
74
+    }
75 75
 
76
-	/**
77
-	 * returns all LDAP users that are marked as deleted
78
-	 * @return \OCA\User_LDAP\User\OfflineUser[]
79
-	 */
80
-	public function getUsers() {
81
-		if (is_array($this->deletedUsers)) {
82
-			return $this->deletedUsers;
83
-		}
84
-		return $this->fetchDeletedUsers();
85
-	}
76
+    /**
77
+     * returns all LDAP users that are marked as deleted
78
+     * @return \OCA\User_LDAP\User\OfflineUser[]
79
+     */
80
+    public function getUsers() {
81
+        if (is_array($this->deletedUsers)) {
82
+            return $this->deletedUsers;
83
+        }
84
+        return $this->fetchDeletedUsers();
85
+    }
86 86
 
87
-	/**
88
-	 * whether at least one user was detected as deleted
89
-	 * @return bool
90
-	 */
91
-	public function hasUsers() {
92
-		if (!is_array($this->deletedUsers)) {
93
-			$this->fetchDeletedUsers();
94
-		}
95
-		return is_array($this->deletedUsers) && (count($this->deletedUsers) > 0);
96
-	}
87
+    /**
88
+     * whether at least one user was detected as deleted
89
+     * @return bool
90
+     */
91
+    public function hasUsers() {
92
+        if (!is_array($this->deletedUsers)) {
93
+            $this->fetchDeletedUsers();
94
+        }
95
+        return is_array($this->deletedUsers) && (count($this->deletedUsers) > 0);
96
+    }
97 97
 
98
-	/**
99
-	 * marks a user as deleted
100
-	 *
101
-	 * @param string $ocName
102
-	 * @throws \OCP\PreConditionNotMetException
103
-	 */
104
-	public function markUser($ocName) {
105
-		$curValue = $this->config->getUserValue($ocName, 'user_ldap', 'isDeleted', '0');
106
-		if ($curValue === '1') {
107
-			// the user is already marked, do not write to DB again
108
-			return;
109
-		}
110
-		$this->config->setUserValue($ocName, 'user_ldap', 'isDeleted', '1');
111
-		$this->config->setUserValue($ocName, 'user_ldap', 'foundDeleted', (string)time());
112
-		$this->deletedUsers = null;
113
-	}
98
+    /**
99
+     * marks a user as deleted
100
+     *
101
+     * @param string $ocName
102
+     * @throws \OCP\PreConditionNotMetException
103
+     */
104
+    public function markUser($ocName) {
105
+        $curValue = $this->config->getUserValue($ocName, 'user_ldap', 'isDeleted', '0');
106
+        if ($curValue === '1') {
107
+            // the user is already marked, do not write to DB again
108
+            return;
109
+        }
110
+        $this->config->setUserValue($ocName, 'user_ldap', 'isDeleted', '1');
111
+        $this->config->setUserValue($ocName, 'user_ldap', 'foundDeleted', (string)time());
112
+        $this->deletedUsers = null;
113
+    }
114 114
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Controller/ConfigAPIController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -292,7 +292,7 @@
 block discarded – undo
292 292
 
293 293
 			$config = new Configuration($configID);
294 294
 			$data = $config->getConfiguration();
295
-			if (!(int)$showPassword) {
295
+			if (!(int) $showPassword) {
296 296
 				$data['ldapAgentPassword'] = '***';
297 297
 			}
298 298
 			foreach ($data as $key => $value) {
Please login to merge, or discard this patch.
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -40,292 +40,292 @@
 block discarded – undo
40 40
 
41 41
 class ConfigAPIController extends OCSController {
42 42
 
43
-	/** @var Helper */
44
-	private $ldapHelper;
43
+    /** @var Helper */
44
+    private $ldapHelper;
45 45
 
46
-	/** @var ILogger */
47
-	private $logger;
46
+    /** @var ILogger */
47
+    private $logger;
48 48
 
49
-	/** @var ConnectionFactory */
50
-	private $connectionFactory;
49
+    /** @var ConnectionFactory */
50
+    private $connectionFactory;
51 51
 
52
-	public function __construct(
53
-		$appName,
54
-		IRequest $request,
55
-		CapabilitiesManager $capabilitiesManager,
56
-		IUserSession $userSession,
57
-		IUserManager $userManager,
58
-		Manager $keyManager,
59
-		Helper $ldapHelper,
60
-		ILogger $logger,
61
-		ConnectionFactory $connectionFactory
62
-	) {
63
-		parent::__construct(
64
-			$appName,
65
-			$request,
66
-			$capabilitiesManager,
67
-			$userSession,
68
-			$userManager,
69
-			$keyManager
70
-		);
52
+    public function __construct(
53
+        $appName,
54
+        IRequest $request,
55
+        CapabilitiesManager $capabilitiesManager,
56
+        IUserSession $userSession,
57
+        IUserManager $userManager,
58
+        Manager $keyManager,
59
+        Helper $ldapHelper,
60
+        ILogger $logger,
61
+        ConnectionFactory $connectionFactory
62
+    ) {
63
+        parent::__construct(
64
+            $appName,
65
+            $request,
66
+            $capabilitiesManager,
67
+            $userSession,
68
+            $userManager,
69
+            $keyManager
70
+        );
71 71
 
72 72
 
73
-		$this->ldapHelper = $ldapHelper;
74
-		$this->logger = $logger;
75
-		$this->connectionFactory = $connectionFactory;
76
-	}
73
+        $this->ldapHelper = $ldapHelper;
74
+        $this->logger = $logger;
75
+        $this->connectionFactory = $connectionFactory;
76
+    }
77 77
 
78
-	/**
79
-	 * Creates a new (empty) configuration and returns the resulting prefix
80
-	 *
81
-	 * Example: curl -X POST -H "OCS-APIREQUEST: true"  -u $admin:$password \
82
-	 *   https://nextcloud.server/ocs/v2.php/apps/user_ldap/api/v1/config
83
-	 *
84
-	 * results in:
85
-	 *
86
-	 * <?xml version="1.0"?>
87
-	 * <ocs>
88
-	 *   <meta>
89
-	 *     <status>ok</status>
90
-	 *     <statuscode>200</statuscode>
91
-	 *     <message>OK</message>
92
-	 *   </meta>
93
-	 *   <data>
94
-	 *     <configID>s40</configID>
95
-	 *   </data>
96
-	 * </ocs>
97
-	 *
98
-	 * Failing example: if an exception is thrown (e.g. Database connection lost)
99
-	 * the detailed error will be logged. The output will then look like:
100
-	 *
101
-	 * <?xml version="1.0"?>
102
-	 * <ocs>
103
-	 *   <meta>
104
-	 *     <status>failure</status>
105
-	 *     <statuscode>999</statuscode>
106
-	 *     <message>An issue occurred when creating the new config.</message>
107
-	 *   </meta>
108
-	 *   <data/>
109
-	 * </ocs>
110
-	 *
111
-	 * For JSON output provide the format=json parameter
112
-	 *
113
-	 * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
114
-	 * @return DataResponse
115
-	 * @throws OCSException
116
-	 */
117
-	public function create() {
118
-		try {
119
-			$configPrefix = $this->ldapHelper->getNextServerConfigurationPrefix();
120
-			$configHolder = new Configuration($configPrefix);
121
-			$configHolder->ldapConfigurationActive = false;
122
-			$configHolder->saveConfiguration();
123
-		} catch (\Exception $e) {
124
-			$this->logger->logException($e);
125
-			throw new OCSException('An issue occurred when creating the new config.');
126
-		}
127
-		return new DataResponse(['configID' => $configPrefix]);
128
-	}
78
+    /**
79
+     * Creates a new (empty) configuration and returns the resulting prefix
80
+     *
81
+     * Example: curl -X POST -H "OCS-APIREQUEST: true"  -u $admin:$password \
82
+     *   https://nextcloud.server/ocs/v2.php/apps/user_ldap/api/v1/config
83
+     *
84
+     * results in:
85
+     *
86
+     * <?xml version="1.0"?>
87
+     * <ocs>
88
+     *   <meta>
89
+     *     <status>ok</status>
90
+     *     <statuscode>200</statuscode>
91
+     *     <message>OK</message>
92
+     *   </meta>
93
+     *   <data>
94
+     *     <configID>s40</configID>
95
+     *   </data>
96
+     * </ocs>
97
+     *
98
+     * Failing example: if an exception is thrown (e.g. Database connection lost)
99
+     * the detailed error will be logged. The output will then look like:
100
+     *
101
+     * <?xml version="1.0"?>
102
+     * <ocs>
103
+     *   <meta>
104
+     *     <status>failure</status>
105
+     *     <statuscode>999</statuscode>
106
+     *     <message>An issue occurred when creating the new config.</message>
107
+     *   </meta>
108
+     *   <data/>
109
+     * </ocs>
110
+     *
111
+     * For JSON output provide the format=json parameter
112
+     *
113
+     * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
114
+     * @return DataResponse
115
+     * @throws OCSException
116
+     */
117
+    public function create() {
118
+        try {
119
+            $configPrefix = $this->ldapHelper->getNextServerConfigurationPrefix();
120
+            $configHolder = new Configuration($configPrefix);
121
+            $configHolder->ldapConfigurationActive = false;
122
+            $configHolder->saveConfiguration();
123
+        } catch (\Exception $e) {
124
+            $this->logger->logException($e);
125
+            throw new OCSException('An issue occurred when creating the new config.');
126
+        }
127
+        return new DataResponse(['configID' => $configPrefix]);
128
+    }
129 129
 
130
-	/**
131
-	 * Deletes a LDAP configuration, if present.
132
-	 *
133
-	 * Example:
134
-	 *   curl -X DELETE -H "OCS-APIREQUEST: true" -u $admin:$password \
135
-	 *    https://nextcloud.server/ocs/v2.php/apps/user_ldap/api/v1/config/s60
136
-	 *
137
-	 * <?xml version="1.0"?>
138
-	 * <ocs>
139
-	 *   <meta>
140
-	 *     <status>ok</status>
141
-	 *     <statuscode>200</statuscode>
142
-	 *     <message>OK</message>
143
-	 *   </meta>
144
-	 *   <data/>
145
-	 * </ocs>
146
-	 *
147
-	 * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
148
-	 * @param string $configID
149
-	 * @return DataResponse
150
-	 * @throws OCSBadRequestException
151
-	 * @throws OCSException
152
-	 */
153
-	public function delete($configID) {
154
-		try {
155
-			$this->ensureConfigIDExists($configID);
156
-			if (!$this->ldapHelper->deleteServerConfiguration($configID)) {
157
-				throw new OCSException('Could not delete configuration');
158
-			}
159
-		} catch (OCSException $e) {
160
-			throw $e;
161
-		} catch (\Exception $e) {
162
-			$this->logger->logException($e);
163
-			throw new OCSException('An issue occurred when deleting the config.');
164
-		}
130
+    /**
131
+     * Deletes a LDAP configuration, if present.
132
+     *
133
+     * Example:
134
+     *   curl -X DELETE -H "OCS-APIREQUEST: true" -u $admin:$password \
135
+     *    https://nextcloud.server/ocs/v2.php/apps/user_ldap/api/v1/config/s60
136
+     *
137
+     * <?xml version="1.0"?>
138
+     * <ocs>
139
+     *   <meta>
140
+     *     <status>ok</status>
141
+     *     <statuscode>200</statuscode>
142
+     *     <message>OK</message>
143
+     *   </meta>
144
+     *   <data/>
145
+     * </ocs>
146
+     *
147
+     * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
148
+     * @param string $configID
149
+     * @return DataResponse
150
+     * @throws OCSBadRequestException
151
+     * @throws OCSException
152
+     */
153
+    public function delete($configID) {
154
+        try {
155
+            $this->ensureConfigIDExists($configID);
156
+            if (!$this->ldapHelper->deleteServerConfiguration($configID)) {
157
+                throw new OCSException('Could not delete configuration');
158
+            }
159
+        } catch (OCSException $e) {
160
+            throw $e;
161
+        } catch (\Exception $e) {
162
+            $this->logger->logException($e);
163
+            throw new OCSException('An issue occurred when deleting the config.');
164
+        }
165 165
 
166
-		return new DataResponse();
167
-	}
166
+        return new DataResponse();
167
+    }
168 168
 
169
-	/**
170
-	 * Modifies a configuration
171
-	 *
172
-	 * Example:
173
-	 *   curl -X PUT -d "configData[ldapHost]=ldaps://my.ldap.server&configData[ldapPort]=636" \
174
-	 *    -H "OCS-APIREQUEST: true" -u $admin:$password \
175
-	 *    https://nextcloud.server/ocs/v2.php/apps/user_ldap/api/v1/config/s60
176
-	 *
177
-	 * <?xml version="1.0"?>
178
-	 * <ocs>
179
-	 *   <meta>
180
-	 *     <status>ok</status>
181
-	 *     <statuscode>200</statuscode>
182
-	 *     <message>OK</message>
183
-	 *   </meta>
184
-	 *   <data/>
185
-	 * </ocs>
186
-	 *
187
-	 * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
188
-	 * @param string $configID
189
-	 * @param array $configData
190
-	 * @return DataResponse
191
-	 * @throws OCSException
192
-	 */
193
-	public function modify($configID, $configData) {
194
-		try {
195
-			$this->ensureConfigIDExists($configID);
169
+    /**
170
+     * Modifies a configuration
171
+     *
172
+     * Example:
173
+     *   curl -X PUT -d "configData[ldapHost]=ldaps://my.ldap.server&configData[ldapPort]=636" \
174
+     *    -H "OCS-APIREQUEST: true" -u $admin:$password \
175
+     *    https://nextcloud.server/ocs/v2.php/apps/user_ldap/api/v1/config/s60
176
+     *
177
+     * <?xml version="1.0"?>
178
+     * <ocs>
179
+     *   <meta>
180
+     *     <status>ok</status>
181
+     *     <statuscode>200</statuscode>
182
+     *     <message>OK</message>
183
+     *   </meta>
184
+     *   <data/>
185
+     * </ocs>
186
+     *
187
+     * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
188
+     * @param string $configID
189
+     * @param array $configData
190
+     * @return DataResponse
191
+     * @throws OCSException
192
+     */
193
+    public function modify($configID, $configData) {
194
+        try {
195
+            $this->ensureConfigIDExists($configID);
196 196
 
197
-			if (!is_array($configData)) {
198
-				throw new OCSBadRequestException('configData is not properly set');
199
-			}
197
+            if (!is_array($configData)) {
198
+                throw new OCSBadRequestException('configData is not properly set');
199
+            }
200 200
 
201
-			$configuration = new Configuration($configID);
202
-			$configKeys = $configuration->getConfigTranslationArray();
201
+            $configuration = new Configuration($configID);
202
+            $configKeys = $configuration->getConfigTranslationArray();
203 203
 
204
-			foreach ($configKeys as $i => $key) {
205
-				if (isset($configData[$key])) {
206
-					$configuration->$key = $configData[$key];
207
-				}
208
-			}
204
+            foreach ($configKeys as $i => $key) {
205
+                if (isset($configData[$key])) {
206
+                    $configuration->$key = $configData[$key];
207
+                }
208
+            }
209 209
 
210
-			$configuration->saveConfiguration();
211
-			$this->connectionFactory->get($configID)->clearCache();
212
-		} catch (OCSException $e) {
213
-			throw $e;
214
-		} catch (\Exception $e) {
215
-			$this->logger->logException($e);
216
-			throw new OCSException('An issue occurred when modifying the config.');
217
-		}
210
+            $configuration->saveConfiguration();
211
+            $this->connectionFactory->get($configID)->clearCache();
212
+        } catch (OCSException $e) {
213
+            throw $e;
214
+        } catch (\Exception $e) {
215
+            $this->logger->logException($e);
216
+            throw new OCSException('An issue occurred when modifying the config.');
217
+        }
218 218
 
219
-		return new DataResponse();
220
-	}
219
+        return new DataResponse();
220
+    }
221 221
 
222
-	/**
223
-	 * Retrieves a configuration
224
-	 *
225
-	 * <?xml version="1.0"?>
226
-	 * <ocs>
227
-	 *   <meta>
228
-	 *     <status>ok</status>
229
-	 *     <statuscode>200</statuscode>
230
-	 *     <message>OK</message>
231
-	 *   </meta>
232
-	 *   <data>
233
-	 *     <ldapHost>ldaps://my.ldap.server</ldapHost>
234
-	 *     <ldapPort>7770</ldapPort>
235
-	 *     <ldapBackupHost></ldapBackupHost>
236
-	 *     <ldapBackupPort></ldapBackupPort>
237
-	 *     <ldapBase>ou=small,dc=my,dc=ldap,dc=server</ldapBase>
238
-	 *     <ldapBaseUsers>ou=users,ou=small,dc=my,dc=ldap,dc=server</ldapBaseUsers>
239
-	 *     <ldapBaseGroups>ou=small,dc=my,dc=ldap,dc=server</ldapBaseGroups>
240
-	 *     <ldapAgentName>cn=root,dc=my,dc=ldap,dc=server</ldapAgentName>
241
-	 *     <ldapAgentPassword>clearTextWithShowPassword=1</ldapAgentPassword>
242
-	 *     <ldapTLS>1</ldapTLS>
243
-	 *     <turnOffCertCheck>0</turnOffCertCheck>
244
-	 *     <ldapIgnoreNamingRules/>
245
-	 *     <ldapUserDisplayName>displayname</ldapUserDisplayName>
246
-	 *     <ldapUserDisplayName2>uid</ldapUserDisplayName2>
247
-	 *     <ldapUserFilterObjectclass>inetOrgPerson</ldapUserFilterObjectclass>
248
-	 *     <ldapUserFilterGroups></ldapUserFilterGroups>
249
-	 *     <ldapUserFilter>(&amp;(objectclass=nextcloudUser)(nextcloudEnabled=TRUE))</ldapUserFilter>
250
-	 *     <ldapUserFilterMode>1</ldapUserFilterMode>
251
-	 *     <ldapGroupFilter>(&amp;(|(objectclass=nextcloudGroup)))</ldapGroupFilter>
252
-	 *     <ldapGroupFilterMode>0</ldapGroupFilterMode>
253
-	 *     <ldapGroupFilterObjectclass>nextcloudGroup</ldapGroupFilterObjectclass>
254
-	 *     <ldapGroupFilterGroups></ldapGroupFilterGroups>
255
-	 *     <ldapGroupDisplayName>cn</ldapGroupDisplayName>
256
-	 *     <ldapGroupMemberAssocAttr>memberUid</ldapGroupMemberAssocAttr>
257
-	 *     <ldapLoginFilter>(&amp;(|(objectclass=inetOrgPerson))(uid=%uid))</ldapLoginFilter>
258
-	 *     <ldapLoginFilterMode>0</ldapLoginFilterMode>
259
-	 *     <ldapLoginFilterEmail>0</ldapLoginFilterEmail>
260
-	 *     <ldapLoginFilterUsername>1</ldapLoginFilterUsername>
261
-	 *     <ldapLoginFilterAttributes></ldapLoginFilterAttributes>
262
-	 *     <ldapQuotaAttribute></ldapQuotaAttribute>
263
-	 *     <ldapQuotaDefault></ldapQuotaDefault>
264
-	 *     <ldapEmailAttribute>mail</ldapEmailAttribute>
265
-	 *     <ldapCacheTTL>20</ldapCacheTTL>
266
-	 *     <ldapUuidUserAttribute>auto</ldapUuidUserAttribute>
267
-	 *     <ldapUuidGroupAttribute>auto</ldapUuidGroupAttribute>
268
-	 *     <ldapOverrideMainServer></ldapOverrideMainServer>
269
-	 *     <ldapConfigurationActive>1</ldapConfigurationActive>
270
-	 *     <ldapAttributesForUserSearch>uid;sn;givenname</ldapAttributesForUserSearch>
271
-	 *     <ldapAttributesForGroupSearch></ldapAttributesForGroupSearch>
272
-	 *     <ldapExperiencedAdmin>0</ldapExperiencedAdmin>
273
-	 *     <homeFolderNamingRule></homeFolderNamingRule>
274
-	 *     <hasMemberOfFilterSupport></hasMemberOfFilterSupport>
275
-	 *     <useMemberOfToDetectMembership>1</useMemberOfToDetectMembership>
276
-	 *     <ldapExpertUsernameAttr>uid</ldapExpertUsernameAttr>
277
-	 *     <ldapExpertUUIDUserAttr>uid</ldapExpertUUIDUserAttr>
278
-	 *     <ldapExpertUUIDGroupAttr></ldapExpertUUIDGroupAttr>
279
-	 *     <lastJpegPhotoLookup>0</lastJpegPhotoLookup>
280
-	 *     <ldapNestedGroups>0</ldapNestedGroups>
281
-	 *     <ldapPagingSize>500</ldapPagingSize>
282
-	 *     <turnOnPasswordChange>1</turnOnPasswordChange>
283
-	 *     <ldapDynamicGroupMemberURL></ldapDynamicGroupMemberURL>
284
-	 *   </data>
285
-	 * </ocs>
286
-	 *
287
-	 * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
288
-	 * @param string $configID
289
-	 * @param bool|string $showPassword
290
-	 * @return DataResponse
291
-	 * @throws OCSException
292
-	 */
293
-	public function show($configID, $showPassword = false) {
294
-		try {
295
-			$this->ensureConfigIDExists($configID);
222
+    /**
223
+     * Retrieves a configuration
224
+     *
225
+     * <?xml version="1.0"?>
226
+     * <ocs>
227
+     *   <meta>
228
+     *     <status>ok</status>
229
+     *     <statuscode>200</statuscode>
230
+     *     <message>OK</message>
231
+     *   </meta>
232
+     *   <data>
233
+     *     <ldapHost>ldaps://my.ldap.server</ldapHost>
234
+     *     <ldapPort>7770</ldapPort>
235
+     *     <ldapBackupHost></ldapBackupHost>
236
+     *     <ldapBackupPort></ldapBackupPort>
237
+     *     <ldapBase>ou=small,dc=my,dc=ldap,dc=server</ldapBase>
238
+     *     <ldapBaseUsers>ou=users,ou=small,dc=my,dc=ldap,dc=server</ldapBaseUsers>
239
+     *     <ldapBaseGroups>ou=small,dc=my,dc=ldap,dc=server</ldapBaseGroups>
240
+     *     <ldapAgentName>cn=root,dc=my,dc=ldap,dc=server</ldapAgentName>
241
+     *     <ldapAgentPassword>clearTextWithShowPassword=1</ldapAgentPassword>
242
+     *     <ldapTLS>1</ldapTLS>
243
+     *     <turnOffCertCheck>0</turnOffCertCheck>
244
+     *     <ldapIgnoreNamingRules/>
245
+     *     <ldapUserDisplayName>displayname</ldapUserDisplayName>
246
+     *     <ldapUserDisplayName2>uid</ldapUserDisplayName2>
247
+     *     <ldapUserFilterObjectclass>inetOrgPerson</ldapUserFilterObjectclass>
248
+     *     <ldapUserFilterGroups></ldapUserFilterGroups>
249
+     *     <ldapUserFilter>(&amp;(objectclass=nextcloudUser)(nextcloudEnabled=TRUE))</ldapUserFilter>
250
+     *     <ldapUserFilterMode>1</ldapUserFilterMode>
251
+     *     <ldapGroupFilter>(&amp;(|(objectclass=nextcloudGroup)))</ldapGroupFilter>
252
+     *     <ldapGroupFilterMode>0</ldapGroupFilterMode>
253
+     *     <ldapGroupFilterObjectclass>nextcloudGroup</ldapGroupFilterObjectclass>
254
+     *     <ldapGroupFilterGroups></ldapGroupFilterGroups>
255
+     *     <ldapGroupDisplayName>cn</ldapGroupDisplayName>
256
+     *     <ldapGroupMemberAssocAttr>memberUid</ldapGroupMemberAssocAttr>
257
+     *     <ldapLoginFilter>(&amp;(|(objectclass=inetOrgPerson))(uid=%uid))</ldapLoginFilter>
258
+     *     <ldapLoginFilterMode>0</ldapLoginFilterMode>
259
+     *     <ldapLoginFilterEmail>0</ldapLoginFilterEmail>
260
+     *     <ldapLoginFilterUsername>1</ldapLoginFilterUsername>
261
+     *     <ldapLoginFilterAttributes></ldapLoginFilterAttributes>
262
+     *     <ldapQuotaAttribute></ldapQuotaAttribute>
263
+     *     <ldapQuotaDefault></ldapQuotaDefault>
264
+     *     <ldapEmailAttribute>mail</ldapEmailAttribute>
265
+     *     <ldapCacheTTL>20</ldapCacheTTL>
266
+     *     <ldapUuidUserAttribute>auto</ldapUuidUserAttribute>
267
+     *     <ldapUuidGroupAttribute>auto</ldapUuidGroupAttribute>
268
+     *     <ldapOverrideMainServer></ldapOverrideMainServer>
269
+     *     <ldapConfigurationActive>1</ldapConfigurationActive>
270
+     *     <ldapAttributesForUserSearch>uid;sn;givenname</ldapAttributesForUserSearch>
271
+     *     <ldapAttributesForGroupSearch></ldapAttributesForGroupSearch>
272
+     *     <ldapExperiencedAdmin>0</ldapExperiencedAdmin>
273
+     *     <homeFolderNamingRule></homeFolderNamingRule>
274
+     *     <hasMemberOfFilterSupport></hasMemberOfFilterSupport>
275
+     *     <useMemberOfToDetectMembership>1</useMemberOfToDetectMembership>
276
+     *     <ldapExpertUsernameAttr>uid</ldapExpertUsernameAttr>
277
+     *     <ldapExpertUUIDUserAttr>uid</ldapExpertUUIDUserAttr>
278
+     *     <ldapExpertUUIDGroupAttr></ldapExpertUUIDGroupAttr>
279
+     *     <lastJpegPhotoLookup>0</lastJpegPhotoLookup>
280
+     *     <ldapNestedGroups>0</ldapNestedGroups>
281
+     *     <ldapPagingSize>500</ldapPagingSize>
282
+     *     <turnOnPasswordChange>1</turnOnPasswordChange>
283
+     *     <ldapDynamicGroupMemberURL></ldapDynamicGroupMemberURL>
284
+     *   </data>
285
+     * </ocs>
286
+     *
287
+     * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
288
+     * @param string $configID
289
+     * @param bool|string $showPassword
290
+     * @return DataResponse
291
+     * @throws OCSException
292
+     */
293
+    public function show($configID, $showPassword = false) {
294
+        try {
295
+            $this->ensureConfigIDExists($configID);
296 296
 
297
-			$config = new Configuration($configID);
298
-			$data = $config->getConfiguration();
299
-			if (!(int)$showPassword) {
300
-				$data['ldapAgentPassword'] = '***';
301
-			}
302
-			foreach ($data as $key => $value) {
303
-				if (is_array($value)) {
304
-					$value = implode(';', $value);
305
-					$data[$key] = $value;
306
-				}
307
-			}
308
-		} catch (OCSException $e) {
309
-			throw $e;
310
-		} catch (\Exception $e) {
311
-			$this->logger->logException($e);
312
-			throw new OCSException('An issue occurred when modifying the config.');
313
-		}
297
+            $config = new Configuration($configID);
298
+            $data = $config->getConfiguration();
299
+            if (!(int)$showPassword) {
300
+                $data['ldapAgentPassword'] = '***';
301
+            }
302
+            foreach ($data as $key => $value) {
303
+                if (is_array($value)) {
304
+                    $value = implode(';', $value);
305
+                    $data[$key] = $value;
306
+                }
307
+            }
308
+        } catch (OCSException $e) {
309
+            throw $e;
310
+        } catch (\Exception $e) {
311
+            $this->logger->logException($e);
312
+            throw new OCSException('An issue occurred when modifying the config.');
313
+        }
314 314
 
315
-		return new DataResponse($data);
316
-	}
315
+        return new DataResponse($data);
316
+    }
317 317
 
318
-	/**
319
-	 * If the given config ID is not available, an exception is thrown
320
-	 *
321
-	 * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
322
-	 * @param string $configID
323
-	 * @throws OCSNotFoundException
324
-	 */
325
-	private function ensureConfigIDExists($configID) {
326
-		$prefixes = $this->ldapHelper->getServerConfigurationPrefixes();
327
-		if (!in_array($configID, $prefixes, true)) {
328
-			throw new OCSNotFoundException('Config ID not found');
329
-		}
330
-	}
318
+    /**
319
+     * If the given config ID is not available, an exception is thrown
320
+     *
321
+     * @AuthorizedAdminSetting(settings=OCA\User_LDAP\Settings\Admin)
322
+     * @param string $configID
323
+     * @throws OCSNotFoundException
324
+     */
325
+    private function ensureConfigIDExists($configID) {
326
+        $prefixes = $this->ldapHelper->getServerConfigurationPrefixes();
327
+        if (!in_array($configID, $prefixes, true)) {
328
+            throw new OCSNotFoundException('Config ID not found');
329
+        }
330
+    }
331 331
 }
Please login to merge, or discard this patch.