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\Files_External\Config\UserContext; |
29
|
|
|
use OCA\User_LDAP\User_Proxy; |
30
|
|
|
|
31
|
|
|
class ExtStorageConfigHandler extends UserContext implements IConfigHandler { |
32
|
|
|
use SimpleSubstitutionTrait; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param mixed $optionValue |
36
|
|
|
* @return mixed the same type as $optionValue |
37
|
|
|
* @since 16.0.0 |
38
|
|
|
* @throws \Exception |
39
|
|
|
*/ |
40
|
|
|
public function handle($optionValue) { |
41
|
|
|
$this->placeholder = 'home'; |
42
|
|
|
$user = $this->getUser(); |
43
|
|
|
|
44
|
|
|
if($user === null) { |
45
|
|
|
return $optionValue; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$backend = $user->getBackend(); |
49
|
|
|
if(!$backend instanceof User_Proxy) { |
50
|
|
|
return $optionValue; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$access = $backend->getLDAPAccess($user->getUID()); |
54
|
|
|
if(!$access) { |
|
|
|
|
55
|
|
|
return $optionValue; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$attribute = $access->connection->ldapExtStorageHomeAttribute; |
59
|
|
|
if(empty($attribute)) { |
60
|
|
|
return $optionValue; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$ldapUser = $access->userManager->get($user->getUID()); |
64
|
|
|
$extHome = $ldapUser->getExtStorageHome(); |
|
|
|
|
65
|
|
|
|
66
|
|
|
return $this->processInput($optionValue, $extHome); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|