|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
namespace Chamilo\UserBundle\Entity; |
|
5
|
|
|
|
|
6
|
|
|
use Chamilo\CoreBundle\Entity\CourseRelUser; |
|
7
|
|
|
use Chamilo\CoreBundle\Entity\ExtraFieldValues; |
|
8
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
|
9
|
|
|
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser; |
|
10
|
|
|
use Chamilo\CoreBundle\Entity\Skill; |
|
11
|
|
|
use Chamilo\CoreBundle\Entity\UsergroupRelUser; |
|
12
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
13
|
|
|
use Doctrine\ORM\Event\LifecycleEventArgs; |
|
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
15
|
|
|
use FOS\UserBundle\Model\GroupInterface; |
|
16
|
|
|
use FOS\UserBundle\Model\UserInterface; |
|
17
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
18
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
|
19
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
20
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @ORM\HasLifecycleCallbacks |
|
24
|
|
|
* @ORM\Table( |
|
25
|
|
|
* name="user", |
|
26
|
|
|
* indexes={ |
|
27
|
|
|
* @ORM\Index(name="idx_user_uid", columns={"user_id"}), |
|
28
|
|
|
* @ORM\Index(name="status", columns={"status"}) |
|
29
|
|
|
* } |
|
30
|
|
|
* ) |
|
31
|
|
|
* @UniqueEntity("username") |
|
32
|
|
|
* @ORM\Entity(repositoryClass="Chamilo\UserBundle\Repository\UserRepository") |
|
33
|
|
|
*/ |
|
34
|
|
|
class User implements UserInterface //implements ParticipantInterface, ThemeUser |
|
35
|
|
|
{ |
|
36
|
|
|
public const COURSE_MANAGER = 1; |
|
37
|
|
|
public const TEACHER = 1; |
|
38
|
|
|
public const SESSION_ADMIN = 3; |
|
39
|
|
|
public const DRH = 4; |
|
40
|
|
|
public const STUDENT = 5; |
|
41
|
|
|
public const ANONYMOUS = 6; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var int |
|
45
|
|
|
* |
|
46
|
|
|
* @ORM\Column(name="id", type="integer") |
|
47
|
|
|
* @ORM\Id |
|
48
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $id; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var int |
|
54
|
|
|
* |
|
55
|
|
|
* @ORM\Column(name="user_id", type="integer", nullable=true) |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $userId; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var string |
|
61
|
|
|
* |
|
62
|
|
|
* @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true) |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $username; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var string |
|
68
|
|
|
* |
|
69
|
|
|
* @ORM\Column(name="username_canonical", type="string", length=100, nullable=false) |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $usernameCanonical; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @var string |
|
75
|
|
|
* @ORM\Column(name="email_canonical", type="string", length=100, nullable=false, unique=false) |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $emailCanonical; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @var string |
|
81
|
|
|
* |
|
82
|
|
|
* @ORM\Column(name="email", type="string", length=100, nullable=false, unique=false) |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $email; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @var bool |
|
88
|
|
|
* @ORM\Column(name="locked", type="boolean") |
|
89
|
|
|
*/ |
|
90
|
|
|
protected $locked; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @var bool |
|
94
|
|
|
* @ORM\Column(name="enabled", type="boolean") |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $enabled; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @var bool |
|
100
|
|
|
* @ORM\Column(name="expired", type="boolean") |
|
101
|
|
|
*/ |
|
102
|
|
|
protected $expired; |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @var bool |
|
106
|
|
|
* @ORM\Column(name="credentials_expired", type="boolean") |
|
107
|
|
|
*/ |
|
108
|
|
|
protected $credentialsExpired; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @var \DateTime |
|
112
|
|
|
* @ORM\Column(name="credentials_expire_at", type="datetime", nullable=true, unique=false) |
|
113
|
|
|
*/ |
|
114
|
|
|
protected $credentialsExpireAt; |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @var \DateTime |
|
118
|
|
|
* @ORM\Column(name="expires_at", type="datetime", nullable=true, unique=false) |
|
119
|
|
|
*/ |
|
120
|
|
|
protected $expiresAt; |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @var string |
|
124
|
|
|
* |
|
125
|
|
|
* @ORM\Column(name="lastname", type="string", length=60, nullable=true, unique=false) |
|
126
|
|
|
*/ |
|
127
|
|
|
protected $lastname; |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @var string |
|
131
|
|
|
* |
|
132
|
|
|
* @ORM\Column(name="firstname", type="string", length=60, nullable=true, unique=false) |
|
133
|
|
|
*/ |
|
134
|
|
|
protected $firstname; |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @var string |
|
138
|
|
|
* |
|
139
|
|
|
* @ORM\Column(name="password", type="string", length=255, nullable=false, unique=false) |
|
140
|
|
|
*/ |
|
141
|
|
|
protected $password; |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @var string |
|
145
|
|
|
* |
|
146
|
|
|
* @ORM\Column(name="phone", type="string", length=30, nullable=true, unique=false) |
|
147
|
|
|
*/ |
|
148
|
|
|
protected $phone; |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @var string |
|
152
|
|
|
* |
|
153
|
|
|
* @ORM\Column(name="address", type="string", length=250, nullable=true, unique=false) |
|
154
|
|
|
*/ |
|
155
|
|
|
protected $address; |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Vich\UploadableField(mapping="user_image", fileNameProperty="picture_uri"). |
|
159
|
|
|
* |
|
160
|
|
|
* note This is not a mapped field of entity metadata, just a simple property. |
|
161
|
|
|
* |
|
162
|
|
|
* @var File |
|
163
|
|
|
*/ |
|
164
|
|
|
protected $imageFile; |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @ORM\Column(type="string", length=255) |
|
168
|
|
|
*/ |
|
169
|
|
|
protected $salt; |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @var \DateTime |
|
173
|
|
|
* |
|
174
|
|
|
* @ORM\Column(name="last_login", type="datetime", nullable=true, unique=false) |
|
175
|
|
|
*/ |
|
176
|
|
|
protected $lastLogin; |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @var \DateTime |
|
180
|
|
|
* @ORM\Column(name="created_at", type="datetime", nullable=true, unique=false) |
|
181
|
|
|
*/ |
|
182
|
|
|
protected $createdAt; |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @var \DateTime |
|
186
|
|
|
* @ORM\Column(name="updated_at", type="datetime", nullable=true, unique=false) |
|
187
|
|
|
*/ |
|
188
|
|
|
protected $updatedAt; |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Random string sent to the user email address in order to verify it. |
|
192
|
|
|
* |
|
193
|
|
|
* @var string |
|
194
|
|
|
* @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true) |
|
195
|
|
|
*/ |
|
196
|
|
|
protected $confirmationToken; |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* @var \DateTime |
|
200
|
|
|
* |
|
201
|
|
|
* @ORM\Column(name="password_requested_at", type="datetime", nullable=true, unique=false) |
|
202
|
|
|
*/ |
|
203
|
|
|
protected $passwordRequestedAt; |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user") |
|
207
|
|
|
*/ |
|
208
|
|
|
protected $courses; |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="user") |
|
212
|
|
|
*/ |
|
213
|
|
|
//protected $items; |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user") |
|
217
|
|
|
*/ |
|
218
|
|
|
protected $classes; |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user"). |
|
222
|
|
|
*/ |
|
223
|
|
|
protected $dropBoxReceivedFiles; |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent"). |
|
227
|
|
|
*/ |
|
228
|
|
|
protected $dropBoxSentFiles; |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* @ORM\Column(type="array") |
|
232
|
|
|
*/ |
|
233
|
|
|
protected $roles; |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* @var bool |
|
237
|
|
|
* |
|
238
|
|
|
* @ORM\Column(name="profile_completed", type="boolean", nullable=true) |
|
239
|
|
|
*/ |
|
240
|
|
|
protected $profileCompleted; |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user") |
|
244
|
|
|
*/ |
|
245
|
|
|
//protected $jurySubscriptions; |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @ORM\ManyToMany(targetEntity="Chamilo\UserBundle\Entity\Group") |
|
249
|
|
|
* @ORM\JoinTable(name="fos_user_user_group", |
|
250
|
|
|
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}, |
|
251
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")} |
|
252
|
|
|
* ) |
|
253
|
|
|
*/ |
|
254
|
|
|
protected $groups; |
|
255
|
|
|
|
|
256
|
|
|
//protected $isActive; |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user"). |
|
260
|
|
|
*/ |
|
261
|
|
|
protected $curriculumItems; |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelUser", mappedBy="user") |
|
265
|
|
|
*/ |
|
266
|
|
|
protected $portals; |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* @var ArrayCollection|Session[] |
|
270
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach") |
|
271
|
|
|
*/ |
|
272
|
|
|
protected $sessionAsGeneralCoach; |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* @var ArrayCollection |
|
276
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UserFieldValues", mappedBy="user", orphanRemoval=true, cascade={"persist"}) |
|
277
|
|
|
*/ |
|
278
|
|
|
protected $extraFields; |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="creator"). |
|
282
|
|
|
*/ |
|
283
|
|
|
protected $resourceNodes; |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", mappedBy="user", cascade={"persist"}) |
|
287
|
|
|
*/ |
|
288
|
|
|
protected $sessionCourseSubscriptions; |
|
289
|
|
|
|
|
290
|
|
|
/** |
|
291
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="user", cascade={"persist"}) |
|
292
|
|
|
*/ |
|
293
|
|
|
protected $achievedSkills; |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", mappedBy="feedbackGiver") |
|
297
|
|
|
*/ |
|
298
|
|
|
protected $commentedUserSkills; |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* @var string |
|
302
|
|
|
* |
|
303
|
|
|
* @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false) |
|
304
|
|
|
*/ |
|
305
|
|
|
private $authSource; |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @var int |
|
309
|
|
|
* |
|
310
|
|
|
* @ORM\Column(name="status", type="integer", nullable=false) |
|
311
|
|
|
*/ |
|
312
|
|
|
private $status; |
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* @var string |
|
316
|
|
|
* |
|
317
|
|
|
* @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false) |
|
318
|
|
|
*/ |
|
319
|
|
|
private $officialCode; |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* @var string |
|
323
|
|
|
* @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false) |
|
324
|
|
|
*/ |
|
325
|
|
|
private $pictureUri; |
|
326
|
|
|
|
|
327
|
|
|
/** |
|
328
|
|
|
* ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"all"} ). |
|
329
|
|
|
* |
|
330
|
|
|
* @ORM\JoinColumn(name="picture_uri", referencedColumnName="id") |
|
331
|
|
|
*/ |
|
332
|
|
|
//protected $pictureUri; |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* @var int |
|
336
|
|
|
* |
|
337
|
|
|
* @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false) |
|
338
|
|
|
*/ |
|
339
|
|
|
private $creatorId; |
|
340
|
|
|
|
|
341
|
|
|
/** |
|
342
|
|
|
* @var string |
|
343
|
|
|
* |
|
344
|
|
|
* @ORM\Column(name="competences", type="text", nullable=true, unique=false) |
|
345
|
|
|
*/ |
|
346
|
|
|
private $competences; |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* @var string |
|
350
|
|
|
* |
|
351
|
|
|
* @ORM\Column(name="diplomas", type="text", nullable=true, unique=false) |
|
352
|
|
|
*/ |
|
353
|
|
|
private $diplomas; |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @var string |
|
357
|
|
|
* |
|
358
|
|
|
* @ORM\Column(name="openarea", type="text", nullable=true, unique=false) |
|
359
|
|
|
*/ |
|
360
|
|
|
private $openarea; |
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* @var string |
|
364
|
|
|
* |
|
365
|
|
|
* @ORM\Column(name="teach", type="text", nullable=true, unique=false) |
|
366
|
|
|
*/ |
|
367
|
|
|
private $teach; |
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* @var string |
|
371
|
|
|
* |
|
372
|
|
|
* @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false) |
|
373
|
|
|
*/ |
|
374
|
|
|
private $productions; |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* @var string |
|
378
|
|
|
* |
|
379
|
|
|
* @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false) |
|
380
|
|
|
*/ |
|
381
|
|
|
private $language; |
|
382
|
|
|
|
|
383
|
|
|
/** |
|
384
|
|
|
* @var \DateTime |
|
385
|
|
|
* |
|
386
|
|
|
* @ORM\Column(name="registration_date", type="datetime", nullable=false, unique=false) |
|
387
|
|
|
*/ |
|
388
|
|
|
private $registrationDate; |
|
389
|
|
|
|
|
390
|
|
|
/** |
|
391
|
|
|
* @var \DateTime |
|
392
|
|
|
* |
|
393
|
|
|
* @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false) |
|
394
|
|
|
*/ |
|
395
|
|
|
private $expirationDate; |
|
396
|
|
|
|
|
397
|
|
|
/** |
|
398
|
|
|
* @var bool |
|
399
|
|
|
* |
|
400
|
|
|
* @ORM\Column(name="active", type="boolean", nullable=false, unique=false) |
|
401
|
|
|
*/ |
|
402
|
|
|
private $active; |
|
403
|
|
|
|
|
404
|
|
|
/** |
|
405
|
|
|
* @var string |
|
406
|
|
|
* |
|
407
|
|
|
* @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false) |
|
408
|
|
|
*/ |
|
409
|
|
|
private $openid; |
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* @var string |
|
413
|
|
|
* |
|
414
|
|
|
* @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false) |
|
415
|
|
|
*/ |
|
416
|
|
|
private $theme; |
|
417
|
|
|
|
|
418
|
|
|
/** |
|
419
|
|
|
* @var int |
|
420
|
|
|
* |
|
421
|
|
|
* @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false) |
|
422
|
|
|
*/ |
|
423
|
|
|
private $hrDeptId; |
|
424
|
|
|
|
|
425
|
|
|
/** |
|
426
|
|
|
* Constructor. |
|
427
|
|
|
*/ |
|
428
|
|
|
public function __construct() |
|
429
|
|
|
{ |
|
430
|
|
|
$this->status = self::STUDENT; |
|
431
|
|
|
$this->salt = sha1(uniqid(null, true)); |
|
432
|
|
|
$this->active = true; |
|
433
|
|
|
$this->registrationDate = new \DateTime(); |
|
434
|
|
|
$this->authSource = 'platform'; |
|
435
|
|
|
$this->courses = new ArrayCollection(); |
|
436
|
|
|
//$this->items = new ArrayCollection(); |
|
437
|
|
|
$this->classes = new ArrayCollection(); |
|
438
|
|
|
$this->curriculumItems = new ArrayCollection(); |
|
439
|
|
|
$this->portals = new ArrayCollection(); |
|
440
|
|
|
$this->dropBoxSentFiles = new ArrayCollection(); |
|
441
|
|
|
$this->dropBoxReceivedFiles = new ArrayCollection(); |
|
442
|
|
|
//$this->extraFields = new ArrayCollection(); |
|
443
|
|
|
//$this->userId = 0; |
|
444
|
|
|
//$this->createdAt = new \DateTime(); |
|
445
|
|
|
//$this->updatedAt = new \DateTime(); |
|
446
|
|
|
|
|
447
|
|
|
$this->enabled = false; |
|
448
|
|
|
$this->locked = false; |
|
449
|
|
|
$this->expired = false; |
|
450
|
|
|
$this->roles = []; |
|
451
|
|
|
$this->credentialsExpired = false; |
|
452
|
|
|
} |
|
453
|
|
|
|
|
454
|
|
|
/** |
|
455
|
|
|
* @return string |
|
456
|
|
|
*/ |
|
457
|
|
|
public function __toString() |
|
458
|
|
|
{ |
|
459
|
|
|
return $this->getUsername(); |
|
460
|
|
|
} |
|
461
|
|
|
public function __serialize(): array |
|
462
|
|
|
{ |
|
463
|
|
|
return get_object_vars($this); |
|
464
|
|
|
} |
|
465
|
|
|
public function __unserialize(array $data): void |
|
466
|
|
|
{ |
|
467
|
|
|
$reflection = new ReflectionClass($this); |
|
|
|
|
|
|
468
|
|
|
$properties = $reflection->getProperties(); |
|
469
|
|
|
$propertyNames = array_map(fn($prop) => $prop->getName(), $properties); |
|
470
|
|
|
|
|
471
|
|
|
foreach ($data as $property => $value) { |
|
472
|
|
|
if (in_array($property, $propertyNames)) { |
|
473
|
|
|
$this->$property = $value; |
|
474
|
|
|
} else { |
|
475
|
|
|
// the attribute does not exist in this version of the class |
|
476
|
|
|
} |
|
477
|
|
|
} |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* Updates the id with the user_id. |
|
482
|
|
|
* |
|
483
|
|
|
* @ORM\PostPersist() |
|
484
|
|
|
*/ |
|
485
|
|
|
public function postPersist(LifecycleEventArgs $args) |
|
486
|
|
|
{ |
|
487
|
|
|
//parent::postPersist(); |
|
488
|
|
|
// Updates the user_id field |
|
489
|
|
|
$user = $args->getEntity(); |
|
490
|
|
|
$this->setUserId($user->getId()); |
|
491
|
|
|
/*$em = $args->getEntityManager(); |
|
492
|
|
|
$em->persist($user); |
|
493
|
|
|
$em->flush();*/ |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
/** |
|
497
|
|
|
* @param int $userId |
|
498
|
|
|
*/ |
|
499
|
|
|
public function setId($userId) |
|
500
|
|
|
{ |
|
501
|
|
|
$this->id = $userId; |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
/** |
|
505
|
|
|
* @param int $userId |
|
506
|
|
|
*/ |
|
507
|
|
|
public function setUserId($userId) |
|
508
|
|
|
{ |
|
509
|
|
|
if (!empty($userId)) { |
|
510
|
|
|
$this->userId = $userId; |
|
511
|
|
|
} |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
/** |
|
515
|
|
|
* @return int |
|
516
|
|
|
*/ |
|
517
|
|
|
public function getId() |
|
518
|
|
|
{ |
|
519
|
|
|
return $this->id; |
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
/** |
|
523
|
|
|
* @return string |
|
524
|
|
|
*/ |
|
525
|
|
|
public function getEncoderName() |
|
526
|
|
|
{ |
|
527
|
|
|
return 'legacy_encoder'; |
|
528
|
|
|
} |
|
529
|
|
|
|
|
530
|
|
|
/** |
|
531
|
|
|
* @return ArrayCollection |
|
532
|
|
|
*/ |
|
533
|
|
|
public function getDropBoxSentFiles() |
|
534
|
|
|
{ |
|
535
|
|
|
return $this->dropBoxSentFiles; |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
/** |
|
539
|
|
|
* @return ArrayCollection |
|
540
|
|
|
*/ |
|
541
|
|
|
public function getDropBoxReceivedFiles() |
|
542
|
|
|
{ |
|
543
|
|
|
return $this->dropBoxReceivedFiles; |
|
544
|
|
|
} |
|
545
|
|
|
|
|
546
|
|
|
/** |
|
547
|
|
|
* @param ArrayCollection $value |
|
548
|
|
|
*/ |
|
549
|
|
|
public function setDropBoxSentFiles($value) |
|
550
|
|
|
{ |
|
551
|
|
|
$this->dropBoxSentFiles = $value; |
|
552
|
|
|
|
|
553
|
|
|
return $this; |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
/** |
|
557
|
|
|
* @param ArrayCollection $value |
|
558
|
|
|
*/ |
|
559
|
|
|
public function setDropBoxReceivedFiles($value) |
|
560
|
|
|
{ |
|
561
|
|
|
$this->dropBoxReceivedFiles = $value; |
|
562
|
|
|
|
|
563
|
|
|
return $this; |
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
/** |
|
567
|
|
|
* @param ArrayCollection $courses |
|
568
|
|
|
*/ |
|
569
|
|
|
public function setCourses($courses) |
|
570
|
|
|
{ |
|
571
|
|
|
$this->courses = $courses; |
|
572
|
|
|
|
|
573
|
|
|
return $this; |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
/** |
|
577
|
|
|
* @return ArrayCollection|CourseRelUser[] |
|
578
|
|
|
*/ |
|
579
|
|
|
public function getCourses() |
|
580
|
|
|
{ |
|
581
|
|
|
return $this->courses; |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
/** |
|
585
|
|
|
* @return array |
|
586
|
|
|
*/ |
|
587
|
|
|
public static function getPasswordConstraints() |
|
588
|
|
|
{ |
|
589
|
|
|
return |
|
590
|
|
|
[ |
|
591
|
|
|
new Assert\Length(['min' => 5]), |
|
592
|
|
|
// Alpha numeric + "_" or "-" |
|
593
|
|
|
new Assert\Regex( |
|
594
|
|
|
[ |
|
595
|
|
|
'pattern' => '/^[a-z\-_0-9]+$/i', |
|
596
|
|
|
'htmlPattern' => '/^[a-z\-_0-9]+$/i', ] |
|
597
|
|
|
), |
|
598
|
|
|
// Min 3 letters - not needed |
|
599
|
|
|
/*new Assert\Regex(array( |
|
600
|
|
|
'pattern' => '/[a-z]{3}/i', |
|
601
|
|
|
'htmlPattern' => '/[a-z]{3}/i') |
|
602
|
|
|
),*/ |
|
603
|
|
|
// Min 2 numbers |
|
604
|
|
|
new Assert\Regex( |
|
605
|
|
|
[ |
|
606
|
|
|
'pattern' => '/[0-9]{2}/', |
|
607
|
|
|
'htmlPattern' => '/[0-9]{2}/', ] |
|
608
|
|
|
), |
|
609
|
|
|
] |
|
610
|
|
|
; |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
public static function loadValidatorMetadata(ClassMetadata $metadata) |
|
614
|
|
|
{ |
|
615
|
|
|
//$metadata->addPropertyConstraint('firstname', new Assert\NotBlank()); |
|
616
|
|
|
//$metadata->addPropertyConstraint('lastname', new Assert\NotBlank()); |
|
617
|
|
|
//$metadata->addPropertyConstraint('email', new Assert\Email()); |
|
618
|
|
|
/* |
|
619
|
|
|
$metadata->addPropertyConstraint('password', |
|
620
|
|
|
new Assert\Collection(self::getPasswordConstraints()) |
|
621
|
|
|
);*/ |
|
622
|
|
|
|
|
623
|
|
|
/*$metadata->addConstraint(new UniqueEntity(array( |
|
624
|
|
|
'fields' => 'username', |
|
625
|
|
|
'message' => 'This value is already used.', |
|
626
|
|
|
)));*/ |
|
627
|
|
|
|
|
628
|
|
|
/*$metadata->addPropertyConstraint( |
|
629
|
|
|
'username', |
|
630
|
|
|
new Assert\Length(array( |
|
631
|
|
|
'min' => 2, |
|
632
|
|
|
'max' => 50, |
|
633
|
|
|
'minMessage' => 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.', |
|
634
|
|
|
'maxMessage' => 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.', |
|
635
|
|
|
)) |
|
636
|
|
|
);*/ |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
/** |
|
640
|
|
|
* {@inheritdoc} |
|
641
|
|
|
*/ |
|
642
|
|
|
public function isEqualTo(UserInterface $user) |
|
643
|
|
|
{ |
|
644
|
|
|
if (!$user instanceof User) { |
|
645
|
|
|
return false; |
|
646
|
|
|
} |
|
647
|
|
|
|
|
648
|
|
|
/*if ($this->password !== $user->getPassword()) { |
|
649
|
|
|
return false; |
|
650
|
|
|
}*/ |
|
651
|
|
|
|
|
652
|
|
|
/*if ($this->getSalt() !== $user->getSalt()) { |
|
653
|
|
|
return false; |
|
654
|
|
|
}*/ |
|
655
|
|
|
|
|
656
|
|
|
/*if ($this->username !== $user->getUsername()) { |
|
657
|
|
|
return false; |
|
658
|
|
|
}*/ |
|
659
|
|
|
|
|
660
|
|
|
return true; |
|
661
|
|
|
} |
|
662
|
|
|
|
|
663
|
|
|
/** |
|
664
|
|
|
* @return ArrayCollection |
|
665
|
|
|
*/ |
|
666
|
|
|
public function getPortals() |
|
667
|
|
|
{ |
|
668
|
|
|
return $this->portals; |
|
669
|
|
|
} |
|
670
|
|
|
|
|
671
|
|
|
/** |
|
672
|
|
|
* @param $portal |
|
673
|
|
|
*/ |
|
674
|
|
|
public function setPortal($portal) |
|
675
|
|
|
{ |
|
676
|
|
|
$this->portals->add($portal); |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
|
|
/** |
|
680
|
|
|
* @param $value |
|
681
|
|
|
*/ |
|
682
|
|
|
public function setPortals($value) |
|
683
|
|
|
{ |
|
684
|
|
|
$this->portals = $value; |
|
685
|
|
|
|
|
686
|
|
|
return $this; |
|
687
|
|
|
} |
|
688
|
|
|
|
|
689
|
|
|
/** |
|
690
|
|
|
* @return ArrayCollection |
|
691
|
|
|
*/ |
|
692
|
|
|
public function getCurriculumItems() |
|
693
|
|
|
{ |
|
694
|
|
|
return $this->curriculumItems; |
|
695
|
|
|
} |
|
696
|
|
|
|
|
697
|
|
|
/** |
|
698
|
|
|
* @param $items |
|
699
|
|
|
* |
|
700
|
|
|
* @return $this |
|
701
|
|
|
*/ |
|
702
|
|
|
public function setCurriculumItems($items) |
|
703
|
|
|
{ |
|
704
|
|
|
$this->curriculumItems = $items; |
|
705
|
|
|
|
|
706
|
|
|
return $this; |
|
707
|
|
|
} |
|
708
|
|
|
|
|
709
|
|
|
/** |
|
710
|
|
|
* @return bool |
|
711
|
|
|
*/ |
|
712
|
|
|
public function getIsActive() |
|
713
|
|
|
{ |
|
714
|
|
|
return $this->active == 1; |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
/** |
|
718
|
|
|
* @return bool |
|
719
|
|
|
*/ |
|
720
|
|
|
public function isActive() |
|
721
|
|
|
{ |
|
722
|
|
|
return $this->getIsActive(); |
|
723
|
|
|
} |
|
724
|
|
|
|
|
725
|
|
|
/** |
|
726
|
|
|
* {@inheritdoc} |
|
727
|
|
|
*/ |
|
728
|
|
|
public function isEnabled() |
|
729
|
|
|
{ |
|
730
|
|
|
return $this->getActive() == 1; |
|
731
|
|
|
} |
|
732
|
|
|
|
|
733
|
|
|
/** |
|
734
|
|
|
* @return ArrayCollection |
|
735
|
|
|
*/ |
|
736
|
|
|
/*public function getRolesObj() |
|
737
|
|
|
{ |
|
738
|
|
|
return $this->roles; |
|
739
|
|
|
}*/ |
|
740
|
|
|
|
|
741
|
|
|
/** |
|
742
|
|
|
* Set salt. |
|
743
|
|
|
* |
|
744
|
|
|
* @param string $salt |
|
745
|
|
|
* |
|
746
|
|
|
* @return User |
|
747
|
|
|
*/ |
|
748
|
|
|
public function setSalt($salt) |
|
749
|
|
|
{ |
|
750
|
|
|
$this->salt = $salt; |
|
751
|
|
|
|
|
752
|
|
|
return $this; |
|
753
|
|
|
} |
|
754
|
|
|
|
|
755
|
|
|
/** |
|
756
|
|
|
* Get salt. |
|
757
|
|
|
* |
|
758
|
|
|
* @return string |
|
759
|
|
|
*/ |
|
760
|
|
|
public function getSalt() |
|
761
|
|
|
{ |
|
762
|
|
|
return $this->salt; |
|
763
|
|
|
} |
|
764
|
|
|
|
|
765
|
|
|
/** |
|
766
|
|
|
* @param ArrayCollection $classes |
|
767
|
|
|
* |
|
768
|
|
|
* @return $this |
|
769
|
|
|
*/ |
|
770
|
|
|
public function setClasses($classes) |
|
771
|
|
|
{ |
|
772
|
|
|
$this->classes = $classes; |
|
773
|
|
|
|
|
774
|
|
|
return $this; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
/** |
|
778
|
|
|
* @return ArrayCollection|UsergroupRelUser[] |
|
779
|
|
|
*/ |
|
780
|
|
|
public function getClasses() |
|
781
|
|
|
{ |
|
782
|
|
|
return $this->classes; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
public function getLps() |
|
786
|
|
|
{ |
|
787
|
|
|
//return $this->lps; |
|
788
|
|
|
/*$criteria = Criteria::create() |
|
789
|
|
|
->where(Criteria::expr()->eq("id", "666")) |
|
790
|
|
|
//->orderBy(array("username" => "ASC")) |
|
791
|
|
|
//->setFirstResult(0) |
|
792
|
|
|
//->setMaxResults(20) |
|
793
|
|
|
; |
|
794
|
|
|
$lps = $this->lps->matching($criteria);*/ |
|
795
|
|
|
/*return $this->lps->filter( |
|
796
|
|
|
function($entry) use ($idsToFilter) { |
|
797
|
|
|
return $entry->getId() == 1; |
|
798
|
|
|
});*/ |
|
799
|
|
|
} |
|
800
|
|
|
|
|
801
|
|
|
/** |
|
802
|
|
|
* Return Complete Name with the Username. |
|
803
|
|
|
* |
|
804
|
|
|
* @return string |
|
805
|
|
|
*/ |
|
806
|
|
|
public function getCompleteNameWithUsername() |
|
807
|
|
|
{ |
|
808
|
|
|
if (api_get_configuration_value('hide_username_with_complete_name')) { |
|
809
|
|
|
return $this->getCompleteName(); |
|
810
|
|
|
} |
|
811
|
|
|
|
|
812
|
|
|
return api_get_person_name($this->firstname, $this->lastname).' ('.$this->username.')'; |
|
813
|
|
|
} |
|
814
|
|
|
|
|
815
|
|
|
/** |
|
816
|
|
|
* @todo don't use api_get_person_name |
|
817
|
|
|
* |
|
818
|
|
|
* @return string |
|
819
|
|
|
*/ |
|
820
|
|
|
public function getCompleteName() |
|
821
|
|
|
{ |
|
822
|
|
|
return api_get_person_name($this->firstname, $this->lastname); |
|
823
|
|
|
} |
|
824
|
|
|
|
|
825
|
|
|
/** |
|
826
|
|
|
* Returns the list of classes for the user. |
|
827
|
|
|
* |
|
828
|
|
|
* @return string |
|
829
|
|
|
*/ |
|
830
|
|
|
public function getCompleteNameWithClasses() |
|
831
|
|
|
{ |
|
832
|
|
|
$classSubscription = $this->getClasses(); |
|
833
|
|
|
$classList = []; |
|
834
|
|
|
/** @var UsergroupRelUser $subscription */ |
|
835
|
|
|
foreach ($classSubscription as $subscription) { |
|
836
|
|
|
$class = $subscription->getUsergroup(); |
|
837
|
|
|
$classList[] = $class->getName(); |
|
838
|
|
|
} |
|
839
|
|
|
$classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null; |
|
840
|
|
|
|
|
841
|
|
|
return $this->getCompleteName().$classString; |
|
842
|
|
|
} |
|
843
|
|
|
|
|
844
|
|
|
/** |
|
845
|
|
|
* Get userId. |
|
846
|
|
|
* |
|
847
|
|
|
* @return int |
|
848
|
|
|
*/ |
|
849
|
|
|
public function getUserId() |
|
850
|
|
|
{ |
|
851
|
|
|
return $this->userId; |
|
852
|
|
|
} |
|
853
|
|
|
|
|
854
|
|
|
/** |
|
855
|
|
|
* Set lastname. |
|
856
|
|
|
* |
|
857
|
|
|
* @param string $lastname |
|
858
|
|
|
* |
|
859
|
|
|
* @return User |
|
860
|
|
|
*/ |
|
861
|
|
|
public function setLastname($lastname) |
|
862
|
|
|
{ |
|
863
|
|
|
$this->lastname = $lastname; |
|
864
|
|
|
|
|
865
|
|
|
return $this; |
|
866
|
|
|
} |
|
867
|
|
|
|
|
868
|
|
|
/** |
|
869
|
|
|
* Set firstname. |
|
870
|
|
|
* |
|
871
|
|
|
* @param string $firstname |
|
872
|
|
|
* |
|
873
|
|
|
* @return User |
|
874
|
|
|
*/ |
|
875
|
|
|
public function setFirstname($firstname) |
|
876
|
|
|
{ |
|
877
|
|
|
$this->firstname = $firstname; |
|
878
|
|
|
|
|
879
|
|
|
return $this; |
|
880
|
|
|
} |
|
881
|
|
|
|
|
882
|
|
|
/** |
|
883
|
|
|
* Set password. |
|
884
|
|
|
* |
|
885
|
|
|
* @param string $password |
|
886
|
|
|
* |
|
887
|
|
|
* @return User |
|
888
|
|
|
*/ |
|
889
|
|
|
public function setPassword($password) |
|
890
|
|
|
{ |
|
891
|
|
|
$this->password = $password; |
|
892
|
|
|
|
|
893
|
|
|
return $this; |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
/** |
|
897
|
|
|
* Get password. |
|
898
|
|
|
* |
|
899
|
|
|
* @return string |
|
900
|
|
|
*/ |
|
901
|
|
|
public function getPassword() |
|
902
|
|
|
{ |
|
903
|
|
|
return $this->password; |
|
904
|
|
|
} |
|
905
|
|
|
|
|
906
|
|
|
/** |
|
907
|
|
|
* Set authSource. |
|
908
|
|
|
* |
|
909
|
|
|
* @param string $authSource |
|
910
|
|
|
* |
|
911
|
|
|
* @return User |
|
912
|
|
|
*/ |
|
913
|
|
|
public function setAuthSource($authSource) |
|
914
|
|
|
{ |
|
915
|
|
|
$this->authSource = $authSource; |
|
916
|
|
|
|
|
917
|
|
|
return $this; |
|
918
|
|
|
} |
|
919
|
|
|
|
|
920
|
|
|
/** |
|
921
|
|
|
* Get authSource. |
|
922
|
|
|
* |
|
923
|
|
|
* @return string |
|
924
|
|
|
*/ |
|
925
|
|
|
public function getAuthSource() |
|
926
|
|
|
{ |
|
927
|
|
|
return $this->authSource; |
|
928
|
|
|
} |
|
929
|
|
|
|
|
930
|
|
|
/** |
|
931
|
|
|
* Set email. |
|
932
|
|
|
* |
|
933
|
|
|
* @param string $email |
|
934
|
|
|
* |
|
935
|
|
|
* @return User |
|
936
|
|
|
*/ |
|
937
|
|
|
public function setEmail($email) |
|
938
|
|
|
{ |
|
939
|
|
|
$this->email = $email; |
|
940
|
|
|
|
|
941
|
|
|
return $this; |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
|
|
/** |
|
945
|
|
|
* Get email. |
|
946
|
|
|
* |
|
947
|
|
|
* @return string |
|
948
|
|
|
*/ |
|
949
|
|
|
public function getEmail() |
|
950
|
|
|
{ |
|
951
|
|
|
return $this->email; |
|
952
|
|
|
} |
|
953
|
|
|
|
|
954
|
|
|
/** |
|
955
|
|
|
* Set status. |
|
956
|
|
|
* |
|
957
|
|
|
* @param int $status |
|
958
|
|
|
* |
|
959
|
|
|
* @return User |
|
960
|
|
|
*/ |
|
961
|
|
|
public function setStatus($status) |
|
962
|
|
|
{ |
|
963
|
|
|
$this->status = $status; |
|
964
|
|
|
|
|
965
|
|
|
return $this; |
|
966
|
|
|
} |
|
967
|
|
|
|
|
968
|
|
|
/** |
|
969
|
|
|
* Get status. |
|
970
|
|
|
* |
|
971
|
|
|
* @return int |
|
972
|
|
|
*/ |
|
973
|
|
|
public function getStatus() |
|
974
|
|
|
{ |
|
975
|
|
|
return $this->status; |
|
976
|
|
|
} |
|
977
|
|
|
|
|
978
|
|
|
/** |
|
979
|
|
|
* Set officialCode. |
|
980
|
|
|
* |
|
981
|
|
|
* @param string $officialCode |
|
982
|
|
|
* |
|
983
|
|
|
* @return User |
|
984
|
|
|
*/ |
|
985
|
|
|
public function setOfficialCode($officialCode) |
|
986
|
|
|
{ |
|
987
|
|
|
$this->officialCode = $officialCode; |
|
988
|
|
|
|
|
989
|
|
|
return $this; |
|
990
|
|
|
} |
|
991
|
|
|
|
|
992
|
|
|
/** |
|
993
|
|
|
* Get officialCode. |
|
994
|
|
|
* |
|
995
|
|
|
* @return string |
|
996
|
|
|
*/ |
|
997
|
|
|
public function getOfficialCode() |
|
998
|
|
|
{ |
|
999
|
|
|
return $this->officialCode; |
|
1000
|
|
|
} |
|
1001
|
|
|
|
|
1002
|
|
|
/** |
|
1003
|
|
|
* Set phone. |
|
1004
|
|
|
* |
|
1005
|
|
|
* @param string $phone |
|
1006
|
|
|
* |
|
1007
|
|
|
* @return User |
|
1008
|
|
|
*/ |
|
1009
|
|
|
public function setPhone($phone) |
|
1010
|
|
|
{ |
|
1011
|
|
|
$this->phone = $phone; |
|
1012
|
|
|
|
|
1013
|
|
|
return $this; |
|
1014
|
|
|
} |
|
1015
|
|
|
|
|
1016
|
|
|
/** |
|
1017
|
|
|
* Get phone. |
|
1018
|
|
|
* |
|
1019
|
|
|
* @return string |
|
1020
|
|
|
*/ |
|
1021
|
|
|
public function getPhone() |
|
1022
|
|
|
{ |
|
1023
|
|
|
return $this->phone; |
|
1024
|
|
|
} |
|
1025
|
|
|
|
|
1026
|
|
|
/** |
|
1027
|
|
|
* Set address. |
|
1028
|
|
|
* |
|
1029
|
|
|
* @param string $address |
|
1030
|
|
|
* |
|
1031
|
|
|
* @return User |
|
1032
|
|
|
*/ |
|
1033
|
|
|
public function setAddress($address) |
|
1034
|
|
|
{ |
|
1035
|
|
|
$this->address = $address; |
|
1036
|
|
|
|
|
1037
|
|
|
return $this; |
|
1038
|
|
|
} |
|
1039
|
|
|
|
|
1040
|
|
|
/** |
|
1041
|
|
|
* Get address. |
|
1042
|
|
|
* |
|
1043
|
|
|
* @return string |
|
1044
|
|
|
*/ |
|
1045
|
|
|
public function getAddress() |
|
1046
|
|
|
{ |
|
1047
|
|
|
return $this->address; |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
|
|
/** |
|
1051
|
|
|
* Set pictureUri. |
|
1052
|
|
|
* |
|
1053
|
|
|
* @param string $pictureUri |
|
1054
|
|
|
* |
|
1055
|
|
|
* @return User |
|
1056
|
|
|
*/ |
|
1057
|
|
|
public function setPictureUri($pictureUri) |
|
1058
|
|
|
{ |
|
1059
|
|
|
$this->pictureUri = $pictureUri; |
|
1060
|
|
|
|
|
1061
|
|
|
return $this; |
|
1062
|
|
|
} |
|
1063
|
|
|
|
|
1064
|
|
|
/** |
|
1065
|
|
|
* Get pictureUri. |
|
1066
|
|
|
* |
|
1067
|
|
|
* @return Media |
|
1068
|
|
|
*/ |
|
1069
|
|
|
public function getPictureUri() |
|
1070
|
|
|
{ |
|
1071
|
|
|
return $this->pictureUri; |
|
1072
|
|
|
} |
|
1073
|
|
|
|
|
1074
|
|
|
/** |
|
1075
|
|
|
* Set creatorId. |
|
1076
|
|
|
* |
|
1077
|
|
|
* @param int $creatorId |
|
1078
|
|
|
* |
|
1079
|
|
|
* @return User |
|
1080
|
|
|
*/ |
|
1081
|
|
|
public function setCreatorId($creatorId) |
|
1082
|
|
|
{ |
|
1083
|
|
|
$this->creatorId = $creatorId; |
|
1084
|
|
|
|
|
1085
|
|
|
return $this; |
|
1086
|
|
|
} |
|
1087
|
|
|
|
|
1088
|
|
|
/** |
|
1089
|
|
|
* Get creatorId. |
|
1090
|
|
|
* |
|
1091
|
|
|
* @return int |
|
1092
|
|
|
*/ |
|
1093
|
|
|
public function getCreatorId() |
|
1094
|
|
|
{ |
|
1095
|
|
|
return $this->creatorId; |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
/** |
|
1099
|
|
|
* Set competences. |
|
1100
|
|
|
* |
|
1101
|
|
|
* @param string $competences |
|
1102
|
|
|
* |
|
1103
|
|
|
* @return User |
|
1104
|
|
|
*/ |
|
1105
|
|
|
public function setCompetences($competences) |
|
1106
|
|
|
{ |
|
1107
|
|
|
$this->competences = $competences; |
|
1108
|
|
|
|
|
1109
|
|
|
return $this; |
|
1110
|
|
|
} |
|
1111
|
|
|
|
|
1112
|
|
|
/** |
|
1113
|
|
|
* Get competences. |
|
1114
|
|
|
* |
|
1115
|
|
|
* @return string |
|
1116
|
|
|
*/ |
|
1117
|
|
|
public function getCompetences() |
|
1118
|
|
|
{ |
|
1119
|
|
|
return $this->competences; |
|
1120
|
|
|
} |
|
1121
|
|
|
|
|
1122
|
|
|
/** |
|
1123
|
|
|
* Set diplomas. |
|
1124
|
|
|
* |
|
1125
|
|
|
* @param string $diplomas |
|
1126
|
|
|
* |
|
1127
|
|
|
* @return User |
|
1128
|
|
|
*/ |
|
1129
|
|
|
public function setDiplomas($diplomas) |
|
1130
|
|
|
{ |
|
1131
|
|
|
$this->diplomas = $diplomas; |
|
1132
|
|
|
|
|
1133
|
|
|
return $this; |
|
1134
|
|
|
} |
|
1135
|
|
|
|
|
1136
|
|
|
/** |
|
1137
|
|
|
* Get diplomas. |
|
1138
|
|
|
* |
|
1139
|
|
|
* @return string |
|
1140
|
|
|
*/ |
|
1141
|
|
|
public function getDiplomas() |
|
1142
|
|
|
{ |
|
1143
|
|
|
return $this->diplomas; |
|
1144
|
|
|
} |
|
1145
|
|
|
|
|
1146
|
|
|
/** |
|
1147
|
|
|
* Set openarea. |
|
1148
|
|
|
* |
|
1149
|
|
|
* @param string $openarea |
|
1150
|
|
|
* |
|
1151
|
|
|
* @return User |
|
1152
|
|
|
*/ |
|
1153
|
|
|
public function setOpenarea($openarea) |
|
1154
|
|
|
{ |
|
1155
|
|
|
$this->openarea = $openarea; |
|
1156
|
|
|
|
|
1157
|
|
|
return $this; |
|
1158
|
|
|
} |
|
1159
|
|
|
|
|
1160
|
|
|
/** |
|
1161
|
|
|
* Get openarea. |
|
1162
|
|
|
* |
|
1163
|
|
|
* @return string |
|
1164
|
|
|
*/ |
|
1165
|
|
|
public function getOpenarea() |
|
1166
|
|
|
{ |
|
1167
|
|
|
return $this->openarea; |
|
1168
|
|
|
} |
|
1169
|
|
|
|
|
1170
|
|
|
/** |
|
1171
|
|
|
* Set teach. |
|
1172
|
|
|
* |
|
1173
|
|
|
* @param string $teach |
|
1174
|
|
|
* |
|
1175
|
|
|
* @return User |
|
1176
|
|
|
*/ |
|
1177
|
|
|
public function setTeach($teach) |
|
1178
|
|
|
{ |
|
1179
|
|
|
$this->teach = $teach; |
|
1180
|
|
|
|
|
1181
|
|
|
return $this; |
|
1182
|
|
|
} |
|
1183
|
|
|
|
|
1184
|
|
|
/** |
|
1185
|
|
|
* Get teach. |
|
1186
|
|
|
* |
|
1187
|
|
|
* @return string |
|
1188
|
|
|
*/ |
|
1189
|
|
|
public function getTeach() |
|
1190
|
|
|
{ |
|
1191
|
|
|
return $this->teach; |
|
1192
|
|
|
} |
|
1193
|
|
|
|
|
1194
|
|
|
/** |
|
1195
|
|
|
* Set productions. |
|
1196
|
|
|
* |
|
1197
|
|
|
* @param string $productions |
|
1198
|
|
|
* |
|
1199
|
|
|
* @return User |
|
1200
|
|
|
*/ |
|
1201
|
|
|
public function setProductions($productions) |
|
1202
|
|
|
{ |
|
1203
|
|
|
$this->productions = $productions; |
|
1204
|
|
|
|
|
1205
|
|
|
return $this; |
|
1206
|
|
|
} |
|
1207
|
|
|
|
|
1208
|
|
|
/** |
|
1209
|
|
|
* Get productions. |
|
1210
|
|
|
* |
|
1211
|
|
|
* @return string |
|
1212
|
|
|
*/ |
|
1213
|
|
|
public function getProductions() |
|
1214
|
|
|
{ |
|
1215
|
|
|
return $this->productions; |
|
1216
|
|
|
} |
|
1217
|
|
|
|
|
1218
|
|
|
/** |
|
1219
|
|
|
* Set language. |
|
1220
|
|
|
* |
|
1221
|
|
|
* @param string $language |
|
1222
|
|
|
* |
|
1223
|
|
|
* @return User |
|
1224
|
|
|
*/ |
|
1225
|
|
|
public function setLanguage($language) |
|
1226
|
|
|
{ |
|
1227
|
|
|
$this->language = $language; |
|
1228
|
|
|
|
|
1229
|
|
|
return $this; |
|
1230
|
|
|
} |
|
1231
|
|
|
|
|
1232
|
|
|
/** |
|
1233
|
|
|
* Get language. |
|
1234
|
|
|
* |
|
1235
|
|
|
* @return string |
|
1236
|
|
|
*/ |
|
1237
|
|
|
public function getLanguage() |
|
1238
|
|
|
{ |
|
1239
|
|
|
return $this->language; |
|
1240
|
|
|
} |
|
1241
|
|
|
|
|
1242
|
|
|
/** |
|
1243
|
|
|
* Set registrationDate. |
|
1244
|
|
|
* |
|
1245
|
|
|
* @param \DateTime $registrationDate |
|
1246
|
|
|
* |
|
1247
|
|
|
* @return User |
|
1248
|
|
|
*/ |
|
1249
|
|
|
public function setRegistrationDate($registrationDate) |
|
1250
|
|
|
{ |
|
1251
|
|
|
$this->registrationDate = $registrationDate; |
|
1252
|
|
|
|
|
1253
|
|
|
return $this; |
|
1254
|
|
|
} |
|
1255
|
|
|
|
|
1256
|
|
|
/** |
|
1257
|
|
|
* Get registrationDate. |
|
1258
|
|
|
* |
|
1259
|
|
|
* @return \DateTime |
|
1260
|
|
|
*/ |
|
1261
|
|
|
public function getRegistrationDate() |
|
1262
|
|
|
{ |
|
1263
|
|
|
return $this->registrationDate; |
|
1264
|
|
|
} |
|
1265
|
|
|
|
|
1266
|
|
|
/** |
|
1267
|
|
|
* Set expirationDate. |
|
1268
|
|
|
* |
|
1269
|
|
|
* @param \DateTime $expirationDate |
|
1270
|
|
|
* |
|
1271
|
|
|
* @return User |
|
1272
|
|
|
*/ |
|
1273
|
|
|
public function setExpirationDate($expirationDate) |
|
1274
|
|
|
{ |
|
1275
|
|
|
$this->expirationDate = $expirationDate; |
|
1276
|
|
|
|
|
1277
|
|
|
return $this; |
|
1278
|
|
|
} |
|
1279
|
|
|
|
|
1280
|
|
|
/** |
|
1281
|
|
|
* Get expirationDate. |
|
1282
|
|
|
* |
|
1283
|
|
|
* @return \DateTime |
|
1284
|
|
|
*/ |
|
1285
|
|
|
public function getExpirationDate() |
|
1286
|
|
|
{ |
|
1287
|
|
|
return $this->expirationDate; |
|
1288
|
|
|
} |
|
1289
|
|
|
|
|
1290
|
|
|
/** |
|
1291
|
|
|
* Set active. |
|
1292
|
|
|
* |
|
1293
|
|
|
* @param bool $active |
|
1294
|
|
|
* |
|
1295
|
|
|
* @return User |
|
1296
|
|
|
*/ |
|
1297
|
|
|
public function setActive($active) |
|
1298
|
|
|
{ |
|
1299
|
|
|
$this->active = $active; |
|
1300
|
|
|
|
|
1301
|
|
|
return $this; |
|
1302
|
|
|
} |
|
1303
|
|
|
|
|
1304
|
|
|
/** |
|
1305
|
|
|
* Get active. |
|
1306
|
|
|
* |
|
1307
|
|
|
* @return bool |
|
1308
|
|
|
*/ |
|
1309
|
|
|
public function getActive() |
|
1310
|
|
|
{ |
|
1311
|
|
|
return $this->active; |
|
1312
|
|
|
} |
|
1313
|
|
|
|
|
1314
|
|
|
/** |
|
1315
|
|
|
* Set openid. |
|
1316
|
|
|
* |
|
1317
|
|
|
* @param string $openid |
|
1318
|
|
|
* |
|
1319
|
|
|
* @return User |
|
1320
|
|
|
*/ |
|
1321
|
|
|
public function setOpenid($openid) |
|
1322
|
|
|
{ |
|
1323
|
|
|
$this->openid = $openid; |
|
1324
|
|
|
|
|
1325
|
|
|
return $this; |
|
1326
|
|
|
} |
|
1327
|
|
|
|
|
1328
|
|
|
/** |
|
1329
|
|
|
* Get openid. |
|
1330
|
|
|
* |
|
1331
|
|
|
* @return string |
|
1332
|
|
|
*/ |
|
1333
|
|
|
public function getOpenid() |
|
1334
|
|
|
{ |
|
1335
|
|
|
return $this->openid; |
|
1336
|
|
|
} |
|
1337
|
|
|
|
|
1338
|
|
|
/** |
|
1339
|
|
|
* Set theme. |
|
1340
|
|
|
* |
|
1341
|
|
|
* @param string $theme |
|
1342
|
|
|
* |
|
1343
|
|
|
* @return User |
|
1344
|
|
|
*/ |
|
1345
|
|
|
public function setTheme($theme) |
|
1346
|
|
|
{ |
|
1347
|
|
|
$this->theme = $theme; |
|
1348
|
|
|
|
|
1349
|
|
|
return $this; |
|
1350
|
|
|
} |
|
1351
|
|
|
|
|
1352
|
|
|
/** |
|
1353
|
|
|
* Get theme. |
|
1354
|
|
|
* |
|
1355
|
|
|
* @return string |
|
1356
|
|
|
*/ |
|
1357
|
|
|
public function getTheme() |
|
1358
|
|
|
{ |
|
1359
|
|
|
return $this->theme; |
|
1360
|
|
|
} |
|
1361
|
|
|
|
|
1362
|
|
|
/** |
|
1363
|
|
|
* Set hrDeptId. |
|
1364
|
|
|
* |
|
1365
|
|
|
* @param int $hrDeptId |
|
1366
|
|
|
* |
|
1367
|
|
|
* @return User |
|
1368
|
|
|
*/ |
|
1369
|
|
|
public function setHrDeptId($hrDeptId) |
|
1370
|
|
|
{ |
|
1371
|
|
|
$this->hrDeptId = $hrDeptId; |
|
1372
|
|
|
|
|
1373
|
|
|
return $this; |
|
1374
|
|
|
} |
|
1375
|
|
|
|
|
1376
|
|
|
/** |
|
1377
|
|
|
* Get hrDeptId. |
|
1378
|
|
|
* |
|
1379
|
|
|
* @return int |
|
1380
|
|
|
*/ |
|
1381
|
|
|
public function getHrDeptId() |
|
1382
|
|
|
{ |
|
1383
|
|
|
return $this->hrDeptId; |
|
1384
|
|
|
} |
|
1385
|
|
|
|
|
1386
|
|
|
/** |
|
1387
|
|
|
* @return Media |
|
1388
|
|
|
*/ |
|
1389
|
|
|
public function getAvatar() |
|
1390
|
|
|
{ |
|
1391
|
|
|
return $this->getPictureUri(); |
|
1392
|
|
|
} |
|
1393
|
|
|
|
|
1394
|
|
|
/** |
|
1395
|
|
|
* @return \DateTime |
|
1396
|
|
|
*/ |
|
1397
|
|
|
public function getMemberSince() |
|
1398
|
|
|
{ |
|
1399
|
|
|
return $this->registrationDate; |
|
1400
|
|
|
} |
|
1401
|
|
|
|
|
1402
|
|
|
/** |
|
1403
|
|
|
* @return bool |
|
1404
|
|
|
*/ |
|
1405
|
|
|
public function isOnline() |
|
1406
|
|
|
{ |
|
1407
|
|
|
return false; |
|
1408
|
|
|
} |
|
1409
|
|
|
|
|
1410
|
|
|
/** |
|
1411
|
|
|
* @return int |
|
1412
|
|
|
*/ |
|
1413
|
|
|
public function getIdentifier() |
|
1414
|
|
|
{ |
|
1415
|
|
|
return $this->getId(); |
|
1416
|
|
|
} |
|
1417
|
|
|
|
|
1418
|
|
|
/** |
|
1419
|
|
|
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance |
|
1420
|
|
|
* of 'UploadedFile' is injected into this setter to trigger the update. If this |
|
1421
|
|
|
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter |
|
1422
|
|
|
* must be able to accept an instance of 'File' as the bundle will inject one here |
|
1423
|
|
|
* during Doctrine hydration. |
|
1424
|
|
|
* |
|
1425
|
|
|
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image |
|
1426
|
|
|
*/ |
|
1427
|
|
|
public function setImageFile(File $image) |
|
1428
|
|
|
{ |
|
1429
|
|
|
$this->imageFile = $image; |
|
1430
|
|
|
|
|
1431
|
|
|
if ($image) { |
|
|
|
|
|
|
1432
|
|
|
// It is required that at least one field changes if you are using doctrine |
|
1433
|
|
|
// otherwise the event listeners won't be called and the file is lost |
|
1434
|
|
|
$this->updatedAt = new \DateTime('now'); |
|
1435
|
|
|
} |
|
1436
|
|
|
} |
|
1437
|
|
|
|
|
1438
|
|
|
/** |
|
1439
|
|
|
* @return File |
|
1440
|
|
|
*/ |
|
1441
|
|
|
public function getImageFile() |
|
1442
|
|
|
{ |
|
1443
|
|
|
return $this->imageFile; |
|
1444
|
|
|
} |
|
1445
|
|
|
|
|
1446
|
|
|
/** |
|
1447
|
|
|
* @return string |
|
1448
|
|
|
*/ |
|
1449
|
|
|
public function getSlug() |
|
1450
|
|
|
{ |
|
1451
|
|
|
return $this->getUsername(); |
|
1452
|
|
|
} |
|
1453
|
|
|
|
|
1454
|
|
|
/** |
|
1455
|
|
|
* @param $slug |
|
1456
|
|
|
* |
|
1457
|
|
|
* @return User |
|
1458
|
|
|
*/ |
|
1459
|
|
|
public function setSlug($slug) |
|
1460
|
|
|
{ |
|
1461
|
|
|
return $this->setUsername($slug); |
|
1462
|
|
|
} |
|
1463
|
|
|
|
|
1464
|
|
|
/** |
|
1465
|
|
|
* Set lastLogin. |
|
1466
|
|
|
* |
|
1467
|
|
|
* @return User |
|
1468
|
|
|
*/ |
|
1469
|
|
|
public function setLastLogin(\DateTime $lastLogin = null) |
|
1470
|
|
|
{ |
|
1471
|
|
|
$this->lastLogin = $lastLogin; |
|
1472
|
|
|
|
|
1473
|
|
|
return $this; |
|
1474
|
|
|
} |
|
1475
|
|
|
|
|
1476
|
|
|
/** |
|
1477
|
|
|
* Get lastLogin. |
|
1478
|
|
|
* |
|
1479
|
|
|
* @return \DateTime |
|
1480
|
|
|
*/ |
|
1481
|
|
|
public function getLastLogin() |
|
1482
|
|
|
{ |
|
1483
|
|
|
// If not last_login has been registered in the user table |
|
1484
|
|
|
// (for users without login after version 1.10), get the last login |
|
1485
|
|
|
// from the track_e_login table |
|
1486
|
|
|
/*if (empty($this->lastLogin)) { |
|
1487
|
|
|
return $this->getExtendedLastLogin(); |
|
1488
|
|
|
}*/ |
|
1489
|
|
|
|
|
1490
|
|
|
return $this->lastLogin; |
|
1491
|
|
|
} |
|
1492
|
|
|
|
|
1493
|
|
|
/** |
|
1494
|
|
|
* {@inheritdoc} |
|
1495
|
|
|
*/ |
|
1496
|
|
|
public function getExtraFields() |
|
1497
|
|
|
{ |
|
1498
|
|
|
return $this->extraFields; |
|
1499
|
|
|
} |
|
1500
|
|
|
|
|
1501
|
|
|
/** |
|
1502
|
|
|
* {@inheritdoc} |
|
1503
|
|
|
*/ |
|
1504
|
|
|
public function setExtraFieldList($extraFields) |
|
1505
|
|
|
{ |
|
1506
|
|
|
$this->extraFields = new ArrayCollection(); |
|
1507
|
|
|
foreach ($extraFields as $extraField) { |
|
1508
|
|
|
$this->addExtraFields($extraField); |
|
1509
|
|
|
} |
|
1510
|
|
|
|
|
1511
|
|
|
return $this; |
|
1512
|
|
|
} |
|
1513
|
|
|
|
|
1514
|
|
|
public function setExtraFields($extraFields) |
|
1515
|
|
|
{ |
|
1516
|
|
|
$this->extraFields = $extraFields; |
|
1517
|
|
|
|
|
1518
|
|
|
return $this; |
|
1519
|
|
|
} |
|
1520
|
|
|
|
|
1521
|
|
|
/** |
|
1522
|
|
|
* {@inheritdoc} |
|
1523
|
|
|
*/ |
|
1524
|
|
|
/*public function addExtraFields(ExtraFieldValues $extraFieldValue) |
|
1525
|
|
|
{ |
|
1526
|
|
|
$extraFieldValue->setUser($this); |
|
1527
|
|
|
$this->extraFields[] = $extraFieldValue; |
|
1528
|
|
|
|
|
1529
|
|
|
return $this; |
|
1530
|
|
|
}*/ |
|
1531
|
|
|
|
|
1532
|
|
|
/** |
|
1533
|
|
|
* {@inheritdoc} |
|
1534
|
|
|
*/ |
|
1535
|
|
|
public function addExtraFields(ExtraFieldValues $extraFieldValue) |
|
1536
|
|
|
{ |
|
1537
|
|
|
//if (!$this->hasExtraField($attribute)) { |
|
1538
|
|
|
$extraFieldValue->setUser($this); |
|
1539
|
|
|
$this->extraFields[] = $extraFieldValue; |
|
1540
|
|
|
//} |
|
1541
|
|
|
|
|
1542
|
|
|
return $this; |
|
1543
|
|
|
} |
|
1544
|
|
|
|
|
1545
|
|
|
/** |
|
1546
|
|
|
* {@inheritdoc} |
|
1547
|
|
|
*/ |
|
1548
|
|
|
public function removeExtraField(ExtraFieldValues $attribute) |
|
1549
|
|
|
{ |
|
1550
|
|
|
//if ($this->hasExtraField($attribute)) { |
|
1551
|
|
|
//$this->extraFields->removeElement($attribute); |
|
1552
|
|
|
//$attribute->setUser($this); |
|
1553
|
|
|
//} |
|
1554
|
|
|
|
|
1555
|
|
|
return $this; |
|
1556
|
|
|
} |
|
1557
|
|
|
|
|
1558
|
|
|
/** |
|
1559
|
|
|
* {@inheritdoc} |
|
1560
|
|
|
*/ |
|
1561
|
|
|
/*public function hasExtraField($attribute) |
|
1562
|
|
|
{ |
|
1563
|
|
|
if (!$this->extraFields) { |
|
1564
|
|
|
return false; |
|
1565
|
|
|
} |
|
1566
|
|
|
return $this->extraFields->contains($attribute); |
|
1567
|
|
|
}*/ |
|
1568
|
|
|
|
|
1569
|
|
|
/** |
|
1570
|
|
|
* {@inheritdoc} |
|
1571
|
|
|
*/ |
|
1572
|
|
|
public function hasExtraFieldByName($attributeName) |
|
1573
|
|
|
{ |
|
1574
|
|
|
foreach ($this->extraFields as $attribute) { |
|
1575
|
|
|
if ($attribute->getName() === $attributeName) { |
|
1576
|
|
|
return true; |
|
1577
|
|
|
} |
|
1578
|
|
|
} |
|
1579
|
|
|
|
|
1580
|
|
|
return false; |
|
1581
|
|
|
} |
|
1582
|
|
|
|
|
1583
|
|
|
/** |
|
1584
|
|
|
* {@inheritdoc} |
|
1585
|
|
|
*/ |
|
1586
|
|
|
public function getExtraFieldByName($attributeName) |
|
1587
|
|
|
{ |
|
1588
|
|
|
foreach ($this->extraFields as $attribute) { |
|
1589
|
|
|
if ($attribute->getName() === $attributeName) { |
|
1590
|
|
|
return $attribute; |
|
1591
|
|
|
} |
|
1592
|
|
|
} |
|
1593
|
|
|
|
|
1594
|
|
|
return null; |
|
1595
|
|
|
} |
|
1596
|
|
|
|
|
1597
|
|
|
/** |
|
1598
|
|
|
* Get sessionCourseSubscription. |
|
1599
|
|
|
* |
|
1600
|
|
|
* @return ArrayCollection|SessionRelCourseRelUser[] |
|
1601
|
|
|
*/ |
|
1602
|
|
|
public function getSessionCourseSubscriptions() |
|
1603
|
|
|
{ |
|
1604
|
|
|
return $this->sessionCourseSubscriptions; |
|
1605
|
|
|
} |
|
1606
|
|
|
|
|
1607
|
|
|
public function setSessionCourseSubscriptions($value) |
|
1608
|
|
|
{ |
|
1609
|
|
|
$this->sessionCourseSubscriptions = $value; |
|
1610
|
|
|
|
|
1611
|
|
|
return $this; |
|
1612
|
|
|
} |
|
1613
|
|
|
|
|
1614
|
|
|
/** |
|
1615
|
|
|
* @return string |
|
1616
|
|
|
*/ |
|
1617
|
|
|
public function getConfirmationToken() |
|
1618
|
|
|
{ |
|
1619
|
|
|
return $this->confirmationToken; |
|
1620
|
|
|
} |
|
1621
|
|
|
|
|
1622
|
|
|
/** |
|
1623
|
|
|
* @param string $confirmationToken |
|
1624
|
|
|
* |
|
1625
|
|
|
* @return User |
|
1626
|
|
|
*/ |
|
1627
|
|
|
public function setConfirmationToken($confirmationToken) |
|
1628
|
|
|
{ |
|
1629
|
|
|
$this->confirmationToken = $confirmationToken; |
|
1630
|
|
|
|
|
1631
|
|
|
return $this; |
|
1632
|
|
|
} |
|
1633
|
|
|
|
|
1634
|
|
|
/** |
|
1635
|
|
|
* @return \DateTime |
|
1636
|
|
|
*/ |
|
1637
|
|
|
public function getPasswordRequestedAt() |
|
1638
|
|
|
{ |
|
1639
|
|
|
return $this->passwordRequestedAt; |
|
1640
|
|
|
} |
|
1641
|
|
|
|
|
1642
|
|
|
/** |
|
1643
|
|
|
* @param int $ttl |
|
1644
|
|
|
* |
|
1645
|
|
|
* @return bool |
|
1646
|
|
|
*/ |
|
1647
|
|
|
public function isPasswordRequestNonExpired($ttl) |
|
1648
|
|
|
{ |
|
1649
|
|
|
return $this->getPasswordRequestedAt() instanceof \DateTime && |
|
1650
|
|
|
$this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); |
|
1651
|
|
|
} |
|
1652
|
|
|
|
|
1653
|
|
|
public function getUsername() |
|
1654
|
|
|
{ |
|
1655
|
|
|
return $this->username; |
|
1656
|
|
|
} |
|
1657
|
|
|
|
|
1658
|
|
|
/** |
|
1659
|
|
|
* Returns the creation date. |
|
1660
|
|
|
* |
|
1661
|
|
|
* @return \DateTime|null |
|
1662
|
|
|
*/ |
|
1663
|
|
|
public function getCreatedAt() |
|
1664
|
|
|
{ |
|
1665
|
|
|
return $this->createdAt; |
|
1666
|
|
|
} |
|
1667
|
|
|
|
|
1668
|
|
|
/** |
|
1669
|
|
|
* Sets the last update date. |
|
1670
|
|
|
* |
|
1671
|
|
|
* @return User |
|
1672
|
|
|
*/ |
|
1673
|
|
|
public function setUpdatedAt(\DateTime $updatedAt = null) |
|
1674
|
|
|
{ |
|
1675
|
|
|
$this->updatedAt = $updatedAt; |
|
1676
|
|
|
|
|
1677
|
|
|
return $this; |
|
1678
|
|
|
} |
|
1679
|
|
|
|
|
1680
|
|
|
/** |
|
1681
|
|
|
* Returns the last update date. |
|
1682
|
|
|
* |
|
1683
|
|
|
* @return \DateTime|null |
|
1684
|
|
|
*/ |
|
1685
|
|
|
public function getUpdatedAt() |
|
1686
|
|
|
{ |
|
1687
|
|
|
return $this->updatedAt; |
|
1688
|
|
|
} |
|
1689
|
|
|
|
|
1690
|
|
|
/** |
|
1691
|
|
|
* Returns the expiration date. |
|
1692
|
|
|
* |
|
1693
|
|
|
* @return \DateTime|null |
|
1694
|
|
|
*/ |
|
1695
|
|
|
public function getExpiresAt() |
|
1696
|
|
|
{ |
|
1697
|
|
|
return $this->expiresAt; |
|
1698
|
|
|
} |
|
1699
|
|
|
|
|
1700
|
|
|
/** |
|
1701
|
|
|
* Returns the credentials expiration date. |
|
1702
|
|
|
* |
|
1703
|
|
|
* @return \DateTime |
|
1704
|
|
|
*/ |
|
1705
|
|
|
public function getCredentialsExpireAt() |
|
1706
|
|
|
{ |
|
1707
|
|
|
return $this->credentialsExpireAt; |
|
1708
|
|
|
} |
|
1709
|
|
|
|
|
1710
|
|
|
/** |
|
1711
|
|
|
* Sets the credentials expiration date. |
|
1712
|
|
|
* |
|
1713
|
|
|
* @return User |
|
1714
|
|
|
*/ |
|
1715
|
|
|
public function setCredentialsExpireAt(\DateTime $date = null) |
|
1716
|
|
|
{ |
|
1717
|
|
|
$this->credentialsExpireAt = $date; |
|
1718
|
|
|
|
|
1719
|
|
|
return $this; |
|
1720
|
|
|
} |
|
1721
|
|
|
|
|
1722
|
|
|
/** |
|
1723
|
|
|
* Sets the user groups. |
|
1724
|
|
|
* |
|
1725
|
|
|
* @param array $groups |
|
1726
|
|
|
* |
|
1727
|
|
|
* @return User |
|
1728
|
|
|
*/ |
|
1729
|
|
|
public function setGroups($groups) |
|
1730
|
|
|
{ |
|
1731
|
|
|
foreach ($groups as $group) { |
|
1732
|
|
|
$this->addGroup($group); |
|
1733
|
|
|
} |
|
1734
|
|
|
|
|
1735
|
|
|
return $this; |
|
1736
|
|
|
} |
|
1737
|
|
|
|
|
1738
|
|
|
/** |
|
1739
|
|
|
* Sets the two-step verification code. |
|
1740
|
|
|
* |
|
1741
|
|
|
* @param string $twoStepVerificationCode |
|
1742
|
|
|
* |
|
1743
|
|
|
* @return User |
|
1744
|
|
|
*/ |
|
1745
|
|
|
public function setTwoStepVerificationCode($twoStepVerificationCode) |
|
1746
|
|
|
{ |
|
1747
|
|
|
$this->twoStepVerificationCode = $twoStepVerificationCode; |
|
1748
|
|
|
|
|
1749
|
|
|
return $this; |
|
1750
|
|
|
} |
|
1751
|
|
|
|
|
1752
|
|
|
/** |
|
1753
|
|
|
* Returns the two-step verification code. |
|
1754
|
|
|
* |
|
1755
|
|
|
* @return string |
|
1756
|
|
|
*/ |
|
1757
|
|
|
public function getTwoStepVerificationCode() |
|
1758
|
|
|
{ |
|
1759
|
|
|
return $this->twoStepVerificationCode; |
|
1760
|
|
|
} |
|
1761
|
|
|
|
|
1762
|
|
|
/** |
|
1763
|
|
|
* @param string $biography |
|
1764
|
|
|
* |
|
1765
|
|
|
* @return User |
|
1766
|
|
|
*/ |
|
1767
|
|
|
public function setBiography($biography) |
|
1768
|
|
|
{ |
|
1769
|
|
|
$this->biography = $biography; |
|
1770
|
|
|
|
|
1771
|
|
|
return $this; |
|
1772
|
|
|
} |
|
1773
|
|
|
|
|
1774
|
|
|
/** |
|
1775
|
|
|
* @return string |
|
1776
|
|
|
*/ |
|
1777
|
|
|
public function getBiography() |
|
1778
|
|
|
{ |
|
1779
|
|
|
return $this->biography; |
|
1780
|
|
|
} |
|
1781
|
|
|
|
|
1782
|
|
|
/** |
|
1783
|
|
|
* @param \DateTime $dateOfBirth |
|
1784
|
|
|
* |
|
1785
|
|
|
* @return User |
|
1786
|
|
|
*/ |
|
1787
|
|
|
public function setDateOfBirth($dateOfBirth) |
|
1788
|
|
|
{ |
|
1789
|
|
|
$this->dateOfBirth = $dateOfBirth; |
|
1790
|
|
|
|
|
1791
|
|
|
return $this; |
|
1792
|
|
|
} |
|
1793
|
|
|
|
|
1794
|
|
|
/** |
|
1795
|
|
|
* @return \DateTime |
|
1796
|
|
|
*/ |
|
1797
|
|
|
public function getDateOfBirth() |
|
1798
|
|
|
{ |
|
1799
|
|
|
return $this->dateOfBirth; |
|
1800
|
|
|
} |
|
1801
|
|
|
|
|
1802
|
|
|
/** |
|
1803
|
|
|
* @param string $facebookData |
|
1804
|
|
|
* |
|
1805
|
|
|
* @return User |
|
1806
|
|
|
*/ |
|
1807
|
|
|
public function setFacebookData($facebookData) |
|
1808
|
|
|
{ |
|
1809
|
|
|
$this->facebookData = $facebookData; |
|
1810
|
|
|
|
|
1811
|
|
|
return $this; |
|
1812
|
|
|
} |
|
1813
|
|
|
|
|
1814
|
|
|
/** |
|
1815
|
|
|
* @return string |
|
1816
|
|
|
*/ |
|
1817
|
|
|
public function getFacebookData() |
|
1818
|
|
|
{ |
|
1819
|
|
|
return $this->facebookData; |
|
1820
|
|
|
} |
|
1821
|
|
|
|
|
1822
|
|
|
/** |
|
1823
|
|
|
* @param string $facebookName |
|
1824
|
|
|
* |
|
1825
|
|
|
* @return User |
|
1826
|
|
|
*/ |
|
1827
|
|
|
public function setFacebookName($facebookName) |
|
1828
|
|
|
{ |
|
1829
|
|
|
$this->facebookName = $facebookName; |
|
1830
|
|
|
|
|
1831
|
|
|
return $this; |
|
1832
|
|
|
} |
|
1833
|
|
|
|
|
1834
|
|
|
/** |
|
1835
|
|
|
* @return string |
|
1836
|
|
|
*/ |
|
1837
|
|
|
public function getFacebookName() |
|
1838
|
|
|
{ |
|
1839
|
|
|
return $this->facebookName; |
|
1840
|
|
|
} |
|
1841
|
|
|
|
|
1842
|
|
|
/** |
|
1843
|
|
|
* @param string $facebookUid |
|
1844
|
|
|
* |
|
1845
|
|
|
* @return User |
|
1846
|
|
|
*/ |
|
1847
|
|
|
public function setFacebookUid($facebookUid) |
|
1848
|
|
|
{ |
|
1849
|
|
|
$this->facebookUid = $facebookUid; |
|
1850
|
|
|
|
|
1851
|
|
|
return $this; |
|
1852
|
|
|
} |
|
1853
|
|
|
|
|
1854
|
|
|
/** |
|
1855
|
|
|
* @return string |
|
1856
|
|
|
*/ |
|
1857
|
|
|
public function getFacebookUid() |
|
1858
|
|
|
{ |
|
1859
|
|
|
return $this->facebookUid; |
|
1860
|
|
|
} |
|
1861
|
|
|
|
|
1862
|
|
|
/** |
|
1863
|
|
|
* @return string |
|
1864
|
|
|
*/ |
|
1865
|
|
|
public function getFirstname() |
|
1866
|
|
|
{ |
|
1867
|
|
|
return $this->firstname; |
|
1868
|
|
|
} |
|
1869
|
|
|
|
|
1870
|
|
|
/** |
|
1871
|
|
|
* @param string $gender |
|
1872
|
|
|
* |
|
1873
|
|
|
* @return User |
|
1874
|
|
|
*/ |
|
1875
|
|
|
public function setGender($gender) |
|
1876
|
|
|
{ |
|
1877
|
|
|
$this->gender = $gender; |
|
1878
|
|
|
|
|
1879
|
|
|
return $this; |
|
1880
|
|
|
} |
|
1881
|
|
|
|
|
1882
|
|
|
/** |
|
1883
|
|
|
* @return string |
|
1884
|
|
|
*/ |
|
1885
|
|
|
public function getGender() |
|
1886
|
|
|
{ |
|
1887
|
|
|
return $this->gender; |
|
1888
|
|
|
} |
|
1889
|
|
|
|
|
1890
|
|
|
/** |
|
1891
|
|
|
* @param string $gplusData |
|
1892
|
|
|
* |
|
1893
|
|
|
* @return User |
|
1894
|
|
|
*/ |
|
1895
|
|
|
public function setGplusData($gplusData) |
|
1896
|
|
|
{ |
|
1897
|
|
|
$this->gplusData = $gplusData; |
|
1898
|
|
|
|
|
1899
|
|
|
return $this; |
|
1900
|
|
|
} |
|
1901
|
|
|
|
|
1902
|
|
|
/** |
|
1903
|
|
|
* @return string |
|
1904
|
|
|
*/ |
|
1905
|
|
|
public function getGplusData() |
|
1906
|
|
|
{ |
|
1907
|
|
|
return $this->gplusData; |
|
1908
|
|
|
} |
|
1909
|
|
|
|
|
1910
|
|
|
/** |
|
1911
|
|
|
* @param string $gplusName |
|
1912
|
|
|
* |
|
1913
|
|
|
* @return User |
|
1914
|
|
|
*/ |
|
1915
|
|
|
public function setGplusName($gplusName) |
|
1916
|
|
|
{ |
|
1917
|
|
|
$this->gplusName = $gplusName; |
|
1918
|
|
|
|
|
1919
|
|
|
return $this; |
|
1920
|
|
|
} |
|
1921
|
|
|
|
|
1922
|
|
|
/** |
|
1923
|
|
|
* @return string |
|
1924
|
|
|
*/ |
|
1925
|
|
|
public function getGplusName() |
|
1926
|
|
|
{ |
|
1927
|
|
|
return $this->gplusName; |
|
1928
|
|
|
} |
|
1929
|
|
|
|
|
1930
|
|
|
/** |
|
1931
|
|
|
* @param string $gplusUid |
|
1932
|
|
|
* |
|
1933
|
|
|
* @return User |
|
1934
|
|
|
*/ |
|
1935
|
|
|
public function setGplusUid($gplusUid) |
|
1936
|
|
|
{ |
|
1937
|
|
|
$this->gplusUid = $gplusUid; |
|
1938
|
|
|
|
|
1939
|
|
|
return $this; |
|
1940
|
|
|
} |
|
1941
|
|
|
|
|
1942
|
|
|
/** |
|
1943
|
|
|
* @return string |
|
1944
|
|
|
*/ |
|
1945
|
|
|
public function getGplusUid() |
|
1946
|
|
|
{ |
|
1947
|
|
|
return $this->gplusUid; |
|
1948
|
|
|
} |
|
1949
|
|
|
|
|
1950
|
|
|
/** |
|
1951
|
|
|
* @return string |
|
1952
|
|
|
*/ |
|
1953
|
|
|
public function getLastname() |
|
1954
|
|
|
{ |
|
1955
|
|
|
return $this->lastname; |
|
1956
|
|
|
} |
|
1957
|
|
|
|
|
1958
|
|
|
/** |
|
1959
|
|
|
* @param string $locale |
|
1960
|
|
|
* |
|
1961
|
|
|
* @return User |
|
1962
|
|
|
*/ |
|
1963
|
|
|
public function setLocale($locale) |
|
1964
|
|
|
{ |
|
1965
|
|
|
$this->locale = $locale; |
|
1966
|
|
|
|
|
1967
|
|
|
return $this; |
|
1968
|
|
|
} |
|
1969
|
|
|
|
|
1970
|
|
|
/** |
|
1971
|
|
|
* @return string |
|
1972
|
|
|
*/ |
|
1973
|
|
|
public function getLocale() |
|
1974
|
|
|
{ |
|
1975
|
|
|
return $this->locale; |
|
1976
|
|
|
} |
|
1977
|
|
|
|
|
1978
|
|
|
/** |
|
1979
|
|
|
* @param string $timezone |
|
1980
|
|
|
* |
|
1981
|
|
|
* @return User |
|
1982
|
|
|
*/ |
|
1983
|
|
|
public function setTimezone($timezone) |
|
1984
|
|
|
{ |
|
1985
|
|
|
$this->timezone = $timezone; |
|
1986
|
|
|
|
|
1987
|
|
|
return $this; |
|
1988
|
|
|
} |
|
1989
|
|
|
|
|
1990
|
|
|
/** |
|
1991
|
|
|
* @return string |
|
1992
|
|
|
*/ |
|
1993
|
|
|
public function getTimezone() |
|
1994
|
|
|
{ |
|
1995
|
|
|
return $this->timezone; |
|
1996
|
|
|
} |
|
1997
|
|
|
|
|
1998
|
|
|
/** |
|
1999
|
|
|
* @param string $twitterData |
|
2000
|
|
|
* |
|
2001
|
|
|
* @return User |
|
2002
|
|
|
*/ |
|
2003
|
|
|
public function setTwitterData($twitterData) |
|
2004
|
|
|
{ |
|
2005
|
|
|
$this->twitterData = $twitterData; |
|
2006
|
|
|
|
|
2007
|
|
|
return $this; |
|
2008
|
|
|
} |
|
2009
|
|
|
|
|
2010
|
|
|
/** |
|
2011
|
|
|
* @return string |
|
2012
|
|
|
*/ |
|
2013
|
|
|
public function getTwitterData() |
|
2014
|
|
|
{ |
|
2015
|
|
|
return $this->twitterData; |
|
2016
|
|
|
} |
|
2017
|
|
|
|
|
2018
|
|
|
/** |
|
2019
|
|
|
* @param string $twitterName |
|
2020
|
|
|
* |
|
2021
|
|
|
* @return User |
|
2022
|
|
|
*/ |
|
2023
|
|
|
public function setTwitterName($twitterName) |
|
2024
|
|
|
{ |
|
2025
|
|
|
$this->twitterName = $twitterName; |
|
2026
|
|
|
|
|
2027
|
|
|
return $this; |
|
2028
|
|
|
} |
|
2029
|
|
|
|
|
2030
|
|
|
/** |
|
2031
|
|
|
* @return string |
|
2032
|
|
|
*/ |
|
2033
|
|
|
public function getTwitterName() |
|
2034
|
|
|
{ |
|
2035
|
|
|
return $this->twitterName; |
|
2036
|
|
|
} |
|
2037
|
|
|
|
|
2038
|
|
|
/** |
|
2039
|
|
|
* @param string $twitterUid |
|
2040
|
|
|
* |
|
2041
|
|
|
* @return User |
|
2042
|
|
|
*/ |
|
2043
|
|
|
public function setTwitterUid($twitterUid) |
|
2044
|
|
|
{ |
|
2045
|
|
|
$this->twitterUid = $twitterUid; |
|
2046
|
|
|
|
|
2047
|
|
|
return $this; |
|
2048
|
|
|
} |
|
2049
|
|
|
|
|
2050
|
|
|
/** |
|
2051
|
|
|
* @return string |
|
2052
|
|
|
*/ |
|
2053
|
|
|
public function getTwitterUid() |
|
2054
|
|
|
{ |
|
2055
|
|
|
return $this->twitterUid; |
|
2056
|
|
|
} |
|
2057
|
|
|
|
|
2058
|
|
|
/** |
|
2059
|
|
|
* @param string $website |
|
2060
|
|
|
* |
|
2061
|
|
|
* @return User |
|
2062
|
|
|
*/ |
|
2063
|
|
|
public function setWebsite($website) |
|
2064
|
|
|
{ |
|
2065
|
|
|
$this->website = $website; |
|
2066
|
|
|
|
|
2067
|
|
|
return $this; |
|
2068
|
|
|
} |
|
2069
|
|
|
|
|
2070
|
|
|
/** |
|
2071
|
|
|
* @return string |
|
2072
|
|
|
*/ |
|
2073
|
|
|
public function getWebsite() |
|
2074
|
|
|
{ |
|
2075
|
|
|
return $this->website; |
|
2076
|
|
|
} |
|
2077
|
|
|
|
|
2078
|
|
|
/** |
|
2079
|
|
|
* @param string $token |
|
2080
|
|
|
* |
|
2081
|
|
|
* @return User |
|
2082
|
|
|
*/ |
|
2083
|
|
|
public function setToken($token) |
|
2084
|
|
|
{ |
|
2085
|
|
|
$this->token = $token; |
|
2086
|
|
|
|
|
2087
|
|
|
return $this; |
|
2088
|
|
|
} |
|
2089
|
|
|
|
|
2090
|
|
|
/** |
|
2091
|
|
|
* @return string |
|
2092
|
|
|
*/ |
|
2093
|
|
|
public function getToken() |
|
2094
|
|
|
{ |
|
2095
|
|
|
return $this->token; |
|
2096
|
|
|
} |
|
2097
|
|
|
|
|
2098
|
|
|
/** |
|
2099
|
|
|
* @return string |
|
2100
|
|
|
*/ |
|
2101
|
|
|
public function getFullname() |
|
2102
|
|
|
{ |
|
2103
|
|
|
return sprintf('%s %s', $this->getFirstname(), $this->getLastname()); |
|
2104
|
|
|
} |
|
2105
|
|
|
|
|
2106
|
|
|
/** |
|
2107
|
|
|
* @return array |
|
2108
|
|
|
*/ |
|
2109
|
|
|
public function getRealRoles() |
|
2110
|
|
|
{ |
|
2111
|
|
|
return $this->roles; |
|
2112
|
|
|
} |
|
2113
|
|
|
|
|
2114
|
|
|
/** |
|
2115
|
|
|
* @return User |
|
2116
|
|
|
*/ |
|
2117
|
|
|
public function setRealRoles(array $roles) |
|
2118
|
|
|
{ |
|
2119
|
|
|
$this->setRoles($roles); |
|
2120
|
|
|
|
|
2121
|
|
|
return $this; |
|
2122
|
|
|
} |
|
2123
|
|
|
|
|
2124
|
|
|
/** |
|
2125
|
|
|
* Removes sensitive data from the user. |
|
2126
|
|
|
*/ |
|
2127
|
|
|
public function eraseCredentials() |
|
2128
|
|
|
{ |
|
2129
|
|
|
$this->plainPassword = null; |
|
2130
|
|
|
} |
|
2131
|
|
|
|
|
2132
|
|
|
/** |
|
2133
|
|
|
* @return string |
|
2134
|
|
|
*/ |
|
2135
|
|
|
public function getUsernameCanonical() |
|
2136
|
|
|
{ |
|
2137
|
|
|
return $this->usernameCanonical; |
|
2138
|
|
|
} |
|
2139
|
|
|
|
|
2140
|
|
|
/** |
|
2141
|
|
|
* @return string |
|
2142
|
|
|
*/ |
|
2143
|
|
|
public function getEmailCanonical() |
|
2144
|
|
|
{ |
|
2145
|
|
|
return $this->emailCanonical; |
|
2146
|
|
|
} |
|
2147
|
|
|
|
|
2148
|
|
|
/** |
|
2149
|
|
|
* @return mixed |
|
2150
|
|
|
*/ |
|
2151
|
|
|
public function getPlainPassword() |
|
2152
|
|
|
{ |
|
2153
|
|
|
if (isset($this->plainPassword)) { |
|
2154
|
|
|
return $this->plainPassword; |
|
2155
|
|
|
} |
|
2156
|
|
|
} |
|
2157
|
|
|
|
|
2158
|
|
|
/** |
|
2159
|
|
|
* Returns the user roles. |
|
2160
|
|
|
* |
|
2161
|
|
|
* @return array The roles |
|
2162
|
|
|
*/ |
|
2163
|
|
|
public function getRoles() |
|
2164
|
|
|
{ |
|
2165
|
|
|
$roles = $this->roles; |
|
2166
|
|
|
|
|
2167
|
|
|
foreach ($this->getGroups() as $group) { |
|
2168
|
|
|
$roles = array_merge($roles, $group->getRoles()); |
|
2169
|
|
|
} |
|
2170
|
|
|
|
|
2171
|
|
|
// we need to make sure to have at least one role |
|
2172
|
|
|
$roles[] = static::ROLE_DEFAULT; |
|
2173
|
|
|
|
|
2174
|
|
|
return array_unique($roles); |
|
2175
|
|
|
} |
|
2176
|
|
|
|
|
2177
|
|
|
/** |
|
2178
|
|
|
* Never use this to check if this user has access to anything! |
|
2179
|
|
|
* |
|
2180
|
|
|
* Use the SecurityContext, or an implementation of AccessDecisionManager |
|
2181
|
|
|
* instead, e.g. |
|
2182
|
|
|
* |
|
2183
|
|
|
* $securityContext->isGranted('ROLE_USER'); |
|
2184
|
|
|
* |
|
2185
|
|
|
* @param string $role |
|
2186
|
|
|
* |
|
2187
|
|
|
* @return bool |
|
2188
|
|
|
*/ |
|
2189
|
|
|
public function hasRole($role) |
|
2190
|
|
|
{ |
|
2191
|
|
|
return in_array(strtoupper($role), $this->getRoles(), true); |
|
2192
|
|
|
} |
|
2193
|
|
|
|
|
2194
|
|
|
public function isAccountNonExpired() |
|
2195
|
|
|
{ |
|
2196
|
|
|
if (true === $this->expired) { |
|
2197
|
|
|
return false; |
|
2198
|
|
|
} |
|
2199
|
|
|
|
|
2200
|
|
|
if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) { |
|
2201
|
|
|
return false; |
|
2202
|
|
|
} |
|
2203
|
|
|
|
|
2204
|
|
|
return true; |
|
2205
|
|
|
} |
|
2206
|
|
|
|
|
2207
|
|
|
public function isAccountNonLocked() |
|
2208
|
|
|
{ |
|
2209
|
|
|
return !$this->locked; |
|
2210
|
|
|
} |
|
2211
|
|
|
|
|
2212
|
|
|
public function isCredentialsNonExpired() |
|
2213
|
|
|
{ |
|
2214
|
|
|
if (true === $this->credentialsExpired) { |
|
2215
|
|
|
return false; |
|
2216
|
|
|
} |
|
2217
|
|
|
|
|
2218
|
|
|
if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) { |
|
2219
|
|
|
return false; |
|
2220
|
|
|
} |
|
2221
|
|
|
|
|
2222
|
|
|
return true; |
|
2223
|
|
|
} |
|
2224
|
|
|
|
|
2225
|
|
|
public function isCredentialsExpired() |
|
2226
|
|
|
{ |
|
2227
|
|
|
return !$this->isCredentialsNonExpired(); |
|
2228
|
|
|
} |
|
2229
|
|
|
|
|
2230
|
|
|
public function isExpired() |
|
2231
|
|
|
{ |
|
2232
|
|
|
return !$this->isAccountNonExpired(); |
|
2233
|
|
|
} |
|
2234
|
|
|
|
|
2235
|
|
|
public function isLocked() |
|
2236
|
|
|
{ |
|
2237
|
|
|
return !$this->isAccountNonLocked(); |
|
2238
|
|
|
} |
|
2239
|
|
|
|
|
2240
|
|
|
public function isSuperAdmin() |
|
2241
|
|
|
{ |
|
2242
|
|
|
return $this->hasRole(static::ROLE_SUPER_ADMIN); |
|
2243
|
|
|
} |
|
2244
|
|
|
|
|
2245
|
|
|
public function isUser(UserInterface $user = null) |
|
2246
|
|
|
{ |
|
2247
|
|
|
return null !== $user && $this->getId() === $user->getId(); |
|
2248
|
|
|
} |
|
2249
|
|
|
|
|
2250
|
|
|
public function removeRole($role) |
|
2251
|
|
|
{ |
|
2252
|
|
|
if (false !== $key = array_search(strtoupper($role), $this->roles, true)) { |
|
2253
|
|
|
unset($this->roles[$key]); |
|
2254
|
|
|
$this->roles = array_values($this->roles); |
|
2255
|
|
|
} |
|
2256
|
|
|
|
|
2257
|
|
|
return $this; |
|
2258
|
|
|
} |
|
2259
|
|
|
|
|
2260
|
|
|
public function setUsername($username) |
|
2261
|
|
|
{ |
|
2262
|
|
|
$this->username = $username; |
|
2263
|
|
|
|
|
2264
|
|
|
return $this; |
|
2265
|
|
|
} |
|
2266
|
|
|
|
|
2267
|
|
|
public function setUsernameCanonical($usernameCanonical) |
|
2268
|
|
|
{ |
|
2269
|
|
|
$this->usernameCanonical = $usernameCanonical; |
|
2270
|
|
|
|
|
2271
|
|
|
return $this; |
|
2272
|
|
|
} |
|
2273
|
|
|
|
|
2274
|
|
|
/** |
|
2275
|
|
|
* @param bool $boolean |
|
2276
|
|
|
* |
|
2277
|
|
|
* @return User |
|
2278
|
|
|
*/ |
|
2279
|
|
|
public function setCredentialsExpired($boolean) |
|
2280
|
|
|
{ |
|
2281
|
|
|
$this->credentialsExpired = $boolean; |
|
2282
|
|
|
|
|
2283
|
|
|
return $this; |
|
2284
|
|
|
} |
|
2285
|
|
|
|
|
2286
|
|
|
public function setEmailCanonical($emailCanonical) |
|
2287
|
|
|
{ |
|
2288
|
|
|
$this->emailCanonical = $emailCanonical; |
|
2289
|
|
|
|
|
2290
|
|
|
return $this; |
|
2291
|
|
|
} |
|
2292
|
|
|
|
|
2293
|
|
|
public function setEnabled($boolean) |
|
2294
|
|
|
{ |
|
2295
|
|
|
$this->enabled = (bool) $boolean; |
|
2296
|
|
|
|
|
2297
|
|
|
return $this; |
|
2298
|
|
|
} |
|
2299
|
|
|
|
|
2300
|
|
|
/** |
|
2301
|
|
|
* Sets this user to expired. |
|
2302
|
|
|
* |
|
2303
|
|
|
* @param bool $boolean |
|
2304
|
|
|
* |
|
2305
|
|
|
* @return User |
|
2306
|
|
|
*/ |
|
2307
|
|
|
public function setExpired($boolean) |
|
2308
|
|
|
{ |
|
2309
|
|
|
$this->expired = (bool) $boolean; |
|
2310
|
|
|
|
|
2311
|
|
|
return $this; |
|
2312
|
|
|
} |
|
2313
|
|
|
|
|
2314
|
|
|
/** |
|
2315
|
|
|
* @return User |
|
2316
|
|
|
*/ |
|
2317
|
|
|
public function setExpiresAt(\DateTime $date) |
|
2318
|
|
|
{ |
|
2319
|
|
|
$this->expiresAt = $date; |
|
2320
|
|
|
|
|
2321
|
|
|
return $this; |
|
2322
|
|
|
} |
|
2323
|
|
|
|
|
2324
|
|
|
/** |
|
2325
|
|
|
* @param bool $boolean |
|
2326
|
|
|
* |
|
2327
|
|
|
* @return $this|UserInterface |
|
2328
|
|
|
*/ |
|
2329
|
|
|
public function setSuperAdmin($boolean) |
|
2330
|
|
|
{ |
|
2331
|
|
|
if (true === $boolean) { |
|
2332
|
|
|
$this->addRole(static::ROLE_SUPER_ADMIN); |
|
2333
|
|
|
} else { |
|
2334
|
|
|
$this->removeRole(static::ROLE_SUPER_ADMIN); |
|
2335
|
|
|
} |
|
2336
|
|
|
|
|
2337
|
|
|
return $this; |
|
2338
|
|
|
} |
|
2339
|
|
|
|
|
2340
|
|
|
public function setPlainPassword($password) |
|
2341
|
|
|
{ |
|
2342
|
|
|
$this->plainPassword = $password; |
|
2343
|
|
|
|
|
2344
|
|
|
return $this; |
|
2345
|
|
|
} |
|
2346
|
|
|
|
|
2347
|
|
|
public function getLocked() |
|
2348
|
|
|
{ |
|
2349
|
|
|
return $this->locked; |
|
2350
|
|
|
} |
|
2351
|
|
|
|
|
2352
|
|
|
public function setLocked($boolean) |
|
2353
|
|
|
{ |
|
2354
|
|
|
$this->locked = $boolean; |
|
2355
|
|
|
|
|
2356
|
|
|
return $this; |
|
2357
|
|
|
} |
|
2358
|
|
|
|
|
2359
|
|
|
public function setPasswordRequestedAt(\DateTime $date = null) |
|
2360
|
|
|
{ |
|
2361
|
|
|
$this->passwordRequestedAt = $date; |
|
2362
|
|
|
|
|
2363
|
|
|
return $this; |
|
2364
|
|
|
} |
|
2365
|
|
|
|
|
2366
|
|
|
public function setRoles(array $roles) |
|
2367
|
|
|
{ |
|
2368
|
|
|
$this->roles = []; |
|
2369
|
|
|
|
|
2370
|
|
|
foreach ($roles as $role) { |
|
2371
|
|
|
$this->addRole($role); |
|
2372
|
|
|
} |
|
2373
|
|
|
|
|
2374
|
|
|
return $this; |
|
2375
|
|
|
} |
|
2376
|
|
|
|
|
2377
|
|
|
/** |
|
2378
|
|
|
* Gets the groups granted to the user. |
|
2379
|
|
|
* |
|
2380
|
|
|
* @return Collection |
|
2381
|
|
|
*/ |
|
2382
|
|
|
public function getGroups() |
|
2383
|
|
|
{ |
|
2384
|
|
|
return $this->groups ?: $this->groups = new ArrayCollection(); |
|
2385
|
|
|
} |
|
2386
|
|
|
|
|
2387
|
|
|
/** |
|
2388
|
|
|
* @return array |
|
2389
|
|
|
*/ |
|
2390
|
|
|
public function getGroupNames() |
|
2391
|
|
|
{ |
|
2392
|
|
|
$names = []; |
|
2393
|
|
|
foreach ($this->getGroups() as $group) { |
|
2394
|
|
|
$names[] = $group->getName(); |
|
2395
|
|
|
} |
|
2396
|
|
|
|
|
2397
|
|
|
return $names; |
|
2398
|
|
|
} |
|
2399
|
|
|
|
|
2400
|
|
|
/** |
|
2401
|
|
|
* @param string $name |
|
2402
|
|
|
* |
|
2403
|
|
|
* @return bool |
|
2404
|
|
|
*/ |
|
2405
|
|
|
public function hasGroup($name) |
|
2406
|
|
|
{ |
|
2407
|
|
|
return in_array($name, $this->getGroupNames()); |
|
2408
|
|
|
} |
|
2409
|
|
|
|
|
2410
|
|
|
/** |
|
2411
|
|
|
* @return $this |
|
2412
|
|
|
*/ |
|
2413
|
|
|
public function addGroup(GroupInterface $group) |
|
2414
|
|
|
{ |
|
2415
|
|
|
if (!$this->getGroups()->contains($group)) { |
|
2416
|
|
|
$this->getGroups()->add($group); |
|
2417
|
|
|
} |
|
2418
|
|
|
|
|
2419
|
|
|
return $this; |
|
2420
|
|
|
} |
|
2421
|
|
|
|
|
2422
|
|
|
public function removeGroup(GroupInterface $group) |
|
2423
|
|
|
{ |
|
2424
|
|
|
if ($this->getGroups()->contains($group)) { |
|
2425
|
|
|
$this->getGroups()->removeElement($group); |
|
2426
|
|
|
} |
|
2427
|
|
|
|
|
2428
|
|
|
return $this; |
|
2429
|
|
|
} |
|
2430
|
|
|
|
|
2431
|
|
|
/** |
|
2432
|
|
|
* @param string $role |
|
2433
|
|
|
* |
|
2434
|
|
|
* @return $this|UserInterface |
|
2435
|
|
|
*/ |
|
2436
|
|
|
public function addRole($role) |
|
2437
|
|
|
{ |
|
2438
|
|
|
$role = strtoupper($role); |
|
2439
|
|
|
if ($role === static::ROLE_DEFAULT) { |
|
2440
|
|
|
return $this; |
|
2441
|
|
|
} |
|
2442
|
|
|
|
|
2443
|
|
|
if (!in_array($role, $this->roles, true)) { |
|
2444
|
|
|
$this->roles[] = $role; |
|
2445
|
|
|
} |
|
2446
|
|
|
|
|
2447
|
|
|
return $this; |
|
2448
|
|
|
} |
|
2449
|
|
|
|
|
2450
|
|
|
/** |
|
2451
|
|
|
* Serializes the user. |
|
2452
|
|
|
* |
|
2453
|
|
|
* The serialized data have to contain the fields used by the equals method and the username. |
|
2454
|
|
|
* |
|
2455
|
|
|
* @return string |
|
2456
|
|
|
*/ |
|
2457
|
|
|
public function serialize() |
|
2458
|
|
|
{ |
|
2459
|
|
|
return serialize([ |
|
2460
|
|
|
$this->password, |
|
2461
|
|
|
$this->salt, |
|
2462
|
|
|
$this->usernameCanonical, |
|
2463
|
|
|
$this->username, |
|
2464
|
|
|
$this->expired, |
|
2465
|
|
|
$this->locked, |
|
2466
|
|
|
$this->credentialsExpired, |
|
2467
|
|
|
$this->enabled, |
|
2468
|
|
|
$this->id, |
|
2469
|
|
|
]); |
|
2470
|
|
|
} |
|
2471
|
|
|
|
|
2472
|
|
|
/** |
|
2473
|
|
|
* Unserializes the user. |
|
2474
|
|
|
* |
|
2475
|
|
|
* @param string $serialized |
|
2476
|
|
|
*/ |
|
2477
|
|
|
public function unserialize($serialized) |
|
2478
|
|
|
{ |
|
2479
|
|
|
$data = unserialize($serialized); |
|
2480
|
|
|
// add a few extra elements in the array to ensure that we have enough keys when unserializing |
|
2481
|
|
|
// older data which does not include all properties. |
|
2482
|
|
|
$data = array_merge($data, array_fill(0, 2, null)); |
|
2483
|
|
|
|
|
2484
|
|
|
list( |
|
2485
|
|
|
$this->password, |
|
2486
|
|
|
$this->salt, |
|
2487
|
|
|
$this->usernameCanonical, |
|
2488
|
|
|
$this->username, |
|
2489
|
|
|
$this->expired, |
|
2490
|
|
|
$this->locked, |
|
2491
|
|
|
$this->credentialsExpired, |
|
2492
|
|
|
$this->enabled, |
|
2493
|
|
|
$this->id |
|
2494
|
|
|
) = $data; |
|
2495
|
|
|
} |
|
2496
|
|
|
|
|
2497
|
|
|
/** |
|
2498
|
|
|
* Get achievedSkills. |
|
2499
|
|
|
* |
|
2500
|
|
|
* @return ArrayCollection |
|
2501
|
|
|
*/ |
|
2502
|
|
|
public function getAchievedSkills() |
|
2503
|
|
|
{ |
|
2504
|
|
|
return $this->achievedSkills; |
|
2505
|
|
|
} |
|
2506
|
|
|
|
|
2507
|
|
|
/** |
|
2508
|
|
|
* @param $value |
|
2509
|
|
|
* |
|
2510
|
|
|
* @return $this |
|
2511
|
|
|
*/ |
|
2512
|
|
|
public function setAchievedSkills($value) |
|
2513
|
|
|
{ |
|
2514
|
|
|
$this->achievedSkills = $value; |
|
2515
|
|
|
|
|
2516
|
|
|
return $this; |
|
2517
|
|
|
} |
|
2518
|
|
|
|
|
2519
|
|
|
/** |
|
2520
|
|
|
* Check if the user has the skill. |
|
2521
|
|
|
* |
|
2522
|
|
|
* @param Skill $skill The skill |
|
2523
|
|
|
* |
|
2524
|
|
|
* @return bool |
|
2525
|
|
|
*/ |
|
2526
|
|
|
public function hasSkill(Skill $skill) |
|
2527
|
|
|
{ |
|
2528
|
|
|
$achievedSkills = $this->getAchievedSkills(); |
|
2529
|
|
|
|
|
2530
|
|
|
foreach ($achievedSkills as $userSkill) { |
|
2531
|
|
|
if ($userSkill->getSkill()->getId() !== $skill->getId()) { |
|
2532
|
|
|
continue; |
|
2533
|
|
|
} |
|
2534
|
|
|
|
|
2535
|
|
|
return true; |
|
2536
|
|
|
} |
|
2537
|
|
|
} |
|
2538
|
|
|
|
|
2539
|
|
|
/** |
|
2540
|
|
|
* @return bool |
|
2541
|
|
|
*/ |
|
2542
|
|
|
public function isProfileCompleted() |
|
2543
|
|
|
{ |
|
2544
|
|
|
return $this->profileCompleted; |
|
2545
|
|
|
} |
|
2546
|
|
|
|
|
2547
|
|
|
/** |
|
2548
|
|
|
* @param mixed $profileCompleted |
|
2549
|
|
|
* |
|
2550
|
|
|
* @return User |
|
2551
|
|
|
*/ |
|
2552
|
|
|
public function setProfileCompleted($profileCompleted) |
|
2553
|
|
|
{ |
|
2554
|
|
|
$this->profileCompleted = $profileCompleted; |
|
2555
|
|
|
|
|
2556
|
|
|
return $this; |
|
2557
|
|
|
} |
|
2558
|
|
|
|
|
2559
|
|
|
/** |
|
2560
|
|
|
* Get sessionAsGeneralCoach. |
|
2561
|
|
|
* |
|
2562
|
|
|
* @return ArrayCollection |
|
2563
|
|
|
*/ |
|
2564
|
|
|
public function getSessionAsGeneralCoach() |
|
2565
|
|
|
{ |
|
2566
|
|
|
return $this->sessionAsGeneralCoach; |
|
2567
|
|
|
} |
|
2568
|
|
|
|
|
2569
|
|
|
/** |
|
2570
|
|
|
* Get sessionAsGeneralCoach. |
|
2571
|
|
|
* |
|
2572
|
|
|
* @param ArrayCollection $value |
|
2573
|
|
|
* |
|
2574
|
|
|
* @return $this |
|
2575
|
|
|
*/ |
|
2576
|
|
|
public function setSessionAsGeneralCoach($value) |
|
2577
|
|
|
{ |
|
2578
|
|
|
$this->sessionAsGeneralCoach = $value; |
|
2579
|
|
|
|
|
2580
|
|
|
return $this; |
|
2581
|
|
|
} |
|
2582
|
|
|
|
|
2583
|
|
|
/** |
|
2584
|
|
|
* @return mixed |
|
2585
|
|
|
*/ |
|
2586
|
|
|
public function getCommentedUserSkills() |
|
2587
|
|
|
{ |
|
2588
|
|
|
return $this->commentedUserSkills; |
|
2589
|
|
|
} |
|
2590
|
|
|
|
|
2591
|
|
|
/** |
|
2592
|
|
|
* @param mixed $commentedUserSkills |
|
2593
|
|
|
* |
|
2594
|
|
|
* @return User |
|
2595
|
|
|
*/ |
|
2596
|
|
|
public function setCommentedUserSkills($commentedUserSkills) |
|
2597
|
|
|
{ |
|
2598
|
|
|
$this->commentedUserSkills = $commentedUserSkills; |
|
2599
|
|
|
|
|
2600
|
|
|
return $this; |
|
2601
|
|
|
} |
|
2602
|
|
|
|
|
2603
|
|
|
/** |
|
2604
|
|
|
* @return string |
|
2605
|
|
|
*/ |
|
2606
|
|
|
public function getPictureLegacy() |
|
2607
|
|
|
{ |
|
2608
|
|
|
$id = $this->id; |
|
2609
|
|
|
|
|
2610
|
|
|
return 'users/'.substr((string) $id, 0, 1).'/'.$id.'/'.'small_'.$this->getPictureUri(); |
|
2611
|
|
|
} |
|
2612
|
|
|
|
|
2613
|
|
|
/** |
|
2614
|
|
|
* Retreives this user's related sessions. |
|
2615
|
|
|
* |
|
2616
|
|
|
* @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key |
|
2617
|
|
|
* |
|
2618
|
|
|
* @return \Chamilo\CoreBundle\Entity\Session[] |
|
2619
|
|
|
*/ |
|
2620
|
|
|
public function getSessions($relationType) |
|
2621
|
|
|
{ |
|
2622
|
|
|
$sessions = []; |
|
2623
|
|
|
foreach (\Database::getManager()->getRepository('ChamiloCoreBundle:SessionRelUser')->findBy([ |
|
2624
|
|
|
'user' => $this, |
|
2625
|
|
|
]) as $sessionRelUser) { |
|
2626
|
|
|
if ($sessionRelUser->getRelationType() == $relationType) { |
|
2627
|
|
|
$sessions[] = $sessionRelUser->getSession(); |
|
2628
|
|
|
} |
|
2629
|
|
|
} |
|
2630
|
|
|
|
|
2631
|
|
|
return $sessions; |
|
2632
|
|
|
} |
|
2633
|
|
|
|
|
2634
|
|
|
/** |
|
2635
|
|
|
* Retreives this user's related student sessions. |
|
2636
|
|
|
* |
|
2637
|
|
|
* @return \Chamilo\CoreBundle\Entity\Session[] |
|
2638
|
|
|
*/ |
|
2639
|
|
|
public function getStudentSessions() |
|
2640
|
|
|
{ |
|
2641
|
|
|
return $this->getSessions(0); |
|
2642
|
|
|
} |
|
2643
|
|
|
|
|
2644
|
|
|
/** |
|
2645
|
|
|
* Retreives this user's related DRH sessions. |
|
2646
|
|
|
* |
|
2647
|
|
|
* @return \Chamilo\CoreBundle\Entity\Session[] |
|
2648
|
|
|
*/ |
|
2649
|
|
|
public function getDRHSessions() |
|
2650
|
|
|
{ |
|
2651
|
|
|
return $this->getSessions(1); |
|
2652
|
|
|
} |
|
2653
|
|
|
|
|
2654
|
|
|
/** |
|
2655
|
|
|
* Retreives this user's related accessible sessions of a type, student by default. |
|
2656
|
|
|
* |
|
2657
|
|
|
* @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key |
|
2658
|
|
|
* |
|
2659
|
|
|
* @return \Chamilo\CoreBundle\Entity\Session[] |
|
2660
|
|
|
*/ |
|
2661
|
|
|
public function getCurrentlyAccessibleSessions($relationType = 0) |
|
2662
|
|
|
{ |
|
2663
|
|
|
$sessions = []; |
|
2664
|
|
|
foreach ($this->getSessions($relationType) as $session) { |
|
2665
|
|
|
if ($session->isCurrentlyAccessible()) { |
|
2666
|
|
|
$sessions[] = $session; |
|
2667
|
|
|
} |
|
2668
|
|
|
} |
|
2669
|
|
|
|
|
2670
|
|
|
return $sessions; |
|
2671
|
|
|
} |
|
2672
|
|
|
} |
|
2673
|
|
|
|