@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | use Icewind\Streams\CallbackWrapper; |
| 38 | 38 | use Icewind\Streams\RetryWrapper; |
| 39 | 39 | |
| 40 | -class FTP extends StreamWrapper{ |
|
| 40 | +class FTP extends StreamWrapper { |
|
| 41 | 41 | private $password; |
| 42 | 42 | private $user; |
| 43 | 43 | private $host; |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function __construct($params) { |
| 48 | 48 | if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { |
| 49 | - $this->host=$params['host']; |
|
| 50 | - $this->user=$params['user']; |
|
| 51 | - $this->password=$params['password']; |
|
| 49 | + $this->host = $params['host']; |
|
| 50 | + $this->user = $params['user']; |
|
| 51 | + $this->password = $params['password']; |
|
| 52 | 52 | if (isset($params['secure'])) { |
| 53 | 53 | $this->secure = $params['secure']; |
| 54 | 54 | } else { |
| 55 | 55 | $this->secure = false; |
| 56 | 56 | } |
| 57 | - $this->root=isset($params['root'])?$params['root']:'/'; |
|
| 58 | - if ( ! $this->root || $this->root[0]!=='/') { |
|
| 59 | - $this->root='/'.$this->root; |
|
| 57 | + $this->root = isset($params['root']) ? $params['root'] : '/'; |
|
| 58 | + if (!$this->root || $this->root[0] !== '/') { |
|
| 59 | + $this->root = '/'.$this->root; |
|
| 60 | 60 | } |
| 61 | 61 | if (substr($this->root, -1) !== '/') { |
| 62 | 62 | $this->root .= '/'; |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function getId(){ |
|
| 71 | - return 'ftp::' . $this->user . '@' . $this->host . '/' . $this->root; |
|
| 70 | + public function getId() { |
|
| 71 | + return 'ftp::'.$this->user.'@'.$this->host.'/'.$this->root; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| 79 | 79 | public function constructUrl($path) { |
| 80 | - $url='ftp'; |
|
| 80 | + $url = 'ftp'; |
|
| 81 | 81 | if ($this->secure) { |
| 82 | - $url.='s'; |
|
| 82 | + $url .= 's'; |
|
| 83 | 83 | } |
| 84 | - $url.='://'.urlencode($this->user).':'.urlencode($this->password).'@'.$this->host.$this->root.$path; |
|
| 84 | + $url .= '://'.urlencode($this->user).':'.urlencode($this->password).'@'.$this->host.$this->root.$path; |
|
| 85 | 85 | return $url; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | return $result; |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | - public function fopen($path,$mode) { |
|
| 104 | - switch($mode) { |
|
| 103 | + public function fopen($path, $mode) { |
|
| 104 | + switch ($mode) { |
|
| 105 | 105 | case 'r': |
| 106 | 106 | case 'rb': |
| 107 | 107 | case 'w': |
@@ -121,17 +121,17 @@ discard block |
||
| 121 | 121 | case 'c': |
| 122 | 122 | case 'c+': |
| 123 | 123 | //emulate these |
| 124 | - if (strrpos($path, '.')!==false) { |
|
| 125 | - $ext=substr($path, strrpos($path, '.')); |
|
| 124 | + if (strrpos($path, '.') !== false) { |
|
| 125 | + $ext = substr($path, strrpos($path, '.')); |
|
| 126 | 126 | } else { |
| 127 | - $ext=''; |
|
| 127 | + $ext = ''; |
|
| 128 | 128 | } |
| 129 | 129 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile(); |
| 130 | 130 | if ($this->file_exists($path)) { |
| 131 | 131 | $this->getFile($path, $tmpFile); |
| 132 | 132 | } |
| 133 | 133 | $handle = fopen($tmpFile, $mode); |
| 134 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
| 134 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
| 135 | 135 | $this->writeBack($tmpFile, $path); |
| 136 | 136 | }); |
| 137 | 137 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | foreach ($options as &$option) { |
| 243 | 243 | $option = self::substitutePlaceholdersInConfig($option); |
| 244 | - if(!self::arePlaceholdersSubstituted($option)) { |
|
| 244 | + if (!self::arePlaceholdersSubstituted($option)) { |
|
| 245 | 245 | \OC::$server->getLogger()->error( |
| 246 | 246 | 'A placeholder was not substituted: {option} for mount type {class}', |
| 247 | 247 | [ |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | public static function arePlaceholdersSubstituted($option):bool { |
| 283 | 283 | $result = true; |
| 284 | - if(is_array($option)) { |
|
| 284 | + if (is_array($option)) { |
|
| 285 | 285 | foreach ($option as $optionItem) { |
| 286 | - if(is_array($optionItem)) { |
|
| 286 | + if (is_array($optionItem)) { |
|
| 287 | 287 | $result = $result && self::arePlaceholdersSubstituted($option); |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | public static function readData($user = null) { |
| 305 | 305 | if (isset($user)) { |
| 306 | - $jsonFile = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json'; |
|
| 306 | + $jsonFile = \OC::$server->getUserManager()->get($user)->getHome().'/mount.json'; |
|
| 307 | 307 | } else { |
| 308 | 308 | $config = \OC::$server->getConfig(); |
| 309 | - $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/'); |
|
| 310 | - $jsonFile = $config->getSystemValue('mount_file', $datadir . '/mount.json'); |
|
| 309 | + $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data/'); |
|
| 310 | + $jsonFile = $config->getSystemValue('mount_file', $datadir.'/mount.json'); |
|
| 311 | 311 | } |
| 312 | 312 | if (is_file($jsonFile)) { |
| 313 | 313 | $mountPoints = json_decode(file_get_contents($jsonFile), true); |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | foreach ($backends as $backend) { |
| 334 | 334 | foreach ($backend->checkDependencies() as $dependency) { |
| 335 | 335 | if ($message = $dependency->getMessage()) { |
| 336 | - $message .= '<p>' . $message . '</p>'; |
|
| 336 | + $message .= '<p>'.$message.'</p>'; |
|
| 337 | 337 | } else { |
| 338 | 338 | $dependencyGroups[$dependency->getDependency()][] = $backend; |
| 339 | 339 | } |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | foreach ($dependencyGroups as $module => $dependants) { |
| 344 | 344 | $backends = implode(', ', array_map(function($backend) { |
| 345 | - return '"' . $backend->getText() . '"'; |
|
| 345 | + return '"'.$backend->getText().'"'; |
|
| 346 | 346 | }, $dependants)); |
| 347 | - $message .= '<p>' . OC_Mount_Config::getSingleDependencyMessage($l, $module, $backends) . '</p>'; |
|
| 347 | + $message .= '<p>'.OC_Mount_Config::getSingleDependencyMessage($l, $module, $backends).'</p>'; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | return $message; |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | private static function getSingleDependencyMessage(\OCP\IL10N $l, $module, $backend) { |
| 362 | 362 | switch (strtolower($module)) { |
| 363 | 363 | case 'curl': |
| 364 | - return (string)$l->t('The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', [$backend]); |
|
| 364 | + return (string) $l->t('The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', [$backend]); |
|
| 365 | 365 | case 'ftp': |
| 366 | - return (string)$l->t('The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', [$backend]); |
|
| 366 | + return (string) $l->t('The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.', [$backend]); |
|
| 367 | 367 | default: |
| 368 | - return (string)$l->t('"%1$s" is not installed. Mounting of %2$s is not possible. Please ask your system administrator to install it.', [$module, $backend]); |
|
| 368 | + return (string) $l->t('"%1$s" is not installed. Mounting of %2$s is not possible. Please ask your system administrator to install it.', [$module, $backend]); |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $cipher = self::getCipher(); |
| 411 | 411 | $iv = \OC::$server->getSecureRandom()->generate(16); |
| 412 | 412 | $cipher->setIV($iv); |
| 413 | - return base64_encode($iv . $cipher->encrypt($password)); |
|
| 413 | + return base64_encode($iv.$cipher->encrypt($password)); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -306,15 +306,15 @@ discard block |
||
| 306 | 306 | */ |
| 307 | 307 | public function registerConfigHandler(string $placeholder, callable $configHandlerLoader) { |
| 308 | 308 | $placeholder = trim(strtolower($placeholder)); |
| 309 | - if(!(bool)\preg_match('/^[a-z0-9]*$/', $placeholder)) { |
|
| 309 | + if (!(bool) \preg_match('/^[a-z0-9]*$/', $placeholder)) { |
|
| 310 | 310 | throw new \RuntimeException(sprintf( |
| 311 | 311 | 'Invalid placeholder %s, only [a-z0-9] are allowed', $placeholder |
| 312 | 312 | )); |
| 313 | 313 | } |
| 314 | - if($placeholder === '') { |
|
| 314 | + if ($placeholder === '') { |
|
| 315 | 315 | throw new \RuntimeException('Invalid empty placeholder'); |
| 316 | 316 | } |
| 317 | - if(isset($this->configHandlerLoaders[$placeholder]) || isset($this->configHandlers[$placeholder])) { |
|
| 317 | + if (isset($this->configHandlerLoaders[$placeholder]) || isset($this->configHandlers[$placeholder])) { |
|
| 318 | 318 | throw new \RuntimeException(sprintf('A handler is already registered for %s', $placeholder)); |
| 319 | 319 | } |
| 320 | 320 | $this->configHandlerLoaders[$placeholder] = $configHandlerLoader; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $newLoaded = false; |
| 325 | 325 | foreach ($this->configHandlerLoaders as $placeholder => $loader) { |
| 326 | 326 | $handler = $loader(); |
| 327 | - if(!$handler instanceof IConfigHandler) { |
|
| 327 | + if (!$handler instanceof IConfigHandler) { |
|
| 328 | 328 | throw new \RuntimeException(sprintf( |
| 329 | 329 | 'Handler for %s is not an instance of IConfigHandler', $placeholder |
| 330 | 330 | )); |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | $newLoaded = true; |
| 334 | 334 | } |
| 335 | 335 | $this->configHandlerLoaders = []; |
| 336 | - if($newLoaded) { |
|
| 336 | + if ($newLoaded) { |
|
| 337 | 337 | // ensure those with longest placeholders come first, |
| 338 | 338 | // to avoid substring matches |
| 339 | - uksort($this->configHandlers, function ($phA, $phB) { |
|
| 339 | + uksort($this->configHandlers, function($phA, $phB) { |
|
| 340 | 340 | return strlen($phB) <=> strlen($phA); |
| 341 | 341 | }); |
| 342 | 342 | } |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function checkPlaceholder(): void { |
| 64 | 64 | $this->sanitizedPlaceholder = trim(strtolower($this->placeholder)); |
| 65 | - if(!(bool)\preg_match('/^[a-z0-9]*$/', $this->sanitizedPlaceholder)) { |
|
| 65 | + if (!(bool) \preg_match('/^[a-z0-9]*$/', $this->sanitizedPlaceholder)) { |
|
| 66 | 66 | throw new \RuntimeException(sprintf( |
| 67 | 67 | 'Invalid placeholder %s, only [a-z0-9] are allowed', $this->sanitizedPlaceholder |
| 68 | 68 | )); |
| 69 | 69 | } |
| 70 | - if($this->sanitizedPlaceholder === '') { |
|
| 70 | + if ($this->sanitizedPlaceholder === '') { |
|
| 71 | 71 | throw new \RuntimeException('Invalid empty placeholder'); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @return mixed |
| 79 | 79 | */ |
| 80 | 80 | protected function substituteIfString($value, string $replacement) { |
| 81 | - if(is_string($value)) { |
|
| 82 | - return str_ireplace('$' . $this->sanitizedPlaceholder, $replacement, $value); |
|
| 81 | + if (is_string($value)) { |
|
| 82 | + return str_ireplace('$'.$this->sanitizedPlaceholder, $replacement, $value); |
|
| 83 | 83 | } |
| 84 | 84 | return $value; |
| 85 | 85 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | public function handle($optionValue) { |
| 45 | 45 | $user = $this->session->getUser(); |
| 46 | - if($user === null) { |
|
| 46 | + if ($user === null) { |
|
| 47 | 47 | return $optionValue; |
| 48 | 48 | } |
| 49 | 49 | $uid = $user->getUID(); |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | * @return null |
| 155 | 155 | */ |
| 156 | 156 | public function update() { |
| 157 | - if(is_null($this->dn)) { |
|
| 157 | + if (is_null($this->dn)) { |
|
| 158 | 158 | return null; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $hasLoggedIn = $this->config->getUserValue($this->uid, 'user_ldap', |
| 162 | 162 | self::USER_PREFKEY_FIRSTLOGIN, 0); |
| 163 | 163 | |
| 164 | - if($this->needsRefresh()) { |
|
| 164 | + if ($this->needsRefresh()) { |
|
| 165 | 165 | $this->updateEmail(); |
| 166 | 166 | $this->updateQuota(); |
| 167 | - if($hasLoggedIn !== 0) { |
|
| 167 | + if ($hasLoggedIn !== 0) { |
|
| 168 | 168 | //we do not need to try it, when the user has not been logged in |
| 169 | 169 | //before, because the file system will not be ready. |
| 170 | 170 | $this->updateAvatar(); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $this->markRefreshTime(); |
| 184 | 184 | //Quota |
| 185 | 185 | $attr = strtolower($this->connection->ldapQuotaAttribute); |
| 186 | - if(isset($ldapEntry[$attr])) { |
|
| 186 | + if (isset($ldapEntry[$attr])) { |
|
| 187 | 187 | $this->updateQuota($ldapEntry[$attr][0]); |
| 188 | 188 | } else { |
| 189 | 189 | if ($this->connection->ldapQuotaDefault !== '') { |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | //displayName |
| 196 | 196 | $displayName = $displayName2 = ''; |
| 197 | 197 | $attr = strtolower($this->connection->ldapUserDisplayName); |
| 198 | - if(isset($ldapEntry[$attr])) { |
|
| 199 | - $displayName = (string)$ldapEntry[$attr][0]; |
|
| 198 | + if (isset($ldapEntry[$attr])) { |
|
| 199 | + $displayName = (string) $ldapEntry[$attr][0]; |
|
| 200 | 200 | } |
| 201 | 201 | $attr = strtolower($this->connection->ldapUserDisplayName2); |
| 202 | - if(isset($ldapEntry[$attr])) { |
|
| 203 | - $displayName2 = (string)$ldapEntry[$attr][0]; |
|
| 202 | + if (isset($ldapEntry[$attr])) { |
|
| 203 | + $displayName2 = (string) $ldapEntry[$attr][0]; |
|
| 204 | 204 | } |
| 205 | 205 | if ($displayName !== '') { |
| 206 | 206 | $this->composeAndStoreDisplayName($displayName, $displayName2); |
@@ -216,22 +216,22 @@ discard block |
||
| 216 | 216 | //email must be stored after displayname, because it would cause a user |
| 217 | 217 | //change event that will trigger fetching the display name again |
| 218 | 218 | $attr = strtolower($this->connection->ldapEmailAttribute); |
| 219 | - if(isset($ldapEntry[$attr])) { |
|
| 219 | + if (isset($ldapEntry[$attr])) { |
|
| 220 | 220 | $this->updateEmail($ldapEntry[$attr][0]); |
| 221 | 221 | } |
| 222 | 222 | unset($attr); |
| 223 | 223 | |
| 224 | 224 | // LDAP Username, needed for s2s sharing |
| 225 | - if(isset($ldapEntry['uid'])) { |
|
| 225 | + if (isset($ldapEntry['uid'])) { |
|
| 226 | 226 | $this->storeLDAPUserName($ldapEntry['uid'][0]); |
| 227 | - } else if(isset($ldapEntry['samaccountname'])) { |
|
| 227 | + } else if (isset($ldapEntry['samaccountname'])) { |
|
| 228 | 228 | $this->storeLDAPUserName($ldapEntry['samaccountname'][0]); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | //homePath |
| 232 | - if(strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { |
|
| 232 | + if (strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { |
|
| 233 | 233 | $attr = strtolower(substr($this->connection->homeFolderNamingRule, strlen('attr:'))); |
| 234 | - if(isset($ldapEntry[$attr])) { |
|
| 234 | + if (isset($ldapEntry[$attr])) { |
|
| 235 | 235 | $this->access->cacheUserHome( |
| 236 | 236 | $this->getUsername(), $this->getHomePath($ldapEntry[$attr][0])); |
| 237 | 237 | } |
@@ -240,14 +240,14 @@ discard block |
||
| 240 | 240 | //memberOf groups |
| 241 | 241 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
| 242 | 242 | $groups = false; |
| 243 | - if(isset($ldapEntry['memberof'])) { |
|
| 243 | + if (isset($ldapEntry['memberof'])) { |
|
| 244 | 244 | $groups = $ldapEntry['memberof']; |
| 245 | 245 | } |
| 246 | 246 | $this->connection->writeToCache($cacheKey, $groups); |
| 247 | 247 | |
| 248 | 248 | //external storage var |
| 249 | 249 | $attr = strtolower($this->connection->ldapExtStorageHomeAttribute); |
| 250 | - if(isset($ldapEntry[$attr])) { |
|
| 250 | + if (isset($ldapEntry[$attr])) { |
|
| 251 | 251 | $this->updateExtStorageHome($ldapEntry[$attr][0]); |
| 252 | 252 | } |
| 253 | 253 | unset($attr); |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | /** @var Connection $connection */ |
| 257 | 257 | $connection = $this->access->getConnection(); |
| 258 | 258 | $attributes = $connection->resolveRule('avatar'); |
| 259 | - foreach ($attributes as $attribute) { |
|
| 260 | - if(isset($ldapEntry[$attribute])) { |
|
| 259 | + foreach ($attributes as $attribute) { |
|
| 260 | + if (isset($ldapEntry[$attribute])) { |
|
| 261 | 261 | $this->avatarImage = $ldapEntry[$attribute][0]; |
| 262 | 262 | // the call to the method that saves the avatar in the file |
| 263 | 263 | // system must be postponed after the login. It is to ensure |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | * @throws \Exception |
| 293 | 293 | */ |
| 294 | 294 | public function getHomePath($valueFromLDAP = null) { |
| 295 | - $path = (string)$valueFromLDAP; |
|
| 295 | + $path = (string) $valueFromLDAP; |
|
| 296 | 296 | $attr = null; |
| 297 | 297 | |
| 298 | 298 | if (is_null($valueFromLDAP) |
@@ -310,12 +310,12 @@ discard block |
||
| 310 | 310 | if ($path !== '') { |
| 311 | 311 | //if attribute's value is an absolute path take this, otherwise append it to data dir |
| 312 | 312 | //check for / at the beginning or pattern c:\ resp. c:/ |
| 313 | - if( '/' !== $path[0] |
|
| 313 | + if ('/' !== $path[0] |
|
| 314 | 314 | && !(3 < strlen($path) && ctype_alpha($path[0]) |
| 315 | 315 | && $path[1] === ':' && ('\\' === $path[2] || '/' === $path[2])) |
| 316 | 316 | ) { |
| 317 | 317 | $path = $this->config->getSystemValue('datadirectory', |
| 318 | - \OC::$SERVERROOT.'/data' ) . '/' . $path; |
|
| 318 | + \OC::$SERVERROOT.'/data').'/'.$path; |
|
| 319 | 319 | } |
| 320 | 320 | //we need it to store it in the DB as well in case a user gets |
| 321 | 321 | //deleted so we can clean up afterwards |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | return $path; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if( !is_null($attr) |
|
| 328 | + if (!is_null($attr) |
|
| 329 | 329 | && $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true) |
| 330 | 330 | ) { |
| 331 | 331 | // a naming rule attribute is defined, but it doesn't exist for that LDAP user |
| 332 | - throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername()); |
|
| 332 | + throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: '.$this->getUsername()); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | //false will apply default behaviour as defined and done by OC_User |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | public function getMemberOfGroups() { |
| 341 | 341 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
| 342 | 342 | $memberOfGroups = $this->connection->getFromCache($cacheKey); |
| 343 | - if(!is_null($memberOfGroups)) { |
|
| 343 | + if (!is_null($memberOfGroups)) { |
|
| 344 | 344 | return $memberOfGroups; |
| 345 | 345 | } |
| 346 | 346 | $groupDNs = $this->access->readAttribute($this->getDN(), 'memberOf'); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @return string data (provided by LDAP) | false |
| 354 | 354 | */ |
| 355 | 355 | public function getAvatarImage() { |
| 356 | - if(!is_null($this->avatarImage)) { |
|
| 356 | + if (!is_null($this->avatarImage)) { |
|
| 357 | 357 | return $this->avatarImage; |
| 358 | 358 | } |
| 359 | 359 | |
@@ -361,9 +361,9 @@ discard block |
||
| 361 | 361 | /** @var Connection $connection */ |
| 362 | 362 | $connection = $this->access->getConnection(); |
| 363 | 363 | $attributes = $connection->resolveRule('avatar'); |
| 364 | - foreach($attributes as $attribute) { |
|
| 364 | + foreach ($attributes as $attribute) { |
|
| 365 | 365 | $result = $this->access->readAttribute($this->dn, $attribute); |
| 366 | - if($result !== false && is_array($result) && isset($result[0])) { |
|
| 366 | + if ($result !== false && is_array($result) && isset($result[0])) { |
|
| 367 | 367 | $this->avatarImage = $result[0]; |
| 368 | 368 | break; |
| 369 | 369 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $lastChecked = $this->config->getUserValue($this->uid, 'user_ldap', |
| 401 | 401 | self::USER_PREFKEY_LASTREFRESH, 0); |
| 402 | 402 | |
| 403 | - if((time() - (int)$lastChecked) < (int)$this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) { |
|
| 403 | + if ((time() - (int) $lastChecked) < (int) $this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) { |
|
| 404 | 404 | return false; |
| 405 | 405 | } |
| 406 | 406 | return true; |
@@ -425,12 +425,12 @@ discard block |
||
| 425 | 425 | * @return string the effective display name |
| 426 | 426 | */ |
| 427 | 427 | public function composeAndStoreDisplayName($displayName, $displayName2 = '') { |
| 428 | - $displayName2 = (string)$displayName2; |
|
| 429 | - if($displayName2 !== '') { |
|
| 430 | - $displayName .= ' (' . $displayName2 . ')'; |
|
| 428 | + $displayName2 = (string) $displayName2; |
|
| 429 | + if ($displayName2 !== '') { |
|
| 430 | + $displayName .= ' ('.$displayName2.')'; |
|
| 431 | 431 | } |
| 432 | 432 | $oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', null); |
| 433 | - if ($oldName !== $displayName) { |
|
| 433 | + if ($oldName !== $displayName) { |
|
| 434 | 434 | $this->store('displayName', $displayName); |
| 435 | 435 | $user = $this->userManager->get($this->getUsername()); |
| 436 | 436 | if (!empty($oldName) && $user instanceof \OC\User\User) { |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @return bool |
| 459 | 459 | */ |
| 460 | 460 | private function wasRefreshed($feature) { |
| 461 | - if(isset($this->refreshedFeatures[$feature])) { |
|
| 461 | + if (isset($this->refreshedFeatures[$feature])) { |
|
| 462 | 462 | return true; |
| 463 | 463 | } |
| 464 | 464 | $this->refreshedFeatures[$feature] = 1; |
@@ -471,23 +471,23 @@ discard block |
||
| 471 | 471 | * @return null |
| 472 | 472 | */ |
| 473 | 473 | public function updateEmail($valueFromLDAP = null) { |
| 474 | - if($this->wasRefreshed('email')) { |
|
| 474 | + if ($this->wasRefreshed('email')) { |
|
| 475 | 475 | return; |
| 476 | 476 | } |
| 477 | - $email = (string)$valueFromLDAP; |
|
| 478 | - if(is_null($valueFromLDAP)) { |
|
| 477 | + $email = (string) $valueFromLDAP; |
|
| 478 | + if (is_null($valueFromLDAP)) { |
|
| 479 | 479 | $emailAttribute = $this->connection->ldapEmailAttribute; |
| 480 | 480 | if ($emailAttribute !== '') { |
| 481 | 481 | $aEmail = $this->access->readAttribute($this->dn, $emailAttribute); |
| 482 | - if(is_array($aEmail) && (count($aEmail) > 0)) { |
|
| 483 | - $email = (string)$aEmail[0]; |
|
| 482 | + if (is_array($aEmail) && (count($aEmail) > 0)) { |
|
| 483 | + $email = (string) $aEmail[0]; |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | if ($email !== '') { |
| 488 | 488 | $user = $this->userManager->get($this->uid); |
| 489 | 489 | if (!is_null($user)) { |
| 490 | - $currentEmail = (string)$user->getEMailAddress(); |
|
| 490 | + $currentEmail = (string) $user->getEMailAddress(); |
|
| 491 | 491 | if ($currentEmail !== $email) { |
| 492 | 492 | $user->setEMailAddress($email); |
| 493 | 493 | } |
@@ -516,35 +516,35 @@ discard block |
||
| 516 | 516 | * @return null |
| 517 | 517 | */ |
| 518 | 518 | public function updateQuota($valueFromLDAP = null) { |
| 519 | - if($this->wasRefreshed('quota')) { |
|
| 519 | + if ($this->wasRefreshed('quota')) { |
|
| 520 | 520 | return; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | $quotaAttribute = $this->connection->ldapQuotaAttribute; |
| 524 | 524 | $defaultQuota = $this->connection->ldapQuotaDefault; |
| 525 | - if($quotaAttribute === '' && $defaultQuota === '') { |
|
| 525 | + if ($quotaAttribute === '' && $defaultQuota === '') { |
|
| 526 | 526 | return; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | $quota = false; |
| 530 | - if(is_null($valueFromLDAP) && $quotaAttribute !== '') { |
|
| 530 | + if (is_null($valueFromLDAP) && $quotaAttribute !== '') { |
|
| 531 | 531 | $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); |
| 532 | - if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { |
|
| 532 | + if ($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { |
|
| 533 | 533 | $quota = $aQuota[0]; |
| 534 | - } else if(is_array($aQuota) && isset($aQuota[0])) { |
|
| 535 | - $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG); |
|
| 534 | + } else if (is_array($aQuota) && isset($aQuota[0])) { |
|
| 535 | + $this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$aQuota[0].']', ILogger::DEBUG); |
|
| 536 | 536 | } |
| 537 | 537 | } else if ($this->verifyQuotaValue($valueFromLDAP)) { |
| 538 | 538 | $quota = $valueFromLDAP; |
| 539 | 539 | } else { |
| 540 | - $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG); |
|
| 540 | + $this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$valueFromLDAP.']', ILogger::DEBUG); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | if ($quota === false && $this->verifyQuotaValue($defaultQuota)) { |
| 544 | 544 | // quota not found using the LDAP attribute (or not parseable). Try the default quota |
| 545 | 545 | $quota = $defaultQuota; |
| 546 | - } else if($quota === false) { |
|
| 547 | - $this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG); |
|
| 546 | + } else if ($quota === false) { |
|
| 547 | + $this->log->log('no suitable default quota found for user '.$this->uid.': ['.$defaultQuota.']', ILogger::DEBUG); |
|
| 548 | 548 | return; |
| 549 | 549 | } |
| 550 | 550 | |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | if ($targetUser instanceof IUser) { |
| 553 | 553 | $targetUser->setQuota($quota); |
| 554 | 554 | } else { |
| 555 | - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO); |
|
| 555 | + $this->log->log('trying to set a quota for user '.$this->uid.' but the user is missing', ILogger::INFO); |
|
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @param array $params |
| 567 | 567 | */ |
| 568 | 568 | public function updateAvatarPostLogin($params) { |
| 569 | - if(isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
| 569 | + if (isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
| 570 | 570 | $this->updateAvatar(); |
| 571 | 571 | } |
| 572 | 572 | } |
@@ -576,15 +576,15 @@ discard block |
||
| 576 | 576 | * @return bool |
| 577 | 577 | */ |
| 578 | 578 | public function updateAvatar($force = false) { |
| 579 | - if(!$force && $this->wasRefreshed('avatar')) { |
|
| 579 | + if (!$force && $this->wasRefreshed('avatar')) { |
|
| 580 | 580 | return false; |
| 581 | 581 | } |
| 582 | 582 | $avatarImage = $this->getAvatarImage(); |
| 583 | - if($avatarImage === false) { |
|
| 583 | + if ($avatarImage === false) { |
|
| 584 | 584 | //not set, nothing left to do; |
| 585 | 585 | return false; |
| 586 | 586 | } |
| 587 | - if(!$this->image->loadFromBase64(base64_encode($avatarImage))) { |
|
| 587 | + if (!$this->image->loadFromBase64(base64_encode($avatarImage))) { |
|
| 588 | 588 | return false; |
| 589 | 589 | } |
| 590 | 590 | return $this->setOwnCloudAvatar(); |
@@ -595,18 +595,18 @@ discard block |
||
| 595 | 595 | * @return bool |
| 596 | 596 | */ |
| 597 | 597 | private function setOwnCloudAvatar() { |
| 598 | - if(!$this->image->valid()) { |
|
| 598 | + if (!$this->image->valid()) { |
|
| 599 | 599 | $this->log->log('avatar image data from LDAP invalid for '.$this->dn, ILogger::ERROR); |
| 600 | 600 | return false; |
| 601 | 601 | } |
| 602 | 602 | //make sure it is a square and not bigger than 128x128 |
| 603 | 603 | $size = min(array($this->image->width(), $this->image->height(), 128)); |
| 604 | - if(!$this->image->centerCrop($size)) { |
|
| 604 | + if (!$this->image->centerCrop($size)) { |
|
| 605 | 605 | $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR); |
| 606 | 606 | return false; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - if(!$this->fs->isLoaded()) { |
|
| 609 | + if (!$this->fs->isLoaded()) { |
|
| 610 | 610 | $this->fs->setup($this->uid); |
| 611 | 611 | } |
| 612 | 612 | |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | return true; |
| 617 | 617 | } catch (\Exception $e) { |
| 618 | 618 | \OC::$server->getLogger()->logException($e, [ |
| 619 | - 'message' => 'Could not set avatar for ' . $this->dn, |
|
| 619 | + 'message' => 'Could not set avatar for '.$this->dn, |
|
| 620 | 620 | 'level' => ILogger::INFO, |
| 621 | 621 | 'app' => 'user_ldap', |
| 622 | 622 | ]); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | * @throws \OC\ServerNotAvailableException |
| 651 | 651 | */ |
| 652 | 652 | public function updateExtStorageHome(string $valueFromLDAP = null):string { |
| 653 | - if($valueFromLDAP === null) { |
|
| 653 | + if ($valueFromLDAP === null) { |
|
| 654 | 654 | $extHomeValues = $this->access->readAttribute($this->getDN(), $this->connection->ldapExtStorageHomeAttribute); |
| 655 | 655 | } else { |
| 656 | 656 | $extHomeValues = [$valueFromLDAP]; |
@@ -672,18 +672,18 @@ discard block |
||
| 672 | 672 | */ |
| 673 | 673 | public function handlePasswordExpiry($params) { |
| 674 | 674 | $ppolicyDN = $this->connection->ldapDefaultPPolicyDN; |
| 675 | - if (empty($ppolicyDN) || ((int)$this->connection->turnOnPasswordChange !== 1)) { |
|
| 676 | - return;//password expiry handling disabled |
|
| 675 | + if (empty($ppolicyDN) || ((int) $this->connection->turnOnPasswordChange !== 1)) { |
|
| 676 | + return; //password expiry handling disabled |
|
| 677 | 677 | } |
| 678 | 678 | $uid = $params['uid']; |
| 679 | - if(isset($uid) && $uid === $this->getUsername()) { |
|
| 679 | + if (isset($uid) && $uid === $this->getUsername()) { |
|
| 680 | 680 | //retrieve relevant user attributes |
| 681 | 681 | $result = $this->access->search('objectclass=*', array($this->dn), ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']); |
| 682 | 682 | |
| 683 | - if(array_key_exists('pwdpolicysubentry', $result[0])) { |
|
| 683 | + if (array_key_exists('pwdpolicysubentry', $result[0])) { |
|
| 684 | 684 | $pwdPolicySubentry = $result[0]['pwdpolicysubentry']; |
| 685 | - if($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){ |
|
| 686 | - $ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN |
|
| 685 | + if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) { |
|
| 686 | + $ppolicyDN = $pwdPolicySubentry[0]; //custom ppolicy DN |
|
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | $pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : null; |
| 693 | 693 | |
| 694 | 694 | //retrieve relevant password policy attributes |
| 695 | - $cacheKey = 'ppolicyAttributes' . $ppolicyDN; |
|
| 695 | + $cacheKey = 'ppolicyAttributes'.$ppolicyDN; |
|
| 696 | 696 | $result = $this->connection->getFromCache($cacheKey); |
| 697 | - if(is_null($result)) { |
|
| 697 | + if (is_null($result)) { |
|
| 698 | 698 | $result = $this->access->search('objectclass=*', array($ppolicyDN), ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); |
| 699 | 699 | $this->connection->writeToCache($cacheKey, $result); |
| 700 | 700 | } |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | //handle grace login |
| 707 | 707 | $pwdGraceUseTimeCount = count($pwdGraceUseTime); |
| 708 | - if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
| 709 | - if($pwdGraceAuthNLimit |
|
| 708 | + if ($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login? |
|
| 709 | + if ($pwdGraceAuthNLimit |
|
| 710 | 710 | && (count($pwdGraceAuthNLimit) > 0) |
| 711 | - &&($pwdGraceUseTimeCount < (int)$pwdGraceAuthNLimit[0])) { //at least one more grace login available? |
|
| 711 | + &&($pwdGraceUseTimeCount < (int) $pwdGraceAuthNLimit[0])) { //at least one more grace login available? |
|
| 712 | 712 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
| 713 | 713 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
| 714 | 714 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
@@ -719,24 +719,24 @@ discard block |
||
| 719 | 719 | exit(); |
| 720 | 720 | } |
| 721 | 721 | //handle pwdReset attribute |
| 722 | - if($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
| 722 | + if ($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password |
|
| 723 | 723 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
| 724 | 724 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
| 725 | 725 | 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid))); |
| 726 | 726 | exit(); |
| 727 | 727 | } |
| 728 | 728 | //handle password expiry warning |
| 729 | - if($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
| 730 | - if($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
| 729 | + if ($pwdChangedTime && (count($pwdChangedTime) > 0)) { |
|
| 730 | + if ($pwdMaxAge && (count($pwdMaxAge) > 0) |
|
| 731 | 731 | && $pwdExpireWarning && (count($pwdExpireWarning) > 0)) { |
| 732 | - $pwdMaxAgeInt = (int)$pwdMaxAge[0]; |
|
| 733 | - $pwdExpireWarningInt = (int)$pwdExpireWarning[0]; |
|
| 734 | - if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){ |
|
| 732 | + $pwdMaxAgeInt = (int) $pwdMaxAge[0]; |
|
| 733 | + $pwdExpireWarningInt = (int) $pwdExpireWarning[0]; |
|
| 734 | + if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0) { |
|
| 735 | 735 | $pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]); |
| 736 | 736 | $pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S')); |
| 737 | 737 | $currentDateTime = new \DateTime(); |
| 738 | 738 | $secondsToExpiry = $pwdChangedTimeDt->getTimestamp() - $currentDateTime->getTimestamp(); |
| 739 | - if($secondsToExpiry <= $pwdExpireWarningInt) { |
|
| 739 | + if ($secondsToExpiry <= $pwdExpireWarningInt) { |
|
| 740 | 740 | //remove last password expiry warning if any |
| 741 | 741 | $notification = $this->notificationManager->createNotification(); |
| 742 | 742 | $notification->setApp('user_ldap') |
@@ -47,22 +47,22 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | public function handle($optionValue) { |
| 49 | 49 | $user = $this->session->getUser(); |
| 50 | - if($user === null) { |
|
| 50 | + if ($user === null) { |
|
| 51 | 51 | return $optionValue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $backend = $user->getBackend(); |
| 55 | - if(!$backend instanceof User_Proxy) { |
|
| 55 | + if (!$backend instanceof User_Proxy) { |
|
| 56 | 56 | return $optionValue; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $access = $backend->getLDAPAccess($user->getUID()); |
| 60 | - if(!$access) { |
|
| 60 | + if (!$access) { |
|
| 61 | 61 | return $optionValue; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $attribute = $access->connection->ldapExtStorageHomeAttribute; |
| 65 | - if(empty($attribute)) { |
|
| 65 | + if (empty($attribute)) { |
|
| 66 | 66 | return $optionValue; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | use OCP\IL10N; |
| 34 | 34 | |
| 35 | 35 | class Application extends App { |
| 36 | - public function __construct () { |
|
| 36 | + public function __construct() { |
|
| 37 | 37 | parent::__construct('user_ldap'); |
| 38 | 38 | $container = $this->getContainer(); |
| 39 | 39 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | }); |
| 57 | 57 | |
| 58 | - $container->registerService(ILDAPWrapper::class, function () { |
|
| 58 | + $container->registerService(ILDAPWrapper::class, function() { |
|
| 59 | 59 | return new LDAP(); |
| 60 | 60 | }); |
| 61 | 61 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | 'OCA\\Files_External::loadAdditionalBackends', |
| 68 | 68 | function() use ($container) { |
| 69 | 69 | $storagesBackendService = $container->query(BackendService::class); |
| 70 | - $storagesBackendService->registerConfigHandler('home', function () use ($container) { |
|
| 70 | + $storagesBackendService->registerConfigHandler('home', function() use ($container) { |
|
| 71 | 71 | return $container->query(ExtStorageConfigHandler::class); |
| 72 | 72 | }); |
| 73 | 73 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function __construct($configPrefix, $autoRead = true) { |
| 117 | 117 | $this->configPrefix = $configPrefix; |
| 118 | - if($autoRead) { |
|
| 118 | + if ($autoRead) { |
|
| 119 | 119 | $this->readConfiguration(); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @return mixed|null |
| 126 | 126 | */ |
| 127 | 127 | public function __get($name) { |
| 128 | - if(isset($this->config[$name])) { |
|
| 128 | + if (isset($this->config[$name])) { |
|
| 129 | 129 | return $this->config[$name]; |
| 130 | 130 | } |
| 131 | 131 | return null; |
@@ -156,22 +156,22 @@ discard block |
||
| 156 | 156 | * @return false|null |
| 157 | 157 | */ |
| 158 | 158 | public function setConfiguration($config, &$applied = null) { |
| 159 | - if(!is_array($config)) { |
|
| 159 | + if (!is_array($config)) { |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $cta = $this->getConfigTranslationArray(); |
| 164 | - foreach($config as $inputKey => $val) { |
|
| 165 | - if(strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) { |
|
| 164 | + foreach ($config as $inputKey => $val) { |
|
| 165 | + if (strpos($inputKey, '_') !== false && array_key_exists($inputKey, $cta)) { |
|
| 166 | 166 | $key = $cta[$inputKey]; |
| 167 | - } elseif(array_key_exists($inputKey, $this->config)) { |
|
| 167 | + } elseif (array_key_exists($inputKey, $this->config)) { |
|
| 168 | 168 | $key = $inputKey; |
| 169 | 169 | } else { |
| 170 | 170 | continue; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $setMethod = 'setValue'; |
| 174 | - switch($key) { |
|
| 174 | + switch ($key) { |
|
| 175 | 175 | case 'ldapAgentPassword': |
| 176 | 176 | $setMethod = 'setRawValue'; |
| 177 | 177 | break; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | break; |
| 196 | 196 | } |
| 197 | 197 | $this->$setMethod($key, $val); |
| 198 | - if(is_array($applied)) { |
|
| 198 | + if (is_array($applied)) { |
|
| 199 | 199 | $applied[] = $inputKey; |
| 200 | 200 | // storing key as index avoids duplication, and as value for simplicity |
| 201 | 201 | } |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | public function readConfiguration() { |
| 208 | - if(!$this->configRead && !is_null($this->configPrefix)) { |
|
| 208 | + if (!$this->configRead && !is_null($this->configPrefix)) { |
|
| 209 | 209 | $cta = array_flip($this->getConfigTranslationArray()); |
| 210 | - foreach($this->config as $key => $val) { |
|
| 211 | - if(!isset($cta[$key])) { |
|
| 210 | + foreach ($this->config as $key => $val) { |
|
| 211 | + if (!isset($cta[$key])) { |
|
| 212 | 212 | //some are determined |
| 213 | 213 | continue; |
| 214 | 214 | } |
| 215 | 215 | $dbKey = $cta[$key]; |
| 216 | - switch($key) { |
|
| 216 | + switch ($key) { |
|
| 217 | 217 | case 'ldapBase': |
| 218 | 218 | case 'ldapBaseUsers': |
| 219 | 219 | case 'ldapBaseGroups': |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function saveConfiguration() { |
| 258 | 258 | $cta = array_flip($this->getConfigTranslationArray()); |
| 259 | - foreach($this->unsavedChanges as $key) { |
|
| 259 | + foreach ($this->unsavedChanges as $key) { |
|
| 260 | 260 | $value = $this->config[$key]; |
| 261 | 261 | switch ($key) { |
| 262 | 262 | case 'ldapAgentPassword': |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | case 'ldapGroupFilterObjectclass': |
| 273 | 273 | case 'ldapGroupFilterGroups': |
| 274 | 274 | case 'ldapLoginFilterAttributes': |
| 275 | - if(is_array($value)) { |
|
| 275 | + if (is_array($value)) { |
|
| 276 | 276 | $value = implode("\n", $value); |
| 277 | 277 | } |
| 278 | 278 | break; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | case 'ldapUuidGroupAttribute': |
| 283 | 283 | continue 2; |
| 284 | 284 | } |
| 285 | - if(is_null($value)) { |
|
| 285 | + if (is_null($value)) { |
|
| 286 | 286 | $value = ''; |
| 287 | 287 | } |
| 288 | 288 | $this->saveValue($cta[$key], $value); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | protected function getMultiLine($varName) { |
| 299 | 299 | $value = $this->getValue($varName); |
| 300 | - if(empty($value)) { |
|
| 300 | + if (empty($value)) { |
|
| 301 | 301 | $value = ''; |
| 302 | 302 | } else { |
| 303 | 303 | $value = preg_split('/\r\n|\r|\n/', $value); |
@@ -313,21 +313,21 @@ discard block |
||
| 313 | 313 | * @param array|string $value to set |
| 314 | 314 | */ |
| 315 | 315 | protected function setMultiLine($varName, $value) { |
| 316 | - if(empty($value)) { |
|
| 316 | + if (empty($value)) { |
|
| 317 | 317 | $value = ''; |
| 318 | 318 | } else if (!is_array($value)) { |
| 319 | 319 | $value = preg_split('/\r\n|\r|\n|;/', $value); |
| 320 | - if($value === false) { |
|
| 320 | + if ($value === false) { |
|
| 321 | 321 | $value = ''; |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if(!is_array($value)) { |
|
| 325 | + if (!is_array($value)) { |
|
| 326 | 326 | $finalValue = trim($value); |
| 327 | 327 | } else { |
| 328 | 328 | $finalValue = []; |
| 329 | - foreach($value as $key => $val) { |
|
| 330 | - if(is_string($val)) { |
|
| 329 | + foreach ($value as $key => $val) { |
|
| 330 | + if (is_string($val)) { |
|
| 331 | 331 | $val = trim($val); |
| 332 | 332 | if ($val !== '') { |
| 333 | 333 | //accidental line breaks are not wanted and can cause |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | protected function getValue($varName) { |
| 376 | 376 | static $defaults; |
| 377 | - if(is_null($defaults)) { |
|
| 377 | + if (is_null($defaults)) { |
|
| 378 | 378 | $defaults = $this->getDefaults(); |
| 379 | 379 | } |
| 380 | 380 | return \OC::$server->getConfig()->getAppValue('user_ldap', |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param mixed $value to set |
| 390 | 390 | */ |
| 391 | 391 | protected function setValue($varName, $value) { |
| 392 | - if(is_string($value)) { |
|
| 392 | + if (is_string($value)) { |
|
| 393 | 393 | $value = trim($value); |
| 394 | 394 | } |
| 395 | 395 | $this->config[$varName] = $value; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | 'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL', |
| 541 | 541 | 'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN', |
| 542 | 542 | 'ldap_ext_storage_home_attribute' => 'ldapExtStorageHomeAttribute', |
| 543 | - 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig |
|
| 543 | + 'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig |
|
| 544 | 544 | ); |
| 545 | 545 | return $array; |
| 546 | 546 | } |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | * @throws \RuntimeException |
| 552 | 552 | */ |
| 553 | 553 | public function resolveRule($rule) { |
| 554 | - if($rule === 'avatar') { |
|
| 554 | + if ($rule === 'avatar') { |
|
| 555 | 555 | return $this->getAvatarAttributes(); |
| 556 | 556 | } |
| 557 | 557 | throw new \RuntimeException('Invalid rule'); |
@@ -561,17 +561,17 @@ discard block |
||
| 561 | 561 | $value = $this->ldapUserAvatarRule ?: self::AVATAR_PREFIX_DEFAULT; |
| 562 | 562 | $defaultAttributes = ['jpegphoto', 'thumbnailphoto']; |
| 563 | 563 | |
| 564 | - if($value === self::AVATAR_PREFIX_NONE) { |
|
| 564 | + if ($value === self::AVATAR_PREFIX_NONE) { |
|
| 565 | 565 | return []; |
| 566 | 566 | } |
| 567 | - if(strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) { |
|
| 567 | + if (strpos($value, self::AVATAR_PREFIX_DATA_ATTRIBUTE) === 0) { |
|
| 568 | 568 | $attribute = trim(substr($value, strlen(self::AVATAR_PREFIX_DATA_ATTRIBUTE))); |
| 569 | - if($attribute === '') { |
|
| 569 | + if ($attribute === '') { |
|
| 570 | 570 | return $defaultAttributes; |
| 571 | 571 | } |
| 572 | 572 | return [strtolower($attribute)]; |
| 573 | 573 | } |
| 574 | - if($value !== self::AVATAR_PREFIX_DEFAULT) { |
|
| 574 | + if ($value !== self::AVATAR_PREFIX_DEFAULT) { |
|
| 575 | 575 | \OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.'); |
| 576 | 576 | } |
| 577 | 577 | return $defaultAttributes; |