@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function __construct($configPrefix, $autoRead = true) { |
119 | 119 | $this->configPrefix = $configPrefix; |
120 | - if($autoRead) { |
|
120 | + if ($autoRead) { |
|
121 | 121 | $this->readConfiguration(); |
122 | 122 | } |
123 | 123 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return mixed|null |
128 | 128 | */ |
129 | 129 | public function __get($name) { |
130 | - if(isset($this->config[$name])) { |
|
130 | + if (isset($this->config[$name])) { |
|
131 | 131 | return $this->config[$name]; |
132 | 132 | } |
133 | 133 | return null; |
@@ -158,22 +158,22 @@ discard block |
||
158 | 158 | * @return false|null |
159 | 159 | */ |
160 | 160 | public function setConfiguration($config, &$applied = null) { |
161 | - if(!is_array($config)) { |
|
161 | + if (!is_array($config)) { |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $cta = $this->getConfigTranslationArray(); |
166 | - foreach($config as $inputKey => $val) { |
|
167 | - if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) { |
|
166 | + foreach ($config as $inputKey => $val) { |
|
167 | + if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) { |
|
168 | 168 | $key = $cta[$inputKey]; |
169 | - } elseif(array_key_exists($inputKey, $this->config)) { |
|
169 | + } elseif (array_key_exists($inputKey, $this->config)) { |
|
170 | 170 | $key = $inputKey; |
171 | 171 | } else { |
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | |
175 | 175 | $setMethod = 'setValue'; |
176 | - switch($key) { |
|
176 | + switch ($key) { |
|
177 | 177 | case 'ldapAgentPassword': |
178 | 178 | $setMethod = 'setRawValue'; |
179 | 179 | break; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | break; |
198 | 198 | } |
199 | 199 | $this->$setMethod($key, $val); |
200 | - if(is_array($applied)) { |
|
200 | + if (is_array($applied)) { |
|
201 | 201 | $applied[] = $inputKey; |
202 | 202 | // storing key as index avoids duplication, and as value for simplicity |
203 | 203 | } |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | public function readConfiguration() { |
210 | - if(!$this->configRead && !is_null($this->configPrefix)) { |
|
210 | + if (!$this->configRead && !is_null($this->configPrefix)) { |
|
211 | 211 | $cta = array_flip($this->getConfigTranslationArray()); |
212 | - foreach($this->config as $key => $val) { |
|
213 | - if(!isset($cta[$key])) { |
|
212 | + foreach ($this->config as $key => $val) { |
|
213 | + if (!isset($cta[$key])) { |
|
214 | 214 | //some are determined |
215 | 215 | continue; |
216 | 216 | } |
217 | 217 | $dbKey = $cta[$key]; |
218 | - switch($key) { |
|
218 | + switch ($key) { |
|
219 | 219 | case 'ldapBase': |
220 | 220 | case 'ldapBaseUsers': |
221 | 221 | case 'ldapBaseGroups': |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function saveConfiguration() { |
260 | 260 | $cta = array_flip($this->getConfigTranslationArray()); |
261 | - foreach($this->unsavedChanges as $key) { |
|
261 | + foreach ($this->unsavedChanges as $key) { |
|
262 | 262 | $value = $this->config[$key]; |
263 | 263 | switch ($key) { |
264 | 264 | case 'ldapAgentPassword': |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | case 'ldapGroupFilterObjectclass': |
275 | 275 | case 'ldapGroupFilterGroups': |
276 | 276 | case 'ldapLoginFilterAttributes': |
277 | - if(is_array($value)) { |
|
277 | + if (is_array($value)) { |
|
278 | 278 | $value = implode("\n", $value); |
279 | 279 | } |
280 | 280 | break; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | case 'ldapUuidGroupAttribute': |
285 | 285 | continue 2; |
286 | 286 | } |
287 | - if(is_null($value)) { |
|
287 | + if (is_null($value)) { |
|
288 | 288 | $value = ''; |
289 | 289 | } |
290 | 290 | $this->saveValue($cta[$key], $value); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function getMultiLine($varName) { |
301 | 301 | $value = $this->getValue($varName); |
302 | - if(empty($value)) { |
|
302 | + if (empty($value)) { |
|
303 | 303 | $value = ''; |
304 | 304 | } else { |
305 | 305 | $value = preg_split('/\r\n|\r|\n/', $value); |
@@ -315,21 +315,21 @@ discard block |
||
315 | 315 | * @param array|string $value to set |
316 | 316 | */ |
317 | 317 | protected function setMultiLine($varName, $value) { |
318 | - if(empty($value)) { |
|
318 | + if (empty($value)) { |
|
319 | 319 | $value = ''; |
320 | 320 | } else if (!is_array($value)) { |
321 | 321 | $value = preg_split('/\r\n|\r|\n|;/', $value); |
322 | - if($value === false) { |
|
322 | + if ($value === false) { |
|
323 | 323 | $value = ''; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | - if(!is_array($value)) { |
|
327 | + if (!is_array($value)) { |
|
328 | 328 | $finalValue = trim($value); |
329 | 329 | } else { |
330 | 330 | $finalValue = []; |
331 | - foreach($value as $key => $val) { |
|
332 | - if(is_string($val)) { |
|
331 | + foreach ($value as $key => $val) { |
|
332 | + if (is_string($val)) { |
|
333 | 333 | $val = trim($val); |
334 | 334 | if ($val !== '') { |
335 | 335 | //accidental line breaks are not wanted and can cause |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | protected function getValue($varName) { |
378 | 378 | static $defaults; |
379 | - if(is_null($defaults)) { |
|
379 | + if (is_null($defaults)) { |
|
380 | 380 | $defaults = $this->getDefaults(); |
381 | 381 | } |
382 | 382 | return \OC::$server->getConfig()->getAppValue('user_ldap', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param mixed $value to set |
392 | 392 | */ |
393 | 393 | protected function setValue($varName, $value) { |
394 | - if(is_string($value)) { |
|
394 | + if (is_string($value)) { |
|
395 | 395 | $value = trim($value); |
396 | 396 | } |
397 | 397 | $this->config[$varName] = $value; |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | 'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL', |
543 | 543 | 'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN', |
544 | 544 | 'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute', |
545 | - 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig |
|
545 | + 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig |
|
546 | 546 | ]; |
547 | 547 | return $array; |
548 | 548 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @throws \RuntimeException |
554 | 554 | */ |
555 | 555 | public function resolveRule($rule) { |
556 | - if($rule === 'avatar') { |
|
556 | + if ($rule === 'avatar') { |
|
557 | 557 | return $this->getAvatarAttributes(); |
558 | 558 | } |
559 | 559 | throw new \RuntimeException('Invalid rule'); |
@@ -563,17 +563,17 @@ discard block |
||
563 | 563 | $value = $this->ldapUserAvatarRule ?: self::AVATAR_PREFIX_DEFAULT; |
564 | 564 | $defaultAttributes = ['jpegphoto', 'thumbnailphoto']; |
565 | 565 | |
566 | - if($value === self::AVATAR_PREFIX_NONE) { |
|
566 | + if ($value === self::AVATAR_PREFIX_NONE) { |
|
567 | 567 | return []; |
568 | 568 | } |
569 | - if(strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) { |
|
569 | + if (strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) { |
|
570 | 570 | $attribute = trim(substr($value, strlen(self::AVATAR_PREFIX_DATA_ATTRIBUTE))); |
571 | - if($attribute === '') { |
|
571 | + if ($attribute === '') { |
|
572 | 572 | return $defaultAttributes; |
573 | 573 | } |
574 | 574 | return [strtolower($attribute)]; |
575 | 575 | } |
576 | - if($value !== self::AVATAR_PREFIX_DEFAULT) { |
|
576 | + if ($value !== self::AVATAR_PREFIX_DEFAULT) { |
|
577 | 577 | \OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.'); |
578 | 578 | } |
579 | 579 | return $defaultAttributes; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $pagingSize = $this->config->getAppValue('user_ldap', $configKey, $minPagingSize); |
111 | 111 | $minPagingSize = $minPagingSize === null ? $pagingSize : min($minPagingSize, $pagingSize); |
112 | 112 | } |
113 | - return (int)$minPagingSize; |
|
113 | + return (int) $minPagingSize; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | |
122 | 122 | $isBackgroundJobModeAjax = $this->config |
123 | 123 | ->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'ajax'; |
124 | - if($isBackgroundJobModeAjax) { |
|
124 | + if ($isBackgroundJobModeAjax) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | 128 | $cycleData = $this->getCycle(); |
129 | - if($cycleData === null) { |
|
129 | + if ($cycleData === null) { |
|
130 | 130 | $cycleData = $this->determineNextCycle(); |
131 | - if($cycleData === null) { |
|
131 | + if ($cycleData === null) { |
|
132 | 132 | $this->updateInterval(); |
133 | 133 | return; |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if(!$this->qualifiesToRun($cycleData)) { |
|
137 | + if (!$this->qualifiesToRun($cycleData)) { |
|
138 | 138 | $this->updateInterval(); |
139 | 139 | return; |
140 | 140 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | $filter = $access->combineFilterWithAnd([ |
165 | 165 | $access->connection->ldapUserFilter, |
166 | - $access->connection->ldapUserDisplayName . '=*', |
|
166 | + $access->connection->ldapUserDisplayName.'=*', |
|
167 | 167 | $access->getFilterPartForUserSearch('') |
168 | 168 | ]); |
169 | 169 | $results = $access->fetchListOfUsers( |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | true |
175 | 175 | ); |
176 | 176 | |
177 | - if((int)$connection->ldapPagingSize === 0) { |
|
177 | + if ((int) $connection->ldapPagingSize === 0) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | - return count($results) >= (int)$connection->ldapPagingSize; |
|
180 | + return count($results) >= (int) $connection->ldapPagingSize; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function getCycle() { |
190 | 190 | $prefixes = $this->ldapHelper->getServerConfigurationPrefixes(true); |
191 | - if(count($prefixes) === 0) { |
|
191 | + if (count($prefixes) === 0) { |
|
192 | 192 | return null; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $cycleData = [ |
196 | 196 | 'prefix' => $this->config->getAppValue('user_ldap', 'background_sync_prefix', null), |
197 | - 'offset' => (int)$this->config->getAppValue('user_ldap', 'background_sync_offset', 0), |
|
197 | + 'offset' => (int) $this->config->getAppValue('user_ldap', 'background_sync_offset', 0), |
|
198 | 198 | ]; |
199 | 199 | |
200 | - if( |
|
200 | + if ( |
|
201 | 201 | $cycleData['prefix'] !== null |
202 | 202 | && in_array($cycleData['prefix'], $prefixes) |
203 | 203 | ) { |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function determineNextCycle(array $cycleData = null) { |
228 | 228 | $prefixes = $this->ldapHelper->getServerConfigurationPrefixes(true); |
229 | - if(count($prefixes) === 0) { |
|
229 | + if (count($prefixes) === 0) { |
|
230 | 230 | return null; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // get the next prefix in line and remember it |
234 | 234 | $oldPrefix = $cycleData === null ? null : $cycleData['prefix']; |
235 | 235 | $prefix = $this->getNextPrefix($oldPrefix); |
236 | - if($prefix === null) { |
|
236 | + if ($prefix === null) { |
|
237 | 237 | return null; |
238 | 238 | } |
239 | 239 | $cycleData['prefix'] = $prefix; |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @return bool |
252 | 252 | */ |
253 | 253 | public function qualifiesToRun($cycleData) { |
254 | - $lastChange = $this->config->getAppValue('user_ldap', $cycleData['prefix'] . '_lastChange', 0); |
|
255 | - if((time() - $lastChange) > 60 * 30) { |
|
254 | + $lastChange = $this->config->getAppValue('user_ldap', $cycleData['prefix'].'_lastChange', 0); |
|
255 | + if ((time() - $lastChange) > 60 * 30) { |
|
256 | 256 | return true; |
257 | 257 | } |
258 | 258 | return false; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | protected function increaseOffset($cycleData) { |
267 | 267 | $ldapConfig = new Configuration($cycleData['prefix']); |
268 | - $cycleData['offset'] += (int)$ldapConfig->ldapPagingSize; |
|
268 | + $cycleData['offset'] += (int) $ldapConfig->ldapPagingSize; |
|
269 | 269 | $this->setCycle($cycleData); |
270 | 270 | } |
271 | 271 | |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | protected function getNextPrefix($lastPrefix) { |
279 | 279 | $prefixes = $this->ldapHelper->getServerConfigurationPrefixes(true); |
280 | 280 | $noOfPrefixes = count($prefixes); |
281 | - if($noOfPrefixes === 0) { |
|
281 | + if ($noOfPrefixes === 0) { |
|
282 | 282 | return null; |
283 | 283 | } |
284 | 284 | $i = $lastPrefix === null ? false : array_search($lastPrefix, $prefixes, true); |
285 | - if($i === false) { |
|
285 | + if ($i === false) { |
|
286 | 286 | $i = -1; |
287 | 287 | } else { |
288 | 288 | $i++; |
289 | 289 | } |
290 | 290 | |
291 | - if(!isset($prefixes[$i])) { |
|
291 | + if (!isset($prefixes[$i])) { |
|
292 | 292 | $i = 0; |
293 | 293 | } |
294 | 294 | return $prefixes[$i]; |
@@ -300,49 +300,49 @@ discard block |
||
300 | 300 | * @param array $argument |
301 | 301 | */ |
302 | 302 | public function setArgument($argument) { |
303 | - if(isset($argument['config'])) { |
|
303 | + if (isset($argument['config'])) { |
|
304 | 304 | $this->config = $argument['config']; |
305 | 305 | } else { |
306 | 306 | $this->config = \OC::$server->getConfig(); |
307 | 307 | } |
308 | 308 | |
309 | - if(isset($argument['helper'])) { |
|
309 | + if (isset($argument['helper'])) { |
|
310 | 310 | $this->ldapHelper = $argument['helper']; |
311 | 311 | } else { |
312 | 312 | $this->ldapHelper = new Helper($this->config); |
313 | 313 | } |
314 | 314 | |
315 | - if(isset($argument['ldapWrapper'])) { |
|
315 | + if (isset($argument['ldapWrapper'])) { |
|
316 | 316 | $this->ldap = $argument['ldapWrapper']; |
317 | 317 | } else { |
318 | 318 | $this->ldap = new LDAP(); |
319 | 319 | } |
320 | 320 | |
321 | - if(isset($argument['avatarManager'])) { |
|
321 | + if (isset($argument['avatarManager'])) { |
|
322 | 322 | $this->avatarManager = $argument['avatarManager']; |
323 | 323 | } else { |
324 | 324 | $this->avatarManager = \OC::$server->getAvatarManager(); |
325 | 325 | } |
326 | 326 | |
327 | - if(isset($argument['dbc'])) { |
|
327 | + if (isset($argument['dbc'])) { |
|
328 | 328 | $this->dbc = $argument['dbc']; |
329 | 329 | } else { |
330 | 330 | $this->dbc = \OC::$server->getDatabaseConnection(); |
331 | 331 | } |
332 | 332 | |
333 | - if(isset($argument['ncUserManager'])) { |
|
333 | + if (isset($argument['ncUserManager'])) { |
|
334 | 334 | $this->ncUserManager = $argument['ncUserManager']; |
335 | 335 | } else { |
336 | 336 | $this->ncUserManager = \OC::$server->getUserManager(); |
337 | 337 | } |
338 | 338 | |
339 | - if(isset($argument['notificationManager'])) { |
|
339 | + if (isset($argument['notificationManager'])) { |
|
340 | 340 | $this->notificationManager = $argument['notificationManager']; |
341 | 341 | } else { |
342 | 342 | $this->notificationManager = \OC::$server->getNotificationManager(); |
343 | 343 | } |
344 | 344 | |
345 | - if(isset($argument['userManager'])) { |
|
345 | + if (isset($argument['userManager'])) { |
|
346 | 346 | $this->userManager = $argument['userManager']; |
347 | 347 | } else { |
348 | 348 | $this->userManager = new Manager( |
@@ -357,19 +357,19 @@ discard block |
||
357 | 357 | ); |
358 | 358 | } |
359 | 359 | |
360 | - if(isset($argument['mapper'])) { |
|
360 | + if (isset($argument['mapper'])) { |
|
361 | 361 | $this->mapper = $argument['mapper']; |
362 | 362 | } else { |
363 | 363 | $this->mapper = new UserMapping($this->dbc); |
364 | 364 | } |
365 | 365 | |
366 | - if(isset($argument['connectionFactory'])) { |
|
366 | + if (isset($argument['connectionFactory'])) { |
|
367 | 367 | $this->connectionFactory = $argument['connectionFactory']; |
368 | 368 | } else { |
369 | 369 | $this->connectionFactory = new ConnectionFactory($this->ldap); |
370 | 370 | } |
371 | 371 | |
372 | - if(isset($argument['accessFactory'])) { |
|
372 | + if (isset($argument['accessFactory'])) { |
|
373 | 373 | $this->accessFactory = $argument['accessFactory']; |
374 | 374 | } else { |
375 | 375 | $this->accessFactory = new AccessFactory( |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | |
50 | 50 | static private $groupBE; |
51 | 51 | |
52 | - public function __construct(){ |
|
52 | + public function __construct() { |
|
53 | 53 | $this->interval = self::getRefreshInterval(); |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @param mixed $argument |
58 | 58 | */ |
59 | - public function run($argument){ |
|
59 | + public function run($argument) { |
|
60 | 60 | self::updateGroups(); |
61 | 61 | } |
62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $knownGroups = array_keys(self::getKnownGroups()); |
67 | 67 | $actualGroups = self::getGroupBE()->getGroups(); |
68 | 68 | |
69 | - if(empty($actualGroups) && empty($knownGroups)) { |
|
69 | + if (empty($actualGroups) && empty($knownGroups)) { |
|
70 | 70 | \OCP\Util::writeLog('user_ldap', |
71 | 71 | 'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.', |
72 | 72 | ILogger::INFO); |
@@ -98,26 +98,26 @@ discard block |
||
98 | 98 | SET `owncloudusers` = ? |
99 | 99 | WHERE `owncloudname` = ? |
100 | 100 | '); |
101 | - foreach($groups as $group) { |
|
101 | + foreach ($groups as $group) { |
|
102 | 102 | //we assume, that self::$groupsFromDB has been retrieved already |
103 | 103 | $knownUsers = unserialize(self::$groupsFromDB[$group]['owncloudusers']); |
104 | 104 | $actualUsers = self::getGroupBE()->usersInGroup($group); |
105 | 105 | $hasChanged = false; |
106 | - foreach(array_diff($knownUsers, $actualUsers) as $removedUser) { |
|
106 | + foreach (array_diff($knownUsers, $actualUsers) as $removedUser) { |
|
107 | 107 | \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', ['uid' => $removedUser, 'gid' => $group]); |
108 | 108 | \OCP\Util::writeLog('user_ldap', |
109 | 109 | 'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".', |
110 | 110 | ILogger::INFO); |
111 | 111 | $hasChanged = true; |
112 | 112 | } |
113 | - foreach(array_diff($actualUsers, $knownUsers) as $addedUser) { |
|
113 | + foreach (array_diff($actualUsers, $knownUsers) as $addedUser) { |
|
114 | 114 | \OCP\Util::emitHook('OC_User', 'post_addToGroup', ['uid' => $addedUser, 'gid' => $group]); |
115 | 115 | \OCP\Util::writeLog('user_ldap', |
116 | 116 | 'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".', |
117 | 117 | ILogger::INFO); |
118 | 118 | $hasChanged = true; |
119 | 119 | } |
120 | - if($hasChanged) { |
|
120 | + if ($hasChanged) { |
|
121 | 121 | $query->execute([serialize($actualUsers), $group]); |
122 | 122 | } |
123 | 123 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`) |
137 | 137 | VALUES (?, ?) |
138 | 138 | '); |
139 | - foreach($createdGroups as $createdGroup) { |
|
139 | + foreach ($createdGroups as $createdGroup) { |
|
140 | 140 | \OCP\Util::writeLog('user_ldap', |
141 | 141 | 'bgJ "updateGroups" – new group "'.$createdGroup.'" found.', |
142 | 142 | ILogger::INFO); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | FROM `*PREFIX*ldap_group_members` |
159 | 159 | WHERE `owncloudname` = ? |
160 | 160 | '); |
161 | - foreach($removedGroups as $removedGroup) { |
|
161 | + foreach ($removedGroups as $removedGroup) { |
|
162 | 162 | \OCP\Util::writeLog('user_ldap', |
163 | 163 | 'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.', |
164 | 164 | ILogger::INFO); |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | * @return \OCA\User_LDAP\Group_LDAP|\OCA\User_LDAP\Group_Proxy |
174 | 174 | */ |
175 | 175 | static private function getGroupBE() { |
176 | - if(!is_null(self::$groupBE)) { |
|
176 | + if (!is_null(self::$groupBE)) { |
|
177 | 177 | return self::$groupBE; |
178 | 178 | } |
179 | 179 | $helper = new Helper(\OC::$server->getConfig()); |
180 | 180 | $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
181 | 181 | $ldapWrapper = new LDAP(); |
182 | - if(count($configPrefixes) === 1) { |
|
182 | + if (count($configPrefixes) === 1) { |
|
183 | 183 | //avoid the proxy when there is only one LDAP server configured |
184 | 184 | $dbc = \OC::$server->getDatabaseConnection(); |
185 | 185 | $userManager = new Manager( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return array |
210 | 210 | */ |
211 | 211 | static private function getKnownGroups() { |
212 | - if(is_array(self::$groupsFromDB)) { |
|
212 | + if (is_array(self::$groupsFromDB)) { |
|
213 | 213 | return self::$groupsFromDB; |
214 | 214 | } |
215 | 215 | $query = \OC_DB::prepare(' |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | '); |
219 | 219 | $result = $query->execute()->fetchAll(); |
220 | 220 | self::$groupsFromDB = []; |
221 | - foreach($result as $dataset) { |
|
221 | + foreach ($result as $dataset) { |
|
222 | 222 | self::$groupsFromDB[$dataset['owncloudname']] = $dataset; |
223 | 223 | } |
224 | 224 |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | return $this->userPluginManager->canChangeAvatar($uid); |
87 | 87 | } |
88 | 88 | |
89 | - if(!$this->implementsActions(Backend::PROVIDE_AVATAR)) { |
|
89 | + if (!$this->implementsActions(Backend::PROVIDE_AVATAR)) { |
|
90 | 90 | return true; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $user = $this->access->userManager->get($uid); |
94 | - if(!$user instanceof User) { |
|
94 | + if (!$user instanceof User) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | $imageData = $user->getAvatarImage(); |
98 | - if($imageData === false) { |
|
98 | + if ($imageData === false) { |
|
99 | 99 | return true; |
100 | 100 | } |
101 | 101 | return !$user->updateAvatar(true); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @throws \Exception |
110 | 110 | */ |
111 | 111 | public function loginName2UserName($loginName) { |
112 | - $cacheKey = 'loginName2UserName-' . $loginName; |
|
112 | + $cacheKey = 'loginName2UserName-'.$loginName; |
|
113 | 113 | $username = $this->access->connection->getFromCache($cacheKey); |
114 | 114 | |
115 | 115 | if ($username !== null) { |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | //find out dn of the user name |
156 | 156 | $attrs = $this->access->userManager->getAttributes(); |
157 | 157 | $users = $this->access->fetchUsersByLoginName($loginName, $attrs); |
158 | - if(count($users) < 1) { |
|
159 | - throw new NotOnLDAP('No user available for the given login name on ' . |
|
160 | - $this->access->connection->ldapHost . ':' . $this->access->connection->ldapPort); |
|
158 | + if (count($users) < 1) { |
|
159 | + throw new NotOnLDAP('No user available for the given login name on '. |
|
160 | + $this->access->connection->ldapHost.':'.$this->access->connection->ldapPort); |
|
161 | 161 | } |
162 | 162 | return $users[0]; |
163 | 163 | } |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | public function checkPassword($uid, $password) { |
173 | 173 | try { |
174 | 174 | $ldapRecord = $this->getLDAPUserByLoginName($uid); |
175 | - } catch(NotOnLDAP $e) { |
|
175 | + } catch (NotOnLDAP $e) { |
|
176 | 176 | \OC::$server->getLogger()->logException($e, ['app' => 'user_ldap', 'level' => ILogger::DEBUG]); |
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | $dn = $ldapRecord['dn'][0]; |
180 | 180 | $user = $this->access->userManager->get($dn); |
181 | 181 | |
182 | - if(!$user instanceof User) { |
|
182 | + if (!$user instanceof User) { |
|
183 | 183 | Util::writeLog('user_ldap', |
184 | - 'LDAP Login: Could not get user object for DN ' . $dn . |
|
184 | + 'LDAP Login: Could not get user object for DN '.$dn. |
|
185 | 185 | '. Maybe the LDAP entry has no set display name attribute?', |
186 | 186 | ILogger::WARN); |
187 | 187 | return false; |
188 | 188 | } |
189 | - if($user->getUsername() !== false) { |
|
189 | + if ($user->getUsername() !== false) { |
|
190 | 190 | //are the credentials OK? |
191 | - if(!$this->access->areCredentialsValid($dn, $password)) { |
|
191 | + if (!$this->access->areCredentialsValid($dn, $password)) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | |
216 | 216 | $user = $this->access->userManager->get($uid); |
217 | 217 | |
218 | - if(!$user instanceof User) { |
|
219 | - throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid . |
|
218 | + if (!$user instanceof User) { |
|
219 | + throw new \Exception('LDAP setPassword: Could not get user object for uid '.$uid. |
|
220 | 220 | '. Maybe the LDAP entry has no set display name attribute?'); |
221 | 221 | } |
222 | - if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
222 | + if ($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) { |
|
223 | 223 | $ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN; |
224 | 224 | $turnOnPasswordChange = $this->access->connection->turnOnPasswordChange; |
225 | - if (!empty($ldapDefaultPPolicyDN) && ((int)$turnOnPasswordChange === 1)) { |
|
225 | + if (!empty($ldapDefaultPPolicyDN) && ((int) $turnOnPasswordChange === 1)) { |
|
226 | 226 | //remove last password expiry warning if any |
227 | 227 | $notification = $this->notificationManager->createNotification(); |
228 | 228 | $notification->setApp('user_ldap') |
@@ -251,18 +251,18 @@ discard block |
||
251 | 251 | |
252 | 252 | //check if users are cached, if so return |
253 | 253 | $ldap_users = $this->access->connection->getFromCache($cachekey); |
254 | - if(!is_null($ldap_users)) { |
|
254 | + if (!is_null($ldap_users)) { |
|
255 | 255 | return $ldap_users; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // if we'd pass -1 to LDAP search, we'd end up in a Protocol |
259 | 259 | // error. With a limit of 0, we get 0 results. So we pass null. |
260 | - if($limit <= 0) { |
|
260 | + if ($limit <= 0) { |
|
261 | 261 | $limit = null; |
262 | 262 | } |
263 | 263 | $filter = $this->access->combineFilterWithAnd([ |
264 | 264 | $this->access->connection->ldapUserFilter, |
265 | - $this->access->connection->ldapUserDisplayName . '=*', |
|
265 | + $this->access->connection->ldapUserDisplayName.'=*', |
|
266 | 266 | $this->access->getFilterPartForUserSearch($search) |
267 | 267 | ]); |
268 | 268 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $this->access->userManager->getAttributes(true), |
276 | 276 | $limit, $offset); |
277 | 277 | $ldap_users = $this->access->nextcloudUserNames($ldap_users); |
278 | - Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', ILogger::DEBUG); |
|
278 | + Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users).' Users found', ILogger::DEBUG); |
|
279 | 279 | |
280 | 280 | $this->access->connection->writeToCache($cachekey, $ldap_users); |
281 | 281 | return $ldap_users; |
@@ -291,22 +291,22 @@ discard block |
||
291 | 291 | * @throws \OC\ServerNotAvailableException |
292 | 292 | */ |
293 | 293 | public function userExistsOnLDAP($user) { |
294 | - if(is_string($user)) { |
|
294 | + if (is_string($user)) { |
|
295 | 295 | $user = $this->access->userManager->get($user); |
296 | 296 | } |
297 | - if(is_null($user)) { |
|
297 | + if (is_null($user)) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | $uid = $user instanceof User ? $user->getUsername() : $user->getOCName(); |
301 | - $cacheKey = 'userExistsOnLDAP' . $uid; |
|
301 | + $cacheKey = 'userExistsOnLDAP'.$uid; |
|
302 | 302 | $userExists = $this->access->connection->getFromCache($cacheKey); |
303 | - if(!is_null($userExists)) { |
|
304 | - return (bool)$userExists; |
|
303 | + if (!is_null($userExists)) { |
|
304 | + return (bool) $userExists; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $dn = $user->getDN(); |
308 | 308 | //check if user really still exists by reading its entry |
309 | - if(!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
309 | + if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) { |
|
310 | 310 | try { |
311 | 311 | $uuid = $this->access->getUserMapper()->getUUIDByDN($dn); |
312 | 312 | if (!$uuid) { |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | - if($user instanceof OfflineUser) { |
|
333 | + if ($user instanceof OfflineUser) { |
|
334 | 334 | $user->unmark(); |
335 | 335 | } |
336 | 336 | |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function userExists($uid) { |
348 | 348 | $userExists = $this->access->connection->getFromCache('userExists'.$uid); |
349 | - if(!is_null($userExists)) { |
|
350 | - return (bool)$userExists; |
|
349 | + if (!is_null($userExists)) { |
|
350 | + return (bool) $userExists; |
|
351 | 351 | } |
352 | 352 | //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking. |
353 | 353 | $user = $this->access->userManager->get($uid); |
354 | 354 | |
355 | - if(is_null($user)) { |
|
355 | + if (is_null($user)) { |
|
356 | 356 | Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. |
357 | 357 | $this->access->connection->ldapHost, ILogger::DEBUG); |
358 | 358 | $this->access->connection->writeToCache('userExists'.$uid, false); |
@@ -372,19 +372,19 @@ discard block |
||
372 | 372 | public function deleteUser($uid) { |
373 | 373 | if ($this->userPluginManager->canDeleteUser()) { |
374 | 374 | $status = $this->userPluginManager->deleteUser($uid); |
375 | - if($status === false) { |
|
375 | + if ($status === false) { |
|
376 | 376 | return false; |
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | $marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0); |
381 | - if((int)$marked === 0) { |
|
381 | + if ((int) $marked === 0) { |
|
382 | 382 | \OC::$server->getLogger()->notice( |
383 | - 'User '.$uid . ' is not marked as deleted, not cleaning up.', |
|
383 | + 'User '.$uid.' is not marked as deleted, not cleaning up.', |
|
384 | 384 | ['app' => 'user_ldap']); |
385 | 385 | return false; |
386 | 386 | } |
387 | - \OC::$server->getLogger()->info('Cleaning up after user ' . $uid, |
|
387 | + \OC::$server->getLogger()->info('Cleaning up after user '.$uid, |
|
388 | 388 | ['app' => 'user_ldap']); |
389 | 389 | |
390 | 390 | $this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function getHome($uid) { |
404 | 404 | // user Exists check required as it is not done in user proxy! |
405 | - if(!$this->userExists($uid)) { |
|
405 | + if (!$this->userExists($uid)) { |
|
406 | 406 | return false; |
407 | 407 | } |
408 | 408 | |
@@ -412,16 +412,16 @@ discard block |
||
412 | 412 | |
413 | 413 | $cacheKey = 'getHome'.$uid; |
414 | 414 | $path = $this->access->connection->getFromCache($cacheKey); |
415 | - if(!is_null($path)) { |
|
415 | + if (!is_null($path)) { |
|
416 | 416 | return $path; |
417 | 417 | } |
418 | 418 | |
419 | 419 | // early return path if it is a deleted user |
420 | 420 | $user = $this->access->userManager->get($uid); |
421 | - if($user instanceof User || $user instanceof OfflineUser) { |
|
421 | + if ($user instanceof User || $user instanceof OfflineUser) { |
|
422 | 422 | $path = $user->getHomePath() ?: false; |
423 | 423 | } else { |
424 | - throw new NoUserException($uid . ' is not a valid user anymore'); |
|
424 | + throw new NoUserException($uid.' is not a valid user anymore'); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | $this->access->cacheUserHome($uid, $path); |
@@ -438,12 +438,12 @@ discard block |
||
438 | 438 | return $this->userPluginManager->getDisplayName($uid); |
439 | 439 | } |
440 | 440 | |
441 | - if(!$this->userExists($uid)) { |
|
441 | + if (!$this->userExists($uid)) { |
|
442 | 442 | return false; |
443 | 443 | } |
444 | 444 | |
445 | 445 | $cacheKey = 'getDisplayName'.$uid; |
446 | - if(!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
446 | + if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) { |
|
447 | 447 | return $displayName; |
448 | 448 | } |
449 | 449 | |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | $this->access->username2dn($uid), |
461 | 461 | $this->access->connection->ldapUserDisplayName); |
462 | 462 | |
463 | - if($displayName && (count($displayName) > 0)) { |
|
463 | + if ($displayName && (count($displayName) > 0)) { |
|
464 | 464 | $displayName = $displayName[0]; |
465 | 465 | |
466 | - if (is_array($displayName2)){ |
|
466 | + if (is_array($displayName2)) { |
|
467 | 467 | $displayName2 = count($displayName2) > 0 ? $displayName2[0] : ''; |
468 | 468 | } |
469 | 469 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
509 | 509 | $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset; |
510 | - if(!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
510 | + if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) { |
|
511 | 511 | return $displayNames; |
512 | 512 | } |
513 | 513 | |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | * compared with \OC\User\Backend::CREATE_USER etc. |
530 | 530 | */ |
531 | 531 | public function implementsActions($actions) { |
532 | - return (bool)((Backend::CHECK_PASSWORD |
|
532 | + return (bool) ((Backend::CHECK_PASSWORD |
|
533 | 533 | | Backend::GET_HOME |
534 | 534 | | Backend::GET_DISPLAYNAME |
535 | 535 | | (($this->access->connection->ldapUserAvatarRule !== 'none') ? Backend::PROVIDE_AVATAR : 0) |
536 | 536 | | Backend::COUNT_USERS |
537 | - | (((int)$this->access->connection->turnOnPasswordChange === 1)? Backend::SET_PASSWORD :0) |
|
537 | + | (((int) $this->access->connection->turnOnPasswordChange === 1) ? Backend::SET_PASSWORD : 0) |
|
538 | 538 | | $this->userPluginManager->getImplementedActions()) |
539 | 539 | & $actions); |
540 | 540 | } |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | |
559 | 559 | $filter = $this->access->getFilterForUserCount(); |
560 | 560 | $cacheKey = 'countUsers-'.$filter; |
561 | - if(!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
561 | + if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) { |
|
562 | 562 | return $entries; |
563 | 563 | } |
564 | 564 | $entries = $this->access->countUsers($filter); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * Backend name to be shown in user management |
571 | 571 | * @return string the name of the backend to be shown |
572 | 572 | */ |
573 | - public function getBackendName(){ |
|
573 | + public function getBackendName() { |
|
574 | 574 | return 'LDAP'; |
575 | 575 | } |
576 | 576 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | if (is_string($dn)) { |
609 | 609 | // the NC user creation work flow requires a know user id up front |
610 | 610 | $uuid = $this->access->getUUID($dn, true); |
611 | - if(is_string($uuid)) { |
|
611 | + if (is_string($uuid)) { |
|
612 | 612 | $this->access->mapAndAnnounceIfApplicable( |
613 | 613 | $this->access->getUserMapper(), |
614 | 614 | $dn, |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | UserPluginManager $userPluginManager |
60 | 60 | ) { |
61 | 61 | parent::__construct($ldap); |
62 | - foreach($serverConfigPrefixes as $configPrefix) { |
|
62 | + foreach ($serverConfigPrefixes as $configPrefix) { |
|
63 | 63 | $this->backends[$configPrefix] = |
64 | 64 | new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager, $userSession, $userPluginManager); |
65 | 65 | |
66 | - if(is_null($this->refBackend)) { |
|
66 | + if (is_null($this->refBackend)) { |
|
67 | 67 | $this->refBackend = &$this->backends[$configPrefix]; |
68 | 68 | } |
69 | 69 | } |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function walkBackends($uid, $method, $parameters) { |
80 | 80 | $cacheKey = $this->getUserCacheKey($uid); |
81 | - foreach($this->backends as $configPrefix => $backend) { |
|
81 | + foreach ($this->backends as $configPrefix => $backend) { |
|
82 | 82 | $instance = $backend; |
83 | - if(!method_exists($instance, $method) |
|
83 | + if (!method_exists($instance, $method) |
|
84 | 84 | && method_exists($this->getAccess($configPrefix), $method)) { |
85 | 85 | $instance = $this->getAccess($configPrefix); |
86 | 86 | } |
87 | - if($result = call_user_func_array([$instance, $method], $parameters)) { |
|
87 | + if ($result = call_user_func_array([$instance, $method], $parameters)) { |
|
88 | 88 | $this->writeToCache($cacheKey, $configPrefix); |
89 | 89 | return $result; |
90 | 90 | } |
@@ -104,22 +104,22 @@ discard block |
||
104 | 104 | $cacheKey = $this->getUserCacheKey($uid); |
105 | 105 | $prefix = $this->getFromCache($cacheKey); |
106 | 106 | //in case the uid has been found in the past, try this stored connection first |
107 | - if(!is_null($prefix)) { |
|
108 | - if(isset($this->backends[$prefix])) { |
|
107 | + if (!is_null($prefix)) { |
|
108 | + if (isset($this->backends[$prefix])) { |
|
109 | 109 | $instance = $this->backends[$prefix]; |
110 | - if(!method_exists($instance, $method) |
|
110 | + if (!method_exists($instance, $method) |
|
111 | 111 | && method_exists($this->getAccess($prefix), $method)) { |
112 | 112 | $instance = $this->getAccess($prefix); |
113 | 113 | } |
114 | 114 | $result = call_user_func_array([$instance, $method], $parameters); |
115 | - if($result === $passOnWhen) { |
|
115 | + if ($result === $passOnWhen) { |
|
116 | 116 | //not found here, reset cache to null if user vanished |
117 | 117 | //because sometimes methods return false with a reason |
118 | 118 | $userExists = call_user_func_array( |
119 | 119 | [$this->backends[$prefix], 'userExistsOnLDAP'], |
120 | 120 | [$uid] |
121 | 121 | ); |
122 | - if(!$userExists) { |
|
122 | + if (!$userExists) { |
|
123 | 123 | $this->writeToCache($cacheKey, null); |
124 | 124 | } |
125 | 125 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function getUsers($search = '', $limit = 10, $offset = 0) { |
162 | 162 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
163 | 163 | $users = []; |
164 | - foreach($this->backends as $backend) { |
|
164 | + foreach ($this->backends as $backend) { |
|
165 | 165 | $backendUsers = $backend->getUsers($search, $limit, $offset); |
166 | 166 | if (is_array($backendUsers)) { |
167 | 167 | $users = array_merge($users, $backendUsers); |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | public function userExists($uid) { |
179 | 179 | $existsOnLDAP = false; |
180 | 180 | $existsLocally = $this->handleRequest($uid, 'userExists', [$uid]); |
181 | - if($existsLocally) { |
|
181 | + if ($existsLocally) { |
|
182 | 182 | $existsOnLDAP = $this->userExistsOnLDAP($uid); |
183 | 183 | } |
184 | - if($existsLocally && !$existsOnLDAP) { |
|
184 | + if ($existsLocally && !$existsOnLDAP) { |
|
185 | 185 | try { |
186 | 186 | $user = $this->getLDAPAccess($uid)->userManager->get($uid); |
187 | - if($user instanceof User) { |
|
187 | + if ($user instanceof User) { |
|
188 | 188 | $user->markUser(); |
189 | 189 | } |
190 | 190 | } catch (\Exception $e) { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return string|false |
225 | 225 | */ |
226 | 226 | public function loginName2UserName($loginName) { |
227 | - $id = 'LOGINNAME,' . $loginName; |
|
227 | + $id = 'LOGINNAME,'.$loginName; |
|
228 | 228 | return $this->handleRequest($id, 'loginName2UserName', [$loginName]); |
229 | 229 | } |
230 | 230 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return string|false with the username |
236 | 236 | */ |
237 | 237 | public function dn2UserName($dn) { |
238 | - $id = 'DN,' . $dn; |
|
238 | + $id = 'DN,'.$dn; |
|
239 | 239 | return $this->handleRequest($id, 'dn2UserName', [$dn]); |
240 | 240 | } |
241 | 241 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
288 | 288 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
289 | 289 | $users = []; |
290 | - foreach($this->backends as $backend) { |
|
290 | + foreach ($this->backends as $backend) { |
|
291 | 291 | $backendUsers = $backend->getDisplayNames($search, $limit, $offset); |
292 | 292 | if (is_array($backendUsers)) { |
293 | 293 | $users = $users + $backendUsers; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function countUsers() { |
333 | 333 | $users = false; |
334 | - foreach($this->backends as $backend) { |
|
334 | + foreach ($this->backends as $backend) { |
|
335 | 335 | $backendUsers = $backend->countUsers(); |
336 | 336 | if ($backendUsers !== false) { |
337 | 337 | $users += $backendUsers; |
@@ -366,6 +366,6 @@ discard block |
||
366 | 366 | * @return bool |
367 | 367 | */ |
368 | 368 | public function createUser($username, $password) { |
369 | - return $this->handleRequest($username, 'createUser', [$username,$password]); |
|
369 | + return $this->handleRequest($username, 'createUser', [$username, $password]); |
|
370 | 370 | } |
371 | 371 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | Filesystem::initMountPoints($uid); |
104 | 104 | if ($uid !== User::getUser()) { |
105 | 105 | $info = Filesystem::getFileInfo($filename); |
106 | - $ownerView = new View('/' . $uid . '/files'); |
|
106 | + $ownerView = new View('/'.$uid.'/files'); |
|
107 | 107 | try { |
108 | 108 | $filename = $ownerView->getPath($info['fileid']); |
109 | 109 | } catch (NotFoundException $e) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | private static function setUpTrash($user) { |
157 | - $view = new View('/' . $user); |
|
157 | + $view = new View('/'.$user); |
|
158 | 158 | if (!$view->is_dir('files_trashbin')) { |
159 | 159 | $view->mkdir('files_trashbin'); |
160 | 160 | } |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | |
190 | 190 | $view = new View('/'); |
191 | 191 | |
192 | - $target = $user . '/files_trashbin/files/' . $targetFilename . '.d' . $timestamp; |
|
193 | - $source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp; |
|
192 | + $target = $user.'/files_trashbin/files/'.$targetFilename.'.d'.$timestamp; |
|
193 | + $source = $owner.'/files_trashbin/files/'.$sourceFilename.'.d'.$timestamp; |
|
194 | 194 | $free = $view->free_space($target); |
195 | 195 | $isUnknownOrUnlimitedFreeSpace = $free < 0; |
196 | 196 | $isEnoughFreeSpaceLeft = $view->filesize($source) < $free; |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | $ownerPath = $file_path; |
230 | 230 | } |
231 | 231 | |
232 | - $ownerView = new View('/' . $owner); |
|
232 | + $ownerView = new View('/'.$owner); |
|
233 | 233 | // file has been deleted in between |
234 | - if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) { |
|
234 | + if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/'.$ownerPath)) { |
|
235 | 235 | return true; |
236 | 236 | } |
237 | 237 | |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | $timestamp = time(); |
249 | 249 | |
250 | 250 | // disable proxy to prevent recursive calls |
251 | - $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; |
|
251 | + $trashPath = '/files_trashbin/files/'.$filename.'.d'.$timestamp; |
|
252 | 252 | |
253 | 253 | /** @var \OC\Files\Storage\Storage $trashStorage */ |
254 | 254 | list($trashStorage, $trashInternalPath) = $ownerView->resolvePath($trashPath); |
255 | 255 | /** @var \OC\Files\Storage\Storage $sourceStorage */ |
256 | - list($sourceStorage, $sourceInternalPath) = $ownerView->resolvePath('/files/' . $ownerPath); |
|
256 | + list($sourceStorage, $sourceInternalPath) = $ownerView->resolvePath('/files/'.$ownerPath); |
|
257 | 257 | try { |
258 | 258 | $moveSuccessful = true; |
259 | 259 | if ($trashStorage->file_exists($trashInternalPath)) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | if ($trashStorage->file_exists($trashInternalPath)) { |
266 | 266 | $trashStorage->unlink($trashInternalPath); |
267 | 267 | } |
268 | - \OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); |
|
268 | + \OC::$server->getLogger()->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); |
287 | 287 | } |
288 | 288 | \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), |
289 | - 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]); |
|
289 | + 'trashPath' => Filesystem::normalizePath($filename.'.d'.$timestamp)]); |
|
290 | 290 | |
291 | 291 | self::retainVersions($filename, $owner, $ownerPath, $timestamp); |
292 | 292 | |
@@ -320,18 +320,18 @@ discard block |
||
320 | 320 | $user = User::getUser(); |
321 | 321 | $rootView = new View('/'); |
322 | 322 | |
323 | - if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { |
|
323 | + if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) { |
|
324 | 324 | if ($owner !== $user) { |
325 | - self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView); |
|
325 | + self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.basename($ownerPath).'.d'.$timestamp, $rootView); |
|
326 | 326 | } |
327 | - self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp); |
|
327 | + self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.$filename.'.d'.$timestamp); |
|
328 | 328 | } else if ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) { |
329 | 329 | |
330 | 330 | foreach ($versions as $v) { |
331 | 331 | if ($owner !== $user) { |
332 | - self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp); |
|
332 | + self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.$v['name'].'.v'.$v['version'].'.d'.$timestamp); |
|
333 | 333 | } |
334 | - self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp); |
|
334 | + self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.$filename.'.v'.$v['version'].'.d'.$timestamp); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | } |
@@ -393,18 +393,18 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public static function restore($file, $filename, $timestamp) { |
395 | 395 | $user = User::getUser(); |
396 | - $view = new View('/' . $user); |
|
396 | + $view = new View('/'.$user); |
|
397 | 397 | |
398 | 398 | $location = ''; |
399 | 399 | if ($timestamp) { |
400 | 400 | $location = self::getLocation($user, $filename, $timestamp); |
401 | 401 | if ($location === false) { |
402 | - \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); |
|
402 | + \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']); |
|
403 | 403 | } else { |
404 | 404 | // if location no longer exists, restore file in the root directory |
405 | 405 | if ($location !== '/' && |
406 | - (!$view->is_dir('files/' . $location) || |
|
407 | - !$view->isCreatable('files/' . $location)) |
|
406 | + (!$view->is_dir('files/'.$location) || |
|
407 | + !$view->isCreatable('files/'.$location)) |
|
408 | 408 | ) { |
409 | 409 | $location = ''; |
410 | 410 | } |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | // we need a extension in case a file/dir with the same name already exists |
415 | 415 | $uniqueFilename = self::getUniqueFilename($location, $filename, $view); |
416 | 416 | |
417 | - $source = Filesystem::normalizePath('files_trashbin/files/' . $file); |
|
418 | - $target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename); |
|
417 | + $source = Filesystem::normalizePath('files_trashbin/files/'.$file); |
|
418 | + $target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename); |
|
419 | 419 | if (!$view->file_exists($source)) { |
420 | 420 | return false; |
421 | 421 | } |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | // handle the restore result |
431 | 431 | if ($restoreResult) { |
432 | 432 | $fakeRoot = $view->getRoot(); |
433 | - $view->chroot('/' . $user . '/files'); |
|
434 | - $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); |
|
433 | + $view->chroot('/'.$user.'/files'); |
|
434 | + $view->touch('/'.$location.'/'.$uniqueFilename, $mtime); |
|
435 | 435 | $view->chroot($fakeRoot); |
436 | - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), |
|
436 | + \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename), |
|
437 | 437 | 'trashPath' => Filesystem::normalizePath($file)]); |
438 | 438 | |
439 | 439 | self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | $user = User::getUser(); |
468 | 468 | $rootView = new View('/'); |
469 | 469 | |
470 | - $target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
470 | + $target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
471 | 471 | |
472 | 472 | list($owner, $ownerPath) = self::getUidAndFilename($target); |
473 | 473 | |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | $versionedFile = $file; |
483 | 483 | } |
484 | 484 | |
485 | - if ($view->is_dir('/files_trashbin/versions/' . $file)) { |
|
486 | - $rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); |
|
485 | + if ($view->is_dir('/files_trashbin/versions/'.$file)) { |
|
486 | + $rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath)); |
|
487 | 487 | } else if ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { |
488 | 488 | foreach ($versions as $v) { |
489 | 489 | if ($timestamp) { |
490 | - $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
490 | + $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v.'.d'.$timestamp, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
491 | 491 | } else { |
492 | - $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
492 | + $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | public static function deleteAll() { |
503 | 503 | $user = User::getUser(); |
504 | 504 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
505 | - $view = new View('/' . $user); |
|
505 | + $view = new View('/'.$user); |
|
506 | 506 | $fileInfos = $view->getDirectoryContent('files_trashbin/files'); |
507 | 507 | |
508 | 508 | try { |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | |
514 | 514 | // Array to store the relative path in (after the file is deleted, the view won't be able to relativise the path anymore) |
515 | 515 | $filePaths = []; |
516 | - foreach($fileInfos as $fileInfo){ |
|
516 | + foreach ($fileInfos as $fileInfo) { |
|
517 | 517 | $filePaths[] = $view->getRelativePath($fileInfo->getPath()); |
518 | 518 | } |
519 | 519 | unset($fileInfos); // save memory |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', ['paths' => $filePaths]); |
523 | 523 | |
524 | 524 | // Single-File Hooks |
525 | - foreach($filePaths as $path){ |
|
525 | + foreach ($filePaths as $path) { |
|
526 | 526 | self::emitTrashbinPreDelete($path); |
527 | 527 | } |
528 | 528 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]); |
536 | 536 | |
537 | 537 | // Single-File Hooks |
538 | - foreach($filePaths as $path){ |
|
538 | + foreach ($filePaths as $path) { |
|
539 | 539 | self::emitTrashbinPostDelete($path); |
540 | 540 | } |
541 | 541 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * wrapper function to emit the 'preDelete' hook of \OCP\Trashbin before a file is deleted |
550 | 550 | * @param string $path |
551 | 551 | */ |
552 | - protected static function emitTrashbinPreDelete($path){ |
|
552 | + protected static function emitTrashbinPreDelete($path) { |
|
553 | 553 | \OC_Hook::emit('\OCP\Trashbin', 'preDelete', ['path' => $path]); |
554 | 554 | } |
555 | 555 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * wrapper function to emit the 'delete' hook of \OCP\Trashbin after a file has been deleted |
558 | 558 | * @param string $path |
559 | 559 | */ |
560 | - protected static function emitTrashbinPostDelete($path){ |
|
560 | + protected static function emitTrashbinPostDelete($path) { |
|
561 | 561 | \OC_Hook::emit('\OCP\Trashbin', 'delete', ['path' => $path]); |
562 | 562 | } |
563 | 563 | |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public static function delete($filename, $user, $timestamp = null) { |
574 | 574 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
575 | - $view = new View('/' . $user); |
|
575 | + $view = new View('/'.$user); |
|
576 | 576 | $size = 0; |
577 | 577 | |
578 | 578 | if ($timestamp) { |
579 | 579 | $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); |
580 | 580 | $query->execute([$user, $filename, $timestamp]); |
581 | - $file = $filename . '.d' . $timestamp; |
|
581 | + $file = $filename.'.d'.$timestamp; |
|
582 | 582 | } else { |
583 | 583 | $file = $filename; |
584 | 584 | } |
@@ -586,20 +586,20 @@ discard block |
||
586 | 586 | $size += self::deleteVersions($view, $file, $filename, $timestamp, $user); |
587 | 587 | |
588 | 588 | try { |
589 | - $node = $userRoot->get('/files_trashbin/files/' . $file); |
|
589 | + $node = $userRoot->get('/files_trashbin/files/'.$file); |
|
590 | 590 | } catch (NotFoundException $e) { |
591 | 591 | return $size; |
592 | 592 | } |
593 | 593 | |
594 | 594 | if ($node instanceof Folder) { |
595 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file)); |
|
595 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file)); |
|
596 | 596 | } else if ($node instanceof File) { |
597 | - $size += $view->filesize('/files_trashbin/files/' . $file); |
|
597 | + $size += $view->filesize('/files_trashbin/files/'.$file); |
|
598 | 598 | } |
599 | 599 | |
600 | - self::emitTrashbinPreDelete('/files_trashbin/files/' . $file); |
|
600 | + self::emitTrashbinPreDelete('/files_trashbin/files/'.$file); |
|
601 | 601 | $node->delete(); |
602 | - self::emitTrashbinPostDelete('/files_trashbin/files/' . $file); |
|
602 | + self::emitTrashbinPostDelete('/files_trashbin/files/'.$file); |
|
603 | 603 | |
604 | 604 | return $size; |
605 | 605 | } |
@@ -615,17 +615,17 @@ discard block |
||
615 | 615 | private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) { |
616 | 616 | $size = 0; |
617 | 617 | if (\OCP\App::isEnabled('files_versions')) { |
618 | - if ($view->is_dir('files_trashbin/versions/' . $file)) { |
|
619 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file)); |
|
620 | - $view->unlink('files_trashbin/versions/' . $file); |
|
618 | + if ($view->is_dir('files_trashbin/versions/'.$file)) { |
|
619 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file)); |
|
620 | + $view->unlink('files_trashbin/versions/'.$file); |
|
621 | 621 | } else if ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) { |
622 | 622 | foreach ($versions as $v) { |
623 | 623 | if ($timestamp) { |
624 | - $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp); |
|
625 | - $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp); |
|
624 | + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); |
|
625 | + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp); |
|
626 | 626 | } else { |
627 | - $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
628 | - $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
627 | + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
628 | + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | } |
@@ -642,13 +642,13 @@ discard block |
||
642 | 642 | */ |
643 | 643 | public static function file_exists($filename, $timestamp = null) { |
644 | 644 | $user = User::getUser(); |
645 | - $view = new View('/' . $user); |
|
645 | + $view = new View('/'.$user); |
|
646 | 646 | |
647 | 647 | if ($timestamp) { |
648 | - $filename = $filename . '.d' . $timestamp; |
|
648 | + $filename = $filename.'.d'.$timestamp; |
|
649 | 649 | } |
650 | 650 | |
651 | - $target = Filesystem::normalizePath('files_trashbin/files/' . $filename); |
|
651 | + $target = Filesystem::normalizePath('files_trashbin/files/'.$filename); |
|
652 | 652 | return $view->file_exists($target); |
653 | 653 | } |
654 | 654 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | private static function calculateFreeSpace($trashbinSize, $user) { |
674 | 674 | $softQuota = true; |
675 | 675 | $userObject = \OC::$server->getUserManager()->get($user); |
676 | - if(is_null($userObject)) { |
|
676 | + if (is_null($userObject)) { |
|
677 | 677 | return 0; |
678 | 678 | } |
679 | 679 | $quota = $userObject->getQuota(); |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | // subtract size of files and current trash bin size from quota |
693 | 693 | if ($softQuota) { |
694 | 694 | $userFolder = \OC::$server->getUserFolder($user); |
695 | - if(is_null($userFolder)) { |
|
695 | + if (is_null($userFolder)) { |
|
696 | 696 | return 0; |
697 | 697 | } |
698 | 698 | $free = $quota - $userFolder->getSize(false); // remaining free space for user |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | foreach ($files as $file) { |
777 | 777 | if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) { |
778 | 778 | $tmp = self::delete($file['name'], $user, $file['mtime']); |
779 | - \OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); |
|
779 | + \OC::$server->getLogger()->info('remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); |
|
780 | 780 | $availableSpace += $tmp; |
781 | 781 | $size += $tmp; |
782 | 782 | } else { |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | $size += self::delete($filename, $user, $timestamp); |
808 | 808 | $count++; |
809 | 809 | } catch (\OCP\Files\NotPermittedException $e) { |
810 | - \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']); |
|
810 | + \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "'.$filename.'" from trashbin failed.']); |
|
811 | 811 | } |
812 | 812 | \OC::$server->getLogger()->info( |
813 | - 'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.', |
|
813 | + 'Remove "'.$filename.'" from trashbin because it exceeds max retention obligation term.', |
|
814 | 814 | ['app' => 'files_trashbin'] |
815 | 815 | ); |
816 | 816 | } else { |
@@ -836,16 +836,16 @@ discard block |
||
836 | 836 | $view->mkdir($destination); |
837 | 837 | $view->touch($destination, $view->filemtime($source)); |
838 | 838 | foreach ($view->getDirectoryContent($source) as $i) { |
839 | - $pathDir = $source . '/' . $i['name']; |
|
839 | + $pathDir = $source.'/'.$i['name']; |
|
840 | 840 | if ($view->is_dir($pathDir)) { |
841 | - $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view); |
|
841 | + $size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view); |
|
842 | 842 | } else { |
843 | 843 | $size += $view->filesize($pathDir); |
844 | - $result = $view->copy($pathDir, $destination . '/' . $i['name']); |
|
844 | + $result = $view->copy($pathDir, $destination.'/'.$i['name']); |
|
845 | 845 | if (!$result) { |
846 | 846 | throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException(); |
847 | 847 | } |
848 | - $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir)); |
|
848 | + $view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir)); |
|
849 | 849 | } |
850 | 850 | } |
851 | 851 | } else { |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | * @return array |
868 | 868 | */ |
869 | 869 | private static function getVersionsFromTrash($filename, $timestamp, $user) { |
870 | - $view = new View('/' . $user . '/files_trashbin/versions'); |
|
870 | + $view = new View('/'.$user.'/files_trashbin/versions'); |
|
871 | 871 | $versions = []; |
872 | 872 | |
873 | 873 | //force rescan of versions, local storage may not have updated the cache |
@@ -880,10 +880,10 @@ discard block |
||
880 | 880 | |
881 | 881 | if ($timestamp) { |
882 | 882 | // fetch for old versions |
883 | - $matches = $view->searchRaw($filename . '.v%.d' . $timestamp); |
|
883 | + $matches = $view->searchRaw($filename.'.v%.d'.$timestamp); |
|
884 | 884 | $offset = -strlen($timestamp) - 2; |
885 | 885 | } else { |
886 | - $matches = $view->searchRaw($filename . '.v%'); |
|
886 | + $matches = $view->searchRaw($filename.'.v%'); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | if (is_array($matches)) { |
@@ -913,18 +913,18 @@ discard block |
||
913 | 913 | $name = pathinfo($filename, PATHINFO_FILENAME); |
914 | 914 | $l = \OC::$server->getL10N('files_trashbin'); |
915 | 915 | |
916 | - $location = '/' . trim($location, '/'); |
|
916 | + $location = '/'.trim($location, '/'); |
|
917 | 917 | |
918 | 918 | // if extension is not empty we set a dot in front of it |
919 | 919 | if ($ext !== '') { |
920 | - $ext = '.' . $ext; |
|
920 | + $ext = '.'.$ext; |
|
921 | 921 | } |
922 | 922 | |
923 | - if ($view->file_exists('files' . $location . '/' . $filename)) { |
|
923 | + if ($view->file_exists('files'.$location.'/'.$filename)) { |
|
924 | 924 | $i = 2; |
925 | - $uniqueName = $name . " (" . $l->t("restored") . ")" . $ext; |
|
926 | - while ($view->file_exists('files' . $location . '/' . $uniqueName)) { |
|
927 | - $uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext; |
|
925 | + $uniqueName = $name." (".$l->t("restored").")".$ext; |
|
926 | + while ($view->file_exists('files'.$location.'/'.$uniqueName)) { |
|
927 | + $uniqueName = $name." (".$l->t("restored")." ".$i.")".$ext; |
|
928 | 928 | $i++; |
929 | 929 | } |
930 | 930 | |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | * @return integer size of the folder |
942 | 942 | */ |
943 | 943 | private static function calculateSize($view) { |
944 | - $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath(''); |
|
944 | + $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath(''); |
|
945 | 945 | if (!file_exists($root)) { |
946 | 946 | return 0; |
947 | 947 | } |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | * @return integer trash bin size |
973 | 973 | */ |
974 | 974 | private static function getTrashbinSize($user) { |
975 | - $view = new View('/' . $user); |
|
975 | + $view = new View('/'.$user); |
|
976 | 976 | $fileInfo = $view->getFileInfo('/files_trashbin'); |
977 | 977 | return isset($fileInfo['size']) ? $fileInfo['size'] : 0; |
978 | 978 | } |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | */ |
1000 | 1000 | public static function isEmpty($user) { |
1001 | 1001 | |
1002 | - $view = new View('/' . $user . '/files_trashbin'); |
|
1002 | + $view = new View('/'.$user.'/files_trashbin'); |
|
1003 | 1003 | if ($view->is_dir('/files') && $dh = $view->opendir('/files')) { |
1004 | 1004 | while ($file = readdir($dh)) { |
1005 | 1005 | if (!Filesystem::isIgnoredDir($file)) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $result = []; |
50 | 50 | $timestamp = null; |
51 | 51 | |
52 | - $view = new \OC\Files\View('/' . $user . '/files_trashbin/files'); |
|
52 | + $view = new \OC\Files\View('/'.$user.'/files_trashbin/files'); |
|
53 | 53 | |
54 | 54 | if (ltrim($dir, '/') !== '' && !$view->is_dir($dir)) { |
55 | 55 | throw new \Exception('Directory does not exists'); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $timestamp = substr(pathinfo($parts[0], PATHINFO_EXTENSION), 1); |
77 | 77 | } |
78 | 78 | $originalPath = ''; |
79 | - $originalName = substr($entryName, 0, -strlen($timestamp)-2); |
|
79 | + $originalName = substr($entryName, 0, -strlen($timestamp) - 2); |
|
80 | 80 | if (isset($originalLocations[$originalName][$timestamp])) { |
81 | 81 | $originalPath = $originalLocations[$originalName][$timestamp]; |
82 | 82 | if (substr($originalPath, -1) === '/') { |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | ]; |
98 | 98 | if ($originalPath) { |
99 | 99 | if ($originalPath !== '.') { |
100 | - $i['extraData'] = $originalPath . '/' . $originalName; |
|
100 | + $i['extraData'] = $originalPath.'/'.$originalName; |
|
101 | 101 | } else { |
102 | 102 | $i['extraData'] = $originalName; |
103 | 103 | } |
104 | 104 | } |
105 | - $result[] = new FileInfo($absoluteDir . '/' . $i['name'], $storage, $internalPath . '/' . $i['name'], $i, $mount); |
|
105 | + $result[] = new FileInfo($absoluteDir.'/'.$i['name'], $storage, $internalPath.'/'.$i['name'], $i, $mount); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($sortAttribute !== '') { |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @throws \Exception |
66 | 66 | */ |
67 | 67 | public function beforeController($controller, $methodName) { |
68 | - if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { |
|
69 | - if(!$this->isSubAdmin) { |
|
68 | + if (!$this->reflector->hasAnnotation('NoSubadminRequired')) { |
|
69 | + if (!$this->isSubAdmin) { |
|
70 | 70 | throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin')); |
71 | 71 | } |
72 | 72 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @throws \Exception |
82 | 82 | */ |
83 | 83 | public function afterException($controller, $methodName, \Exception $exception) { |
84 | - if($exception instanceof NotAdminException) { |
|
84 | + if ($exception instanceof NotAdminException) { |
|
85 | 85 | $response = new TemplateResponse('core', '403', [], 'guest'); |
86 | 86 | $response->setStatus(Http::STATUS_FORBIDDEN); |
87 | 87 | return $response; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * Defaults to ``60*60*24*15`` seconds (15 days) |
236 | 236 | */ |
237 | -'remember_login_cookie_lifetime' => 60*60*24*15, |
|
237 | +'remember_login_cookie_lifetime' => 60 * 60 * 24 * 15, |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * The lifetime of a session after inactivity. |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | * https://github.com/phpredis/phpredis/commit/c5994f2a42b8a348af92d3acb4edff1328ad8ce1 |
1185 | 1185 | */ |
1186 | 1186 | 'redis.cluster' => [ |
1187 | - 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required |
|
1187 | + 'seeds' => [// provide some/all of the cluster servers to bootstrap discovery, port required |
|
1188 | 1188 | 'localhost:7000', |
1189 | 1189 | 'localhost:7001', |
1190 | 1190 | ], |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | * |
1250 | 1250 | * Defaults to ``60*60*24`` (1 day) |
1251 | 1251 | */ |
1252 | -'cache_chunk_gc_ttl' => 60*60*24, |
|
1252 | +'cache_chunk_gc_ttl' => 60 * 60 * 24, |
|
1253 | 1253 | |
1254 | 1254 | /** |
1255 | 1255 | * Using Object Store with Nextcloud |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | * Defaults to ``60*60`` seconds (1 hour) or the php |
1683 | 1683 | * max_execution_time, whichever is higher. |
1684 | 1684 | */ |
1685 | -'filelocking.ttl' => 60*60, |
|
1685 | +'filelocking.ttl' => 60 * 60, |
|
1686 | 1686 | |
1687 | 1687 | /** |
1688 | 1688 | * Memory caching backend for file locking |