2019-02-12 18:14:56 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2019-02-12 18:14:56 -05:00
|
|
|
/**
|
2024-05-29 05:32:54 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-02-12 18:14:56 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCA\User_LDAP\Handler;
|
|
|
|
|
|
|
|
|
|
use OCA\Files_External\Config\IConfigHandler;
|
|
|
|
|
use OCA\Files_External\Config\SimpleSubstitutionTrait;
|
2019-07-24 05:53:53 -04:00
|
|
|
use OCA\Files_External\Config\UserContext;
|
2019-02-12 18:14:56 -05:00
|
|
|
use OCA\User_LDAP\User_Proxy;
|
|
|
|
|
|
2019-07-24 05:53:53 -04:00
|
|
|
class ExtStorageConfigHandler extends UserContext implements IConfigHandler {
|
2019-02-12 18:14:56 -05:00
|
|
|
use SimpleSubstitutionTrait;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param mixed $optionValue
|
|
|
|
|
* @return mixed the same type as $optionValue
|
|
|
|
|
* @since 16.0.0
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
*/
|
|
|
|
|
public function handle($optionValue) {
|
2019-07-24 05:53:53 -04:00
|
|
|
$this->placeholder = 'home';
|
2019-07-25 11:58:13 -04:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
|
2020-04-10 08:19:56 -04:00
|
|
|
if ($user === null) {
|
2019-02-12 18:14:56 -05:00
|
|
|
return $optionValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$backend = $user->getBackend();
|
2020-04-10 08:19:56 -04:00
|
|
|
if (!$backend instanceof User_Proxy) {
|
2019-02-12 18:14:56 -05:00
|
|
|
return $optionValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$access = $backend->getLDAPAccess($user->getUID());
|
2020-04-10 08:19:56 -04:00
|
|
|
if (!$access) {
|
2019-02-12 18:14:56 -05:00
|
|
|
return $optionValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$attribute = $access->connection->ldapExtStorageHomeAttribute;
|
2020-04-10 08:19:56 -04:00
|
|
|
if (empty($attribute)) {
|
2019-02-12 18:14:56 -05:00
|
|
|
return $optionValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ldapUser = $access->userManager->get($user->getUID());
|
2023-03-22 08:54:27 -04:00
|
|
|
$extHome = $ldapUser !== null ? $ldapUser->getExtStorageHome() : '';
|
2019-02-12 18:14:56 -05:00
|
|
|
|
|
|
|
|
return $this->processInput($optionValue, $extHome);
|
|
|
|
|
}
|
|
|
|
|
}
|