2019-02-13 00:14:56 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2024-05-29 11:32:54 +02:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-02-13 00:14:56 +01:00
|
|
|
*/
|
|
|
|
namespace OCA\User_LDAP\Handler;
|
|
|
|
|
|
|
|
use OCA\Files_External\Config\IConfigHandler;
|
|
|
|
use OCA\Files_External\Config\SimpleSubstitutionTrait;
|
2019-07-24 11:53:53 +02:00
|
|
|
use OCA\Files_External\Config\UserContext;
|
2019-02-13 00:14:56 +01:00
|
|
|
use OCA\User_LDAP\User_Proxy;
|
|
|
|
|
2019-07-24 11:53:53 +02:00
|
|
|
class ExtStorageConfigHandler extends UserContext implements IConfigHandler {
|
2019-02-13 00:14:56 +01: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 11:53:53 +02:00
|
|
|
$this->placeholder = 'home';
|
2019-07-25 17:58:13 +02:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
2019-08-02 13:09:38 +02:00
|
|
|
if ($user === null) {
|
2019-02-13 00:14:56 +01:00
|
|
|
return $optionValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$backend = $user->getBackend();
|
|
|
|
if (!$backend instanceof User_Proxy) {
|
|
|
|
return $optionValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$access = $backend->getLDAPAccess($user->getUID());
|
|
|
|
if (!$access) {
|
|
|
|
return $optionValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$attribute = $access->connection->ldapExtStorageHomeAttribute;
|
|
|
|
if (empty($attribute)) {
|
|
|
|
return $optionValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$ldapUser = $access->userManager->get($user->getUID());
|
2023-03-22 13:54:27 +01:00
|
|
|
$extHome = $ldapUser !== null ? $ldapUser->getExtStorageHome() : '';
|
2019-02-13 00:14:56 +01:00
|
|
|
|
|
|
|
return $this->processInput($optionValue, $extHome);
|
|
|
|
}
|
|
|
|
}
|