Completed
Push — stable10 ( cf82aa...d8253d )
by Björn
24:47 queued 09:12
created
apps/testing/locking/provisioning.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 
81 81
 	/**
82 82
 	 * @param array $parameters
83
-	 * @return int
83
+	 * @return string
84 84
 	 */
85 85
 	protected function getPath($parameters) {
86 86
 		$node = \OC::$server->getRootFolder()
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,6 @@
 block discarded – undo
22 22
 namespace OCA\Testing\Locking;
23 23
 
24 24
 use OC\Lock\DBLockingProvider;
25
-use OC\Lock\MemcacheLockingProvider;
26 25
 use OC\User\NoUserException;
27 26
 use OCP\AppFramework\Http;
28 27
 use OCP\Files\NotFoundException;
Please login to merge, or discard this patch.
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -35,194 +35,194 @@
 block discarded – undo
35 35
 
36 36
 class Provisioning {
37 37
 
38
-	/** @var ILockingProvider */
39
-	protected $lockingProvider;
40
-
41
-	/** @var IDBConnection */
42
-	protected $connection;
43
-
44
-	/** @var IConfig */
45
-	protected $config;
46
-
47
-	/** @var IRequest */
48
-	protected $request;
49
-
50
-	/**
51
-	 * @param ILockingProvider $lockingProvider
52
-	 * @param IDBConnection $connection
53
-	 * @param IConfig $config
54
-	 * @param IRequest $request
55
-	 */
56
-	public function __construct(ILockingProvider $lockingProvider, IDBConnection $connection, IConfig $config, IRequest $request) {
57
-		$this->lockingProvider = $lockingProvider;
58
-		$this->connection = $connection;
59
-		$this->config = $config;
60
-		$this->request = $request;
61
-	}
62
-
63
-	/**
64
-	 * @return ILockingProvider
65
-	 */
66
-	protected function getLockingProvider() {
67
-		if ($this->lockingProvider instanceof DBLockingProvider) {
68
-			return \OC::$server->query('OCA\Testing\Locking\FakeDBLockingProvider');
69
-		} else {
70
-			throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider');
71
-		}
72
-	}
73
-
74
-	/**
75
-	 * @param array $parameters
76
-	 * @return int
77
-	 */
78
-	protected function getType($parameters) {
79
-		return isset($parameters['type']) ? (int) $parameters['type'] : 0;
80
-	}
81
-
82
-	/**
83
-	 * @param array $parameters
84
-	 * @return int
85
-	 */
86
-	protected function getPath($parameters) {
87
-		$node = \OC::$server->getRootFolder()
88
-			->getUserFolder($parameters['user'])
89
-			->get($this->request->getParam('path'));
90
-		return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
91
-	}
92
-
93
-	/**
94
-	 * @return \OC_OCS_Result
95
-	 */
96
-	public function isLockingEnabled() {
97
-		try {
98
-			$this->getLockingProvider();
99
-			return new \OC_OCS_Result(null, 100);
100
-		} catch (\RuntimeException $e) {
101
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_IMPLEMENTED, $e->getMessage());
102
-		}
103
-	}
104
-
105
-	/**
106
-	 * @param array $parameters
107
-	 * @return \OC_OCS_Result
108
-	 */
109
-	public function acquireLock(array $parameters) {
110
-		try {
111
-			$path = $this->getPath($parameters);
112
-		} catch (NoUserException $e) {
113
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
114
-		} catch (NotFoundException $e) {
115
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
116
-		}
117
-		$type = $this->getType($parameters);
118
-
119
-		$lockingProvider = $this->getLockingProvider();
120
-
121
-		try {
122
-			$lockingProvider->acquireLock($path, $type);
123
-			$this->config->setAppValue('testing', 'locking_' . $path, $type);
124
-			return new \OC_OCS_Result(null, 100);
125
-		} catch (LockedException $e) {
126
-			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * @param array $parameters
132
-	 * @return \OC_OCS_Result
133
-	 */
134
-	public function changeLock(array $parameters) {
135
-		try {
136
-			$path = $this->getPath($parameters);
137
-		} catch (NoUserException $e) {
138
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
139
-		} catch (NotFoundException $e) {
140
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
141
-		}
142
-		$type = $this->getType($parameters);
143
-
144
-		$lockingProvider = $this->getLockingProvider();
145
-
146
-		try {
147
-			$lockingProvider->changeLock($path, $type);
148
-			$this->config->setAppValue('testing', 'locking_' . $path, $type);
149
-			return new \OC_OCS_Result(null, 100);
150
-		} catch (LockedException $e) {
151
-			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * @param array $parameters
157
-	 * @return \OC_OCS_Result
158
-	 */
159
-	public function releaseLock(array $parameters) {
160
-		try {
161
-			$path = $this->getPath($parameters);
162
-		} catch (NoUserException $e) {
163
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
164
-		} catch (NotFoundException $e) {
165
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
166
-		}
167
-		$type = $this->getType($parameters);
168
-
169
-		$lockingProvider = $this->getLockingProvider();
170
-
171
-		try {
172
-			$lockingProvider->releaseLock($path, $type);
173
-			$this->config->deleteAppValue('testing', 'locking_' . $path);
174
-			return new \OC_OCS_Result(null, 100);
175
-		} catch (LockedException $e) {
176
-			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
177
-		}
178
-	}
179
-
180
-	/**
181
-	 * @param array $parameters
182
-	 * @return \OC_OCS_Result
183
-	 */
184
-	public function isLocked(array $parameters) {
185
-		try {
186
-			$path = $this->getPath($parameters);
187
-		} catch (NoUserException $e) {
188
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
189
-		} catch (NotFoundException $e) {
190
-			return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
191
-		}
192
-		$type = $this->getType($parameters);
193
-
194
-		$lockingProvider = $this->getLockingProvider();
195
-
196
-		if ($lockingProvider->isLocked($path, $type)) {
197
-			return new \OC_OCS_Result(null, 100);
198
-		}
199
-
200
-		return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
201
-	}
202
-
203
-	/**
204
-	 * @param array $parameters
205
-	 * @return \OC_OCS_Result
206
-	 */
207
-	public function releaseAll(array $parameters) {
208
-		$type = $this->getType($parameters);
209
-
210
-		$lockingProvider = $this->getLockingProvider();
211
-
212
-		foreach ($this->config->getAppKeys('testing') as $lock) {
213
-			if (strpos($lock, 'locking_') === 0) {
214
-				$path = substr($lock, strlen('locking_'));
215
-
216
-				if ($type === ILockingProvider::LOCK_EXCLUSIVE && $this->config->getAppValue('testing', $lock) == ILockingProvider::LOCK_EXCLUSIVE) {
217
-					$lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock));
218
-				} else if ($type === ILockingProvider::LOCK_SHARED && $this->config->getAppValue('testing', $lock) == ILockingProvider::LOCK_SHARED) {
219
-					$lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock));
220
-				} else {
221
-					$lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock));
222
-				}
223
-			}
224
-		}
225
-
226
-		return new \OC_OCS_Result(null, 100);
227
-	}
38
+    /** @var ILockingProvider */
39
+    protected $lockingProvider;
40
+
41
+    /** @var IDBConnection */
42
+    protected $connection;
43
+
44
+    /** @var IConfig */
45
+    protected $config;
46
+
47
+    /** @var IRequest */
48
+    protected $request;
49
+
50
+    /**
51
+     * @param ILockingProvider $lockingProvider
52
+     * @param IDBConnection $connection
53
+     * @param IConfig $config
54
+     * @param IRequest $request
55
+     */
56
+    public function __construct(ILockingProvider $lockingProvider, IDBConnection $connection, IConfig $config, IRequest $request) {
57
+        $this->lockingProvider = $lockingProvider;
58
+        $this->connection = $connection;
59
+        $this->config = $config;
60
+        $this->request = $request;
61
+    }
62
+
63
+    /**
64
+     * @return ILockingProvider
65
+     */
66
+    protected function getLockingProvider() {
67
+        if ($this->lockingProvider instanceof DBLockingProvider) {
68
+            return \OC::$server->query('OCA\Testing\Locking\FakeDBLockingProvider');
69
+        } else {
70
+            throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider');
71
+        }
72
+    }
73
+
74
+    /**
75
+     * @param array $parameters
76
+     * @return int
77
+     */
78
+    protected function getType($parameters) {
79
+        return isset($parameters['type']) ? (int) $parameters['type'] : 0;
80
+    }
81
+
82
+    /**
83
+     * @param array $parameters
84
+     * @return int
85
+     */
86
+    protected function getPath($parameters) {
87
+        $node = \OC::$server->getRootFolder()
88
+            ->getUserFolder($parameters['user'])
89
+            ->get($this->request->getParam('path'));
90
+        return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
91
+    }
92
+
93
+    /**
94
+     * @return \OC_OCS_Result
95
+     */
96
+    public function isLockingEnabled() {
97
+        try {
98
+            $this->getLockingProvider();
99
+            return new \OC_OCS_Result(null, 100);
100
+        } catch (\RuntimeException $e) {
101
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_IMPLEMENTED, $e->getMessage());
102
+        }
103
+    }
104
+
105
+    /**
106
+     * @param array $parameters
107
+     * @return \OC_OCS_Result
108
+     */
109
+    public function acquireLock(array $parameters) {
110
+        try {
111
+            $path = $this->getPath($parameters);
112
+        } catch (NoUserException $e) {
113
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
114
+        } catch (NotFoundException $e) {
115
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
116
+        }
117
+        $type = $this->getType($parameters);
118
+
119
+        $lockingProvider = $this->getLockingProvider();
120
+
121
+        try {
122
+            $lockingProvider->acquireLock($path, $type);
123
+            $this->config->setAppValue('testing', 'locking_' . $path, $type);
124
+            return new \OC_OCS_Result(null, 100);
125
+        } catch (LockedException $e) {
126
+            return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
127
+        }
128
+    }
129
+
130
+    /**
131
+     * @param array $parameters
132
+     * @return \OC_OCS_Result
133
+     */
134
+    public function changeLock(array $parameters) {
135
+        try {
136
+            $path = $this->getPath($parameters);
137
+        } catch (NoUserException $e) {
138
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
139
+        } catch (NotFoundException $e) {
140
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
141
+        }
142
+        $type = $this->getType($parameters);
143
+
144
+        $lockingProvider = $this->getLockingProvider();
145
+
146
+        try {
147
+            $lockingProvider->changeLock($path, $type);
148
+            $this->config->setAppValue('testing', 'locking_' . $path, $type);
149
+            return new \OC_OCS_Result(null, 100);
150
+        } catch (LockedException $e) {
151
+            return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
152
+        }
153
+    }
154
+
155
+    /**
156
+     * @param array $parameters
157
+     * @return \OC_OCS_Result
158
+     */
159
+    public function releaseLock(array $parameters) {
160
+        try {
161
+            $path = $this->getPath($parameters);
162
+        } catch (NoUserException $e) {
163
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
164
+        } catch (NotFoundException $e) {
165
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
166
+        }
167
+        $type = $this->getType($parameters);
168
+
169
+        $lockingProvider = $this->getLockingProvider();
170
+
171
+        try {
172
+            $lockingProvider->releaseLock($path, $type);
173
+            $this->config->deleteAppValue('testing', 'locking_' . $path);
174
+            return new \OC_OCS_Result(null, 100);
175
+        } catch (LockedException $e) {
176
+            return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
177
+        }
178
+    }
179
+
180
+    /**
181
+     * @param array $parameters
182
+     * @return \OC_OCS_Result
183
+     */
184
+    public function isLocked(array $parameters) {
185
+        try {
186
+            $path = $this->getPath($parameters);
187
+        } catch (NoUserException $e) {
188
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'User not found');
189
+        } catch (NotFoundException $e) {
190
+            return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND, 'Path not found');
191
+        }
192
+        $type = $this->getType($parameters);
193
+
194
+        $lockingProvider = $this->getLockingProvider();
195
+
196
+        if ($lockingProvider->isLocked($path, $type)) {
197
+            return new \OC_OCS_Result(null, 100);
198
+        }
199
+
200
+        return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
201
+    }
202
+
203
+    /**
204
+     * @param array $parameters
205
+     * @return \OC_OCS_Result
206
+     */
207
+    public function releaseAll(array $parameters) {
208
+        $type = $this->getType($parameters);
209
+
210
+        $lockingProvider = $this->getLockingProvider();
211
+
212
+        foreach ($this->config->getAppKeys('testing') as $lock) {
213
+            if (strpos($lock, 'locking_') === 0) {
214
+                $path = substr($lock, strlen('locking_'));
215
+
216
+                if ($type === ILockingProvider::LOCK_EXCLUSIVE && $this->config->getAppValue('testing', $lock) == ILockingProvider::LOCK_EXCLUSIVE) {
217
+                    $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock));
218
+                } else if ($type === ILockingProvider::LOCK_SHARED && $this->config->getAppValue('testing', $lock) == ILockingProvider::LOCK_SHARED) {
219
+                    $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock));
220
+                } else {
221
+                    $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock));
222
+                }
223
+            }
224
+        }
225
+
226
+        return new \OC_OCS_Result(null, 100);
227
+    }
228 228
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$node = \OC::$server->getRootFolder()
88 88
 			->getUserFolder($parameters['user'])
89 89
 			->get($this->request->getParam('path'));
90
-		return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
90
+		return 'files/'.md5($node->getStorage()->getId().'::'.trim($node->getInternalPath(), '/'));
91 91
 	}
92 92
 
93 93
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 		try {
122 122
 			$lockingProvider->acquireLock($path, $type);
123
-			$this->config->setAppValue('testing', 'locking_' . $path, $type);
123
+			$this->config->setAppValue('testing', 'locking_'.$path, $type);
124 124
 			return new \OC_OCS_Result(null, 100);
125 125
 		} catch (LockedException $e) {
126 126
 			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
 		try {
147 147
 			$lockingProvider->changeLock($path, $type);
148
-			$this->config->setAppValue('testing', 'locking_' . $path, $type);
148
+			$this->config->setAppValue('testing', 'locking_'.$path, $type);
149 149
 			return new \OC_OCS_Result(null, 100);
150 150
 		} catch (LockedException $e) {
151 151
 			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 		try {
172 172
 			$lockingProvider->releaseLock($path, $type);
173
-			$this->config->deleteAppValue('testing', 'locking_' . $path);
173
+			$this->config->deleteAppValue('testing', 'locking_'.$path);
174 174
 			return new \OC_OCS_Result(null, 100);
175 175
 		} catch (LockedException $e) {
176 176
 			return new \OC_OCS_Result(null, Http::STATUS_LOCKED);
Please login to merge, or discard this patch.
apps/updatenotification/lib/Notification/Notifier.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -102,6 +102,9 @@
 block discarded – undo
102 102
 		return \OC_App::getAppVersions();
103 103
 	}
104 104
 
105
+	/**
106
+	 * @param string $appId
107
+	 */
105 108
 	protected function getAppInfo($appId) {
106 109
 		return \OC_App::getAppInfo($appId);
107 110
 	}
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -31,82 +31,82 @@
 block discarded – undo
31 31
 
32 32
 class Notifier implements INotifier {
33 33
 
34
-	/** @var IManager */
35
-	protected $notificationManager;
36
-
37
-	/** @var IFactory */
38
-	protected $l10NFactory;
39
-
40
-	/** @var string[] */
41
-	protected $appVersions;
42
-
43
-	/**
44
-	 * Notifier constructor.
45
-	 *
46
-	 * @param IManager $notificationManager
47
-	 * @param IFactory $l10NFactory
48
-	 */
49
-	public function __construct(IManager $notificationManager, IFactory $l10NFactory) {
50
-		$this->notificationManager = $notificationManager;
51
-		$this->l10NFactory = $l10NFactory;
52
-		$this->appVersions = $this->getAppVersions();
53
-	}
54
-
55
-	/**
56
-	 * @param INotification $notification
57
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
58
-	 * @return INotification
59
-	 * @throws \InvalidArgumentException When the notification was not prepared by a notifier
60
-	 * @since 9.0.0
61
-	 */
62
-	public function prepare(INotification $notification, $languageCode) {
63
-		if ($notification->getApp() !== 'updatenotification') {
64
-			throw new \InvalidArgumentException();
65
-		}
66
-
67
-		$l = $this->l10NFactory->get('updatenotification', $languageCode);
68
-		if ($notification->getObjectType() === 'core') {
69
-			$this->updateAlreadyInstalledCheck($notification, $this->getCoreVersions());
70
-
71
-			$parameters = $notification->getSubjectParameters();
72
-			$notification->setParsedSubject($l->t('Update to %1$s is available.', [$parameters['version']]));
73
-		} else {
74
-			$appInfo = $this->getAppInfo($notification->getObjectType());
75
-			$appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name'];
76
-
77
-			if (isset($this->appVersions[$notification->getObjectType()])) {
78
-				$this->updateAlreadyInstalledCheck($notification, $this->appVersions[$notification->getObjectType()]);
79
-			}
80
-
81
-			$notification->setParsedSubject($l->t('Update for %1$s to version %2$s is available.', [$appName, $notification->getObjectId()]));
82
-		}
83
-
84
-		return $notification;
85
-	}
86
-
87
-	/**
88
-	 * Remove the notification and prevent rendering, when the update is installed
89
-	 *
90
-	 * @param INotification $notification
91
-	 * @param string $installedVersion
92
-	 * @throws \InvalidArgumentException When the update is already installed
93
-	 */
94
-	protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion) {
95
-		if (version_compare($notification->getObjectId(), $installedVersion, '<=')) {
96
-			$this->notificationManager->markProcessed($notification);
97
-			throw new \InvalidArgumentException();
98
-		}
99
-	}
100
-
101
-	protected function getCoreVersions() {
102
-		return implode('.', \OCP\Util::getVersion());
103
-	}
104
-
105
-	protected function getAppVersions() {
106
-		return \OC_App::getAppVersions();
107
-	}
108
-
109
-	protected function getAppInfo($appId) {
110
-		return \OC_App::getAppInfo($appId);
111
-	}
34
+    /** @var IManager */
35
+    protected $notificationManager;
36
+
37
+    /** @var IFactory */
38
+    protected $l10NFactory;
39
+
40
+    /** @var string[] */
41
+    protected $appVersions;
42
+
43
+    /**
44
+     * Notifier constructor.
45
+     *
46
+     * @param IManager $notificationManager
47
+     * @param IFactory $l10NFactory
48
+     */
49
+    public function __construct(IManager $notificationManager, IFactory $l10NFactory) {
50
+        $this->notificationManager = $notificationManager;
51
+        $this->l10NFactory = $l10NFactory;
52
+        $this->appVersions = $this->getAppVersions();
53
+    }
54
+
55
+    /**
56
+     * @param INotification $notification
57
+     * @param string $languageCode The code of the language that should be used to prepare the notification
58
+     * @return INotification
59
+     * @throws \InvalidArgumentException When the notification was not prepared by a notifier
60
+     * @since 9.0.0
61
+     */
62
+    public function prepare(INotification $notification, $languageCode) {
63
+        if ($notification->getApp() !== 'updatenotification') {
64
+            throw new \InvalidArgumentException();
65
+        }
66
+
67
+        $l = $this->l10NFactory->get('updatenotification', $languageCode);
68
+        if ($notification->getObjectType() === 'core') {
69
+            $this->updateAlreadyInstalledCheck($notification, $this->getCoreVersions());
70
+
71
+            $parameters = $notification->getSubjectParameters();
72
+            $notification->setParsedSubject($l->t('Update to %1$s is available.', [$parameters['version']]));
73
+        } else {
74
+            $appInfo = $this->getAppInfo($notification->getObjectType());
75
+            $appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name'];
76
+
77
+            if (isset($this->appVersions[$notification->getObjectType()])) {
78
+                $this->updateAlreadyInstalledCheck($notification, $this->appVersions[$notification->getObjectType()]);
79
+            }
80
+
81
+            $notification->setParsedSubject($l->t('Update for %1$s to version %2$s is available.', [$appName, $notification->getObjectId()]));
82
+        }
83
+
84
+        return $notification;
85
+    }
86
+
87
+    /**
88
+     * Remove the notification and prevent rendering, when the update is installed
89
+     *
90
+     * @param INotification $notification
91
+     * @param string $installedVersion
92
+     * @throws \InvalidArgumentException When the update is already installed
93
+     */
94
+    protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion) {
95
+        if (version_compare($notification->getObjectId(), $installedVersion, '<=')) {
96
+            $this->notificationManager->markProcessed($notification);
97
+            throw new \InvalidArgumentException();
98
+        }
99
+    }
100
+
101
+    protected function getCoreVersions() {
102
+        return implode('.', \OCP\Util::getVersion());
103
+    }
104
+
105
+    protected function getAppVersions() {
106
+        return \OC_App::getAppVersions();
107
+    }
108
+
109
+    protected function getAppInfo($appId) {
110
+        return \OC_App::getAppInfo($appId);
111
+    }
112 112
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/SetConfig.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -74,8 +74,6 @@
 block discarded – undo
74 74
 	/**
75 75
 	 * save the configuration value as provided
76 76
 	 * @param string $configID
77
-	 * @param string $configKey
78
-	 * @param string $configValue
79 77
 	 */
80 78
 	protected function setValue($configID, $key, $value) {
81 79
 		$configHolder = new Configuration($configID);
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -34,53 +34,53 @@
 block discarded – undo
34 34
 
35 35
 class SetConfig extends Command {
36 36
 
37
-	protected function configure() {
38
-		$this
39
-			->setName('ldap:set-config')
40
-			->setDescription('modifies an LDAP configuration')
41
-			->addArgument(
42
-					'configID',
43
-					InputArgument::REQUIRED,
44
-					'the configuration ID'
45
-				     )
46
-			->addArgument(
47
-					'configKey',
48
-					InputArgument::REQUIRED,
49
-					'the configuration key'
50
-				     )
51
-			->addArgument(
52
-					'configValue',
53
-					InputArgument::REQUIRED,
54
-					'the new configuration value'
55
-				     )
56
-		;
57
-	}
37
+    protected function configure() {
38
+        $this
39
+            ->setName('ldap:set-config')
40
+            ->setDescription('modifies an LDAP configuration')
41
+            ->addArgument(
42
+                    'configID',
43
+                    InputArgument::REQUIRED,
44
+                    'the configuration ID'
45
+                        )
46
+            ->addArgument(
47
+                    'configKey',
48
+                    InputArgument::REQUIRED,
49
+                    'the configuration key'
50
+                        )
51
+            ->addArgument(
52
+                    'configValue',
53
+                    InputArgument::REQUIRED,
54
+                    'the new configuration value'
55
+                        )
56
+        ;
57
+    }
58 58
 
59
-	protected function execute(InputInterface $input, OutputInterface $output) {
60
-		$helper = new Helper();
61
-		$availableConfigs = $helper->getServerConfigurationPrefixes();
62
-		$configID = $input->getArgument('configID');
63
-		if(!in_array($configID, $availableConfigs)) {
64
-			$output->writeln("Invalid configID");
65
-			return;
66
-		}
59
+    protected function execute(InputInterface $input, OutputInterface $output) {
60
+        $helper = new Helper();
61
+        $availableConfigs = $helper->getServerConfigurationPrefixes();
62
+        $configID = $input->getArgument('configID');
63
+        if(!in_array($configID, $availableConfigs)) {
64
+            $output->writeln("Invalid configID");
65
+            return;
66
+        }
67 67
 
68
-		$this->setValue(
69
-			$configID,
70
-			$input->getArgument('configKey'),
71
-			$input->getArgument('configValue')
72
-		);
73
-	}
68
+        $this->setValue(
69
+            $configID,
70
+            $input->getArgument('configKey'),
71
+            $input->getArgument('configValue')
72
+        );
73
+    }
74 74
 
75
-	/**
76
-	 * save the configuration value as provided
77
-	 * @param string $configID
78
-	 * @param string $configKey
79
-	 * @param string $configValue
80
-	 */
81
-	protected function setValue($configID, $key, $value) {
82
-		$configHolder = new Configuration($configID);
83
-		$configHolder->$key = $value;
84
-		$configHolder->saveConfiguration();
85
-	}
75
+    /**
76
+     * save the configuration value as provided
77
+     * @param string $configID
78
+     * @param string $configKey
79
+     * @param string $configValue
80
+     */
81
+    protected function setValue($configID, $key, $value) {
82
+        $configHolder = new Configuration($configID);
83
+        $configHolder->$key = $value;
84
+        $configHolder->saveConfiguration();
85
+    }
86 86
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 		$helper = new Helper();
61 61
 		$availableConfigs = $helper->getServerConfigurationPrefixes();
62 62
 		$configID = $input->getArgument('configID');
63
-		if(!in_array($configID, $availableConfigs)) {
63
+		if (!in_array($configID, $availableConfigs)) {
64 64
 			$output->writeln("Invalid configID");
65 65
 			return;
66 66
 		}
Please login to merge, or discard this patch.
apps/user_ldap/lib/Jobs/UpdateGroups.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	}
78 78
 
79 79
 	/**
80
-	 * @return int
80
+	 * @return string
81 81
 	 */
82 82
 	static private function getRefreshInterval() {
83 83
 		//defaults to every hour
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -41,183 +41,183 @@
 block discarded – undo
41 41
 use OCA\User_LDAP\User\Manager;
42 42
 
43 43
 class UpdateGroups extends \OC\BackgroundJob\TimedJob {
44
-	static private $groupsFromDB;
45
-
46
-	static private $groupBE;
47
-	static private $connector;
48
-
49
-	public function __construct(){
50
-		$this->interval = self::getRefreshInterval();
51
-	}
52
-
53
-	/**
54
-	 * @param mixed $argument
55
-	 */
56
-	public function run($argument){
57
-		self::updateGroups();
58
-	}
59
-
60
-	static public function updateGroups() {
61
-		\OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', \OCP\Util::DEBUG);
62
-
63
-		$knownGroups = array_keys(self::getKnownGroups());
64
-		$actualGroups = self::getGroupBE()->getGroups();
65
-
66
-		if(empty($actualGroups) && empty($knownGroups)) {
67
-			\OCP\Util::writeLog('user_ldap',
68
-				'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.',
69
-				\OCP\Util::INFO);
70
-			return;
71
-		}
72
-
73
-		self::handleKnownGroups(array_intersect($actualGroups, $knownGroups));
74
-		self::handleCreatedGroups(array_diff($actualGroups, $knownGroups));
75
-		self::handleRemovedGroups(array_diff($knownGroups, $actualGroups));
76
-
77
-		\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', \OCP\Util::DEBUG);
78
-	}
79
-
80
-	/**
81
-	 * @return int
82
-	 */
83
-	static private function getRefreshInterval() {
84
-		//defaults to every hour
85
-		return \OCP\Config::getAppValue('user_ldap', 'bgjRefreshInterval', 3600);
86
-	}
87
-
88
-	/**
89
-	 * @param string[] $groups
90
-	 */
91
-	static private function handleKnownGroups($groups) {
92
-		\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', \OCP\Util::DEBUG);
93
-		$query = \OCP\DB::prepare('
44
+    static private $groupsFromDB;
45
+
46
+    static private $groupBE;
47
+    static private $connector;
48
+
49
+    public function __construct(){
50
+        $this->interval = self::getRefreshInterval();
51
+    }
52
+
53
+    /**
54
+     * @param mixed $argument
55
+     */
56
+    public function run($argument){
57
+        self::updateGroups();
58
+    }
59
+
60
+    static public function updateGroups() {
61
+        \OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', \OCP\Util::DEBUG);
62
+
63
+        $knownGroups = array_keys(self::getKnownGroups());
64
+        $actualGroups = self::getGroupBE()->getGroups();
65
+
66
+        if(empty($actualGroups) && empty($knownGroups)) {
67
+            \OCP\Util::writeLog('user_ldap',
68
+                'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.',
69
+                \OCP\Util::INFO);
70
+            return;
71
+        }
72
+
73
+        self::handleKnownGroups(array_intersect($actualGroups, $knownGroups));
74
+        self::handleCreatedGroups(array_diff($actualGroups, $knownGroups));
75
+        self::handleRemovedGroups(array_diff($knownGroups, $actualGroups));
76
+
77
+        \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', \OCP\Util::DEBUG);
78
+    }
79
+
80
+    /**
81
+     * @return int
82
+     */
83
+    static private function getRefreshInterval() {
84
+        //defaults to every hour
85
+        return \OCP\Config::getAppValue('user_ldap', 'bgjRefreshInterval', 3600);
86
+    }
87
+
88
+    /**
89
+     * @param string[] $groups
90
+     */
91
+    static private function handleKnownGroups($groups) {
92
+        \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', \OCP\Util::DEBUG);
93
+        $query = \OCP\DB::prepare('
94 94
 			UPDATE `*PREFIX*ldap_group_members`
95 95
 			SET `owncloudusers` = ?
96 96
 			WHERE `owncloudname` = ?
97 97
 		');
98
-		foreach($groups as $group) {
99
-			//we assume, that self::$groupsFromDB has been retrieved already
100
-			$knownUsers = unserialize(self::$groupsFromDB[$group]['owncloudusers']);
101
-			$actualUsers = self::getGroupBE()->usersInGroup($group);
102
-			$hasChanged = false;
103
-			foreach(array_diff($knownUsers, $actualUsers) as $removedUser) {
104
-				\OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group));
105
-				\OCP\Util::writeLog('user_ldap',
106
-				'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".',
107
-				\OCP\Util::INFO);
108
-				$hasChanged = true;
109
-			}
110
-			foreach(array_diff($actualUsers, $knownUsers) as $addedUser) {
111
-				\OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group));
112
-				\OCP\Util::writeLog('user_ldap',
113
-				'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
114
-				\OCP\Util::INFO);
115
-				$hasChanged = true;
116
-			}
117
-			if($hasChanged) {
118
-				$query->execute(array(serialize($actualUsers), $group));
119
-			}
120
-		}
121
-		\OCP\Util::writeLog('user_ldap',
122
-			'bgJ "updateGroups" – FINISHED dealing with known Groups.',
123
-			\OCP\Util::DEBUG);
124
-	}
125
-
126
-	/**
127
-	 * @param string[] $createdGroups
128
-	 */
129
-	static private function handleCreatedGroups($createdGroups) {
130
-		\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', \OCP\Util::DEBUG);
131
-		$query = \OCP\DB::prepare('
98
+        foreach($groups as $group) {
99
+            //we assume, that self::$groupsFromDB has been retrieved already
100
+            $knownUsers = unserialize(self::$groupsFromDB[$group]['owncloudusers']);
101
+            $actualUsers = self::getGroupBE()->usersInGroup($group);
102
+            $hasChanged = false;
103
+            foreach(array_diff($knownUsers, $actualUsers) as $removedUser) {
104
+                \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group));
105
+                \OCP\Util::writeLog('user_ldap',
106
+                'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".',
107
+                \OCP\Util::INFO);
108
+                $hasChanged = true;
109
+            }
110
+            foreach(array_diff($actualUsers, $knownUsers) as $addedUser) {
111
+                \OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group));
112
+                \OCP\Util::writeLog('user_ldap',
113
+                'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
114
+                \OCP\Util::INFO);
115
+                $hasChanged = true;
116
+            }
117
+            if($hasChanged) {
118
+                $query->execute(array(serialize($actualUsers), $group));
119
+            }
120
+        }
121
+        \OCP\Util::writeLog('user_ldap',
122
+            'bgJ "updateGroups" – FINISHED dealing with known Groups.',
123
+            \OCP\Util::DEBUG);
124
+    }
125
+
126
+    /**
127
+     * @param string[] $createdGroups
128
+     */
129
+    static private function handleCreatedGroups($createdGroups) {
130
+        \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', \OCP\Util::DEBUG);
131
+        $query = \OCP\DB::prepare('
132 132
 			INSERT
133 133
 			INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`)
134 134
 			VALUES (?, ?)
135 135
 		');
136
-		foreach($createdGroups as $createdGroup) {
137
-			\OCP\Util::writeLog('user_ldap',
138
-				'bgJ "updateGroups" – new group "'.$createdGroup.'" found.',
139
-				\OCP\Util::INFO);
140
-			$users = serialize(self::getGroupBE()->usersInGroup($createdGroup));
141
-			$query->execute(array($createdGroup, $users));
142
-		}
143
-		\OCP\Util::writeLog('user_ldap',
144
-			'bgJ "updateGroups" – FINISHED dealing with created Groups.',
145
-			\OCP\Util::DEBUG);
146
-	}
147
-
148
-	/**
149
-	 * @param string[] $removedGroups
150
-	 */
151
-	static private function handleRemovedGroups($removedGroups) {
152
-		\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', \OCP\Util::DEBUG);
153
-		$query = \OCP\DB::prepare('
136
+        foreach($createdGroups as $createdGroup) {
137
+            \OCP\Util::writeLog('user_ldap',
138
+                'bgJ "updateGroups" – new group "'.$createdGroup.'" found.',
139
+                \OCP\Util::INFO);
140
+            $users = serialize(self::getGroupBE()->usersInGroup($createdGroup));
141
+            $query->execute(array($createdGroup, $users));
142
+        }
143
+        \OCP\Util::writeLog('user_ldap',
144
+            'bgJ "updateGroups" – FINISHED dealing with created Groups.',
145
+            \OCP\Util::DEBUG);
146
+    }
147
+
148
+    /**
149
+     * @param string[] $removedGroups
150
+     */
151
+    static private function handleRemovedGroups($removedGroups) {
152
+        \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', \OCP\Util::DEBUG);
153
+        $query = \OCP\DB::prepare('
154 154
 			DELETE
155 155
 			FROM `*PREFIX*ldap_group_members`
156 156
 			WHERE `owncloudname` = ?
157 157
 		');
158
-		foreach($removedGroups as $removedGroup) {
159
-			\OCP\Util::writeLog('user_ldap',
160
-				'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.',
161
-				\OCP\Util::INFO);
162
-			$query->execute(array($removedGroup));
163
-		}
164
-		\OCP\Util::writeLog('user_ldap',
165
-			'bgJ "updateGroups" – FINISHED dealing with removed groups.',
166
-			\OCP\Util::DEBUG);
167
-	}
168
-
169
-	/**
170
-	 * @return \OCA\User_LDAP\Group_LDAP|\OCA\User_LDAP\Group_Proxy
171
-	 */
172
-	static private function getGroupBE() {
173
-		if(!is_null(self::$groupBE)) {
174
-			return self::$groupBE;
175
-		}
176
-		$helper = new Helper();
177
-		$configPrefixes = $helper->getServerConfigurationPrefixes(true);
178
-		$ldapWrapper = new LDAP();
179
-		if(count($configPrefixes) === 1) {
180
-			//avoid the proxy when there is only one LDAP server configured
181
-			$dbc = \OC::$server->getDatabaseConnection();
182
-			$userManager = new Manager(
183
-				\OC::$server->getConfig(),
184
-				new FilesystemHelper(),
185
-				new LogWrapper(),
186
-				\OC::$server->getAvatarManager(),
187
-				new \OCP\Image(),
188
-				$dbc,
189
-				\OC::$server->getUserManager());
190
-			$connector = new Connection($ldapWrapper, $configPrefixes[0]);
191
-			$ldapAccess = new Access($connector, $ldapWrapper, $userManager, $helper);
192
-			$groupMapper = new GroupMapping($dbc);
193
-			$userMapper  = new UserMapping($dbc);
194
-			$ldapAccess->setGroupMapper($groupMapper);
195
-			$ldapAccess->setUserMapper($userMapper);
196
-			self::$groupBE = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
197
-		} else {
198
-			self::$groupBE = new \OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
199
-		}
200
-
201
-		return self::$groupBE;
202
-	}
203
-
204
-	/**
205
-	 * @return array
206
-	 */
207
-	static private function getKnownGroups() {
208
-		if(is_array(self::$groupsFromDB)) {
209
-			return self::$groupsFromDB;
210
-		}
211
-		$query = \OCP\DB::prepare('
158
+        foreach($removedGroups as $removedGroup) {
159
+            \OCP\Util::writeLog('user_ldap',
160
+                'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.',
161
+                \OCP\Util::INFO);
162
+            $query->execute(array($removedGroup));
163
+        }
164
+        \OCP\Util::writeLog('user_ldap',
165
+            'bgJ "updateGroups" – FINISHED dealing with removed groups.',
166
+            \OCP\Util::DEBUG);
167
+    }
168
+
169
+    /**
170
+     * @return \OCA\User_LDAP\Group_LDAP|\OCA\User_LDAP\Group_Proxy
171
+     */
172
+    static private function getGroupBE() {
173
+        if(!is_null(self::$groupBE)) {
174
+            return self::$groupBE;
175
+        }
176
+        $helper = new Helper();
177
+        $configPrefixes = $helper->getServerConfigurationPrefixes(true);
178
+        $ldapWrapper = new LDAP();
179
+        if(count($configPrefixes) === 1) {
180
+            //avoid the proxy when there is only one LDAP server configured
181
+            $dbc = \OC::$server->getDatabaseConnection();
182
+            $userManager = new Manager(
183
+                \OC::$server->getConfig(),
184
+                new FilesystemHelper(),
185
+                new LogWrapper(),
186
+                \OC::$server->getAvatarManager(),
187
+                new \OCP\Image(),
188
+                $dbc,
189
+                \OC::$server->getUserManager());
190
+            $connector = new Connection($ldapWrapper, $configPrefixes[0]);
191
+            $ldapAccess = new Access($connector, $ldapWrapper, $userManager, $helper);
192
+            $groupMapper = new GroupMapping($dbc);
193
+            $userMapper  = new UserMapping($dbc);
194
+            $ldapAccess->setGroupMapper($groupMapper);
195
+            $ldapAccess->setUserMapper($userMapper);
196
+            self::$groupBE = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
197
+        } else {
198
+            self::$groupBE = new \OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
199
+        }
200
+
201
+        return self::$groupBE;
202
+    }
203
+
204
+    /**
205
+     * @return array
206
+     */
207
+    static private function getKnownGroups() {
208
+        if(is_array(self::$groupsFromDB)) {
209
+            return self::$groupsFromDB;
210
+        }
211
+        $query = \OCP\DB::prepare('
212 212
 			SELECT `owncloudname`, `owncloudusers`
213 213
 			FROM `*PREFIX*ldap_group_members`
214 214
 		');
215
-		$result = $query->execute()->fetchAll();
216
-		self::$groupsFromDB = array();
217
-		foreach($result as $dataset) {
218
-			self::$groupsFromDB[$dataset['owncloudname']] = $dataset;
219
-		}
220
-
221
-		return self::$groupsFromDB;
222
-	}
215
+        $result = $query->execute()->fetchAll();
216
+        self::$groupsFromDB = array();
217
+        foreach($result as $dataset) {
218
+            self::$groupsFromDB[$dataset['owncloudname']] = $dataset;
219
+        }
220
+
221
+        return self::$groupsFromDB;
222
+    }
223 223
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	static private $groupBE;
47 47
 	static private $connector;
48 48
 
49
-	public function __construct(){
49
+	public function __construct() {
50 50
 		$this->interval = self::getRefreshInterval();
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * @param mixed $argument
55 55
 	 */
56
-	public function run($argument){
56
+	public function run($argument) {
57 57
 		self::updateGroups();
58 58
 	}
59 59
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$knownGroups = array_keys(self::getKnownGroups());
64 64
 		$actualGroups = self::getGroupBE()->getGroups();
65 65
 
66
-		if(empty($actualGroups) && empty($knownGroups)) {
66
+		if (empty($actualGroups) && empty($knownGroups)) {
67 67
 			\OCP\Util::writeLog('user_ldap',
68 68
 				'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.',
69 69
 				\OCP\Util::INFO);
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 			SET `owncloudusers` = ?
96 96
 			WHERE `owncloudname` = ?
97 97
 		');
98
-		foreach($groups as $group) {
98
+		foreach ($groups as $group) {
99 99
 			//we assume, that self::$groupsFromDB has been retrieved already
100 100
 			$knownUsers = unserialize(self::$groupsFromDB[$group]['owncloudusers']);
101 101
 			$actualUsers = self::getGroupBE()->usersInGroup($group);
102 102
 			$hasChanged = false;
103
-			foreach(array_diff($knownUsers, $actualUsers) as $removedUser) {
103
+			foreach (array_diff($knownUsers, $actualUsers) as $removedUser) {
104 104
 				\OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group));
105 105
 				\OCP\Util::writeLog('user_ldap',
106 106
 				'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".',
107 107
 				\OCP\Util::INFO);
108 108
 				$hasChanged = true;
109 109
 			}
110
-			foreach(array_diff($actualUsers, $knownUsers) as $addedUser) {
110
+			foreach (array_diff($actualUsers, $knownUsers) as $addedUser) {
111 111
 				\OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group));
112 112
 				\OCP\Util::writeLog('user_ldap',
113 113
 				'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
114 114
 				\OCP\Util::INFO);
115 115
 				$hasChanged = true;
116 116
 			}
117
-			if($hasChanged) {
117
+			if ($hasChanged) {
118 118
 				$query->execute(array(serialize($actualUsers), $group));
119 119
 			}
120 120
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`)
134 134
 			VALUES (?, ?)
135 135
 		');
136
-		foreach($createdGroups as $createdGroup) {
136
+		foreach ($createdGroups as $createdGroup) {
137 137
 			\OCP\Util::writeLog('user_ldap',
138 138
 				'bgJ "updateGroups" – new group "'.$createdGroup.'" found.',
139 139
 				\OCP\Util::INFO);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			FROM `*PREFIX*ldap_group_members`
156 156
 			WHERE `owncloudname` = ?
157 157
 		');
158
-		foreach($removedGroups as $removedGroup) {
158
+		foreach ($removedGroups as $removedGroup) {
159 159
 			\OCP\Util::writeLog('user_ldap',
160 160
 				'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.',
161 161
 				\OCP\Util::INFO);
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
 	 * @return \OCA\User_LDAP\Group_LDAP|\OCA\User_LDAP\Group_Proxy
171 171
 	 */
172 172
 	static private function getGroupBE() {
173
-		if(!is_null(self::$groupBE)) {
173
+		if (!is_null(self::$groupBE)) {
174 174
 			return self::$groupBE;
175 175
 		}
176 176
 		$helper = new Helper();
177 177
 		$configPrefixes = $helper->getServerConfigurationPrefixes(true);
178 178
 		$ldapWrapper = new LDAP();
179
-		if(count($configPrefixes) === 1) {
179
+		if (count($configPrefixes) === 1) {
180 180
 			//avoid the proxy when there is only one LDAP server configured
181 181
 			$dbc = \OC::$server->getDatabaseConnection();
182 182
 			$userManager = new Manager(
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @return array
206 206
 	 */
207 207
 	static private function getKnownGroups() {
208
-		if(is_array(self::$groupsFromDB)) {
208
+		if (is_array(self::$groupsFromDB)) {
209 209
 			return self::$groupsFromDB;
210 210
 		}
211 211
 		$query = \OCP\DB::prepare('
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		');
215 215
 		$result = $query->execute()->fetchAll();
216 216
 		self::$groupsFromDB = array();
217
-		foreach($result as $dataset) {
217
+		foreach ($result as $dataset) {
218 218
 			self::$groupsFromDB[$dataset['owncloudname']] = $dataset;
219 219
 		}
220 220
 
Please login to merge, or discard this patch.
core/Command/Maintenance/Repair.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,6 @@
 block discarded – undo
32 32
 use Symfony\Component\Console\Input\InputInterface;
33 33
 use Symfony\Component\Console\Input\InputOption;
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35
-use Symfony\Component\EventDispatcher\EventDispatcher;
36 35
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
37 36
 use Symfony\Component\EventDispatcher\GenericEvent;
38 37
 
Please login to merge, or discard this patch.
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -38,111 +38,111 @@
 block discarded – undo
38 38
 use Symfony\Component\EventDispatcher\GenericEvent;
39 39
 
40 40
 class Repair extends Command {
41
-	/** @var \OC\Repair $repair */
42
-	protected $repair;
43
-	/** @var IConfig */
44
-	protected $config;
45
-	/** @var EventDispatcherInterface */
46
-	private $dispatcher;
47
-	/** @var ProgressBar */
48
-	private $progress;
49
-	/** @var OutputInterface */
50
-	private $output;
41
+    /** @var \OC\Repair $repair */
42
+    protected $repair;
43
+    /** @var IConfig */
44
+    protected $config;
45
+    /** @var EventDispatcherInterface */
46
+    private $dispatcher;
47
+    /** @var ProgressBar */
48
+    private $progress;
49
+    /** @var OutputInterface */
50
+    private $output;
51 51
 
52
-	/**
53
-	 * @param \OC\Repair $repair
54
-	 * @param IConfig $config
55
-	 */
56
-	public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher) {
57
-		$this->repair = $repair;
58
-		$this->config = $config;
59
-		$this->dispatcher = $dispatcher;
60
-		parent::__construct();
61
-	}
52
+    /**
53
+     * @param \OC\Repair $repair
54
+     * @param IConfig $config
55
+     */
56
+    public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher) {
57
+        $this->repair = $repair;
58
+        $this->config = $config;
59
+        $this->dispatcher = $dispatcher;
60
+        parent::__construct();
61
+    }
62 62
 
63
-	protected function configure() {
64
-		$this
65
-			->setName('maintenance:repair')
66
-			->setDescription('repair this installation')
67
-			->addOption(
68
-				'include-expensive',
69
-				null,
70
-				InputOption::VALUE_NONE,
71
-				'Use this option when you want to include resource and load expensive tasks');
72
-	}
63
+    protected function configure() {
64
+        $this
65
+            ->setName('maintenance:repair')
66
+            ->setDescription('repair this installation')
67
+            ->addOption(
68
+                'include-expensive',
69
+                null,
70
+                InputOption::VALUE_NONE,
71
+                'Use this option when you want to include resource and load expensive tasks');
72
+    }
73 73
 
74
-	protected function execute(InputInterface $input, OutputInterface $output) {
75
-		$includeExpensive = $input->getOption('include-expensive');
76
-		if ($includeExpensive) {
77
-			foreach ($this->repair->getExpensiveRepairSteps() as $step) {
78
-				$this->repair->addStep($step);
79
-			}
80
-		}
74
+    protected function execute(InputInterface $input, OutputInterface $output) {
75
+        $includeExpensive = $input->getOption('include-expensive');
76
+        if ($includeExpensive) {
77
+            foreach ($this->repair->getExpensiveRepairSteps() as $step) {
78
+                $this->repair->addStep($step);
79
+            }
80
+        }
81 81
 
82
-		$apps = \OC::$server->getAppManager()->getInstalledApps();
83
-		foreach ($apps as $app) {
84
-			if (!\OC_App::isEnabled($app)) {
85
-				continue;
86
-			}
87
-			$info = \OC_App::getAppInfo($app);
88
-			if (!is_array($info)) {
89
-				continue;
90
-			}
91
-			$steps = $info['repair-steps']['post-migration'];
92
-			foreach ($steps as $step) {
93
-				try {
94
-					$this->repair->addStep($step);
95
-				} catch (Exception $ex) {
96
-					$output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>");
97
-				}
98
-			}
99
-		}
82
+        $apps = \OC::$server->getAppManager()->getInstalledApps();
83
+        foreach ($apps as $app) {
84
+            if (!\OC_App::isEnabled($app)) {
85
+                continue;
86
+            }
87
+            $info = \OC_App::getAppInfo($app);
88
+            if (!is_array($info)) {
89
+                continue;
90
+            }
91
+            $steps = $info['repair-steps']['post-migration'];
92
+            foreach ($steps as $step) {
93
+                try {
94
+                    $this->repair->addStep($step);
95
+                } catch (Exception $ex) {
96
+                    $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>");
97
+                }
98
+            }
99
+        }
100 100
 
101
-		$maintenanceMode = $this->config->getSystemValue('maintenance', false);
102
-		$this->config->setSystemValue('maintenance', true);
101
+        $maintenanceMode = $this->config->getSystemValue('maintenance', false);
102
+        $this->config->setSystemValue('maintenance', true);
103 103
 
104
-		$this->progress = new ProgressBar($output);
105
-		$this->output = $output;
106
-		$this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']);
107
-		$this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']);
108
-		$this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
109
-		$this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']);
110
-		$this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']);
111
-		$this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']);
112
-		$this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']);
104
+        $this->progress = new ProgressBar($output);
105
+        $this->output = $output;
106
+        $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']);
107
+        $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']);
108
+        $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
109
+        $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']);
110
+        $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']);
111
+        $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']);
112
+        $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']);
113 113
 
114
-		$this->repair->run();
114
+        $this->repair->run();
115 115
 
116
-		$this->config->setSystemValue('maintenance', $maintenanceMode);
117
-	}
116
+        $this->config->setSystemValue('maintenance', $maintenanceMode);
117
+    }
118 118
 
119
-	public function handleRepairFeedBack($event) {
120
-		if (!$event instanceof GenericEvent) {
121
-			return;
122
-		}
123
-		switch ($event->getSubject()) {
124
-			case '\OC\Repair::startProgress':
125
-				$this->progress->start($event->getArgument(0));
126
-				break;
127
-			case '\OC\Repair::advance':
128
-				$this->progress->advance($event->getArgument(0));
129
-				break;
130
-			case '\OC\Repair::finishProgress':
131
-				$this->progress->finish();
132
-				$this->output->writeln('');
133
-				break;
134
-			case '\OC\Repair::step':
135
-				$this->output->writeln(' - ' . $event->getArgument(0));
136
-				break;
137
-			case '\OC\Repair::info':
138
-				$this->output->writeln('     - ' . $event->getArgument(0));
139
-				break;
140
-			case '\OC\Repair::warning':
141
-				$this->output->writeln('     - WARNING: ' . $event->getArgument(0));
142
-				break;
143
-			case '\OC\Repair::error':
144
-				$this->output->writeln('     - ERROR: ' . $event->getArgument(0));
145
-				break;
146
-		}
147
-	}
119
+    public function handleRepairFeedBack($event) {
120
+        if (!$event instanceof GenericEvent) {
121
+            return;
122
+        }
123
+        switch ($event->getSubject()) {
124
+            case '\OC\Repair::startProgress':
125
+                $this->progress->start($event->getArgument(0));
126
+                break;
127
+            case '\OC\Repair::advance':
128
+                $this->progress->advance($event->getArgument(0));
129
+                break;
130
+            case '\OC\Repair::finishProgress':
131
+                $this->progress->finish();
132
+                $this->output->writeln('');
133
+                break;
134
+            case '\OC\Repair::step':
135
+                $this->output->writeln(' - ' . $event->getArgument(0));
136
+                break;
137
+            case '\OC\Repair::info':
138
+                $this->output->writeln('     - ' . $event->getArgument(0));
139
+                break;
140
+            case '\OC\Repair::warning':
141
+                $this->output->writeln('     - WARNING: ' . $event->getArgument(0));
142
+                break;
143
+            case '\OC\Repair::error':
144
+                $this->output->writeln('     - ERROR: ' . $event->getArgument(0));
145
+                break;
146
+        }
147
+    }
148 148
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,16 +132,16 @@
 block discarded – undo
132 132
 				$this->output->writeln('');
133 133
 				break;
134 134
 			case '\OC\Repair::step':
135
-				$this->output->writeln(' - ' . $event->getArgument(0));
135
+				$this->output->writeln(' - '.$event->getArgument(0));
136 136
 				break;
137 137
 			case '\OC\Repair::info':
138
-				$this->output->writeln('     - ' . $event->getArgument(0));
138
+				$this->output->writeln('     - '.$event->getArgument(0));
139 139
 				break;
140 140
 			case '\OC\Repair::warning':
141
-				$this->output->writeln('     - WARNING: ' . $event->getArgument(0));
141
+				$this->output->writeln('     - WARNING: '.$event->getArgument(0));
142 142
 				break;
143 143
 			case '\OC\Repair::error':
144
-				$this->output->writeln('     - ERROR: ' . $event->getArgument(0));
144
+				$this->output->writeln('     - ERROR: '.$event->getArgument(0));
145 145
 				break;
146 146
 		}
147 147
 	}
Please login to merge, or discard this patch.
core/Command/Security/ListCertificates.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,6 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Command\Command;
29 29
 use Symfony\Component\Console\Helper\Table;
30 30
 use Symfony\Component\Console\Input\InputInterface;
31
-use Symfony\Component\Console\Input\InputOption;
32 31
 use Symfony\Component\Console\Output\OutputInterface;
33 32
 
34 33
 class ListCertificates extends Base {
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -34,64 +34,64 @@
 block discarded – undo
34 34
 
35 35
 class ListCertificates extends Base {
36 36
 
37
-	/** @var ICertificateManager */
38
-	protected $certificateManager;
39
-	/** @var IL10N */
40
-	protected $l;
37
+    /** @var ICertificateManager */
38
+    protected $certificateManager;
39
+    /** @var IL10N */
40
+    protected $l;
41 41
 
42
-	public function __construct(ICertificateManager $certificateManager, IL10N $l) {
43
-		$this->certificateManager = $certificateManager;
44
-		$this->l = $l;
45
-		parent::__construct();
46
-	}
42
+    public function __construct(ICertificateManager $certificateManager, IL10N $l) {
43
+        $this->certificateManager = $certificateManager;
44
+        $this->l = $l;
45
+        parent::__construct();
46
+    }
47 47
 
48
-	protected function configure() {
49
-		$this
50
-			->setName('security:certificates')
51
-			->setDescription('list trusted certificates');
52
-		parent::configure();
53
-	}
48
+    protected function configure() {
49
+        $this
50
+            ->setName('security:certificates')
51
+            ->setDescription('list trusted certificates');
52
+        parent::configure();
53
+    }
54 54
 
55
-	protected function execute(InputInterface $input, OutputInterface $output) {
56
-		$outputType = $input->getOption('output');
57
-		if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
58
-			$certificates = array_map(function (ICertificate $certificate) {
59
-				return [
60
-					'name' => $certificate->getName(),
61
-					'common_name' => $certificate->getCommonName(),
62
-					'organization' => $certificate->getOrganization(),
63
-					'expire' => $certificate->getExpireDate()->format(\DateTime::ATOM),
64
-					'issuer' => $certificate->getIssuerName(),
65
-					'issuer_organization' => $certificate->getIssuerOrganization(),
66
-					'issue_date' => $certificate->getIssueDate()->format(\DateTime::ATOM)
67
-				];
68
-			}, $this->certificateManager->listCertificates());
69
-			if ($outputType === self::OUTPUT_FORMAT_JSON) {
70
-				$output->writeln(json_encode(array_values($certificates)));
71
-			} else {
72
-				$output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT));
73
-			}
74
-		} else {
75
-			$table = new Table($output);
76
-			$table->setHeaders([
77
-				'File Name',
78
-				'Common Name',
79
-				'Organization',
80
-				'Valid Until',
81
-				'Issued By'
82
-			]);
55
+    protected function execute(InputInterface $input, OutputInterface $output) {
56
+        $outputType = $input->getOption('output');
57
+        if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
58
+            $certificates = array_map(function (ICertificate $certificate) {
59
+                return [
60
+                    'name' => $certificate->getName(),
61
+                    'common_name' => $certificate->getCommonName(),
62
+                    'organization' => $certificate->getOrganization(),
63
+                    'expire' => $certificate->getExpireDate()->format(\DateTime::ATOM),
64
+                    'issuer' => $certificate->getIssuerName(),
65
+                    'issuer_organization' => $certificate->getIssuerOrganization(),
66
+                    'issue_date' => $certificate->getIssueDate()->format(\DateTime::ATOM)
67
+                ];
68
+            }, $this->certificateManager->listCertificates());
69
+            if ($outputType === self::OUTPUT_FORMAT_JSON) {
70
+                $output->writeln(json_encode(array_values($certificates)));
71
+            } else {
72
+                $output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT));
73
+            }
74
+        } else {
75
+            $table = new Table($output);
76
+            $table->setHeaders([
77
+                'File Name',
78
+                'Common Name',
79
+                'Organization',
80
+                'Valid Until',
81
+                'Issued By'
82
+            ]);
83 83
 
84
-			$rows = array_map(function (ICertificate $certificate) {
85
-				return [
86
-					$certificate->getName(),
87
-					$certificate->getCommonName(),
88
-					$certificate->getOrganization(),
89
-					$this->l->l('date', $certificate->getExpireDate()),
90
-					$certificate->getIssuerName()
91
-				];
92
-			}, $this->certificateManager->listCertificates());
93
-			$table->setRows($rows);
94
-			$table->render();
95
-		}
96
-	}
84
+            $rows = array_map(function (ICertificate $certificate) {
85
+                return [
86
+                    $certificate->getName(),
87
+                    $certificate->getCommonName(),
88
+                    $certificate->getOrganization(),
89
+                    $this->l->l('date', $certificate->getExpireDate()),
90
+                    $certificate->getIssuerName()
91
+                ];
92
+            }, $this->certificateManager->listCertificates());
93
+            $table->setRows($rows);
94
+            $table->render();
95
+        }
96
+    }
97 97
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	protected function execute(InputInterface $input, OutputInterface $output) {
56 56
 		$outputType = $input->getOption('output');
57 57
 		if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
58
-			$certificates = array_map(function (ICertificate $certificate) {
58
+			$certificates = array_map(function(ICertificate $certificate) {
59 59
 				return [
60 60
 					'name' => $certificate->getName(),
61 61
 					'common_name' => $certificate->getCommonName(),
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 				'Issued By'
82 82
 			]);
83 83
 
84
-			$rows = array_map(function (ICertificate $certificate) {
84
+			$rows = array_map(function(ICertificate $certificate) {
85 85
 				return [
86 86
 					$certificate->getName(),
87 87
 					$certificate->getCommonName(),
Please login to merge, or discard this patch.
core/Controller/LostController.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,6 +146,7 @@  discard block
 block discarded – undo
146 146
 	/**
147 147
 	 * @param string $userId
148 148
 	 * @param string $userId
149
+	 * @param string $token
149 150
 	 * @throws \Exception
150 151
 	 */
151 152
 	private function checkPasswordResetToken($token, $userId) {
@@ -167,7 +168,7 @@  discard block
 block discarded – undo
167 168
 	}
168 169
 
169 170
 	/**
170
-	 * @param $message
171
+	 * @param string $message
171 172
 	 * @param array $additional
172 173
 	 * @return array
173 174
 	 */
Please login to merge, or discard this patch.
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -51,228 +51,228 @@
 block discarded – undo
51 51
  */
52 52
 class LostController extends Controller {
53 53
 
54
-	/** @var IURLGenerator */
55
-	protected $urlGenerator;
56
-	/** @var IUserManager */
57
-	protected $userManager;
58
-	/** @var \OC_Defaults */
59
-	protected $defaults;
60
-	/** @var IL10N */
61
-	protected $l10n;
62
-	/** @var string */
63
-	protected $from;
64
-	/** @var bool */
65
-	protected $isDataEncrypted;
66
-	/** @var IConfig */
67
-	protected $config;
68
-	/** @var ISecureRandom */
69
-	protected $secureRandom;
70
-	/** @var IMailer */
71
-	protected $mailer;
72
-	/** @var ITimeFactory */
73
-	protected $timeFactory;
54
+    /** @var IURLGenerator */
55
+    protected $urlGenerator;
56
+    /** @var IUserManager */
57
+    protected $userManager;
58
+    /** @var \OC_Defaults */
59
+    protected $defaults;
60
+    /** @var IL10N */
61
+    protected $l10n;
62
+    /** @var string */
63
+    protected $from;
64
+    /** @var bool */
65
+    protected $isDataEncrypted;
66
+    /** @var IConfig */
67
+    protected $config;
68
+    /** @var ISecureRandom */
69
+    protected $secureRandom;
70
+    /** @var IMailer */
71
+    protected $mailer;
72
+    /** @var ITimeFactory */
73
+    protected $timeFactory;
74 74
 
75
-	/**
76
-	 * @param string $appName
77
-	 * @param IRequest $request
78
-	 * @param IURLGenerator $urlGenerator
79
-	 * @param IUserManager $userManager
80
-	 * @param \OC_Defaults $defaults
81
-	 * @param IL10N $l10n
82
-	 * @param IConfig $config
83
-	 * @param ISecureRandom $secureRandom
84
-	 * @param string $from
85
-	 * @param string $isDataEncrypted
86
-	 * @param IMailer $mailer
87
-	 * @param ITimeFactory $timeFactory
88
-	 */
89
-	public function __construct($appName,
90
-								IRequest $request,
91
-								IURLGenerator $urlGenerator,
92
-								IUserManager $userManager,
93
-								\OC_Defaults $defaults,
94
-								IL10N $l10n,
95
-								IConfig $config,
96
-								ISecureRandom $secureRandom,
97
-								$from,
98
-								$isDataEncrypted,
99
-								IMailer $mailer,
100
-								ITimeFactory $timeFactory) {
101
-		parent::__construct($appName, $request);
102
-		$this->urlGenerator = $urlGenerator;
103
-		$this->userManager = $userManager;
104
-		$this->defaults = $defaults;
105
-		$this->l10n = $l10n;
106
-		$this->secureRandom = $secureRandom;
107
-		$this->from = $from;
108
-		$this->isDataEncrypted = $isDataEncrypted;
109
-		$this->config = $config;
110
-		$this->mailer = $mailer;
111
-		$this->timeFactory = $timeFactory;
112
-	}
75
+    /**
76
+     * @param string $appName
77
+     * @param IRequest $request
78
+     * @param IURLGenerator $urlGenerator
79
+     * @param IUserManager $userManager
80
+     * @param \OC_Defaults $defaults
81
+     * @param IL10N $l10n
82
+     * @param IConfig $config
83
+     * @param ISecureRandom $secureRandom
84
+     * @param string $from
85
+     * @param string $isDataEncrypted
86
+     * @param IMailer $mailer
87
+     * @param ITimeFactory $timeFactory
88
+     */
89
+    public function __construct($appName,
90
+                                IRequest $request,
91
+                                IURLGenerator $urlGenerator,
92
+                                IUserManager $userManager,
93
+                                \OC_Defaults $defaults,
94
+                                IL10N $l10n,
95
+                                IConfig $config,
96
+                                ISecureRandom $secureRandom,
97
+                                $from,
98
+                                $isDataEncrypted,
99
+                                IMailer $mailer,
100
+                                ITimeFactory $timeFactory) {
101
+        parent::__construct($appName, $request);
102
+        $this->urlGenerator = $urlGenerator;
103
+        $this->userManager = $userManager;
104
+        $this->defaults = $defaults;
105
+        $this->l10n = $l10n;
106
+        $this->secureRandom = $secureRandom;
107
+        $this->from = $from;
108
+        $this->isDataEncrypted = $isDataEncrypted;
109
+        $this->config = $config;
110
+        $this->mailer = $mailer;
111
+        $this->timeFactory = $timeFactory;
112
+    }
113 113
 
114
-	/**
115
-	 * Someone wants to reset their password:
116
-	 *
117
-	 * @PublicPage
118
-	 * @NoCSRFRequired
119
-	 *
120
-	 * @param string $token
121
-	 * @param string $userId
122
-	 * @return TemplateResponse
123
-	 */
124
-	public function resetform($token, $userId) {
125
-		try {
126
-			$this->checkPasswordResetToken($token, $userId);
127
-		} catch (\Exception $e) {
128
-			return new TemplateResponse(
129
-				'core', 'error', [
130
-					"errors" => array(array("error" => $e->getMessage()))
131
-				],
132
-				'guest'
133
-			);
134
-		}
114
+    /**
115
+     * Someone wants to reset their password:
116
+     *
117
+     * @PublicPage
118
+     * @NoCSRFRequired
119
+     *
120
+     * @param string $token
121
+     * @param string $userId
122
+     * @return TemplateResponse
123
+     */
124
+    public function resetform($token, $userId) {
125
+        try {
126
+            $this->checkPasswordResetToken($token, $userId);
127
+        } catch (\Exception $e) {
128
+            return new TemplateResponse(
129
+                'core', 'error', [
130
+                    "errors" => array(array("error" => $e->getMessage()))
131
+                ],
132
+                'guest'
133
+            );
134
+        }
135 135
 
136
-		return new TemplateResponse(
137
-			'core',
138
-			'lostpassword/resetpassword',
139
-			array(
140
-				'link' => $this->urlGenerator->linkToRouteAbsolute('core.lost.setPassword', array('userId' => $userId, 'token' => $token)),
141
-			),
142
-			'guest'
143
-		);
144
-	}
136
+        return new TemplateResponse(
137
+            'core',
138
+            'lostpassword/resetpassword',
139
+            array(
140
+                'link' => $this->urlGenerator->linkToRouteAbsolute('core.lost.setPassword', array('userId' => $userId, 'token' => $token)),
141
+            ),
142
+            'guest'
143
+        );
144
+    }
145 145
 
146
-	/**
147
-	 * @param string $userId
148
-	 * @param string $userId
149
-	 * @throws \Exception
150
-	 */
151
-	private function checkPasswordResetToken($token, $userId) {
152
-		$user = $this->userManager->get($userId);
146
+    /**
147
+     * @param string $userId
148
+     * @param string $userId
149
+     * @throws \Exception
150
+     */
151
+    private function checkPasswordResetToken($token, $userId) {
152
+        $user = $this->userManager->get($userId);
153 153
 
154
-		$splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud', 'lostpassword', null));
155
-		if(count($splittedToken) !== 2) {
156
-			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
157
-		}
154
+        $splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud', 'lostpassword', null));
155
+        if(count($splittedToken) !== 2) {
156
+            throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
157
+        }
158 158
 
159
-		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) ||
160
-			$user->getLastLogin() > $splittedToken[0]) {
161
-			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired'));
162
-		}
159
+        if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) ||
160
+            $user->getLastLogin() > $splittedToken[0]) {
161
+            throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired'));
162
+        }
163 163
 
164
-		if (!StringUtils::equals($splittedToken[1], $token)) {
165
-			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
166
-		}
167
-	}
164
+        if (!StringUtils::equals($splittedToken[1], $token)) {
165
+            throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
166
+        }
167
+    }
168 168
 
169
-	/**
170
-	 * @param $message
171
-	 * @param array $additional
172
-	 * @return array
173
-	 */
174
-	private function error($message, array $additional=array()) {
175
-		return array_merge(array('status' => 'error', 'msg' => $message), $additional);
176
-	}
169
+    /**
170
+     * @param $message
171
+     * @param array $additional
172
+     * @return array
173
+     */
174
+    private function error($message, array $additional=array()) {
175
+        return array_merge(array('status' => 'error', 'msg' => $message), $additional);
176
+    }
177 177
 
178
-	/**
179
-	 * @return array
180
-	 */
181
-	private function success() {
182
-		return array('status'=>'success');
183
-	}
178
+    /**
179
+     * @return array
180
+     */
181
+    private function success() {
182
+        return array('status'=>'success');
183
+    }
184 184
 
185
-	/**
186
-	 * @PublicPage
187
-	 *
188
-	 * @param string $user
189
-	 * @return array
190
-	 */
191
-	public function email($user){
192
-		// FIXME: use HTTP error codes
193
-		try {
194
-			$this->sendEmail($user);
195
-		} catch (\Exception $e){
196
-			return $this->error($e->getMessage());
197
-		}
185
+    /**
186
+     * @PublicPage
187
+     *
188
+     * @param string $user
189
+     * @return array
190
+     */
191
+    public function email($user){
192
+        // FIXME: use HTTP error codes
193
+        try {
194
+            $this->sendEmail($user);
195
+        } catch (\Exception $e){
196
+            return $this->error($e->getMessage());
197
+        }
198 198
 
199
-		return $this->success();
200
-	}
199
+        return $this->success();
200
+    }
201 201
 
202
-	/**
203
-	 * @PublicPage
204
-	 * @param string $token
205
-	 * @param string $userId
206
-	 * @param string $password
207
-	 * @param boolean $proceed
208
-	 * @return array
209
-	 */
210
-	public function setPassword($token, $userId, $password, $proceed) {
211
-		if ($this->isDataEncrypted && !$proceed) {
212
-			return $this->error('', array('encryption' => true));
213
-		}
202
+    /**
203
+     * @PublicPage
204
+     * @param string $token
205
+     * @param string $userId
206
+     * @param string $password
207
+     * @param boolean $proceed
208
+     * @return array
209
+     */
210
+    public function setPassword($token, $userId, $password, $proceed) {
211
+        if ($this->isDataEncrypted && !$proceed) {
212
+            return $this->error('', array('encryption' => true));
213
+        }
214 214
 
215
-		try {
216
-			$this->checkPasswordResetToken($token, $userId);
217
-			$user = $this->userManager->get($userId);
215
+        try {
216
+            $this->checkPasswordResetToken($token, $userId);
217
+            $user = $this->userManager->get($userId);
218 218
 
219
-			if (!$user->setPassword($password)) {
220
-				throw new \Exception();
221
-			}
219
+            if (!$user->setPassword($password)) {
220
+                throw new \Exception();
221
+            }
222 222
 
223
-			\OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', array('uid' => $userId, 'password' => $password));
223
+            \OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', array('uid' => $userId, 'password' => $password));
224 224
 
225
-			$this->config->deleteUserValue($userId, 'owncloud', 'lostpassword');
226
-			@\OC_User::unsetMagicInCookie();
227
-		} catch (\Exception $e){
228
-			return $this->error($e->getMessage());
229
-		}
225
+            $this->config->deleteUserValue($userId, 'owncloud', 'lostpassword');
226
+            @\OC_User::unsetMagicInCookie();
227
+        } catch (\Exception $e){
228
+            return $this->error($e->getMessage());
229
+        }
230 230
 
231
-		return $this->success();
232
-	}
231
+        return $this->success();
232
+    }
233 233
 
234
-	/**
235
-	 * @param string $user
236
-	 * @throws \Exception
237
-	 */
238
-	protected function sendEmail($user) {
239
-		if (!$this->userManager->userExists($user)) {
240
-			throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
241
-		}
234
+    /**
235
+     * @param string $user
236
+     * @throws \Exception
237
+     */
238
+    protected function sendEmail($user) {
239
+        if (!$this->userManager->userExists($user)) {
240
+            throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
241
+        }
242 242
 
243
-		$userObject = $this->userManager->get($user);
244
-		$email = $userObject->getEMailAddress();
243
+        $userObject = $this->userManager->get($user);
244
+        $email = $userObject->getEMailAddress();
245 245
 
246
-		if (empty($email)) {
247
-			throw new \Exception(
248
-				$this->l10n->t('Could not send reset email because there is no email address for this username. Please contact your administrator.')
249
-			);
250
-		}
246
+        if (empty($email)) {
247
+            throw new \Exception(
248
+                $this->l10n->t('Could not send reset email because there is no email address for this username. Please contact your administrator.')
249
+            );
250
+        }
251 251
 
252
-		$token = $this->secureRandom->generate(21,
253
-			ISecureRandom::CHAR_DIGITS.
254
-			ISecureRandom::CHAR_LOWER.
255
-			ISecureRandom::CHAR_UPPER);
256
-		$this->config->setUserValue($user, 'owncloud', 'lostpassword', $this->timeFactory->getTime() .':'. $token);
252
+        $token = $this->secureRandom->generate(21,
253
+            ISecureRandom::CHAR_DIGITS.
254
+            ISecureRandom::CHAR_LOWER.
255
+            ISecureRandom::CHAR_UPPER);
256
+        $this->config->setUserValue($user, 'owncloud', 'lostpassword', $this->timeFactory->getTime() .':'. $token);
257 257
 
258
-		$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user, 'token' => $token));
258
+        $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user, 'token' => $token));
259 259
 
260
-		$tmpl = new \OC_Template('core', 'lostpassword/email');
261
-		$tmpl->assign('link', $link);
262
-		$msg = $tmpl->fetchPage();
260
+        $tmpl = new \OC_Template('core', 'lostpassword/email');
261
+        $tmpl->assign('link', $link);
262
+        $msg = $tmpl->fetchPage();
263 263
 
264
-		try {
265
-			$message = $this->mailer->createMessage();
266
-			$message->setTo([$email => $user]);
267
-			$message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
268
-			$message->setPlainBody($msg);
269
-			$message->setFrom([$this->from => $this->defaults->getName()]);
270
-			$this->mailer->send($message);
271
-		} catch (\Exception $e) {
272
-			throw new \Exception($this->l10n->t(
273
-				'Couldn\'t send reset email. Please contact your administrator.'
274
-			));
275
-		}
276
-	}
264
+        try {
265
+            $message = $this->mailer->createMessage();
266
+            $message->setTo([$email => $user]);
267
+            $message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
268
+            $message->setPlainBody($msg);
269
+            $message->setFrom([$this->from => $this->defaults->getName()]);
270
+            $this->mailer->send($message);
271
+        } catch (\Exception $e) {
272
+            throw new \Exception($this->l10n->t(
273
+                'Couldn\'t send reset email. Please contact your administrator.'
274
+            ));
275
+        }
276
+    }
277 277
 
278 278
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 		$user = $this->userManager->get($userId);
153 153
 
154 154
 		$splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud', 'lostpassword', null));
155
-		if(count($splittedToken) !== 2) {
155
+		if (count($splittedToken) !== 2) {
156 156
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
157 157
 		}
158 158
 
159
-		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) ||
159
+		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60 * 60 * 12) ||
160 160
 			$user->getLastLogin() > $splittedToken[0]) {
161 161
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired'));
162 162
 		}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @param array $additional
172 172
 	 * @return array
173 173
 	 */
174
-	private function error($message, array $additional=array()) {
174
+	private function error($message, array $additional = array()) {
175 175
 		return array_merge(array('status' => 'error', 'msg' => $message), $additional);
176 176
 	}
177 177
 
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	 * @param string $user
189 189
 	 * @return array
190 190
 	 */
191
-	public function email($user){
191
+	public function email($user) {
192 192
 		// FIXME: use HTTP error codes
193 193
 		try {
194 194
 			$this->sendEmail($user);
195
-		} catch (\Exception $e){
195
+		} catch (\Exception $e) {
196 196
 			return $this->error($e->getMessage());
197 197
 		}
198 198
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 			$this->config->deleteUserValue($userId, 'owncloud', 'lostpassword');
226 226
 			@\OC_User::unsetMagicInCookie();
227
-		} catch (\Exception $e){
227
+		} catch (\Exception $e) {
228 228
 			return $this->error($e->getMessage());
229 229
 		}
230 230
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			ISecureRandom::CHAR_DIGITS.
254 254
 			ISecureRandom::CHAR_LOWER.
255 255
 			ISecureRandom::CHAR_UPPER);
256
-		$this->config->setUserValue($user, 'owncloud', 'lostpassword', $this->timeFactory->getTime() .':'. $token);
256
+		$this->config->setUserValue($user, 'owncloud', 'lostpassword', $this->timeFactory->getTime().':'.$token);
257 257
 
258 258
 		$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user, 'token' => $token));
259 259
 
Please login to merge, or discard this patch.
core/Middleware/TwoFactorMiddleware.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -96,6 +96,10 @@
 block discarded – undo
96 96
 		// TODO: dont check/enforce 2FA if a auth token is used
97 97
 	}
98 98
 
99
+	/**
100
+	 * @param Controller $controller
101
+	 * @param string $methodName
102
+	 */
99 103
 	private function checkTwoFactor($controller, $methodName) {
100 104
 		// If two-factor auth is in progress disallow access to any controllers
101 105
 		// defined within "LoginController".
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -39,96 +39,96 @@
 block discarded – undo
39 39
 
40 40
 class TwoFactorMiddleware extends Middleware {
41 41
 
42
-	/** @var Manager */
43
-	private $twoFactorManager;
44
-
45
-	/** @var Session */
46
-	private $userSession;
47
-
48
-	/** @var ISession */
49
-	private $session;
50
-
51
-	/** @var IURLGenerator */
52
-	private $urlGenerator;
53
-
54
-	/** @var IControllerMethodReflector */
55
-	private $reflector;
56
-
57
-	/** @var IRequest */
58
-	private $request;
59
-
60
-	/**
61
-	 * @param Manager $twoFactorManager
62
-	 * @param Session $userSession
63
-	 * @param ISession $session
64
-	 * @param IURLGenerator $urlGenerator
65
-	 */
66
-	public function __construct(Manager $twoFactorManager, Session $userSession, ISession $session,
67
-		IURLGenerator $urlGenerator, IControllerMethodReflector $reflector, IRequest $request) {
68
-		$this->twoFactorManager = $twoFactorManager;
69
-		$this->userSession = $userSession;
70
-		$this->session = $session;
71
-		$this->urlGenerator = $urlGenerator;
72
-		$this->reflector = $reflector;
73
-		$this->request = $request;
74
-	}
75
-
76
-	/**
77
-	 * @param Controller $controller
78
-	 * @param string $methodName
79
-	 */
80
-	public function beforeController($controller, $methodName) {
81
-		if ($this->reflector->hasAnnotation('PublicPage')) {
82
-			// Don't block public pages
83
-			return;
84
-		}
85
-
86
-		if ($controller instanceof \OC\Core\Controller\LoginController && $methodName === 'logout') {
87
-			// Don't block the logout page, to allow canceling the 2FA
88
-			return;
89
-		}
90
-
91
-		if ($this->userSession->isLoggedIn()) {
92
-			$user = $this->userSession->getUser();
93
-
94
-			if ($this->twoFactorManager->isTwoFactorAuthenticated($user)) {
95
-				$this->checkTwoFactor($controller, $methodName);
96
-			} else if ($controller instanceof TwoFactorChallengeController) {
97
-				// Allow access to the two-factor controllers only if two-factor authentication
98
-				// is in progress.
99
-				throw new UserAlreadyLoggedInException();
100
-			}
101
-		}
102
-		// TODO: dont check/enforce 2FA if a auth token is used
103
-	}
104
-
105
-	private function checkTwoFactor($controller, $methodName) {
106
-		// If two-factor auth is in progress disallow access to any controllers
107
-		// defined within "LoginController".
108
-		$needsSecondFactor = $this->twoFactorManager->needsSecondFactor();
109
-		$twoFactor = $controller instanceof TwoFactorChallengeController;
110
-
111
-		// Disallow access to any controller if 2FA needs to be checked
112
-		if ($needsSecondFactor && !$twoFactor) {
113
-			throw new TwoFactorAuthRequiredException();
114
-		}
115
-
116
-		// Allow access to the two-factor controllers only if two-factor authentication
117
-		// is in progress.
118
-		if (!$needsSecondFactor && $twoFactor) {
119
-			throw new UserAlreadyLoggedInException();
120
-		}
121
-	}
122
-
123
-	public function afterException($controller, $methodName, Exception $exception) {
124
-		if ($exception instanceof TwoFactorAuthRequiredException) {
125
-			return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge', [
126
-					'redirect_url' => urlencode($this->request->server['REQUEST_URI']),
127
-			]));
128
-		}
129
-		if ($exception instanceof UserAlreadyLoggedInException) {
130
-			return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index'));
131
-		}
132
-	}
42
+    /** @var Manager */
43
+    private $twoFactorManager;
44
+
45
+    /** @var Session */
46
+    private $userSession;
47
+
48
+    /** @var ISession */
49
+    private $session;
50
+
51
+    /** @var IURLGenerator */
52
+    private $urlGenerator;
53
+
54
+    /** @var IControllerMethodReflector */
55
+    private $reflector;
56
+
57
+    /** @var IRequest */
58
+    private $request;
59
+
60
+    /**
61
+     * @param Manager $twoFactorManager
62
+     * @param Session $userSession
63
+     * @param ISession $session
64
+     * @param IURLGenerator $urlGenerator
65
+     */
66
+    public function __construct(Manager $twoFactorManager, Session $userSession, ISession $session,
67
+        IURLGenerator $urlGenerator, IControllerMethodReflector $reflector, IRequest $request) {
68
+        $this->twoFactorManager = $twoFactorManager;
69
+        $this->userSession = $userSession;
70
+        $this->session = $session;
71
+        $this->urlGenerator = $urlGenerator;
72
+        $this->reflector = $reflector;
73
+        $this->request = $request;
74
+    }
75
+
76
+    /**
77
+     * @param Controller $controller
78
+     * @param string $methodName
79
+     */
80
+    public function beforeController($controller, $methodName) {
81
+        if ($this->reflector->hasAnnotation('PublicPage')) {
82
+            // Don't block public pages
83
+            return;
84
+        }
85
+
86
+        if ($controller instanceof \OC\Core\Controller\LoginController && $methodName === 'logout') {
87
+            // Don't block the logout page, to allow canceling the 2FA
88
+            return;
89
+        }
90
+
91
+        if ($this->userSession->isLoggedIn()) {
92
+            $user = $this->userSession->getUser();
93
+
94
+            if ($this->twoFactorManager->isTwoFactorAuthenticated($user)) {
95
+                $this->checkTwoFactor($controller, $methodName);
96
+            } else if ($controller instanceof TwoFactorChallengeController) {
97
+                // Allow access to the two-factor controllers only if two-factor authentication
98
+                // is in progress.
99
+                throw new UserAlreadyLoggedInException();
100
+            }
101
+        }
102
+        // TODO: dont check/enforce 2FA if a auth token is used
103
+    }
104
+
105
+    private function checkTwoFactor($controller, $methodName) {
106
+        // If two-factor auth is in progress disallow access to any controllers
107
+        // defined within "LoginController".
108
+        $needsSecondFactor = $this->twoFactorManager->needsSecondFactor();
109
+        $twoFactor = $controller instanceof TwoFactorChallengeController;
110
+
111
+        // Disallow access to any controller if 2FA needs to be checked
112
+        if ($needsSecondFactor && !$twoFactor) {
113
+            throw new TwoFactorAuthRequiredException();
114
+        }
115
+
116
+        // Allow access to the two-factor controllers only if two-factor authentication
117
+        // is in progress.
118
+        if (!$needsSecondFactor && $twoFactor) {
119
+            throw new UserAlreadyLoggedInException();
120
+        }
121
+    }
122
+
123
+    public function afterException($controller, $methodName, Exception $exception) {
124
+        if ($exception instanceof TwoFactorAuthRequiredException) {
125
+            return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge', [
126
+                    'redirect_url' => urlencode($this->request->server['REQUEST_URI']),
127
+            ]));
128
+        }
129
+        if ($exception instanceof UserAlreadyLoggedInException) {
130
+            return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index'));
131
+        }
132
+    }
133 133
 
134 134
 }
Please login to merge, or discard this patch.
lib/private/App/AppManager.php 3 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	/**
118 118
 	 * List all installed apps
119 119
 	 *
120
-	 * @return string[]
120
+	 * @return integer[]
121 121
 	 */
122 122
 	public function getInstalledApps() {
123 123
 		return array_keys($this->getInstalledAppsValues());
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	/**
275 275
 	 * Returns a list of apps that need upgrade
276 276
 	 *
277
-	 * @param array $version ownCloud version as array of version components
277
+	 * @param array $ocVersion ownCloud version as array of version components
278 278
 	 * @return array list of app info from apps that need an upgrade
279 279
 	 *
280 280
 	 * @internal
@@ -344,6 +344,9 @@  discard block
 block discarded – undo
344 344
 		return in_array($appId, $this->shippedApps);
345 345
 	}
346 346
 
347
+	/**
348
+	 * @param string $appId
349
+	 */
347 350
 	private function isAlwaysEnabled($appId) {
348 351
 		$alwaysEnabled = $this->getAlwaysEnabledApps();
349 352
 		return in_array($appId, $alwaysEnabled);
Please login to merge, or discard this patch.
Indentation   +328 added lines, -328 removed lines patch added patch discarded remove patch
@@ -42,332 +42,332 @@
 block discarded – undo
42 42
 
43 43
 class AppManager implements IAppManager {
44 44
 
45
-	/**
46
-	 * Apps with these types can not be enabled for certain groups only
47
-	 * @var string[]
48
-	 */
49
-	protected $protectedAppTypes = [
50
-		'filesystem',
51
-		'prelogin',
52
-		'authentication',
53
-		'logging',
54
-		'prevent_group_restriction',
55
-	];
56
-
57
-	/** @var \OCP\IUserSession */
58
-	private $userSession;
59
-
60
-	/** @var \OCP\IAppConfig */
61
-	private $appConfig;
62
-
63
-	/** @var \OCP\IGroupManager */
64
-	private $groupManager;
65
-
66
-	/** @var \OCP\ICacheFactory */
67
-	private $memCacheFactory;
68
-
69
-	/** @var string[] $appId => $enabled */
70
-	private $installedAppsCache;
71
-
72
-	/** @var string[] */
73
-	private $shippedApps;
74
-
75
-	/** @var string[] */
76
-	private $alwaysEnabled;
77
-
78
-	/** @var EventDispatcherInterface */
79
-	private $dispatcher;
80
-
81
-	/**
82
-	 * @param \OCP\IUserSession $userSession
83
-	 * @param \OCP\IAppConfig $appConfig
84
-	 * @param \OCP\IGroupManager $groupManager
85
-	 * @param \OCP\ICacheFactory $memCacheFactory
86
-	 */
87
-	public function __construct(IUserSession $userSession,
88
-								IAppConfig $appConfig,
89
-								IGroupManager $groupManager,
90
-								ICacheFactory $memCacheFactory,
91
-								EventDispatcherInterface $dispatcher) {
92
-		$this->userSession = $userSession;
93
-		$this->appConfig = $appConfig;
94
-		$this->groupManager = $groupManager;
95
-		$this->memCacheFactory = $memCacheFactory;
96
-		$this->dispatcher = $dispatcher;
97
-	}
98
-
99
-	/**
100
-	 * @return string[] $appId => $enabled
101
-	 */
102
-	private function getInstalledAppsValues() {
103
-		if (!$this->installedAppsCache) {
104
-			$values = $this->appConfig->getValues(false, 'enabled');
105
-
106
-			$alwaysEnabledApps = $this->getAlwaysEnabledApps();
107
-			foreach($alwaysEnabledApps as $appId) {
108
-				$values[$appId] = 'yes';
109
-			}
110
-
111
-			$this->installedAppsCache = array_filter($values, function ($value) {
112
-				return $value !== 'no';
113
-			});
114
-			ksort($this->installedAppsCache);
115
-		}
116
-		return $this->installedAppsCache;
117
-	}
118
-
119
-	/**
120
-	 * List all installed apps
121
-	 *
122
-	 * @return string[]
123
-	 */
124
-	public function getInstalledApps() {
125
-		return array_keys($this->getInstalledAppsValues());
126
-	}
127
-
128
-	/**
129
-	 * List all apps enabled for a user
130
-	 *
131
-	 * @param \OCP\IUser $user
132
-	 * @return string[]
133
-	 */
134
-	public function getEnabledAppsForUser(IUser $user) {
135
-		$apps = $this->getInstalledAppsValues();
136
-		$appsForUser = array_filter($apps, function ($enabled) use ($user) {
137
-			return $this->checkAppForUser($enabled, $user);
138
-		});
139
-		return array_keys($appsForUser);
140
-	}
141
-
142
-	/**
143
-	 * Check if an app is enabled for user
144
-	 *
145
-	 * @param string $appId
146
-	 * @param \OCP\IUser $user (optional) if not defined, the currently logged in user will be used
147
-	 * @return bool
148
-	 */
149
-	public function isEnabledForUser($appId, $user = null) {
150
-		if ($this->isAlwaysEnabled($appId)) {
151
-			return true;
152
-		}
153
-		if (is_null($user)) {
154
-			$user = $this->userSession->getUser();
155
-		}
156
-		$installedApps = $this->getInstalledAppsValues();
157
-		if (isset($installedApps[$appId])) {
158
-			return $this->checkAppForUser($installedApps[$appId], $user);
159
-		} else {
160
-			return false;
161
-		}
162
-	}
163
-
164
-	/**
165
-	 * @param string $enabled
166
-	 * @param IUser $user
167
-	 * @return bool
168
-	 */
169
-	private function checkAppForUser($enabled, $user) {
170
-		if ($enabled === 'yes') {
171
-			return true;
172
-		} elseif (is_null($user)) {
173
-			return false;
174
-		} else {
175
-			if(empty($enabled)){
176
-				return false;
177
-			}
178
-
179
-			$groupIds = json_decode($enabled);
180
-
181
-			if (!is_array($groupIds)) {
182
-				$jsonError = json_last_error();
183
-				\OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']);
184
-				return false;
185
-			}
186
-
187
-			$userGroups = $this->groupManager->getUserGroupIds($user);
188
-			foreach ($userGroups as $groupId) {
189
-				if (array_search($groupId, $groupIds) !== false) {
190
-					return true;
191
-				}
192
-			}
193
-			return false;
194
-		}
195
-	}
196
-
197
-	/**
198
-	 * Check if an app is installed in the instance
199
-	 *
200
-	 * @param string $appId
201
-	 * @return bool
202
-	 */
203
-	public function isInstalled($appId) {
204
-		$installedApps = $this->getInstalledAppsValues();
205
-		return isset($installedApps[$appId]);
206
-	}
207
-
208
-	/**
209
-	 * Enable an app for every user
210
-	 *
211
-	 * @param string $appId
212
-	 */
213
-	public function enableApp($appId) {
214
-		$this->installedAppsCache[$appId] = 'yes';
215
-		$this->appConfig->setValue($appId, 'enabled', 'yes');
216
-		$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
217
-			ManagerEvent::EVENT_APP_ENABLE, $appId
218
-		));
219
-		$this->clearAppsCache();
220
-	}
221
-
222
-	/**
223
-	 * Enable an app only for specific groups
224
-	 *
225
-	 * @param string $appId
226
-	 * @param \OCP\IGroup[] $groups
227
-	 * @throws \Exception if app can't be enabled for groups
228
-	 */
229
-	public function enableAppForGroups($appId, $groups) {
230
-		$info = $this->getAppInfo($appId);
231
-		if (!empty($info['types'])) {
232
-			$protectedTypes = array_intersect($this->protectedAppTypes, $info['types']);
233
-			if (!empty($protectedTypes)) {
234
-				throw new \Exception("$appId can't be enabled for groups.");
235
-			}
236
-		}
237
-
238
-		$groupIds = array_map(function ($group) {
239
-			/** @var \OCP\IGroup $group */
240
-			return $group->getGID();
241
-		}, $groups);
242
-		$this->installedAppsCache[$appId] = json_encode($groupIds);
243
-		$this->appConfig->setValue($appId, 'enabled', json_encode($groupIds));
244
-		$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent(
245
-			ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups
246
-		));
247
-		$this->clearAppsCache();
248
-	}
249
-
250
-	/**
251
-	 * Disable an app for every user
252
-	 *
253
-	 * @param string $appId
254
-	 * @throws \Exception if app can't be disabled
255
-	 */
256
-	public function disableApp($appId) {
257
-		if ($this->isAlwaysEnabled($appId)) {
258
-			throw new \Exception("$appId can't be disabled.");
259
-		}
260
-		unset($this->installedAppsCache[$appId]);
261
-		$this->appConfig->setValue($appId, 'enabled', 'no');
262
-		$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent(
263
-			ManagerEvent::EVENT_APP_DISABLE, $appId
264
-		));
265
-		$this->clearAppsCache();
266
-	}
267
-
268
-	/**
269
-	 * Clear the cached list of apps when enabling/disabling an app
270
-	 */
271
-	public function clearAppsCache() {
272
-		$settingsMemCache = $this->memCacheFactory->create('settings');
273
-		$settingsMemCache->clear('listApps');
274
-	}
275
-
276
-	/**
277
-	 * Returns a list of apps that need upgrade
278
-	 *
279
-	 * @param array $version ownCloud version as array of version components
280
-	 * @return array list of app info from apps that need an upgrade
281
-	 *
282
-	 * @internal
283
-	 */
284
-	public function getAppsNeedingUpgrade($ocVersion) {
285
-		$appsToUpgrade = [];
286
-		$apps = $this->getInstalledApps();
287
-		foreach ($apps as $appId) {
288
-			$appInfo = $this->getAppInfo($appId);
289
-			$appDbVersion = $this->appConfig->getValue($appId, 'installed_version');
290
-			if ($appDbVersion
291
-				&& isset($appInfo['version'])
292
-				&& version_compare($appInfo['version'], $appDbVersion, '>')
293
-				&& \OC_App::isAppCompatible($ocVersion, $appInfo)
294
-			) {
295
-				$appsToUpgrade[] = $appInfo;
296
-			}
297
-		}
298
-
299
-		return $appsToUpgrade;
300
-	}
301
-
302
-	/**
303
-	 * Returns the app information from "appinfo/info.xml".
304
-	 *
305
-	 * @param string $appId app id
306
-	 *
307
-	 * @return array app info
308
-	 *
309
-	 * @internal
310
-	 */
311
-	public function getAppInfo($appId) {
312
-		$appInfo = \OC_App::getAppInfo($appId);
313
-		if (!isset($appInfo['version'])) {
314
-			// read version from separate file
315
-			$appInfo['version'] = \OC_App::getAppVersion($appId);
316
-		}
317
-		return $appInfo;
318
-	}
319
-
320
-	/**
321
-	 * Returns a list of apps incompatible with the given version
322
-	 *
323
-	 * @param array $version ownCloud version as array of version components
324
-	 *
325
-	 * @return array list of app info from incompatible apps
326
-	 *
327
-	 * @internal
328
-	 */
329
-	public function getIncompatibleApps($version) {
330
-		$apps = $this->getInstalledApps();
331
-		$incompatibleApps = array();
332
-		foreach ($apps as $appId) {
333
-			$info = $this->getAppInfo($appId);
334
-			if (!\OC_App::isAppCompatible($version, $info)) {
335
-				$incompatibleApps[] = $info;
336
-			}
337
-		}
338
-		return $incompatibleApps;
339
-	}
340
-
341
-	/**
342
-	 * @inheritdoc
343
-	 */
344
-	public function isShipped($appId) {
345
-		$this->loadShippedJson();
346
-		return in_array($appId, $this->shippedApps);
347
-	}
348
-
349
-	private function isAlwaysEnabled($appId) {
350
-		$alwaysEnabled = $this->getAlwaysEnabledApps();
351
-		return in_array($appId, $alwaysEnabled);
352
-	}
353
-
354
-	private function loadShippedJson() {
355
-		if (is_null($this->shippedApps)) {
356
-			$shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
357
-			if (!file_exists($shippedJson)) {
358
-				throw new \Exception("File not found: $shippedJson");
359
-			}
360
-			$content = json_decode(file_get_contents($shippedJson), true);
361
-			$this->shippedApps = $content['shippedApps'];
362
-			$this->alwaysEnabled = $content['alwaysEnabled'];
363
-		}
364
-	}
365
-
366
-	/**
367
-	 * @inheritdoc
368
-	 */
369
-	public function getAlwaysEnabledApps() {
370
-		$this->loadShippedJson();
371
-		return $this->alwaysEnabled;
372
-	}
45
+    /**
46
+     * Apps with these types can not be enabled for certain groups only
47
+     * @var string[]
48
+     */
49
+    protected $protectedAppTypes = [
50
+        'filesystem',
51
+        'prelogin',
52
+        'authentication',
53
+        'logging',
54
+        'prevent_group_restriction',
55
+    ];
56
+
57
+    /** @var \OCP\IUserSession */
58
+    private $userSession;
59
+
60
+    /** @var \OCP\IAppConfig */
61
+    private $appConfig;
62
+
63
+    /** @var \OCP\IGroupManager */
64
+    private $groupManager;
65
+
66
+    /** @var \OCP\ICacheFactory */
67
+    private $memCacheFactory;
68
+
69
+    /** @var string[] $appId => $enabled */
70
+    private $installedAppsCache;
71
+
72
+    /** @var string[] */
73
+    private $shippedApps;
74
+
75
+    /** @var string[] */
76
+    private $alwaysEnabled;
77
+
78
+    /** @var EventDispatcherInterface */
79
+    private $dispatcher;
80
+
81
+    /**
82
+     * @param \OCP\IUserSession $userSession
83
+     * @param \OCP\IAppConfig $appConfig
84
+     * @param \OCP\IGroupManager $groupManager
85
+     * @param \OCP\ICacheFactory $memCacheFactory
86
+     */
87
+    public function __construct(IUserSession $userSession,
88
+                                IAppConfig $appConfig,
89
+                                IGroupManager $groupManager,
90
+                                ICacheFactory $memCacheFactory,
91
+                                EventDispatcherInterface $dispatcher) {
92
+        $this->userSession = $userSession;
93
+        $this->appConfig = $appConfig;
94
+        $this->groupManager = $groupManager;
95
+        $this->memCacheFactory = $memCacheFactory;
96
+        $this->dispatcher = $dispatcher;
97
+    }
98
+
99
+    /**
100
+     * @return string[] $appId => $enabled
101
+     */
102
+    private function getInstalledAppsValues() {
103
+        if (!$this->installedAppsCache) {
104
+            $values = $this->appConfig->getValues(false, 'enabled');
105
+
106
+            $alwaysEnabledApps = $this->getAlwaysEnabledApps();
107
+            foreach($alwaysEnabledApps as $appId) {
108
+                $values[$appId] = 'yes';
109
+            }
110
+
111
+            $this->installedAppsCache = array_filter($values, function ($value) {
112
+                return $value !== 'no';
113
+            });
114
+            ksort($this->installedAppsCache);
115
+        }
116
+        return $this->installedAppsCache;
117
+    }
118
+
119
+    /**
120
+     * List all installed apps
121
+     *
122
+     * @return string[]
123
+     */
124
+    public function getInstalledApps() {
125
+        return array_keys($this->getInstalledAppsValues());
126
+    }
127
+
128
+    /**
129
+     * List all apps enabled for a user
130
+     *
131
+     * @param \OCP\IUser $user
132
+     * @return string[]
133
+     */
134
+    public function getEnabledAppsForUser(IUser $user) {
135
+        $apps = $this->getInstalledAppsValues();
136
+        $appsForUser = array_filter($apps, function ($enabled) use ($user) {
137
+            return $this->checkAppForUser($enabled, $user);
138
+        });
139
+        return array_keys($appsForUser);
140
+    }
141
+
142
+    /**
143
+     * Check if an app is enabled for user
144
+     *
145
+     * @param string $appId
146
+     * @param \OCP\IUser $user (optional) if not defined, the currently logged in user will be used
147
+     * @return bool
148
+     */
149
+    public function isEnabledForUser($appId, $user = null) {
150
+        if ($this->isAlwaysEnabled($appId)) {
151
+            return true;
152
+        }
153
+        if (is_null($user)) {
154
+            $user = $this->userSession->getUser();
155
+        }
156
+        $installedApps = $this->getInstalledAppsValues();
157
+        if (isset($installedApps[$appId])) {
158
+            return $this->checkAppForUser($installedApps[$appId], $user);
159
+        } else {
160
+            return false;
161
+        }
162
+    }
163
+
164
+    /**
165
+     * @param string $enabled
166
+     * @param IUser $user
167
+     * @return bool
168
+     */
169
+    private function checkAppForUser($enabled, $user) {
170
+        if ($enabled === 'yes') {
171
+            return true;
172
+        } elseif (is_null($user)) {
173
+            return false;
174
+        } else {
175
+            if(empty($enabled)){
176
+                return false;
177
+            }
178
+
179
+            $groupIds = json_decode($enabled);
180
+
181
+            if (!is_array($groupIds)) {
182
+                $jsonError = json_last_error();
183
+                \OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']);
184
+                return false;
185
+            }
186
+
187
+            $userGroups = $this->groupManager->getUserGroupIds($user);
188
+            foreach ($userGroups as $groupId) {
189
+                if (array_search($groupId, $groupIds) !== false) {
190
+                    return true;
191
+                }
192
+            }
193
+            return false;
194
+        }
195
+    }
196
+
197
+    /**
198
+     * Check if an app is installed in the instance
199
+     *
200
+     * @param string $appId
201
+     * @return bool
202
+     */
203
+    public function isInstalled($appId) {
204
+        $installedApps = $this->getInstalledAppsValues();
205
+        return isset($installedApps[$appId]);
206
+    }
207
+
208
+    /**
209
+     * Enable an app for every user
210
+     *
211
+     * @param string $appId
212
+     */
213
+    public function enableApp($appId) {
214
+        $this->installedAppsCache[$appId] = 'yes';
215
+        $this->appConfig->setValue($appId, 'enabled', 'yes');
216
+        $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
217
+            ManagerEvent::EVENT_APP_ENABLE, $appId
218
+        ));
219
+        $this->clearAppsCache();
220
+    }
221
+
222
+    /**
223
+     * Enable an app only for specific groups
224
+     *
225
+     * @param string $appId
226
+     * @param \OCP\IGroup[] $groups
227
+     * @throws \Exception if app can't be enabled for groups
228
+     */
229
+    public function enableAppForGroups($appId, $groups) {
230
+        $info = $this->getAppInfo($appId);
231
+        if (!empty($info['types'])) {
232
+            $protectedTypes = array_intersect($this->protectedAppTypes, $info['types']);
233
+            if (!empty($protectedTypes)) {
234
+                throw new \Exception("$appId can't be enabled for groups.");
235
+            }
236
+        }
237
+
238
+        $groupIds = array_map(function ($group) {
239
+            /** @var \OCP\IGroup $group */
240
+            return $group->getGID();
241
+        }, $groups);
242
+        $this->installedAppsCache[$appId] = json_encode($groupIds);
243
+        $this->appConfig->setValue($appId, 'enabled', json_encode($groupIds));
244
+        $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent(
245
+            ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups
246
+        ));
247
+        $this->clearAppsCache();
248
+    }
249
+
250
+    /**
251
+     * Disable an app for every user
252
+     *
253
+     * @param string $appId
254
+     * @throws \Exception if app can't be disabled
255
+     */
256
+    public function disableApp($appId) {
257
+        if ($this->isAlwaysEnabled($appId)) {
258
+            throw new \Exception("$appId can't be disabled.");
259
+        }
260
+        unset($this->installedAppsCache[$appId]);
261
+        $this->appConfig->setValue($appId, 'enabled', 'no');
262
+        $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent(
263
+            ManagerEvent::EVENT_APP_DISABLE, $appId
264
+        ));
265
+        $this->clearAppsCache();
266
+    }
267
+
268
+    /**
269
+     * Clear the cached list of apps when enabling/disabling an app
270
+     */
271
+    public function clearAppsCache() {
272
+        $settingsMemCache = $this->memCacheFactory->create('settings');
273
+        $settingsMemCache->clear('listApps');
274
+    }
275
+
276
+    /**
277
+     * Returns a list of apps that need upgrade
278
+     *
279
+     * @param array $version ownCloud version as array of version components
280
+     * @return array list of app info from apps that need an upgrade
281
+     *
282
+     * @internal
283
+     */
284
+    public function getAppsNeedingUpgrade($ocVersion) {
285
+        $appsToUpgrade = [];
286
+        $apps = $this->getInstalledApps();
287
+        foreach ($apps as $appId) {
288
+            $appInfo = $this->getAppInfo($appId);
289
+            $appDbVersion = $this->appConfig->getValue($appId, 'installed_version');
290
+            if ($appDbVersion
291
+                && isset($appInfo['version'])
292
+                && version_compare($appInfo['version'], $appDbVersion, '>')
293
+                && \OC_App::isAppCompatible($ocVersion, $appInfo)
294
+            ) {
295
+                $appsToUpgrade[] = $appInfo;
296
+            }
297
+        }
298
+
299
+        return $appsToUpgrade;
300
+    }
301
+
302
+    /**
303
+     * Returns the app information from "appinfo/info.xml".
304
+     *
305
+     * @param string $appId app id
306
+     *
307
+     * @return array app info
308
+     *
309
+     * @internal
310
+     */
311
+    public function getAppInfo($appId) {
312
+        $appInfo = \OC_App::getAppInfo($appId);
313
+        if (!isset($appInfo['version'])) {
314
+            // read version from separate file
315
+            $appInfo['version'] = \OC_App::getAppVersion($appId);
316
+        }
317
+        return $appInfo;
318
+    }
319
+
320
+    /**
321
+     * Returns a list of apps incompatible with the given version
322
+     *
323
+     * @param array $version ownCloud version as array of version components
324
+     *
325
+     * @return array list of app info from incompatible apps
326
+     *
327
+     * @internal
328
+     */
329
+    public function getIncompatibleApps($version) {
330
+        $apps = $this->getInstalledApps();
331
+        $incompatibleApps = array();
332
+        foreach ($apps as $appId) {
333
+            $info = $this->getAppInfo($appId);
334
+            if (!\OC_App::isAppCompatible($version, $info)) {
335
+                $incompatibleApps[] = $info;
336
+            }
337
+        }
338
+        return $incompatibleApps;
339
+    }
340
+
341
+    /**
342
+     * @inheritdoc
343
+     */
344
+    public function isShipped($appId) {
345
+        $this->loadShippedJson();
346
+        return in_array($appId, $this->shippedApps);
347
+    }
348
+
349
+    private function isAlwaysEnabled($appId) {
350
+        $alwaysEnabled = $this->getAlwaysEnabledApps();
351
+        return in_array($appId, $alwaysEnabled);
352
+    }
353
+
354
+    private function loadShippedJson() {
355
+        if (is_null($this->shippedApps)) {
356
+            $shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
357
+            if (!file_exists($shippedJson)) {
358
+                throw new \Exception("File not found: $shippedJson");
359
+            }
360
+            $content = json_decode(file_get_contents($shippedJson), true);
361
+            $this->shippedApps = $content['shippedApps'];
362
+            $this->alwaysEnabled = $content['alwaysEnabled'];
363
+        }
364
+    }
365
+
366
+    /**
367
+     * @inheritdoc
368
+     */
369
+    public function getAlwaysEnabledApps() {
370
+        $this->loadShippedJson();
371
+        return $this->alwaysEnabled;
372
+    }
373 373
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 			$values = $this->appConfig->getValues(false, 'enabled');
105 105
 
106 106
 			$alwaysEnabledApps = $this->getAlwaysEnabledApps();
107
-			foreach($alwaysEnabledApps as $appId) {
107
+			foreach ($alwaysEnabledApps as $appId) {
108 108
 				$values[$appId] = 'yes';
109 109
 			}
110 110
 
111
-			$this->installedAppsCache = array_filter($values, function ($value) {
111
+			$this->installedAppsCache = array_filter($values, function($value) {
112 112
 				return $value !== 'no';
113 113
 			});
114 114
 			ksort($this->installedAppsCache);
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function getEnabledAppsForUser(IUser $user) {
135 135
 		$apps = $this->getInstalledAppsValues();
136
-		$appsForUser = array_filter($apps, function ($enabled) use ($user) {
136
+		$appsForUser = array_filter($apps, function($enabled) use ($user) {
137 137
 			return $this->checkAppForUser($enabled, $user);
138 138
 		});
139 139
 		return array_keys($appsForUser);
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		} elseif (is_null($user)) {
173 173
 			return false;
174 174
 		} else {
175
-			if(empty($enabled)){
175
+			if (empty($enabled)) {
176 176
 				return false;
177 177
 			}
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 			if (!is_array($groupIds)) {
182 182
 				$jsonError = json_last_error();
183
-				\OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']);
183
+				\OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: '.print_r($enabled, true).' - json error code: '.$jsonError, ['app' => 'lib']);
184 184
 				return false;
185 185
 			}
186 186
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			}
236 236
 		}
237 237
 
238
-		$groupIds = array_map(function ($group) {
238
+		$groupIds = array_map(function($group) {
239 239
 			/** @var \OCP\IGroup $group */
240 240
 			return $group->getGID();
241 241
 		}, $groups);
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
 	private function loadShippedJson() {
355 355
 		if (is_null($this->shippedApps)) {
356
-			$shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
356
+			$shippedJson = \OC::$SERVERROOT.'/core/shipped.json';
357 357
 			if (!file_exists($shippedJson)) {
358 358
 				throw new \Exception("File not found: $shippedJson");
359 359
 			}
Please login to merge, or discard this patch.