@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $keys = $this->getServersConfig($referenceConfigkey); |
97 | 97 | |
98 | 98 | $result = array(); |
99 | - foreach($keys as $key) { |
|
99 | + foreach ($keys as $key) { |
|
100 | 100 | $len = strlen($key) - strlen($referenceConfigkey); |
101 | 101 | $prefix = substr($key, 0, $len); |
102 | 102 | $result[$prefix] = $this->config->getAppValue('user_ldap', $key); |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | public function getNextServerConfigurationPrefix() { |
114 | 114 | $serverConnections = $this->getServerConfigurationPrefixes(); |
115 | 115 | |
116 | - if(count($serverConnections) === 0) { |
|
116 | + if (count($serverConnections) === 0) { |
|
117 | 117 | return 's01'; |
118 | 118 | } |
119 | 119 | |
120 | 120 | sort($serverConnections); |
121 | 121 | $lastKey = array_pop($serverConnections); |
122 | 122 | $lastNumber = intval(str_replace('s', '', $lastKey)); |
123 | - $nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT); |
|
123 | + $nextPrefix = 's'.str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT); |
|
124 | 124 | return $nextPrefix; |
125 | 125 | } |
126 | 126 | |
127 | 127 | private function getServersConfig($value) { |
128 | - $regex = '/' . $value . '$/S'; |
|
128 | + $regex = '/'.$value.'$/S'; |
|
129 | 129 | |
130 | 130 | $keys = $this->config->getAppKeys('user_ldap'); |
131 | 131 | $result = []; |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | * @return bool true on success, false otherwise |
145 | 145 | */ |
146 | 146 | public function deleteServerConfiguration($prefix) { |
147 | - if(!in_array($prefix, self::getServerConfigurationPrefixes())) { |
|
147 | + if (!in_array($prefix, self::getServerConfigurationPrefixes())) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
151 | 151 | $saveOtherConfigurations = ''; |
152 | - if(empty($prefix)) { |
|
152 | + if (empty($prefix)) { |
|
153 | 153 | $saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\''; |
154 | 154 | } |
155 | 155 | |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | '); |
164 | 164 | $delRows = $query->execute(array($prefix.'%')); |
165 | 165 | |
166 | - if(\OCP\DB::isError($delRows)) { |
|
166 | + if (\OCP\DB::isError($delRows)) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | |
170 | - if($delRows === 0) { |
|
170 | + if ($delRows === 0) { |
|
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $all = $this->getServerConfigurationPrefixes(false); |
184 | 184 | $active = $this->getServerConfigurationPrefixes(true); |
185 | 185 | |
186 | - if(!is_array($all) || !is_array($active)) { |
|
186 | + if (!is_array($all) || !is_array($active)) { |
|
187 | 187 | throw new \Exception('Unexpected Return Value'); |
188 | 188 | } |
189 | 189 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function getDomainFromURL($url) { |
199 | 199 | $uinfo = parse_url($url); |
200 | - if(!is_array($uinfo)) { |
|
200 | + if (!is_array($uinfo)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $domain = false; |
205 | - if(isset($uinfo['host'])) { |
|
205 | + if (isset($uinfo['host'])) { |
|
206 | 206 | $domain = $uinfo['host']; |
207 | - } else if(isset($uinfo['path'])) { |
|
207 | + } else if (isset($uinfo['path'])) { |
|
208 | 208 | $domain = $uinfo['path']; |
209 | 209 | } |
210 | 210 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function setLDAPProvider() { |
220 | 220 | $current = \OC::$server->getConfig()->getSystemValue('ldapProviderFactory', null); |
221 | - if(is_null($current)) { |
|
221 | + if (is_null($current)) { |
|
222 | 222 | \OC::$server->getConfig()->setSystemValue('ldapProviderFactory', '\\OCA\\User_LDAP\\LDAPProviderFactory'); |
223 | 223 | } |
224 | 224 | } |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function sanitizeDN($dn) { |
232 | 232 | //treating multiple base DNs |
233 | - if(is_array($dn)) { |
|
233 | + if (is_array($dn)) { |
|
234 | 234 | $result = array(); |
235 | - foreach($dn as $singleDN) { |
|
235 | + foreach ($dn as $singleDN) { |
|
236 | 236 | $result[] = $this->sanitizeDN($singleDN); |
237 | 237 | } |
238 | 238 | return $result; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @throws \Exception |
284 | 284 | */ |
285 | 285 | public static function loginName2UserName($param) { |
286 | - if(!isset($param['uid'])) { |
|
286 | + if (!isset($param['uid'])) { |
|
287 | 287 | throw new \Exception('key uid is expected to be set in $param'); |
288 | 288 | } |
289 | 289 | |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | $notificationManager = \OC::$server->getNotificationManager(); |
297 | 297 | $userSession = \OC::$server->getUserSession(); |
298 | 298 | |
299 | - $userBackend = new User_Proxy( |
|
299 | + $userBackend = new User_Proxy( |
|
300 | 300 | $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession |
301 | 301 | ); |
302 | - $uid = $userBackend->loginName2UserName($param['uid'] ); |
|
303 | - if($uid !== false) { |
|
302 | + $uid = $userBackend->loginName2UserName($param['uid']); |
|
303 | + if ($uid !== false) { |
|
304 | 304 | $param['uid'] = $uid; |
305 | 305 | } |
306 | 306 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig, |
51 | 51 | INotificationManager $notificationManager, IUserSession $userSession) { |
52 | 52 | parent::__construct($ldap); |
53 | - foreach($serverConfigPrefixes as $configPrefix) { |
|
53 | + foreach ($serverConfigPrefixes as $configPrefix) { |
|
54 | 54 | $this->backends[$configPrefix] = |
55 | 55 | new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession); |
56 | - if(is_null($this->refBackend)) { |
|
56 | + if (is_null($this->refBackend)) { |
|
57 | 57 | $this->refBackend = &$this->backends[$configPrefix]; |
58 | 58 | } |
59 | 59 | } |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | */ |
69 | 69 | protected function walkBackends($uid, $method, $parameters) { |
70 | 70 | $cacheKey = $this->getUserCacheKey($uid); |
71 | - foreach($this->backends as $configPrefix => $backend) { |
|
71 | + foreach ($this->backends as $configPrefix => $backend) { |
|
72 | 72 | $instance = $backend; |
73 | - if(!method_exists($instance, $method) |
|
73 | + if (!method_exists($instance, $method) |
|
74 | 74 | && method_exists($this->getAccess($configPrefix), $method)) { |
75 | 75 | $instance = $this->getAccess($configPrefix); |
76 | 76 | } |
77 | - if($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
77 | + if ($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
78 | 78 | $this->writeToCache($cacheKey, $configPrefix); |
79 | 79 | return $result; |
80 | 80 | } |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | $cacheKey = $this->getUserCacheKey($uid); |
95 | 95 | $prefix = $this->getFromCache($cacheKey); |
96 | 96 | //in case the uid has been found in the past, try this stored connection first |
97 | - if(!is_null($prefix)) { |
|
98 | - if(isset($this->backends[$prefix])) { |
|
97 | + if (!is_null($prefix)) { |
|
98 | + if (isset($this->backends[$prefix])) { |
|
99 | 99 | $instance = $this->backends[$prefix]; |
100 | - if(!method_exists($instance, $method) |
|
100 | + if (!method_exists($instance, $method) |
|
101 | 101 | && method_exists($this->getAccess($prefix), $method)) { |
102 | 102 | $instance = $this->getAccess($prefix); |
103 | 103 | } |
104 | 104 | $result = call_user_func_array(array($instance, $method), $parameters); |
105 | - if($result === $passOnWhen) { |
|
105 | + if ($result === $passOnWhen) { |
|
106 | 106 | //not found here, reset cache to null if user vanished |
107 | 107 | //because sometimes methods return false with a reason |
108 | 108 | $userExists = call_user_func_array( |
109 | 109 | array($this->backends[$prefix], 'userExists'), |
110 | 110 | array($uid) |
111 | 111 | ); |
112 | - if(!$userExists) { |
|
112 | + if (!$userExists) { |
|
113 | 113 | $this->writeToCache($cacheKey, null); |
114 | 114 | } |
115 | 115 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function getUsers($search = '', $limit = 10, $offset = 0) { |
152 | 152 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
153 | 153 | $users = array(); |
154 | - foreach($this->backends as $backend) { |
|
154 | + foreach ($this->backends as $backend) { |
|
155 | 155 | $backendUsers = $backend->getUsers($search, $limit, $offset); |
156 | 156 | if (is_array($backendUsers)) { |
157 | 157 | $users = array_merge($users, $backendUsers); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return string|false |
200 | 200 | */ |
201 | 201 | public function loginName2UserName($loginName) { |
202 | - $id = 'LOGINNAME,' . $loginName; |
|
202 | + $id = 'LOGINNAME,'.$loginName; |
|
203 | 203 | return $this->handleRequest($id, 'loginName2UserName', array($loginName)); |
204 | 204 | } |
205 | 205 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @return string|false with the username |
211 | 211 | */ |
212 | 212 | public function dn2UserName($dn) { |
213 | - $id = 'DN,' . $dn; |
|
213 | + $id = 'DN,'.$dn; |
|
214 | 214 | return $this->handleRequest($id, 'dn2UserName', array($dn)); |
215 | 215 | } |
216 | 216 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
252 | 252 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
253 | 253 | $users = array(); |
254 | - foreach($this->backends as $backend) { |
|
254 | + foreach ($this->backends as $backend) { |
|
255 | 255 | $backendUsers = $backend->getDisplayNames($search, $limit, $offset); |
256 | 256 | if (is_array($backendUsers)) { |
257 | 257 | $users = $users + $backendUsers; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function countUsers() { |
297 | 297 | $users = false; |
298 | - foreach($this->backends as $backend) { |
|
298 | + foreach ($this->backends as $backend) { |
|
299 | 299 | $backendUsers = $backend->countUsers(); |
300 | 300 | if ($backendUsers !== false) { |
301 | 301 | $users += $backendUsers; |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function canChangeAvatar($uid) { |
91 | 91 | $user = $this->access->userManager->get($uid); |
92 | - if(!$user instanceof User) { |
|
92 | + if (!$user instanceof User) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | - if($user->getAvatarImage() === false) { |
|
95 | + if ($user->getAvatarImage() === false) { |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | public function loginName2UserName($loginName) { |
109 | 109 | $cacheKey = 'loginName2UserName-'.$loginName; |
110 | 110 | $username = $this->access->connection->getFromCache($cacheKey); |
111 | - if(!is_null($username)) { |
|
111 | + if (!is_null($username)) { |
|
112 | 112 | return $username; |
113 | 113 | } |
114 | 114 | |
115 | 115 | try { |
116 | 116 | $ldapRecord = $this->getLDAPUserByLoginName($loginName); |
117 | 117 | $user = $this->access->userManager->get($ldapRecord['dn'][0]); |
118 | - if($user instanceof OfflineUser) { |
|
118 | + if ($user instanceof OfflineUser) { |
|
119 | 119 | // this path is not really possible, however get() is documented |
120 | 120 | // to return User or OfflineUser so we are very defensive here. |
121 | 121 | $this->access->connection->writeToCache($cacheKey, false); |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | //find out dn of the user name |
152 | 152 | $attrs = $this->access->userManager->getAttributes(); |
153 | 153 | $users = $this->access->fetchUsersByLoginName($loginName, $attrs); |
154 | - if(count($users) < 1) { |
|
155 | - throw new NotOnLDAP('No user available for the given login name on ' . |
|
156 | - $this->access->connection->ldapHost . ':' . $this->access->connection->ldapPort); |
|
154 | + if (count($users) < 1) { |
|
155 | + throw new NotOnLDAP('No user available for the given login name on '. |
|
156 | + $this->access->connection->ldapHost.':'.$this->access->connection->ldapPort); |
|
157 | 157 | } |
158 | 158 | return $users[0]; |
159 | 159 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | public function checkPassword($uid, $password) { |
169 | 169 | try { |
170 | 170 | $ldapRecord = $this->getLDAPUserByLoginName($uid); |
171 | - } catch(NotOnLDAP $e) { |
|
172 | - if($this->ocConfig->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { |
|
171 | + } catch (NotOnLDAP $e) { |
|
172 | + if ($this->ocConfig->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { |
|
173 | 173 | \OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']); |
174 | 174 | } |
175 | 175 | return false; |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | $dn = $ldapRecord['dn'][0]; |
178 | 178 | $user = $this->access->userManager->get($dn); |
179 | 179 | |
180 | - if(!$user instanceof User) { |
|
180 | + if (!$user instanceof User) { |
|
181 | 181 | Util::writeLog('user_ldap', |
182 | - 'LDAP Login: Could not get user object for DN ' . $dn . |
|
182 | + 'LDAP Login: Could not get user object for DN '.$dn. |
|
183 | 183 | '. Maybe the LDAP entry has no set display name attribute?', |
184 | 184 | Util::WARN); |
185 | 185 | return false; |
186 | 186 | } |
187 | - if($user->getUsername() !== false) { |
|
187 | + if ($user->getUsername() !== false) { |
|
188 | 188 | //are the credentials OK? |
189 | - if(!$this->access->areCredentialsValid($dn, $password)) { |
|
189 | + if (!$this->access->areCredentialsValid($dn, $password)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | public function setPassword($uid, $password) { |
210 | 210 | $user = $this->access->userManager->get($uid); |
211 | 211 | |
212 | - if(!$user instanceof User) { |
|
213 | - throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid . |
|
212 | + if (!$user instanceof User) { |
|
213 | + throw new \Exception('LDAP setPassword: Could not get user object for uid '.$uid. |
|
214 | 214 | '. Maybe the LDAP entry has no set display name attribute?'); |
215 | 215 | } |
216 | - if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
216 | + if ($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
217 | 217 | $ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN; |
218 | 218 | $turnOnPasswordChange = $this->access->connection->turnOnPasswordChange; |
219 | 219 | if (!empty($ldapDefaultPPolicyDN) && (intval($turnOnPasswordChange) === 1)) { |
@@ -245,18 +245,18 @@ discard block |
||
245 | 245 | |
246 | 246 | //check if users are cached, if so return |
247 | 247 | $ldap_users = $this->access->connection->getFromCache($cachekey); |
248 | - if(!is_null($ldap_users)) { |
|
248 | + if (!is_null($ldap_users)) { |
|
249 | 249 | return $ldap_users; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // if we'd pass -1 to LDAP search, we'd end up in a Protocol |
253 | 253 | // error. With a limit of 0, we get 0 results. So we pass null. |
254 | - if($limit <= 0) { |
|
254 | + if ($limit <= 0) { |
|
255 | 255 | $limit = null; |
256 | 256 | } |
257 | 257 | $filter = $this->access->combineFilterWithAnd(array( |
258 | 258 | $this->access->connection->ldapUserFilter, |
259 | - $this->access->connection->ldapUserDisplayName . '=*', |
|
259 | + $this->access->connection->ldapUserDisplayName.'=*', |
|
260 | 260 | $this->access->getFilterPartForUserSearch($search) |
261 | 261 | )); |
262 | 262 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $this->access->userManager->getAttributes(true), |
270 | 270 | $limit, $offset); |
271 | 271 | $ldap_users = $this->access->nextcloudUserNames($ldap_users); |
272 | - Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', Util::DEBUG); |
|
272 | + Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users).' Users found', Util::DEBUG); |
|
273 | 273 | |
274 | 274 | $this->access->connection->writeToCache($cachekey, $ldap_users); |
275 | 275 | return $ldap_users; |
@@ -285,29 +285,29 @@ discard block |
||
285 | 285 | * @throws \OC\ServerNotAvailableException |
286 | 286 | */ |
287 | 287 | public function userExistsOnLDAP($user) { |
288 | - if(is_string($user)) { |
|
288 | + if (is_string($user)) { |
|
289 | 289 | $user = $this->access->userManager->get($user); |
290 | 290 | } |
291 | - if(is_null($user)) { |
|
291 | + if (is_null($user)) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | 295 | $dn = $user->getDN(); |
296 | 296 | //check if user really still exists by reading its entry |
297 | - if(!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
297 | + if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
298 | 298 | $lcr = $this->access->connection->getConnectionResource(); |
299 | - if(is_null($lcr)) { |
|
300 | - throw new \Exception('No LDAP Connection to server ' . $this->access->connection->ldapHost); |
|
299 | + if (is_null($lcr)) { |
|
300 | + throw new \Exception('No LDAP Connection to server '.$this->access->connection->ldapHost); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | try { |
304 | 304 | $uuid = $this->access->getUserMapper()->getUUIDByDN($dn); |
305 | - if(!$uuid) { |
|
305 | + if (!$uuid) { |
|
306 | 306 | return false; |
307 | 307 | } |
308 | 308 | $newDn = $this->access->getUserDnByUuid($uuid); |
309 | 309 | //check if renamed user is still valid by reapplying the ldap filter |
310 | - if(!is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) { |
|
310 | + if (!is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) { |
|
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | $this->access->getUserMapper()->setDNbyUUID($newDn, $uuid); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if($user instanceof OfflineUser) { |
|
320 | + if ($user instanceof OfflineUser) { |
|
321 | 321 | $user->unmark(); |
322 | 322 | } |
323 | 323 | |
@@ -332,18 +332,18 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function userExists($uid) { |
334 | 334 | $userExists = $this->access->connection->getFromCache('userExists'.$uid); |
335 | - if(!is_null($userExists)) { |
|
336 | - return (bool)$userExists; |
|
335 | + if (!is_null($userExists)) { |
|
336 | + return (bool) $userExists; |
|
337 | 337 | } |
338 | 338 | //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking. |
339 | 339 | $user = $this->access->userManager->get($uid); |
340 | 340 | |
341 | - if(is_null($user)) { |
|
341 | + if (is_null($user)) { |
|
342 | 342 | Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. |
343 | 343 | $this->access->connection->ldapHost, Util::DEBUG); |
344 | 344 | $this->access->connection->writeToCache('userExists'.$uid, false); |
345 | 345 | return false; |
346 | - } else if($user instanceof OfflineUser) { |
|
346 | + } else if ($user instanceof OfflineUser) { |
|
347 | 347 | //express check for users marked as deleted. Returning true is |
348 | 348 | //necessary for cleanup |
349 | 349 | return true; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | $result = $this->userExistsOnLDAP($user); |
353 | 353 | $this->access->connection->writeToCache('userExists'.$uid, $result); |
354 | - if($result === true) { |
|
354 | + if ($result === true) { |
|
355 | 355 | $user->update(); |
356 | 356 | } |
357 | 357 | return $result; |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function deleteUser($uid) { |
367 | 367 | $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); |
368 | - if(intval($marked) === 0) { |
|
368 | + if (intval($marked) === 0) { |
|
369 | 369 | \OC::$server->getLogger()->notice( |
370 | - 'User '.$uid . ' is not marked as deleted, not cleaning up.', |
|
370 | + 'User '.$uid.' is not marked as deleted, not cleaning up.', |
|
371 | 371 | array('app' => 'user_ldap')); |
372 | 372 | return false; |
373 | 373 | } |
374 | - \OC::$server->getLogger()->info('Cleaning up after user ' . $uid, |
|
374 | + \OC::$server->getLogger()->info('Cleaning up after user '.$uid, |
|
375 | 375 | array('app' => 'user_ldap')); |
376 | 376 | |
377 | 377 | $this->access->getUserMapper()->unmap($uid); |
@@ -389,28 +389,28 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public function getHome($uid) { |
391 | 391 | // user Exists check required as it is not done in user proxy! |
392 | - if(!$this->userExists($uid)) { |
|
392 | + if (!$this->userExists($uid)) { |
|
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $cacheKey = 'getHome'.$uid; |
397 | 397 | $path = $this->access->connection->getFromCache($cacheKey); |
398 | - if(!is_null($path)) { |
|
398 | + if (!is_null($path)) { |
|
399 | 399 | return $path; |
400 | 400 | } |
401 | 401 | |
402 | 402 | // early return path if it is a deleted user |
403 | 403 | $user = $this->access->userManager->get($uid); |
404 | - if($user instanceof OfflineUser) { |
|
405 | - if($this->currentUserInDeletionProcess !== null |
|
404 | + if ($user instanceof OfflineUser) { |
|
405 | + if ($this->currentUserInDeletionProcess !== null |
|
406 | 406 | && $this->currentUserInDeletionProcess === $user->getOCName() |
407 | 407 | ) { |
408 | 408 | return $user->getHomePath(); |
409 | 409 | } else { |
410 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
410 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
411 | 411 | } |
412 | 412 | } else if ($user === null) { |
413 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
413 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | $path = $user->getHomePath(); |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | * @return string|false display name |
426 | 426 | */ |
427 | 427 | public function getDisplayName($uid) { |
428 | - if(!$this->userExists($uid)) { |
|
428 | + if (!$this->userExists($uid)) { |
|
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | 432 | $cacheKey = 'getDisplayName'.$uid; |
433 | - if(!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
433 | + if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
434 | 434 | return $displayName; |
435 | 435 | } |
436 | 436 | |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | $this->access->username2dn($uid), |
448 | 448 | $this->access->connection->ldapUserDisplayName); |
449 | 449 | |
450 | - if($displayName && (count($displayName) > 0)) { |
|
450 | + if ($displayName && (count($displayName) > 0)) { |
|
451 | 451 | $displayName = $displayName[0]; |
452 | 452 | |
453 | - if (is_array($displayName2)){ |
|
453 | + if (is_array($displayName2)) { |
|
454 | 454 | $displayName2 = count($displayName2) > 0 ? $displayName2[0] : ''; |
455 | 455 | } |
456 | 456 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
481 | 481 | $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset; |
482 | - if(!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
482 | + if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
483 | 483 | return $displayNames; |
484 | 484 | } |
485 | 485 | |
@@ -501,12 +501,12 @@ discard block |
||
501 | 501 | * compared with \OC\User\Backend::CREATE_USER etc. |
502 | 502 | */ |
503 | 503 | public function implementsActions($actions) { |
504 | - return (bool)((Backend::CHECK_PASSWORD |
|
504 | + return (bool) ((Backend::CHECK_PASSWORD |
|
505 | 505 | | Backend::GET_HOME |
506 | 506 | | Backend::GET_DISPLAYNAME |
507 | 507 | | Backend::PROVIDE_AVATAR |
508 | 508 | | Backend::COUNT_USERS |
509 | - | ((intval($this->access->connection->turnOnPasswordChange) === 1)?(Backend::SET_PASSWORD):0)) |
|
509 | + | ((intval($this->access->connection->turnOnPasswordChange) === 1) ? (Backend::SET_PASSWORD) : 0)) |
|
510 | 510 | & $actions); |
511 | 511 | } |
512 | 512 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | public function countUsers() { |
526 | 526 | $filter = $this->access->getFilterForUserCount(); |
527 | 527 | $cacheKey = 'countUsers-'.$filter; |
528 | - if(!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
528 | + if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
529 | 529 | return $entries; |
530 | 530 | } |
531 | 531 | $entries = $this->access->countUsers($filter); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * Backend name to be shown in user management |
538 | 538 | * @return string the name of the backend to be shown |
539 | 539 | */ |
540 | - public function getBackendName(){ |
|
540 | + public function getBackendName() { |
|
541 | 541 | return 'LDAP'; |
542 | 542 | } |
543 | 543 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig()); |
31 | 31 | $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
32 | -if(count($configPrefixes) > 0) { |
|
32 | +if (count($configPrefixes) > 0) { |
|
33 | 33 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
34 | 34 | $ocConfig = \OC::$server->getConfig(); |
35 | 35 | $notificationManager = \OC::$server->getNotificationManager(); |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | }); |
47 | 47 | $userSession = \OC::$server->getUserSession(); |
48 | 48 | |
49 | - $userBackend = new OCA\User_LDAP\User_Proxy( |
|
49 | + $userBackend = new OCA\User_LDAP\User_Proxy( |
|
50 | 50 | $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession |
51 | 51 | ); |
52 | - $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
52 | + $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
53 | 53 | // register user backend |
54 | 54 | OC_User::useBackend($userBackend); |
55 | 55 | \OC::$server->getGroupManager()->addBackend($groupBackend); |