@@ -32,240 +32,240 @@ |
||
32 | 32 | use OCP\Share\IShare; |
33 | 33 | |
34 | 34 | class OfflineUser { |
35 | - /** |
|
36 | - * @var string $ocName |
|
37 | - */ |
|
38 | - protected $ocName; |
|
39 | - /** |
|
40 | - * @var string $dn |
|
41 | - */ |
|
42 | - protected $dn; |
|
43 | - /** |
|
44 | - * @var string $uid the UID as provided by LDAP |
|
45 | - */ |
|
46 | - protected $uid; |
|
47 | - /** |
|
48 | - * @var string $displayName |
|
49 | - */ |
|
50 | - protected $displayName; |
|
51 | - /** |
|
52 | - * @var string $homePath |
|
53 | - */ |
|
54 | - protected $homePath; |
|
55 | - /** |
|
56 | - * @var string $lastLogin the timestamp of the last login |
|
57 | - */ |
|
58 | - protected $lastLogin; |
|
59 | - /** |
|
60 | - * @var string $foundDeleted the timestamp when the user was detected as unavailable |
|
61 | - */ |
|
62 | - protected $foundDeleted; |
|
63 | - /** |
|
64 | - * @var string $email |
|
65 | - */ |
|
66 | - protected $email; |
|
67 | - /** |
|
68 | - * @var bool $hasActiveShares |
|
69 | - */ |
|
70 | - protected $hasActiveShares; |
|
71 | - /** |
|
72 | - * @var IConfig $config |
|
73 | - */ |
|
74 | - protected $config; |
|
75 | - /** |
|
76 | - * @var IDBConnection $db |
|
77 | - */ |
|
78 | - protected $db; |
|
79 | - /** |
|
80 | - * @var \OCA\User_LDAP\Mapping\UserMapping |
|
81 | - */ |
|
82 | - protected $mapping; |
|
83 | - /** @var IManager */ |
|
84 | - private $shareManager; |
|
35 | + /** |
|
36 | + * @var string $ocName |
|
37 | + */ |
|
38 | + protected $ocName; |
|
39 | + /** |
|
40 | + * @var string $dn |
|
41 | + */ |
|
42 | + protected $dn; |
|
43 | + /** |
|
44 | + * @var string $uid the UID as provided by LDAP |
|
45 | + */ |
|
46 | + protected $uid; |
|
47 | + /** |
|
48 | + * @var string $displayName |
|
49 | + */ |
|
50 | + protected $displayName; |
|
51 | + /** |
|
52 | + * @var string $homePath |
|
53 | + */ |
|
54 | + protected $homePath; |
|
55 | + /** |
|
56 | + * @var string $lastLogin the timestamp of the last login |
|
57 | + */ |
|
58 | + protected $lastLogin; |
|
59 | + /** |
|
60 | + * @var string $foundDeleted the timestamp when the user was detected as unavailable |
|
61 | + */ |
|
62 | + protected $foundDeleted; |
|
63 | + /** |
|
64 | + * @var string $email |
|
65 | + */ |
|
66 | + protected $email; |
|
67 | + /** |
|
68 | + * @var bool $hasActiveShares |
|
69 | + */ |
|
70 | + protected $hasActiveShares; |
|
71 | + /** |
|
72 | + * @var IConfig $config |
|
73 | + */ |
|
74 | + protected $config; |
|
75 | + /** |
|
76 | + * @var IDBConnection $db |
|
77 | + */ |
|
78 | + protected $db; |
|
79 | + /** |
|
80 | + * @var \OCA\User_LDAP\Mapping\UserMapping |
|
81 | + */ |
|
82 | + protected $mapping; |
|
83 | + /** @var IManager */ |
|
84 | + private $shareManager; |
|
85 | 85 | |
86 | - public function __construct( |
|
87 | - $ocName, |
|
88 | - IConfig $config, |
|
89 | - UserMapping $mapping, |
|
90 | - IManager $shareManager |
|
91 | - ) { |
|
92 | - $this->ocName = $ocName; |
|
93 | - $this->config = $config; |
|
94 | - $this->mapping = $mapping; |
|
95 | - $this->shareManager = $shareManager; |
|
96 | - } |
|
86 | + public function __construct( |
|
87 | + $ocName, |
|
88 | + IConfig $config, |
|
89 | + UserMapping $mapping, |
|
90 | + IManager $shareManager |
|
91 | + ) { |
|
92 | + $this->ocName = $ocName; |
|
93 | + $this->config = $config; |
|
94 | + $this->mapping = $mapping; |
|
95 | + $this->shareManager = $shareManager; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * remove the Delete-flag from the user. |
|
100 | - */ |
|
101 | - public function unmark() { |
|
102 | - $this->config->deleteUserValue($this->ocName, 'user_ldap', 'isDeleted'); |
|
103 | - $this->config->deleteUserValue($this->ocName, 'user_ldap', 'foundDeleted'); |
|
104 | - } |
|
98 | + /** |
|
99 | + * remove the Delete-flag from the user. |
|
100 | + */ |
|
101 | + public function unmark() { |
|
102 | + $this->config->deleteUserValue($this->ocName, 'user_ldap', 'isDeleted'); |
|
103 | + $this->config->deleteUserValue($this->ocName, 'user_ldap', 'foundDeleted'); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * exports the user details in an assoc array |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function export() { |
|
111 | - $data = []; |
|
112 | - $data['ocName'] = $this->getOCName(); |
|
113 | - $data['dn'] = $this->getDN(); |
|
114 | - $data['uid'] = $this->getUID(); |
|
115 | - $data['displayName'] = $this->getDisplayName(); |
|
116 | - $data['homePath'] = $this->getHomePath(); |
|
117 | - $data['lastLogin'] = $this->getLastLogin(); |
|
118 | - $data['email'] = $this->getEmail(); |
|
119 | - $data['hasActiveShares'] = $this->getHasActiveShares(); |
|
106 | + /** |
|
107 | + * exports the user details in an assoc array |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function export() { |
|
111 | + $data = []; |
|
112 | + $data['ocName'] = $this->getOCName(); |
|
113 | + $data['dn'] = $this->getDN(); |
|
114 | + $data['uid'] = $this->getUID(); |
|
115 | + $data['displayName'] = $this->getDisplayName(); |
|
116 | + $data['homePath'] = $this->getHomePath(); |
|
117 | + $data['lastLogin'] = $this->getLastLogin(); |
|
118 | + $data['email'] = $this->getEmail(); |
|
119 | + $data['hasActiveShares'] = $this->getHasActiveShares(); |
|
120 | 120 | |
121 | - return $data; |
|
122 | - } |
|
121 | + return $data; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * getter for Nextcloud internal name |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function getOCName() { |
|
129 | - return $this->ocName; |
|
130 | - } |
|
124 | + /** |
|
125 | + * getter for Nextcloud internal name |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function getOCName() { |
|
129 | + return $this->ocName; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * getter for LDAP uid |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function getUID() { |
|
137 | - if ($this->uid === null) { |
|
138 | - $this->fetchDetails(); |
|
139 | - } |
|
140 | - return $this->uid; |
|
141 | - } |
|
132 | + /** |
|
133 | + * getter for LDAP uid |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function getUID() { |
|
137 | + if ($this->uid === null) { |
|
138 | + $this->fetchDetails(); |
|
139 | + } |
|
140 | + return $this->uid; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * getter for LDAP DN |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function getDN() { |
|
148 | - if ($this->dn === null) { |
|
149 | - $this->fetchDetails(); |
|
150 | - } |
|
151 | - return $this->dn; |
|
152 | - } |
|
143 | + /** |
|
144 | + * getter for LDAP DN |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function getDN() { |
|
148 | + if ($this->dn === null) { |
|
149 | + $this->fetchDetails(); |
|
150 | + } |
|
151 | + return $this->dn; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * getter for display name |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function getDisplayName() { |
|
159 | - if ($this->displayName === null) { |
|
160 | - $this->fetchDetails(); |
|
161 | - } |
|
162 | - return $this->displayName; |
|
163 | - } |
|
154 | + /** |
|
155 | + * getter for display name |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function getDisplayName() { |
|
159 | + if ($this->displayName === null) { |
|
160 | + $this->fetchDetails(); |
|
161 | + } |
|
162 | + return $this->displayName; |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * getter for email |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - public function getEmail() { |
|
170 | - if ($this->email === null) { |
|
171 | - $this->fetchDetails(); |
|
172 | - } |
|
173 | - return $this->email; |
|
174 | - } |
|
165 | + /** |
|
166 | + * getter for email |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + public function getEmail() { |
|
170 | + if ($this->email === null) { |
|
171 | + $this->fetchDetails(); |
|
172 | + } |
|
173 | + return $this->email; |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * getter for home directory path |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function getHomePath() { |
|
181 | - if ($this->homePath === null) { |
|
182 | - $this->fetchDetails(); |
|
183 | - } |
|
184 | - return $this->homePath; |
|
185 | - } |
|
176 | + /** |
|
177 | + * getter for home directory path |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function getHomePath() { |
|
181 | + if ($this->homePath === null) { |
|
182 | + $this->fetchDetails(); |
|
183 | + } |
|
184 | + return $this->homePath; |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * getter for the last login timestamp |
|
189 | - * @return int |
|
190 | - */ |
|
191 | - public function getLastLogin() { |
|
192 | - if ($this->lastLogin === null) { |
|
193 | - $this->fetchDetails(); |
|
194 | - } |
|
195 | - return (int)$this->lastLogin; |
|
196 | - } |
|
187 | + /** |
|
188 | + * getter for the last login timestamp |
|
189 | + * @return int |
|
190 | + */ |
|
191 | + public function getLastLogin() { |
|
192 | + if ($this->lastLogin === null) { |
|
193 | + $this->fetchDetails(); |
|
194 | + } |
|
195 | + return (int)$this->lastLogin; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * getter for the detection timestamp |
|
200 | - * @return int |
|
201 | - */ |
|
202 | - public function getDetectedOn() { |
|
203 | - if ($this->foundDeleted === null) { |
|
204 | - $this->fetchDetails(); |
|
205 | - } |
|
206 | - return (int)$this->foundDeleted; |
|
207 | - } |
|
198 | + /** |
|
199 | + * getter for the detection timestamp |
|
200 | + * @return int |
|
201 | + */ |
|
202 | + public function getDetectedOn() { |
|
203 | + if ($this->foundDeleted === null) { |
|
204 | + $this->fetchDetails(); |
|
205 | + } |
|
206 | + return (int)$this->foundDeleted; |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * getter for having active shares |
|
211 | - * @return bool |
|
212 | - */ |
|
213 | - public function getHasActiveShares() { |
|
214 | - if ($this->hasActiveShares === null) { |
|
215 | - $this->fetchDetails(); |
|
216 | - } |
|
217 | - return $this->hasActiveShares; |
|
218 | - } |
|
209 | + /** |
|
210 | + * getter for having active shares |
|
211 | + * @return bool |
|
212 | + */ |
|
213 | + public function getHasActiveShares() { |
|
214 | + if ($this->hasActiveShares === null) { |
|
215 | + $this->fetchDetails(); |
|
216 | + } |
|
217 | + return $this->hasActiveShares; |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * reads the user details |
|
222 | - */ |
|
223 | - protected function fetchDetails() { |
|
224 | - $properties = [ |
|
225 | - 'displayName' => 'user_ldap', |
|
226 | - 'uid' => 'user_ldap', |
|
227 | - 'homePath' => 'user_ldap', |
|
228 | - 'foundDeleted' => 'user_ldap', |
|
229 | - 'email' => 'settings', |
|
230 | - 'lastLogin' => 'login', |
|
231 | - ]; |
|
232 | - foreach ($properties as $property => $app) { |
|
233 | - $this->$property = $this->config->getUserValue($this->ocName, $app, $property, ''); |
|
234 | - } |
|
220 | + /** |
|
221 | + * reads the user details |
|
222 | + */ |
|
223 | + protected function fetchDetails() { |
|
224 | + $properties = [ |
|
225 | + 'displayName' => 'user_ldap', |
|
226 | + 'uid' => 'user_ldap', |
|
227 | + 'homePath' => 'user_ldap', |
|
228 | + 'foundDeleted' => 'user_ldap', |
|
229 | + 'email' => 'settings', |
|
230 | + 'lastLogin' => 'login', |
|
231 | + ]; |
|
232 | + foreach ($properties as $property => $app) { |
|
233 | + $this->$property = $this->config->getUserValue($this->ocName, $app, $property, ''); |
|
234 | + } |
|
235 | 235 | |
236 | - $dn = $this->mapping->getDNByName($this->ocName); |
|
237 | - $this->dn = ($dn !== false) ? $dn : ''; |
|
236 | + $dn = $this->mapping->getDNByName($this->ocName); |
|
237 | + $this->dn = ($dn !== false) ? $dn : ''; |
|
238 | 238 | |
239 | - $this->determineShares(); |
|
240 | - } |
|
239 | + $this->determineShares(); |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * finds out whether the user has active shares. The result is stored in |
|
244 | - * $this->hasActiveShares |
|
245 | - */ |
|
246 | - protected function determineShares() { |
|
247 | - $shareInterface = new \ReflectionClass(IShare::class); |
|
248 | - $shareConstants = $shareInterface->getConstants(); |
|
242 | + /** |
|
243 | + * finds out whether the user has active shares. The result is stored in |
|
244 | + * $this->hasActiveShares |
|
245 | + */ |
|
246 | + protected function determineShares() { |
|
247 | + $shareInterface = new \ReflectionClass(IShare::class); |
|
248 | + $shareConstants = $shareInterface->getConstants(); |
|
249 | 249 | |
250 | - foreach ($shareConstants as $constantName => $constantValue) { |
|
251 | - if (strpos($constantName, 'TYPE_') !== 0 |
|
252 | - || $constantValue === IShare::TYPE_USERGROUP |
|
253 | - ) { |
|
254 | - continue; |
|
255 | - } |
|
256 | - $shares = $this->shareManager->getSharesBy( |
|
257 | - $this->ocName, |
|
258 | - $constantValue, |
|
259 | - null, |
|
260 | - false, |
|
261 | - 1 |
|
262 | - ); |
|
263 | - if (!empty($shares)) { |
|
264 | - $this->hasActiveShares = true; |
|
265 | - return; |
|
266 | - } |
|
267 | - } |
|
250 | + foreach ($shareConstants as $constantName => $constantValue) { |
|
251 | + if (strpos($constantName, 'TYPE_') !== 0 |
|
252 | + || $constantValue === IShare::TYPE_USERGROUP |
|
253 | + ) { |
|
254 | + continue; |
|
255 | + } |
|
256 | + $shares = $this->shareManager->getSharesBy( |
|
257 | + $this->ocName, |
|
258 | + $constantValue, |
|
259 | + null, |
|
260 | + false, |
|
261 | + 1 |
|
262 | + ); |
|
263 | + if (!empty($shares)) { |
|
264 | + $this->hasActiveShares = true; |
|
265 | + return; |
|
266 | + } |
|
267 | + } |
|
268 | 268 | |
269 | - $this->hasActiveShares = false; |
|
270 | - } |
|
269 | + $this->hasActiveShares = false; |
|
270 | + } |
|
271 | 271 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($this->lastLogin === null) { |
193 | 193 | $this->fetchDetails(); |
194 | 194 | } |
195 | - return (int)$this->lastLogin; |
|
195 | + return (int) $this->lastLogin; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | if ($this->foundDeleted === null) { |
204 | 204 | $this->fetchDetails(); |
205 | 205 | } |
206 | - return (int)$this->foundDeleted; |
|
206 | + return (int) $this->foundDeleted; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |