1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* User class |
4
|
|
|
* |
5
|
|
|
* This file describes the User classes |
6
|
|
|
* |
7
|
|
|
* PHP version 5 and 7 |
8
|
|
|
* |
9
|
|
|
* @author Patrick Boyd / [email protected] |
10
|
|
|
* @copyright Copyright (c) 2015, Austin Artistic Reconstruction |
11
|
|
|
* @license http://www.apache.org/licenses/ Apache 2.0 License |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Auth; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* A class to abstract access to Users regardless of the Authentication type used. |
18
|
|
|
* |
19
|
|
|
* This class is the primary method to access user information. |
20
|
|
|
*/ |
21
|
|
|
class User extends \SerializableObject |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* An array to cache the title to string mappings so that they don't need to be pulled from the database |
25
|
|
|
* everytime |
26
|
|
|
*/ |
27
|
|
|
public static $titlenames = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Is this user in the Group or a child of that group? |
31
|
|
|
* |
32
|
|
|
* @param string $name The name of the group to check if the user is in |
33
|
|
|
* |
34
|
|
|
* @return boolean True if the user is in the group, false otherwise |
35
|
|
|
*/ |
36
|
|
|
public function isInGroupNamed($name) |
37
|
|
|
{ |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function __get($propName) |
42
|
|
|
{ |
43
|
|
|
return false; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function __set($propName, $value) |
47
|
|
|
{ |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function __isset($propName) |
51
|
|
|
{ |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* The list of titles for the user |
57
|
|
|
* |
58
|
|
|
* @return boolean|array The user's title(s) in user friendly strings |
59
|
|
|
* |
60
|
|
|
* @SuppressWarnings("StaticAccess") |
61
|
|
|
*/ |
62
|
|
|
public function getTitleNames() |
63
|
|
|
{ |
64
|
|
|
$titles = $this->title; |
|
|
|
|
65
|
|
|
if($titles === false) |
66
|
|
|
{ |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
if(self::$titlenames === null) |
70
|
|
|
{ |
71
|
|
|
$dataSet = \DataSetFactory::getDataSetByName('profiles'); |
72
|
|
|
$dataTable = $dataSet['position']; |
73
|
|
|
$titlenames = $dataTable->read(); |
74
|
|
|
self::$titlenames = array(); |
75
|
|
|
$count = count($titlenames); |
76
|
|
|
for($i = 0; $i < $count; $i++) |
77
|
|
|
{ |
78
|
|
|
self::$titlenames[$titlenames[$i]['short_name']] = $titlenames[$i]; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
$count = count($titles); |
82
|
|
|
for($i = 0; $i < $count; $i++) |
83
|
|
|
{ |
84
|
|
|
if(isset(self::$titlenames[$titles[$i]])) |
85
|
|
|
{ |
86
|
|
|
$title = self::$titlenames[$titles[$i]]; |
87
|
|
|
$titles[$i] = $title['name']; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
return $titles; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* The groups the user is a part of |
95
|
|
|
* |
96
|
|
|
* @return boolean|array The user's Auth\Group structures |
97
|
|
|
*/ |
98
|
|
|
public function getGroups() |
99
|
|
|
{ |
100
|
|
|
return false; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Add a supplemental login type that the user can use to login |
105
|
|
|
* |
106
|
|
|
* @param string $provider The hostname for the provider |
107
|
|
|
*/ |
108
|
|
|
public function addLoginProvider($provider) |
109
|
|
|
{ |
110
|
|
|
if(isset($this->host)) |
111
|
|
|
{ |
112
|
|
|
$tmp = $this->host; |
|
|
|
|
113
|
|
|
$tmp[] = $provider; |
114
|
|
|
$this->host = $tmp; |
|
|
|
|
115
|
|
|
} |
116
|
|
|
else |
117
|
|
|
{ |
118
|
|
|
$this->host = array($provider); |
|
|
|
|
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Can the user login with this provider? |
124
|
|
|
* |
125
|
|
|
* @param string $provider The hostname for the provider |
126
|
|
|
* |
127
|
|
|
* @return boolean true if they can login with the provider, false otherwise |
128
|
|
|
*/ |
129
|
|
|
public function canLoginWith($provider) |
130
|
|
|
{ |
131
|
|
|
$hosts = $this->host; |
|
|
|
|
132
|
|
|
if($hosts === false) |
133
|
|
|
{ |
134
|
|
|
return false; |
135
|
|
|
} |
136
|
|
|
$count = count($hosts); |
137
|
|
|
for($i = 0; $i < $count; $i++) |
138
|
|
|
{ |
139
|
|
|
if(strcasecmp($hosts[$i], $provider) === 0) |
140
|
|
|
{ |
141
|
|
|
return true; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
return false; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Set the user's password without verifying the current password |
149
|
|
|
* |
150
|
|
|
* @param string $password The new user password |
151
|
|
|
* |
152
|
|
|
* @return boolean true if the user's password was changed, false otherwise |
153
|
|
|
*/ |
154
|
|
|
protected function setPass($password) |
155
|
|
|
{ |
156
|
|
|
return false; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Has the user completely filled out their user profile? |
161
|
|
|
* |
162
|
|
|
* @return boolean true if the user's profile is complete, false otherwise |
163
|
|
|
*/ |
164
|
|
|
public function isProfileComplete() |
165
|
|
|
{ |
166
|
|
|
if($this->c === false || $this->postalAddress === false || |
|
|
|
|
167
|
|
|
$this->postalCode === false || $this->l === false || |
|
|
|
|
168
|
|
|
$this->st === false || $this->mobile === false) |
|
|
|
|
169
|
|
|
{ |
170
|
|
|
return false; |
171
|
|
|
} |
172
|
|
|
return true; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Validate that the user's password is the specified password |
177
|
|
|
* |
178
|
|
|
* @param string $password The user's current password |
179
|
|
|
* |
180
|
|
|
* @return boolean true if the user's password is correct, false otherwise |
181
|
|
|
* |
182
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
183
|
|
|
*/ |
184
|
|
|
public function validate_password($password) |
185
|
|
|
{ |
186
|
|
|
return false; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Validate that the user's reset hash is the sepcified hash |
191
|
|
|
* |
192
|
|
|
* @param string $hash The user's reset hash |
193
|
|
|
* |
194
|
|
|
* @return boolean true if the user's hash is correct, false otherwise |
195
|
|
|
* |
196
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
197
|
|
|
*/ |
198
|
|
|
public function validate_reset_hash($hash) |
199
|
|
|
{ |
200
|
|
|
return false; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Change the user's password, validating the old password or reset hash |
205
|
|
|
* |
206
|
|
|
* @param string $oldpass The user's original password or reset hash if $isHash is true |
207
|
|
|
* @param string $newpass The user's new password |
208
|
|
|
* @param boolean $isHash Is $old_pass a password or a hash |
209
|
|
|
* |
210
|
|
|
* @return boolean true if the user's password was changed, false otherwise |
211
|
|
|
*/ |
212
|
|
|
public function change_pass($oldpass, $newpass, $isHash = false) |
213
|
|
|
{ |
214
|
|
|
if($isHash === false && $this->validate_password($oldpass) === false) |
215
|
|
|
{ |
216
|
|
|
throw new \Exception('Invalid Password!', 3); |
217
|
|
|
} |
218
|
|
|
if($isHash === true && $this->validate_reset_hash($oldpass) === false) |
219
|
|
|
{ |
220
|
|
|
throw new \Exception('Invalid Reset Hash!', 3); |
221
|
|
|
} |
222
|
|
|
if($this->setPass($newpass) === false) |
223
|
|
|
{ |
224
|
|
|
throw new \Exception('Unable to set password!', 6); |
225
|
|
|
} |
226
|
|
|
return true; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* Set the user's display name |
231
|
|
|
* |
232
|
|
|
* @param string $name The user's new display name |
233
|
|
|
* |
234
|
|
|
* @return boolean true if the user's display name was changed, false otherwise |
235
|
|
|
*/ |
236
|
|
|
public function setDisplayName($name) |
237
|
|
|
{ |
238
|
|
|
return $this->setNickName($name); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Set the user's given (first) name |
243
|
|
|
* |
244
|
|
|
* @param string $name The user's new given name |
245
|
|
|
* |
246
|
|
|
* @return boolean true if the user's given name was changed, false otherwise |
247
|
|
|
*/ |
248
|
|
|
public function setGivenName($name) |
249
|
|
|
{ |
250
|
|
|
return $this->setUid($name); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Set the user's email address |
255
|
|
|
* |
256
|
|
|
* @param string $email The user's new email address |
257
|
|
|
* |
258
|
|
|
* @return boolean true if the user's email address was changed, false otherwise |
259
|
|
|
* |
260
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
261
|
|
|
*/ |
262
|
|
|
public function setEmail($email) |
263
|
|
|
{ |
264
|
|
|
return false; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Set the user's user ID or user name |
269
|
|
|
* |
270
|
|
|
* @param string $uid The user's new user ID |
271
|
|
|
* |
272
|
|
|
* @return boolean true if the user's ID was changed, false otherwise |
273
|
|
|
* |
274
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
275
|
|
|
*/ |
276
|
|
|
public function setUid($uid) |
277
|
|
|
{ |
278
|
|
|
return false; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Set the user's photo |
283
|
|
|
* |
284
|
|
|
* @param string $photo The user's new photo as a binary string |
285
|
|
|
* |
286
|
|
|
* @return boolean true if the user's photo was changed, false otherwise |
287
|
|
|
* |
288
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
289
|
|
|
*/ |
290
|
|
|
public function setPhoto($photo) |
291
|
|
|
{ |
292
|
|
|
return false; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* Set the user's phone number |
297
|
|
|
* |
298
|
|
|
* @param string $phone The user's new phonew number |
299
|
|
|
* |
300
|
|
|
* @return boolean true if the user's phone number was changed, false otherwise |
301
|
|
|
* |
302
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
303
|
|
|
*/ |
304
|
|
|
public function setPhoneNumber($phone) |
305
|
|
|
{ |
306
|
|
|
return false; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Set the user's organization |
311
|
|
|
* |
312
|
|
|
* @param string $org The user's new organization |
313
|
|
|
* |
314
|
|
|
* @return boolean true if the user's organization was changed, false otherwise |
315
|
|
|
* |
316
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
317
|
|
|
*/ |
318
|
|
|
public function setOrganization($org) |
319
|
|
|
{ |
320
|
|
|
return false; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Set the user's titles |
325
|
|
|
* |
326
|
|
|
* @param string $titles The user's new titles |
327
|
|
|
* |
328
|
|
|
* @return boolean true if the user's titles were changed, false otherwise |
329
|
|
|
* |
330
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
331
|
|
|
*/ |
332
|
|
|
public function setTitles($titles) |
333
|
|
|
{ |
334
|
|
|
return false; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Set the user's state |
339
|
|
|
* |
340
|
|
|
* @param string $state The user's new state |
341
|
|
|
* |
342
|
|
|
* @return boolean true if the user's state was changed, false otherwise |
343
|
|
|
* |
344
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
345
|
|
|
*/ |
346
|
|
|
public function setState($state) |
347
|
|
|
{ |
348
|
|
|
return false; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Set the user's city |
353
|
|
|
* |
354
|
|
|
* @param string $city The user's new city |
355
|
|
|
* |
356
|
|
|
* @return boolean true if the user's city was changed, false otherwise |
357
|
|
|
* |
358
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
359
|
|
|
*/ |
360
|
|
|
public function setCity($city) |
361
|
|
|
{ |
362
|
|
|
return false; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* Set the user's last name |
367
|
|
|
* |
368
|
|
|
* @param string $sn The user's new last name |
369
|
|
|
* |
370
|
|
|
* @return boolean true if the user's last name was changed, false otherwise |
371
|
|
|
* |
372
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
373
|
|
|
*/ |
374
|
|
|
public function setLastName($sn) |
375
|
|
|
{ |
376
|
|
|
return false; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Set the user's nick name |
381
|
|
|
* |
382
|
|
|
* @param string $displayName The user's new nick name |
383
|
|
|
* |
384
|
|
|
* @return boolean true if the user's nick name was changed, false otherwise |
385
|
|
|
*/ |
386
|
|
|
public function setNickName($displayName) |
387
|
|
|
{ |
388
|
|
|
return $this->setUid($displayName); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Set the user's mailing address |
393
|
|
|
* |
394
|
|
|
* @param string $address The user's new mailing address |
395
|
|
|
* |
396
|
|
|
* @return boolean true if the user's mailing address was changed, false otherwise |
397
|
|
|
* |
398
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
399
|
|
|
*/ |
400
|
|
|
public function setAddress($address) |
401
|
|
|
{ |
402
|
|
|
return false; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Set the user's postal or zip code |
407
|
|
|
* |
408
|
|
|
* @param string $postalcode The user's new postal code |
409
|
|
|
* |
410
|
|
|
* @return boolean true if the user's postal code was changed, false otherwise |
411
|
|
|
* |
412
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
413
|
|
|
*/ |
414
|
|
|
public function setPostalCode($postalcode) |
415
|
|
|
{ |
416
|
|
|
return false; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Set the user's country |
421
|
|
|
* |
422
|
|
|
* @param string $country The user's new country |
423
|
|
|
* |
424
|
|
|
* @return boolean true if the user's country was changed, false otherwise |
425
|
|
|
* |
426
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
427
|
|
|
*/ |
428
|
|
|
public function setCountry($country) |
429
|
|
|
{ |
430
|
|
|
return false; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Set the user's organizations |
435
|
|
|
* |
436
|
|
|
* @param string $ous The user's new organizations |
437
|
|
|
* |
438
|
|
|
* @return boolean true if the user's organizations was changed, false otherwise |
439
|
|
|
* |
440
|
|
|
* @SuppressWarnings("UnusedFormalParameter") |
441
|
|
|
*/ |
442
|
|
|
public function setOrganizationUnits($ous) |
443
|
|
|
{ |
444
|
|
|
return false; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Allow write for the user |
449
|
|
|
*/ |
450
|
|
|
protected function enableReadWrite() |
451
|
|
|
{ |
452
|
|
|
//Make sure we are bound in write mode |
453
|
|
|
$auth = \AuthProvider::getInstance(); |
454
|
|
|
$ldap = $auth->getMethodByName('Auth\LDAPAuthenticator'); |
455
|
|
|
if($ldap !== false) |
456
|
|
|
{ |
457
|
|
|
$ldap->get_and_bind_server(true); |
458
|
|
|
} |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* Update the user password if required |
463
|
|
|
*/ |
464
|
|
|
private function editUserPassword($data) |
465
|
|
|
{ |
466
|
|
|
if(isset($data->password)) |
467
|
|
|
{ |
468
|
|
|
if(isset($data->oldpass)) |
469
|
|
|
{ |
470
|
|
|
$this->change_pass($data->oldpass, $data->password); |
471
|
|
|
unset($data->oldpass); |
472
|
|
|
} |
473
|
|
|
else if(isset($data->hash)) |
474
|
|
|
{ |
475
|
|
|
$this->change_pass($data->hash, $data->password, true); |
476
|
|
|
unset($data->hash); |
477
|
|
|
} |
478
|
|
|
unset($data->password); |
479
|
|
|
} |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
private function editNames($data) |
483
|
|
|
{ |
484
|
|
|
if(isset($data->displayName)) |
485
|
|
|
{ |
486
|
|
|
$this->setDisplayName($data->displayName); |
487
|
|
|
unset($data->displayName); |
488
|
|
|
} |
489
|
|
|
if(isset($data->givenName)) |
490
|
|
|
{ |
491
|
|
|
$this->setGivenName($data->givenName); |
492
|
|
|
unset($data->givenName); |
493
|
|
|
} |
494
|
|
|
if(isset($data->sn)) |
495
|
|
|
{ |
496
|
|
|
$this->setLastName($data->sn); |
497
|
|
|
unset($data->sn); |
498
|
|
|
} |
499
|
|
|
if(isset($data->cn)) |
500
|
|
|
{ |
501
|
|
|
$this->setNickName($data->cn); |
502
|
|
|
unset($data->cn); |
503
|
|
|
} |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
private function checkForUnsettableElements($data) |
507
|
|
|
{ |
508
|
|
View Code Duplication |
if(isset($data->mail)) |
|
|
|
|
509
|
|
|
{ |
510
|
|
|
if($data->mail !== $this->mail) |
|
|
|
|
511
|
|
|
{ |
512
|
|
|
throw new \Exception('Unable to change email!'); |
513
|
|
|
} |
514
|
|
|
unset($data->mail); |
515
|
|
|
} |
516
|
|
View Code Duplication |
if(isset($data->uid)) |
|
|
|
|
517
|
|
|
{ |
518
|
|
|
if($data->uid !== $this->uid) |
|
|
|
|
519
|
|
|
{ |
520
|
|
|
throw new \Exception('Unable to change uid!'); |
521
|
|
|
} |
522
|
|
|
unset($data->uid); |
523
|
|
|
} |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
private function editAddressElements($data) |
527
|
|
|
{ |
528
|
|
|
if(isset($data->postalAddress)) |
529
|
|
|
{ |
530
|
|
|
$this->setAddress($data->postalAddress); |
531
|
|
|
unset($data->postalAddress); |
532
|
|
|
} |
533
|
|
|
if(isset($data->l)) |
534
|
|
|
{ |
535
|
|
|
$this->setCity($data->l); |
536
|
|
|
unset($data->l); |
537
|
|
|
} |
538
|
|
|
if(isset($data->st)) |
539
|
|
|
{ |
540
|
|
|
$this->setState($data->st); |
541
|
|
|
unset($data->st); |
542
|
|
|
} |
543
|
|
|
if(isset($data->postalCode)) |
544
|
|
|
{ |
545
|
|
|
$this->setPostalCode($data->postalCode); |
546
|
|
|
unset($data->postalCode); |
547
|
|
|
} |
548
|
|
|
if(isset($data->c)) |
549
|
|
|
{ |
550
|
|
|
$this->setCountry($data->c); |
551
|
|
|
unset($data->c); |
552
|
|
|
} |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
private function editOrganizationElements($data) |
556
|
|
|
{ |
557
|
|
|
if(isset($data->o)) |
558
|
|
|
{ |
559
|
|
|
$this->setOrganization($data->o); |
560
|
|
|
unset($data->o); |
561
|
|
|
} |
562
|
|
|
if(isset($data->title)) |
563
|
|
|
{ |
564
|
|
|
$this->setTitles($data->title); |
565
|
|
|
unset($data->title); |
566
|
|
|
} |
567
|
|
|
if(isset($data->ou)) |
568
|
|
|
{ |
569
|
|
|
$this->setOrganizationUnits($data->ou); |
570
|
|
|
unset($data->ou); |
571
|
|
|
} |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* Modify the user given the provided data object |
576
|
|
|
* |
577
|
|
|
* @param stdClass $data The user's new data |
578
|
|
|
* |
579
|
|
|
* @return boolean true if the user's data was changed, false otherwise |
580
|
|
|
*/ |
581
|
|
|
public function editUser($data) |
582
|
|
|
{ |
583
|
|
|
$this->enableReadWrite(); |
584
|
|
|
|
585
|
|
|
$this->checkForUnsettableElements($data); |
586
|
|
|
$this->editUserPassword($data); |
587
|
|
|
$this->editNames($data); |
588
|
|
|
$this->editAddressElements($data); |
589
|
|
|
$this->editOrganizationElements($data); |
590
|
|
|
|
591
|
|
|
if(isset($data->jpegPhoto)) |
592
|
|
|
{ |
593
|
|
|
$this->setPhoto(base64_decode($data->jpegPhoto)); |
594
|
|
|
unset($data->jpegPhoto); |
595
|
|
|
} |
596
|
|
|
if(isset($data->mobile)) |
597
|
|
|
{ |
598
|
|
|
$this->setPhoneNumber($data->mobile); |
599
|
|
|
unset($data->mobile); |
600
|
|
|
} |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
/** |
604
|
|
|
* Obtain the user's password reset hash |
605
|
|
|
* |
606
|
|
|
* @return string|false A hash if available, false otherwise |
607
|
|
|
*/ |
608
|
|
|
public function getPasswordResetHash() |
609
|
|
|
{ |
610
|
|
|
return false; |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* Serialize the user data into a format usable by the json_encode method |
615
|
|
|
* |
616
|
|
|
* @return array A simple keyed array representing the user |
617
|
|
|
*/ |
618
|
|
|
public function jsonSerialize() |
619
|
|
|
{ |
620
|
|
|
$user = array(); |
621
|
|
|
$user['displayName'] = $this->displayName; |
|
|
|
|
622
|
|
|
$user['givenName'] = $this->givenName; |
|
|
|
|
623
|
|
|
$user['jpegPhoto'] = base64_encode($this->jpegPhoto); |
|
|
|
|
624
|
|
|
$user['mail'] = $this->mail; |
|
|
|
|
625
|
|
|
$user['mobile'] = $this->mobile; |
|
|
|
|
626
|
|
|
$user['uid'] = $this->uid; |
|
|
|
|
627
|
|
|
$user['o'] = $this->o; |
|
|
|
|
628
|
|
|
$user['title'] = $this->title; |
|
|
|
|
629
|
|
|
$user['titlenames'] = $this->getTitleNames(); |
630
|
|
|
$user['st'] = $this->st; |
|
|
|
|
631
|
|
|
$user['l'] = $this->l; |
|
|
|
|
632
|
|
|
$user['sn'] = $this->sn; |
|
|
|
|
633
|
|
|
$user['cn'] = $this->cn; |
|
|
|
|
634
|
|
|
$user['postalAddress'] = $this->postalAddress; |
|
|
|
|
635
|
|
|
$user['postalCode'] = $this->postalCode; |
|
|
|
|
636
|
|
|
$user['c'] = $this->c; |
|
|
|
|
637
|
|
|
$user['ou'] = $this->ou; |
|
|
|
|
638
|
|
|
$user['host'] = $this->host; |
|
|
|
|
639
|
|
|
$user['class'] = get_class($this); |
640
|
|
|
return $user; |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
/** |
644
|
|
|
* Serialize the user data into a VCARD 2.1 format |
645
|
|
|
* |
646
|
|
|
* @return string The VCARD for the user |
647
|
|
|
*/ |
648
|
|
|
public function getVcard() |
649
|
|
|
{ |
650
|
|
|
$ret = "BEGIN:VCARD\nVERSION:2.1\n"; |
651
|
|
|
$ret .= 'N:'.$this->sn.';'.$this->givenName."\n"; |
|
|
|
|
652
|
|
|
$ret .= 'FN:'.$this->givenName."\n"; |
|
|
|
|
653
|
|
|
$titles = $this->title; |
|
|
|
|
654
|
|
|
if($titles !== false) |
655
|
|
|
{ |
656
|
|
|
$ret .= 'TITLE:'.implode(',', $titles)."\n"; |
657
|
|
|
} |
658
|
|
|
$ret .= "ORG: Austin Artistic Reconstruction\n"; |
659
|
|
|
$ret .= 'TEL;TYPE=MOBILE,VOICE:'.$this->mobile."\n"; |
|
|
|
|
660
|
|
|
$ret .= 'EMAIL;TYPE=PREF,INTERNET:'.$this->mail."\n"; |
|
|
|
|
661
|
|
|
$ret .= "END:VCARD\n"; |
662
|
|
|
return $ret; |
663
|
|
|
} |
664
|
|
|
} |
665
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
666
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.