|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2019 Arthur Schiwon <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Arthur Schiwon <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OCA\User_LDAP\Handler; |
|
25
|
|
|
|
|
26
|
|
|
use OCA\Files_External\Config\IConfigHandler; |
|
27
|
|
|
use OCA\Files_External\Config\SimpleSubstitutionTrait; |
|
28
|
|
|
use OCA\User_LDAP\User_Proxy; |
|
29
|
|
|
use OCP\IUserSession; |
|
30
|
|
|
|
|
31
|
|
|
class ExtStorageConfigHandler implements IConfigHandler { |
|
32
|
|
|
use SimpleSubstitutionTrait; |
|
33
|
|
|
|
|
34
|
|
|
/** @var IUserSession */ |
|
35
|
|
|
private $session; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct(IUserSession $session) { |
|
38
|
|
|
$this->placeholder = 'home'; |
|
39
|
|
|
$this->session = $session; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param mixed $optionValue |
|
44
|
|
|
* @return mixed the same type as $optionValue |
|
45
|
|
|
* @since 16.0.0 |
|
46
|
|
|
* @throws \Exception |
|
47
|
|
|
*/ |
|
48
|
|
|
public function handle($optionValue) { |
|
49
|
|
|
$user = $this->session->getUser(); |
|
50
|
|
|
if($user === null) { |
|
51
|
|
|
return $optionValue; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$backend = $user->getBackend(); |
|
55
|
|
|
if(!$backend instanceof User_Proxy) { |
|
56
|
|
|
return $optionValue; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$access = $backend->getLDAPAccess($user->getUID()); |
|
60
|
|
|
if(!$access) { |
|
|
|
|
|
|
61
|
|
|
return $optionValue; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$attribute = $access->connection->ldapExtStorageHomeAttribute; |
|
65
|
|
|
if(empty($attribute)) { |
|
66
|
|
|
return $optionValue; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$ldapUser = $access->userManager->get($user->getUID()); |
|
70
|
|
|
$extHome = $ldapUser->getExtStorageHome(); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
return $this->processInput($optionValue, $extHome); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|