1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Viktar Dubiniuk <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\FederatedFileSharing; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class Address |
26
|
|
|
* |
27
|
|
|
* @package OCA\FederatedFileSharing |
28
|
|
|
*/ |
29
|
|
|
class Address { |
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $userId; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $displayName; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $hostName; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Address constructor. |
47
|
|
|
* |
48
|
|
|
* @param string $hostName |
49
|
|
|
* @param string $userId |
50
|
|
|
* @param string $displayName |
51
|
|
|
*/ |
52
|
|
|
public function __construct($hostName, $userId, $displayName = '') { |
53
|
|
|
$this->hostName = $hostName; |
54
|
|
|
$this->userId = $userId; |
55
|
|
|
$this->displayName = $displayName; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get user federated id |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getCloudId() { |
64
|
|
|
return "{$this->userId}@{$this->hostName}"; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get user id |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getUserId() { |
73
|
|
|
return $this->userId; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get user host |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getHostName() { |
82
|
|
|
return $this->hostName; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get user display name, fallback to userId if it is empty |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getDisplayName() { |
91
|
|
|
return ($this->displayName !== '') ? $this->displayName : $this->userId; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|