1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Entity; |
8
|
|
|
|
9
|
|
|
use ApiPlatform\Core\Annotation\ApiFilter; |
10
|
|
|
use ApiPlatform\Core\Annotation\ApiProperty; |
11
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
12
|
|
|
use ApiPlatform\Core\Annotation\ApiSubresource; |
13
|
|
|
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter; |
14
|
|
|
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; |
15
|
|
|
use Chamilo\CoreBundle\Traits\UserCreatorTrait; |
16
|
|
|
use Chamilo\CourseBundle\Entity\CGroupRelTutor; |
17
|
|
|
use Chamilo\CourseBundle\Entity\CGroupRelUser; |
18
|
|
|
use Chamilo\CourseBundle\Entity\CSurveyInvitation; |
19
|
|
|
use DateTime; |
20
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
21
|
|
|
use Doctrine\Common\Collections\Collection; |
22
|
|
|
use Doctrine\Common\Collections\Criteria; |
23
|
|
|
use Doctrine\ORM\Mapping as ORM; |
24
|
|
|
use Gedmo\Timestampable\Traits\TimestampableEntity; |
25
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
26
|
|
|
use Symfony\Component\Security\Core\User\EquatableInterface; |
27
|
|
|
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface; |
28
|
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; |
29
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
30
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
31
|
|
|
use Symfony\Component\Uid\NilUuid; |
32
|
|
|
use Symfony\Component\Uid\Uuid; |
33
|
|
|
use Symfony\Component\Uid\UuidV4; |
34
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
35
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata; |
36
|
|
|
use UserManager; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* EquatableInterface is needed to check if the user needs to be refreshed. |
40
|
|
|
* |
41
|
|
|
* @ORM\Table( |
42
|
|
|
* name="user", |
43
|
|
|
* indexes={ |
44
|
|
|
* @ORM\Index(name="status", columns={"status"}) |
45
|
|
|
* } |
46
|
|
|
* ) |
47
|
|
|
* @UniqueEntity("username") |
48
|
|
|
* @ORM\Entity |
49
|
|
|
* @ORM\EntityListeners({"Chamilo\CoreBundle\Entity\Listener\UserListener"}) |
50
|
|
|
*/ |
51
|
|
|
#[ApiResource( |
52
|
|
|
collectionOperations: [ |
53
|
|
|
'get' => [ |
54
|
|
|
'security' => "is_granted('ROLE_USER')", // @todo increase security |
55
|
|
|
], |
56
|
|
|
'post' => [ |
57
|
|
|
'security' => "is_granted('ROLE_ADMIN')", |
58
|
|
|
], |
59
|
|
|
], |
60
|
|
|
iri: 'http://schema.org/Person', |
61
|
|
|
itemOperations: [ |
62
|
|
|
'get' => [ |
63
|
|
|
'security' => "is_granted('ROLE_ADMIN')", |
64
|
|
|
], |
65
|
|
|
'put' => [ |
66
|
|
|
'security' => "is_granted('ROLE_ADMIN')", |
67
|
|
|
], |
68
|
|
|
'delete' => [ |
69
|
|
|
'security' => "is_granted('ROLE_ADMIN')", |
70
|
|
|
], |
71
|
|
|
], |
72
|
|
|
attributes: [ |
73
|
|
|
'security' => 'is_granted("ROLE_USER")', |
74
|
|
|
], |
75
|
|
|
denormalizationContext: [ |
76
|
|
|
'groups' => ['user:write'], |
77
|
|
|
], |
78
|
|
|
normalizationContext: [ |
79
|
|
|
'groups' => ['user:read'], |
80
|
|
|
], |
81
|
|
|
)] |
82
|
|
|
#[ApiFilter(SearchFilter::class, properties: [ |
83
|
|
|
'username' => 'partial', |
84
|
|
|
'firstname' => 'partial', |
85
|
|
|
'lastname' => 'partial', |
86
|
|
|
])] |
87
|
|
|
#[ApiFilter(BooleanFilter::class, properties: ['isActive'])] |
88
|
|
|
class User implements UserInterface, EquatableInterface, ResourceInterface, ResourceIllustrationInterface, PasswordAuthenticatedUserInterface, LegacyPasswordAuthenticatedUserInterface |
89
|
|
|
{ |
90
|
|
|
use TimestampableEntity; |
91
|
|
|
use UserCreatorTrait; |
92
|
|
|
|
93
|
|
|
public const USERNAME_MAX_LENGTH = 100; |
94
|
|
|
public const ROLE_DEFAULT = 'ROLE_USER'; |
95
|
|
|
|
96
|
|
|
public const ANONYMOUS = 6; |
97
|
|
|
|
98
|
|
|
/*public const COURSE_MANAGER = 1; |
99
|
|
|
public const TEACHER = 1; |
100
|
|
|
public const SESSION_ADMIN = 3; |
101
|
|
|
public const DRH = 4; |
102
|
|
|
public const STUDENT = 5; |
103
|
|
|
public const ANONYMOUS = 6;*/ |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @ORM\OneToOne( |
107
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", cascade={"remove"}, orphanRemoval=true |
108
|
|
|
* ) |
109
|
|
|
* @ORM\JoinColumn(name="resource_node_id", onDelete="CASCADE") |
110
|
|
|
*/ |
111
|
|
|
#[Groups(['user_json:read'])] |
112
|
|
|
public ?ResourceNode $resourceNode = null; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Resource illustration URL - Property set by ResourceNormalizer.php. |
116
|
|
|
* |
117
|
|
|
* @ApiProperty(iri="http://schema.org/contentUrl") |
118
|
|
|
*/ |
119
|
|
|
#[Groups([ |
120
|
|
|
'user:read', |
121
|
|
|
'resource_node:read', |
122
|
|
|
'document:read', |
123
|
|
|
'media_object_read', |
124
|
|
|
'course:read', |
125
|
|
|
'course_rel_user:read', |
126
|
|
|
'user_json:read', |
127
|
|
|
'message:read', |
128
|
|
|
'user_rel_user:read', |
129
|
|
|
])] |
130
|
|
|
public ?string $illustrationUrl = null; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @Groups({"user:read", "resource_node:read", "user_json:read"}) |
134
|
|
|
* @ORM\Column(name="id", type="integer") |
135
|
|
|
* @ORM\Id |
136
|
|
|
* @ORM\GeneratedValue() |
137
|
|
|
*/ |
138
|
|
|
#[Groups([ |
139
|
|
|
'message:read', |
140
|
|
|
'user_rel_user:read', |
141
|
|
|
])] |
142
|
|
|
protected ?int $id = null; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @ORM\Column(name="username", type="string", length=100, unique=true) |
146
|
|
|
*/ |
147
|
|
|
#[Assert\NotBlank] |
148
|
|
|
#[Groups([ |
149
|
|
|
'user:read', |
150
|
|
|
'user:write', |
151
|
|
|
'course:read', |
152
|
|
|
'resource_node:read', |
153
|
|
|
'user_json:read', |
154
|
|
|
'message:read', |
155
|
|
|
'user_rel_user:read', |
156
|
|
|
])] |
157
|
|
|
protected string $username; |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @ORM\Column(name="api_token", type="string", unique=true, nullable=true) |
161
|
|
|
*/ |
162
|
|
|
protected ?string $apiToken = null; |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @ApiProperty(iri="http://schema.org/name") |
166
|
|
|
* @ORM\Column(name="firstname", type="string", length=64, nullable=true) |
167
|
|
|
*/ |
168
|
|
|
#[Assert\NotBlank] |
169
|
|
|
#[Groups([ |
170
|
|
|
'user:read', |
171
|
|
|
'user:write', |
172
|
|
|
'resource_node:read', |
173
|
|
|
'user_json:read', |
174
|
|
|
])] |
175
|
|
|
protected ?string $firstname = null; |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @ORM\Column(name="lastname", type="string", length=64, nullable=true) |
179
|
|
|
*/ |
180
|
|
|
#[Groups([ |
181
|
|
|
'user:read', |
182
|
|
|
'user:write', |
183
|
|
|
'resource_node:read', |
184
|
|
|
'user_json:read', |
185
|
|
|
])] |
186
|
|
|
protected ?string $lastname = null; |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @Groups({"user:read", "user:write"}) |
190
|
|
|
* @ORM\Column(name="website", type="string", length=255, nullable=true) |
191
|
|
|
*/ |
192
|
|
|
protected ?string $website; |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @Groups({"user:read", "user:write"}) |
196
|
|
|
* @ORM\Column(name="biography", type="text", nullable=true) |
197
|
|
|
*/ |
198
|
|
|
protected ?string $biography; |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @Groups({"user:read", "user:write", "user_json:read"}) |
202
|
|
|
* @ORM\Column(name="locale", type="string", length=8) |
203
|
|
|
*/ |
204
|
|
|
protected string $locale; |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @Groups({"user:write"}) |
208
|
|
|
*/ |
209
|
|
|
protected ?string $plainPassword = null; |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @ORM\Column(name="password", type="string", length=255) |
213
|
|
|
*/ |
214
|
|
|
protected string $password; |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @ORM\Column(name="username_canonical", type="string", length=180) |
218
|
|
|
*/ |
219
|
|
|
protected string $usernameCanonical; |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @Groups({"user:read", "user:write", "user_json:read"}) |
223
|
|
|
* @ORM\Column(name="timezone", type="string", length=64) |
224
|
|
|
*/ |
225
|
|
|
protected string $timezone; |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @ORM\Column(name="email_canonical", type="string", length=100) |
229
|
|
|
*/ |
230
|
|
|
protected string $emailCanonical; |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @Groups({"user:read", "user:write", "user_json:read"}) |
234
|
|
|
* |
235
|
|
|
* @ORM\Column(name="email", type="string", length=100) |
236
|
|
|
*/ |
237
|
|
|
#[Assert\NotBlank] |
238
|
|
|
#[Assert\Email] |
239
|
|
|
protected string $email; |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @ORM\Column(name="locked", type="boolean") |
243
|
|
|
*/ |
244
|
|
|
protected bool $locked; |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @Groups({"user:read", "user:write"}) |
248
|
|
|
* @ORM\Column(name="enabled", type="boolean") |
249
|
|
|
*/ |
250
|
|
|
#[Assert\NotBlank] |
251
|
|
|
protected bool $enabled; |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @Groups({"user:read", "user:write"}) |
255
|
|
|
* @ORM\Column(name="expired", type="boolean") |
256
|
|
|
*/ |
257
|
|
|
protected bool $expired; |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @ORM\Column(name="credentials_expired", type="boolean") |
261
|
|
|
*/ |
262
|
|
|
protected bool $credentialsExpired; |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @ORM\Column(name="credentials_expire_at", type="datetime", nullable=true) |
266
|
|
|
*/ |
267
|
|
|
protected ?DateTime $credentialsExpireAt; |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @ORM\Column(name="date_of_birth", type="datetime", nullable=true) |
271
|
|
|
*/ |
272
|
|
|
protected ?DateTime $dateOfBirth; |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @Groups({"user:read", "user:write"}) |
276
|
|
|
* @ORM\Column(name="expires_at", type="datetime", nullable=true) |
277
|
|
|
*/ |
278
|
|
|
protected ?DateTime $expiresAt; |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @Groups({"user:read", "user:write"}) |
282
|
|
|
* @ORM\Column(name="phone", type="string", length=64, nullable=true) |
283
|
|
|
*/ |
284
|
|
|
protected ?string $phone = null; |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @Groups({"user:read", "user:write"}) |
288
|
|
|
* @ORM\Column(name="address", type="string", length=250, nullable=true) |
289
|
|
|
*/ |
290
|
|
|
protected ?string $address = null; |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* @ORM\Column(type="string", length=255) |
294
|
|
|
*/ |
295
|
|
|
protected string $salt; |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @ORM\Column(name="gender", type="string", length=1, nullable=true) |
299
|
|
|
*/ |
300
|
|
|
protected ?string $gender = null; |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @Groups({"user:read"}) |
304
|
|
|
* @ORM\Column(name="last_login", type="datetime", nullable=true) |
305
|
|
|
*/ |
306
|
|
|
protected ?DateTime $lastLogin = null; |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* Random string sent to the user email address in order to verify it. |
310
|
|
|
* |
311
|
|
|
* @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true) |
312
|
|
|
*/ |
313
|
|
|
protected ?string $confirmationToken = null; |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @ORM\Column(name="password_requested_at", type="datetime", nullable=true) |
317
|
|
|
*/ |
318
|
|
|
protected ?DateTime $passwordRequestedAt; |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* @var Collection<int, CourseRelUser>|CourseRelUser[] |
322
|
|
|
* |
323
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user", orphanRemoval=true) |
324
|
|
|
*/ |
325
|
|
|
#[ApiSubresource] |
326
|
|
|
protected Collection $courses; |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @var Collection<int, UsergroupRelUser>|UsergroupRelUser[] |
330
|
|
|
* |
331
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user") |
332
|
|
|
*/ |
333
|
|
|
protected Collection $classes; |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user"). |
337
|
|
|
*/ |
338
|
|
|
protected Collection $dropBoxReceivedFiles; |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent"). |
342
|
|
|
*/ |
343
|
|
|
protected Collection $dropBoxSentFiles; |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* An array of roles. Example: ROLE_USER, ROLE_TEACHER, ROLE_ADMIN. |
347
|
|
|
* |
348
|
|
|
* @Groups({"user:read", "user:write", "user_json:read"}) |
349
|
|
|
* @ORM\Column(type="array") |
350
|
|
|
* |
351
|
|
|
* @var mixed[]|string[] |
352
|
|
|
*/ |
353
|
|
|
protected array $roles = []; |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @ORM\Column(name="profile_completed", type="boolean", nullable=true) |
357
|
|
|
*/ |
358
|
|
|
protected ?bool $profileCompleted = null; |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user") |
362
|
|
|
*/ |
363
|
|
|
//protected $jurySubscriptions; |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* @var Collection|Group[] |
367
|
|
|
* @ORM\ManyToMany(targetEntity="Chamilo\CoreBundle\Entity\Group", inversedBy="users") |
368
|
|
|
* @ORM\JoinTable( |
369
|
|
|
* name="fos_user_user_group", |
370
|
|
|
* joinColumns={ |
371
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="cascade") |
372
|
|
|
* }, |
373
|
|
|
* inverseJoinColumns={ |
374
|
|
|
* @ORM\JoinColumn(name="group_id", referencedColumnName="id") |
375
|
|
|
* } |
376
|
|
|
* ) |
377
|
|
|
*/ |
378
|
|
|
protected Collection $groups; |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user"). |
382
|
|
|
* |
383
|
|
|
* @var Collection|mixed[] |
384
|
|
|
*/ |
385
|
|
|
protected Collection $curriculumItems; |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @var AccessUrlRelUser[]|Collection<int, AccessUrlRelUser> |
389
|
|
|
* |
390
|
|
|
* @ORM\OneToMany( |
391
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelUser", |
392
|
|
|
* mappedBy="user", |
393
|
|
|
* cascade={"persist", "remove"}, |
394
|
|
|
* orphanRemoval=true |
395
|
|
|
* ) |
396
|
|
|
*/ |
397
|
|
|
protected Collection $portals; |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* @var Collection<int, Session>|Session[] |
401
|
|
|
* |
402
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach") |
403
|
|
|
*/ |
404
|
|
|
protected Collection $sessionsAsGeneralCoach; |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\ResourceNode", mappedBy="creator") |
408
|
|
|
* |
409
|
|
|
* @var Collection<int, ResourceNode>|ResourceNode[] |
410
|
|
|
*/ |
411
|
|
|
protected Collection $resourceNodes; |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* @var Collection<int, SessionRelCourseRelUser>|SessionRelCourseRelUser[] |
415
|
|
|
* |
416
|
|
|
* @ORM\OneToMany( |
417
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", |
418
|
|
|
* mappedBy="user", |
419
|
|
|
* cascade={"persist"}, |
420
|
|
|
* orphanRemoval=true |
421
|
|
|
* ) |
422
|
|
|
*/ |
423
|
|
|
protected Collection $sessionRelCourseRelUsers; |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* @var Collection<int, SessionRelUser>|SessionRelUser[] |
427
|
|
|
* |
428
|
|
|
* @ORM\OneToMany( |
429
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\SessionRelUser", |
430
|
|
|
* mappedBy="user", |
431
|
|
|
* cascade={"persist", "remove"}, |
432
|
|
|
* orphanRemoval=true |
433
|
|
|
* ) |
434
|
|
|
*/ |
435
|
|
|
#[ApiSubresource] |
436
|
|
|
protected Collection $sessionsRelUser; |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* @var Collection<int, SkillRelUser>|SkillRelUser[] |
440
|
|
|
* |
441
|
|
|
* @ORM\OneToMany( |
442
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", |
443
|
|
|
* mappedBy="user", |
444
|
|
|
* cascade={"persist", "remove"}, |
445
|
|
|
* orphanRemoval=true |
446
|
|
|
* ) |
447
|
|
|
*/ |
448
|
|
|
protected Collection $achievedSkills; |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* @ORM\OneToMany( |
452
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", |
453
|
|
|
* mappedBy="feedbackGiver", |
454
|
|
|
* cascade={"persist", "remove"}, |
455
|
|
|
* orphanRemoval=true |
456
|
|
|
* ) |
457
|
|
|
* |
458
|
|
|
* @var Collection<int, SkillRelUserComment>|SkillRelUserComment[] |
459
|
|
|
*/ |
460
|
|
|
protected Collection $commentedUserSkills; |
461
|
|
|
|
462
|
|
|
/** |
463
|
|
|
* @var Collection<int, GradebookCategory>|GradebookCategory[] |
464
|
|
|
* |
465
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookCategory", mappedBy="user") |
466
|
|
|
*/ |
467
|
|
|
protected Collection $gradeBookCategories; |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* @var Collection<int, GradebookCertificate>|GradebookCertificate[] |
471
|
|
|
* |
472
|
|
|
* @ORM\OneToMany( |
473
|
|
|
* targetEntity="GradebookCertificate", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true |
474
|
|
|
* ) |
475
|
|
|
*/ |
476
|
|
|
protected Collection $gradeBookCertificates; |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* @var Collection<int, GradebookComment>|GradebookComment[] |
480
|
|
|
* |
481
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookComment", mappedBy="user") |
482
|
|
|
*/ |
483
|
|
|
protected Collection $gradeBookComments; |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* @ORM\OneToMany( |
487
|
|
|
* targetEntity="GradebookEvaluation", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true |
488
|
|
|
* ) |
489
|
|
|
* |
490
|
|
|
* @var Collection<int, GradebookEvaluation>|GradebookEvaluation[] |
491
|
|
|
*/ |
492
|
|
|
protected Collection $gradeBookEvaluations; |
493
|
|
|
|
494
|
|
|
/** |
495
|
|
|
* @ORM\OneToMany(targetEntity="GradebookLink", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
496
|
|
|
* |
497
|
|
|
* @var Collection<int, GradebookLink>|GradebookLink[] |
498
|
|
|
*/ |
499
|
|
|
protected Collection $gradeBookLinks; |
500
|
|
|
|
501
|
|
|
/** |
502
|
|
|
* @ORM\OneToMany(targetEntity="GradebookResult", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
503
|
|
|
* |
504
|
|
|
* @var Collection<int, GradebookResult>|GradebookResult[] |
505
|
|
|
*/ |
506
|
|
|
protected Collection $gradeBookResults; |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* @ORM\OneToMany( |
510
|
|
|
* targetEntity="GradebookResultLog", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true |
511
|
|
|
* ) |
512
|
|
|
* |
513
|
|
|
* @var Collection<int, GradebookResultLog>|GradebookResultLog[] |
514
|
|
|
*/ |
515
|
|
|
protected Collection $gradeBookResultLogs; |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* @ORM\OneToMany( |
519
|
|
|
* targetEntity="GradebookScoreLog", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true |
520
|
|
|
* ) |
521
|
|
|
* |
522
|
|
|
* @var Collection<int, GradebookScoreLog>|GradebookScoreLog[] |
523
|
|
|
*/ |
524
|
|
|
protected Collection $gradeBookScoreLogs; |
525
|
|
|
|
526
|
|
|
/** |
527
|
|
|
* @var Collection<int, UserRelUser>|UserRelUser[] |
528
|
|
|
* @ORM\OneToMany(targetEntity="UserRelUser", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY") |
529
|
|
|
*/ |
530
|
|
|
protected Collection $friends; |
531
|
|
|
|
532
|
|
|
/** |
533
|
|
|
* @var Collection<int, UserRelUser>|UserRelUser[] |
534
|
|
|
* @ORM\OneToMany(targetEntity="UserRelUser", mappedBy="friend", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EXTRA_LAZY") |
535
|
|
|
*/ |
536
|
|
|
protected Collection $friendsWithMe; |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* @var Collection<int, GradebookLinkevalLog>|GradebookLinkevalLog[] |
540
|
|
|
* @ORM\OneToMany( |
541
|
|
|
* targetEntity="GradebookLinkevalLog", |
542
|
|
|
* mappedBy="user", |
543
|
|
|
* cascade={"persist", "remove"}, |
544
|
|
|
* orphanRemoval=true |
545
|
|
|
* ) |
546
|
|
|
*/ |
547
|
|
|
protected Collection $gradeBookLinkEvalLogs; |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* @var Collection<int, SequenceValue>|SequenceValue[] |
551
|
|
|
* @ORM\OneToMany(targetEntity="SequenceValue", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
552
|
|
|
*/ |
553
|
|
|
protected Collection $sequenceValues; |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* @var Collection<int, TrackEExerciseConfirmation>|TrackEExerciseConfirmation[] |
557
|
|
|
* @ORM\OneToMany( |
558
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\TrackEExerciseConfirmation", |
559
|
|
|
* mappedBy="user", |
560
|
|
|
* cascade={"persist", "remove"}, |
561
|
|
|
* orphanRemoval=true |
562
|
|
|
* ) |
563
|
|
|
*/ |
564
|
|
|
protected Collection $trackEExerciseConfirmations; |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* @var Collection<int, TrackEAttempt>|TrackEAttempt[] |
568
|
|
|
* @ORM\OneToMany( |
569
|
|
|
* targetEntity="TrackEAccessComplete", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true |
570
|
|
|
* ) |
571
|
|
|
*/ |
572
|
|
|
protected Collection $trackEAccessCompleteList; |
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* @var Collection<int, Templates>|Templates[] |
576
|
|
|
* @ORM\OneToMany(targetEntity="Templates", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
577
|
|
|
*/ |
578
|
|
|
protected Collection $templates; |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* @var Collection<int, TrackEAttempt>|TrackEAttempt[] |
582
|
|
|
* @ORM\OneToMany(targetEntity="TrackEAttempt", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
583
|
|
|
*/ |
584
|
|
|
protected Collection $trackEAttempts; |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* @ORM\OneToMany( |
588
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\TrackECourseAccess", |
589
|
|
|
* mappedBy="user", |
590
|
|
|
* cascade={"persist", "remove"}, |
591
|
|
|
* orphanRemoval=true |
592
|
|
|
* ) |
593
|
|
|
* |
594
|
|
|
* @var Collection<int, TrackECourseAccess>|TrackECourseAccess[] |
595
|
|
|
*/ |
596
|
|
|
protected Collection $trackECourseAccess; |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* @var Collection<int, UserCourseCategory>|UserCourseCategory[] |
600
|
|
|
* |
601
|
|
|
* @ORM\OneToMany( |
602
|
|
|
* targetEntity="UserCourseCategory", |
603
|
|
|
* mappedBy="user", |
604
|
|
|
* cascade={"persist", "remove"}, |
605
|
|
|
* orphanRemoval=true |
606
|
|
|
* ) |
607
|
|
|
*/ |
608
|
|
|
protected Collection $userCourseCategories; |
609
|
|
|
|
610
|
|
|
/** |
611
|
|
|
* @var Collection<int, UserRelCourseVote>|UserRelCourseVote[] |
612
|
|
|
* @ORM\OneToMany(targetEntity="UserRelCourseVote", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
613
|
|
|
*/ |
614
|
|
|
protected Collection $userRelCourseVotes; |
615
|
|
|
|
616
|
|
|
/** |
617
|
|
|
* @var Collection<int, UserRelTag>|UserRelTag[] |
618
|
|
|
* @ORM\OneToMany(targetEntity="UserRelTag", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
619
|
|
|
*/ |
620
|
|
|
protected Collection $userRelTags; |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* @var Collection<int, PersonalAgenda>|PersonalAgenda[] |
624
|
|
|
* @ORM\OneToMany(targetEntity="PersonalAgenda", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
625
|
|
|
*/ |
626
|
|
|
protected Collection $personalAgendas; |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* @var CGroupRelUser[]|Collection<int, CGroupRelUser> |
630
|
|
|
* |
631
|
|
|
* @ORM\OneToMany( |
632
|
|
|
* targetEntity="Chamilo\CourseBundle\Entity\CGroupRelUser", |
633
|
|
|
* mappedBy="user", |
634
|
|
|
* cascade={"persist", "remove"}, |
635
|
|
|
* orphanRemoval=true |
636
|
|
|
* ) |
637
|
|
|
*/ |
638
|
|
|
protected Collection $courseGroupsAsMember; |
639
|
|
|
|
640
|
|
|
/** |
641
|
|
|
* @var CGroupRelTutor[]|Collection<int, CGroupRelTutor> |
642
|
|
|
* |
643
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupRelTutor", mappedBy="user", orphanRemoval=true) |
644
|
|
|
*/ |
645
|
|
|
protected Collection $courseGroupsAsTutor; |
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* @ORM\Column(name="auth_source", type="string", length=50, nullable=true) |
649
|
|
|
*/ |
650
|
|
|
protected ?string $authSource; |
651
|
|
|
|
652
|
|
|
/** |
653
|
|
|
* @ORM\Column(name="status", type="integer") |
654
|
|
|
*/ |
655
|
|
|
protected int $status; |
656
|
|
|
|
657
|
|
|
/** |
658
|
|
|
* @ORM\Column(name="official_code", type="string", length=40, nullable=true) |
659
|
|
|
*/ |
660
|
|
|
protected ?string $officialCode = null; |
661
|
|
|
|
662
|
|
|
/** |
663
|
|
|
* @ORM\Column(name="picture_uri", type="string", length=250, nullable=true) |
664
|
|
|
*/ |
665
|
|
|
protected ?string $pictureUri = null; |
666
|
|
|
|
667
|
|
|
/** |
668
|
|
|
* @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false) |
669
|
|
|
*/ |
670
|
|
|
protected ?int $creatorId = null; |
671
|
|
|
|
672
|
|
|
/** |
673
|
|
|
* @ORM\Column(name="competences", type="text", nullable=true, unique=false) |
674
|
|
|
*/ |
675
|
|
|
protected ?string $competences = null; |
676
|
|
|
|
677
|
|
|
/** |
678
|
|
|
* @ORM\Column(name="diplomas", type="text", nullable=true, unique=false) |
679
|
|
|
*/ |
680
|
|
|
protected ?string $diplomas = null; |
681
|
|
|
|
682
|
|
|
/** |
683
|
|
|
* @ORM\Column(name="openarea", type="text", nullable=true, unique=false) |
684
|
|
|
*/ |
685
|
|
|
protected ?string $openarea = null; |
686
|
|
|
|
687
|
|
|
/** |
688
|
|
|
* @ORM\Column(name="teach", type="text", nullable=true, unique=false) |
689
|
|
|
*/ |
690
|
|
|
protected ?string $teach = null; |
691
|
|
|
|
692
|
|
|
/** |
693
|
|
|
* @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false) |
694
|
|
|
*/ |
695
|
|
|
protected ?string $productions = null; |
696
|
|
|
|
697
|
|
|
/** |
698
|
|
|
* @ORM\Column(name="registration_date", type="datetime") |
699
|
|
|
*/ |
700
|
|
|
protected DateTime $registrationDate; |
701
|
|
|
|
702
|
|
|
/** |
703
|
|
|
* @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false) |
704
|
|
|
*/ |
705
|
|
|
protected ?DateTime $expirationDate = null; |
706
|
|
|
|
707
|
|
|
/** |
708
|
|
|
* @ORM\Column(name="active", type="boolean") |
709
|
|
|
*/ |
710
|
|
|
protected bool $active; |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false) |
714
|
|
|
*/ |
715
|
|
|
protected ?string $openid = null; |
716
|
|
|
|
717
|
|
|
/** |
718
|
|
|
* @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false) |
719
|
|
|
*/ |
720
|
|
|
protected ?string $theme = null; |
721
|
|
|
|
722
|
|
|
/** |
723
|
|
|
* @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false) |
724
|
|
|
*/ |
725
|
|
|
protected ?int $hrDeptId = null; |
726
|
|
|
|
727
|
|
|
protected AccessUrl $currentUrl; |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* @var Collection<int, MessageTag>|MessageTag[] |
731
|
|
|
*/ |
732
|
|
|
#[Assert\Valid] |
733
|
|
|
#[ORM\OneToMany( |
734
|
|
|
targetEntity: MessageTag::class, |
735
|
|
|
mappedBy: 'user', |
736
|
|
|
cascade: ['persist', 'remove'], |
737
|
|
|
orphanRemoval: true |
738
|
|
|
)] |
739
|
|
|
protected Collection $messageTags; |
740
|
|
|
|
741
|
|
|
/** |
742
|
|
|
* @var Collection<int, Message>|Message[] |
743
|
|
|
* |
744
|
|
|
* @ORM\OneToMany( |
745
|
|
|
* targetEntity="Message", |
746
|
|
|
* mappedBy="sender", |
747
|
|
|
* cascade={"persist", "remove"}, |
748
|
|
|
* orphanRemoval=true |
749
|
|
|
* ) |
750
|
|
|
*/ |
751
|
|
|
protected Collection $sentMessages; |
752
|
|
|
|
753
|
|
|
/** |
754
|
|
|
* @var Collection<int, MessageRelUser>|MessageRelUser[] |
755
|
|
|
* |
756
|
|
|
* @ORM\OneToMany( |
757
|
|
|
* targetEntity="Chamilo\CoreBundle\Entity\MessageRelUser", |
758
|
|
|
* mappedBy="receiver", |
759
|
|
|
* cascade={"persist", "remove"} |
760
|
|
|
* ) |
761
|
|
|
*/ |
762
|
|
|
protected Collection $receivedMessages; |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* @var Collection<int, CSurveyInvitation>|CSurveyInvitation[] |
766
|
|
|
*/ |
767
|
|
|
#[ORM\OneToMany( |
768
|
|
|
targetEntity: 'Chamilo\CourseBundle\Entity\CSurveyInvitation', |
769
|
|
|
mappedBy: 'user', |
770
|
|
|
cascade: ['remove'] |
771
|
|
|
)] |
772
|
|
|
protected Collection $surveyInvitations; |
773
|
|
|
|
774
|
|
|
/** |
775
|
|
|
* @var Collection<int, TrackELogin>|TrackELogin[] |
776
|
|
|
*/ |
777
|
|
|
#[ORM\OneToMany( |
778
|
|
|
targetEntity: 'TrackELogin', |
779
|
|
|
mappedBy: 'user', |
780
|
|
|
cascade: ['remove'] |
781
|
|
|
)] |
782
|
|
|
protected Collection $logins; |
783
|
|
|
|
784
|
|
|
/** |
785
|
|
|
* @ORM\OneToOne(targetEntity="Admin", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) |
786
|
|
|
*/ |
787
|
|
|
protected ?Admin $admin = null; |
788
|
|
|
|
789
|
|
|
/** |
790
|
|
|
* @var null|NilUuid|UuidV4 |
791
|
|
|
* |
792
|
|
|
* @ORM\Column(type="uuid", unique=true) |
793
|
|
|
*/ |
794
|
|
|
protected $uuid; |
795
|
|
|
|
796
|
|
|
// Property used only during installation. |
797
|
|
|
protected bool $skipResourceNode = false; |
798
|
|
|
|
799
|
|
|
public function __construct() |
800
|
|
|
{ |
801
|
|
|
$this->skipResourceNode = false; |
802
|
|
|
$this->uuid = Uuid::v4(); |
803
|
|
|
$this->apiToken = null; |
804
|
|
|
$this->biography = ''; |
805
|
|
|
$this->website = ''; |
806
|
|
|
$this->locale = 'en'; |
807
|
|
|
$this->timezone = 'Europe\Paris'; |
808
|
|
|
$this->authSource = 'platform'; |
809
|
|
|
|
810
|
|
|
$this->status = CourseRelUser::STUDENT; |
811
|
|
|
$this->salt = sha1(uniqid('', true)); |
812
|
|
|
$this->active = true; |
813
|
|
|
$this->enabled = true; |
814
|
|
|
$this->locked = false; |
815
|
|
|
$this->expired = false; |
816
|
|
|
|
817
|
|
|
$this->courses = new ArrayCollection(); |
818
|
|
|
$this->classes = new ArrayCollection(); |
819
|
|
|
$this->curriculumItems = new ArrayCollection(); |
820
|
|
|
$this->portals = new ArrayCollection(); |
821
|
|
|
$this->dropBoxSentFiles = new ArrayCollection(); |
822
|
|
|
$this->dropBoxReceivedFiles = new ArrayCollection(); |
823
|
|
|
$this->groups = new ArrayCollection(); |
824
|
|
|
$this->gradeBookCertificates = new ArrayCollection(); |
825
|
|
|
$this->courseGroupsAsMember = new ArrayCollection(); |
826
|
|
|
$this->courseGroupsAsTutor = new ArrayCollection(); |
827
|
|
|
$this->sessionsAsGeneralCoach = new ArrayCollection(); |
828
|
|
|
$this->resourceNodes = new ArrayCollection(); |
829
|
|
|
$this->sessionRelCourseRelUsers = new ArrayCollection(); |
830
|
|
|
$this->achievedSkills = new ArrayCollection(); |
831
|
|
|
$this->commentedUserSkills = new ArrayCollection(); |
832
|
|
|
$this->gradeBookCategories = new ArrayCollection(); |
833
|
|
|
$this->gradeBookComments = new ArrayCollection(); |
834
|
|
|
$this->gradeBookEvaluations = new ArrayCollection(); |
835
|
|
|
$this->gradeBookLinks = new ArrayCollection(); |
836
|
|
|
$this->gradeBookResults = new ArrayCollection(); |
837
|
|
|
$this->gradeBookResultLogs = new ArrayCollection(); |
838
|
|
|
$this->gradeBookScoreLogs = new ArrayCollection(); |
839
|
|
|
$this->friends = new ArrayCollection(); |
840
|
|
|
$this->friendsWithMe = new ArrayCollection(); |
841
|
|
|
$this->gradeBookLinkEvalLogs = new ArrayCollection(); |
842
|
|
|
$this->sequenceValues = new ArrayCollection(); |
843
|
|
|
$this->trackEExerciseConfirmations = new ArrayCollection(); |
844
|
|
|
$this->trackEAccessCompleteList = new ArrayCollection(); |
845
|
|
|
$this->templates = new ArrayCollection(); |
846
|
|
|
$this->trackEAttempts = new ArrayCollection(); |
847
|
|
|
$this->trackECourseAccess = new ArrayCollection(); |
848
|
|
|
$this->userCourseCategories = new ArrayCollection(); |
849
|
|
|
$this->userRelCourseVotes = new ArrayCollection(); |
850
|
|
|
$this->userRelTags = new ArrayCollection(); |
851
|
|
|
$this->personalAgendas = new ArrayCollection(); |
852
|
|
|
$this->sessionsRelUser = new ArrayCollection(); |
853
|
|
|
$this->sentMessages = new ArrayCollection(); |
854
|
|
|
$this->receivedMessages = new ArrayCollection(); |
855
|
|
|
$this->surveyInvitations = new ArrayCollection(); |
856
|
|
|
$this->logins = new ArrayCollection(); |
857
|
|
|
|
858
|
|
|
//$this->extraFields = new ArrayCollection(); |
859
|
|
|
$this->createdAt = new DateTime(); |
860
|
|
|
$this->updatedAt = new DateTime(); |
861
|
|
|
$this->registrationDate = new DateTime(); |
862
|
|
|
|
863
|
|
|
$this->roles = []; |
864
|
|
|
$this->credentialsExpired = false; |
865
|
|
|
$this->credentialsExpireAt = new DateTime(); |
866
|
|
|
$this->dateOfBirth = new DateTime(); |
867
|
|
|
$this->expiresAt = new DateTime(); |
868
|
|
|
$this->passwordRequestedAt = new DateTime(); |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
public function __toString(): string |
872
|
|
|
{ |
873
|
|
|
return $this->username; |
874
|
|
|
} |
875
|
|
|
|
876
|
|
|
public static function getPasswordConstraints(): array |
877
|
|
|
{ |
878
|
|
|
return [ |
879
|
|
|
new Assert\Length([ |
880
|
|
|
'min' => 5, |
881
|
|
|
]), |
882
|
|
|
// Alpha numeric + "_" or "-" |
883
|
|
|
new Assert\Regex( |
884
|
|
|
[ |
885
|
|
|
'pattern' => '/^[a-z\-_0-9]+$/i', |
886
|
|
|
'htmlPattern' => '/^[a-z\-_0-9]+$/i', |
887
|
|
|
] |
888
|
|
|
), |
889
|
|
|
// Min 3 letters - not needed |
890
|
|
|
/*new Assert\Regex(array( |
891
|
|
|
'pattern' => '/[a-z]{3}/i', |
892
|
|
|
'htmlPattern' => '/[a-z]{3}/i') |
893
|
|
|
),*/ |
894
|
|
|
// Min 2 numbers |
895
|
|
|
new Assert\Regex( |
896
|
|
|
[ |
897
|
|
|
'pattern' => '/[0-9]{2}/', |
898
|
|
|
'htmlPattern' => '/[0-9]{2}/', |
899
|
|
|
] |
900
|
|
|
), |
901
|
|
|
]; |
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void |
905
|
|
|
{ |
906
|
|
|
//$metadata->addPropertyConstraint('firstname', new Assert\NotBlank()); |
907
|
|
|
//$metadata->addPropertyConstraint('lastname', new Assert\NotBlank()); |
908
|
|
|
//$metadata->addPropertyConstraint('email', new Assert\Email()); |
909
|
|
|
/* |
910
|
|
|
$metadata->addPropertyConstraint('password', |
911
|
|
|
new Assert\Collection(self::getPasswordConstraints()) |
912
|
|
|
);*/ |
913
|
|
|
|
914
|
|
|
/*$metadata->addConstraint(new UniqueEntity(array( |
915
|
|
|
'fields' => 'username', |
916
|
|
|
'message' => 'This value is already used.', |
917
|
|
|
)));*/ |
918
|
|
|
|
919
|
|
|
/*$metadata->addPropertyConstraint( |
920
|
|
|
'username', |
921
|
|
|
new Assert\Length(array( |
922
|
|
|
'min' => 2, |
923
|
|
|
'max' => 50, |
924
|
|
|
'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.', |
925
|
|
|
'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.', |
926
|
|
|
)) |
927
|
|
|
);*/ |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
public function getUuid(): UuidV4 |
931
|
|
|
{ |
932
|
|
|
return $this->uuid; |
|
|
|
|
933
|
|
|
} |
934
|
|
|
|
935
|
|
|
public function setUuid(UuidV4 $uuid): self |
936
|
|
|
{ |
937
|
|
|
$this->uuid = $uuid; |
938
|
|
|
|
939
|
|
|
return $this; |
940
|
|
|
} |
941
|
|
|
|
942
|
|
|
public function getResourceNode(): ?ResourceNode |
943
|
|
|
{ |
944
|
|
|
return $this->resourceNode; |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
public function setResourceNode(ResourceNode $resourceNode): self |
948
|
|
|
{ |
949
|
|
|
$this->resourceNode = $resourceNode; |
950
|
|
|
|
951
|
|
|
return $this; |
952
|
|
|
} |
953
|
|
|
|
954
|
|
|
public function hasResourceNode(): bool |
955
|
|
|
{ |
956
|
|
|
return $this->resourceNode instanceof ResourceNode; |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
public function getResourceNodes(): Collection |
960
|
|
|
{ |
961
|
|
|
return $this->resourceNodes; |
962
|
|
|
} |
963
|
|
|
|
964
|
|
|
/** |
965
|
|
|
* @param Collection<int, ResourceNode>|ResourceNode[] $resourceNodes |
966
|
|
|
*/ |
967
|
|
|
public function setResourceNodes(Collection $resourceNodes): self |
968
|
|
|
{ |
969
|
|
|
$this->resourceNodes = $resourceNodes; |
970
|
|
|
|
971
|
|
|
return $this; |
972
|
|
|
} |
973
|
|
|
|
974
|
|
|
public function getDropBoxSentFiles(): Collection |
975
|
|
|
{ |
976
|
|
|
return $this->dropBoxSentFiles; |
977
|
|
|
} |
978
|
|
|
|
979
|
|
|
public function setDropBoxSentFiles(Collection $value): self |
980
|
|
|
{ |
981
|
|
|
$this->dropBoxSentFiles = $value; |
982
|
|
|
|
983
|
|
|
return $this; |
984
|
|
|
} |
985
|
|
|
|
986
|
|
|
/*public function getDropBoxReceivedFiles() |
987
|
|
|
{ |
988
|
|
|
return $this->dropBoxReceivedFiles; |
989
|
|
|
} |
990
|
|
|
|
991
|
|
|
public function setDropBoxReceivedFiles($value): void |
992
|
|
|
{ |
993
|
|
|
$this->dropBoxReceivedFiles = $value; |
994
|
|
|
}*/ |
995
|
|
|
|
996
|
|
|
public function getCourses(): Collection |
997
|
|
|
{ |
998
|
|
|
return $this->courses; |
999
|
|
|
} |
1000
|
|
|
|
1001
|
|
|
/** |
1002
|
|
|
* @param Collection<int, CourseRelUser>|CourseRelUser[] $courses |
1003
|
|
|
*/ |
1004
|
|
|
public function setCourses(Collection $courses): self |
1005
|
|
|
{ |
1006
|
|
|
$this->courses = $courses; |
1007
|
|
|
|
1008
|
|
|
return $this; |
1009
|
|
|
} |
1010
|
|
|
|
1011
|
|
|
public function setPortal(AccessUrlRelUser $portal): self |
1012
|
|
|
{ |
1013
|
|
|
$this->portals->add($portal); |
1014
|
|
|
|
1015
|
|
|
return $this; |
1016
|
|
|
} |
1017
|
|
|
|
1018
|
|
|
/*public function getCurriculumItems(): Collection |
1019
|
|
|
{ |
1020
|
|
|
return $this->curriculumItems; |
1021
|
|
|
} |
1022
|
|
|
|
1023
|
|
|
public function setCurriculumItems(array $items): self |
1024
|
|
|
{ |
1025
|
|
|
$this->curriculumItems = $items; |
1026
|
|
|
|
1027
|
|
|
return $this; |
1028
|
|
|
}*/ |
1029
|
|
|
|
1030
|
|
|
public function getIsActive(): bool |
1031
|
|
|
{ |
1032
|
|
|
return $this->active; |
1033
|
|
|
} |
1034
|
|
|
|
1035
|
|
|
public function isEnabled(): bool |
1036
|
|
|
{ |
1037
|
|
|
return $this->isActive(); |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
public function setEnabled(bool $boolean): self |
1041
|
|
|
{ |
1042
|
|
|
$this->enabled = $boolean; |
1043
|
|
|
|
1044
|
|
|
return $this; |
1045
|
|
|
} |
1046
|
|
|
|
1047
|
|
|
public function getSalt(): ?string |
1048
|
|
|
{ |
1049
|
|
|
return $this->salt; |
1050
|
|
|
} |
1051
|
|
|
|
1052
|
|
|
public function setSalt(string $salt): self |
1053
|
|
|
{ |
1054
|
|
|
$this->salt = $salt; |
1055
|
|
|
|
1056
|
|
|
return $this; |
1057
|
|
|
} |
1058
|
|
|
|
1059
|
|
|
public function getLps(): void |
1060
|
|
|
{ |
1061
|
|
|
//return $this->lps; |
1062
|
|
|
/*$criteria = Criteria::create() |
1063
|
|
|
->where(Criteria::expr()->eq("id", "666")) |
1064
|
|
|
//->orderBy(array("username" => "ASC")) |
1065
|
|
|
//->setFirstResult(0) |
1066
|
|
|
//->setMaxResults(20) |
1067
|
|
|
; |
1068
|
|
|
$lps = $this->lps->matching($criteria);*/ |
1069
|
|
|
/*return $this->lps->filter( |
1070
|
|
|
function($entry) use ($idsToFilter) { |
1071
|
|
|
return $entry->getId() == 1; |
1072
|
|
|
});*/ |
1073
|
|
|
} |
1074
|
|
|
|
1075
|
|
|
/** |
1076
|
|
|
* Returns the list of classes for the user. |
1077
|
|
|
*/ |
1078
|
|
|
public function getCompleteNameWithClasses(): string |
1079
|
|
|
{ |
1080
|
|
|
$classSubscription = $this->getClasses(); |
1081
|
|
|
$classList = []; |
1082
|
|
|
/** @var UsergroupRelUser $subscription */ |
1083
|
|
|
foreach ($classSubscription as $subscription) { |
1084
|
|
|
$class = $subscription->getUsergroup(); |
1085
|
|
|
$classList[] = $class->getName(); |
1086
|
|
|
} |
1087
|
|
|
$classString = empty($classList) ? null : ' ['.implode(', ', $classList).']'; |
1088
|
|
|
|
1089
|
|
|
return UserManager::formatUserFullName($this).$classString; |
1090
|
|
|
} |
1091
|
|
|
|
1092
|
|
|
public function getClasses(): Collection |
1093
|
|
|
{ |
1094
|
|
|
return $this->classes; |
1095
|
|
|
} |
1096
|
|
|
|
1097
|
|
|
/** |
1098
|
|
|
* @param Collection<int, UsergroupRelUser>|UsergroupRelUser[] $classes |
1099
|
|
|
*/ |
1100
|
|
|
public function setClasses(Collection $classes): self |
1101
|
|
|
{ |
1102
|
|
|
$this->classes = $classes; |
1103
|
|
|
|
1104
|
|
|
return $this; |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
public function getPassword(): ?string |
1108
|
|
|
{ |
1109
|
|
|
return $this->password; |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
|
public function setPassword(string $password): self |
1113
|
|
|
{ |
1114
|
|
|
$this->password = $password; |
1115
|
|
|
|
1116
|
|
|
return $this; |
1117
|
|
|
} |
1118
|
|
|
|
1119
|
|
|
public function getAuthSource(): ?string |
1120
|
|
|
{ |
1121
|
|
|
return $this->authSource; |
1122
|
|
|
} |
1123
|
|
|
|
1124
|
|
|
public function setAuthSource(string $authSource): self |
1125
|
|
|
{ |
1126
|
|
|
$this->authSource = $authSource; |
1127
|
|
|
|
1128
|
|
|
return $this; |
1129
|
|
|
} |
1130
|
|
|
|
1131
|
|
|
public function getEmail(): string |
1132
|
|
|
{ |
1133
|
|
|
return $this->email; |
1134
|
|
|
} |
1135
|
|
|
|
1136
|
|
|
public function setEmail(string $email): self |
1137
|
|
|
{ |
1138
|
|
|
$this->email = $email; |
1139
|
|
|
|
1140
|
|
|
return $this; |
1141
|
|
|
} |
1142
|
|
|
|
1143
|
|
|
public function getOfficialCode(): ?string |
1144
|
|
|
{ |
1145
|
|
|
return $this->officialCode; |
1146
|
|
|
} |
1147
|
|
|
|
1148
|
|
|
public function setOfficialCode(?string $officialCode): self |
1149
|
|
|
{ |
1150
|
|
|
$this->officialCode = $officialCode; |
1151
|
|
|
|
1152
|
|
|
return $this; |
1153
|
|
|
} |
1154
|
|
|
|
1155
|
|
|
public function getPhone(): ?string |
1156
|
|
|
{ |
1157
|
|
|
return $this->phone; |
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
public function setPhone(?string $phone): self |
1161
|
|
|
{ |
1162
|
|
|
$this->phone = $phone; |
1163
|
|
|
|
1164
|
|
|
return $this; |
1165
|
|
|
} |
1166
|
|
|
|
1167
|
|
|
public function getAddress(): ?string |
1168
|
|
|
{ |
1169
|
|
|
return $this->address; |
1170
|
|
|
} |
1171
|
|
|
|
1172
|
|
|
public function setAddress(?string $address): self |
1173
|
|
|
{ |
1174
|
|
|
$this->address = $address; |
1175
|
|
|
|
1176
|
|
|
return $this; |
1177
|
|
|
} |
1178
|
|
|
|
1179
|
|
|
public function getCreatorId(): ?int |
1180
|
|
|
{ |
1181
|
|
|
return $this->creatorId; |
1182
|
|
|
} |
1183
|
|
|
|
1184
|
|
|
public function setCreatorId(int $creatorId): self |
1185
|
|
|
{ |
1186
|
|
|
$this->creatorId = $creatorId; |
1187
|
|
|
|
1188
|
|
|
return $this; |
1189
|
|
|
} |
1190
|
|
|
|
1191
|
|
|
public function getCompetences(): ?string |
1192
|
|
|
{ |
1193
|
|
|
return $this->competences; |
1194
|
|
|
} |
1195
|
|
|
|
1196
|
|
|
public function setCompetences(?string $competences): self |
1197
|
|
|
{ |
1198
|
|
|
$this->competences = $competences; |
1199
|
|
|
|
1200
|
|
|
return $this; |
1201
|
|
|
} |
1202
|
|
|
|
1203
|
|
|
public function getDiplomas(): ?string |
1204
|
|
|
{ |
1205
|
|
|
return $this->diplomas; |
1206
|
|
|
} |
1207
|
|
|
|
1208
|
|
|
public function setDiplomas(?string $diplomas): self |
1209
|
|
|
{ |
1210
|
|
|
$this->diplomas = $diplomas; |
1211
|
|
|
|
1212
|
|
|
return $this; |
1213
|
|
|
} |
1214
|
|
|
|
1215
|
|
|
public function getOpenarea(): ?string |
1216
|
|
|
{ |
1217
|
|
|
return $this->openarea; |
1218
|
|
|
} |
1219
|
|
|
|
1220
|
|
|
public function setOpenarea(?string $openarea): self |
1221
|
|
|
{ |
1222
|
|
|
$this->openarea = $openarea; |
1223
|
|
|
|
1224
|
|
|
return $this; |
1225
|
|
|
} |
1226
|
|
|
|
1227
|
|
|
public function getTeach(): ?string |
1228
|
|
|
{ |
1229
|
|
|
return $this->teach; |
1230
|
|
|
} |
1231
|
|
|
|
1232
|
|
|
public function setTeach(?string $teach): self |
1233
|
|
|
{ |
1234
|
|
|
$this->teach = $teach; |
1235
|
|
|
|
1236
|
|
|
return $this; |
1237
|
|
|
} |
1238
|
|
|
|
1239
|
|
|
public function getProductions(): ?string |
1240
|
|
|
{ |
1241
|
|
|
return $this->productions; |
1242
|
|
|
} |
1243
|
|
|
|
1244
|
|
|
public function setProductions(?string $productions): self |
1245
|
|
|
{ |
1246
|
|
|
$this->productions = $productions; |
1247
|
|
|
|
1248
|
|
|
return $this; |
1249
|
|
|
} |
1250
|
|
|
|
1251
|
|
|
public function getRegistrationDate(): DateTime |
1252
|
|
|
{ |
1253
|
|
|
return $this->registrationDate; |
1254
|
|
|
} |
1255
|
|
|
|
1256
|
|
|
public function setRegistrationDate(DateTime $registrationDate): self |
1257
|
|
|
{ |
1258
|
|
|
$this->registrationDate = $registrationDate; |
1259
|
|
|
|
1260
|
|
|
return $this; |
1261
|
|
|
} |
1262
|
|
|
|
1263
|
|
|
public function getExpirationDate(): ?DateTime |
1264
|
|
|
{ |
1265
|
|
|
return $this->expirationDate; |
1266
|
|
|
} |
1267
|
|
|
|
1268
|
|
|
public function setExpirationDate(?DateTime $expirationDate): self |
1269
|
|
|
{ |
1270
|
|
|
$this->expirationDate = $expirationDate; |
1271
|
|
|
|
1272
|
|
|
return $this; |
1273
|
|
|
} |
1274
|
|
|
|
1275
|
|
|
public function getActive(): bool |
1276
|
|
|
{ |
1277
|
|
|
return $this->active; |
1278
|
|
|
} |
1279
|
|
|
|
1280
|
|
|
public function isActive(): bool |
1281
|
|
|
{ |
1282
|
|
|
return $this->getIsActive(); |
1283
|
|
|
} |
1284
|
|
|
|
1285
|
|
|
public function setActive(bool $active): self |
1286
|
|
|
{ |
1287
|
|
|
$this->active = $active; |
1288
|
|
|
|
1289
|
|
|
return $this; |
1290
|
|
|
} |
1291
|
|
|
|
1292
|
|
|
public function getOpenid(): ?string |
1293
|
|
|
{ |
1294
|
|
|
return $this->openid; |
1295
|
|
|
} |
1296
|
|
|
|
1297
|
|
|
public function setOpenid(string $openid): self |
1298
|
|
|
{ |
1299
|
|
|
$this->openid = $openid; |
1300
|
|
|
|
1301
|
|
|
return $this; |
1302
|
|
|
} |
1303
|
|
|
|
1304
|
|
|
public function getTheme(): ?string |
1305
|
|
|
{ |
1306
|
|
|
return $this->theme; |
1307
|
|
|
} |
1308
|
|
|
|
1309
|
|
|
public function setTheme(string $theme): self |
1310
|
|
|
{ |
1311
|
|
|
$this->theme = $theme; |
1312
|
|
|
|
1313
|
|
|
return $this; |
1314
|
|
|
} |
1315
|
|
|
|
1316
|
|
|
public function getHrDeptId(): ?int |
1317
|
|
|
{ |
1318
|
|
|
return $this->hrDeptId; |
1319
|
|
|
} |
1320
|
|
|
|
1321
|
|
|
public function setHrDeptId(int $hrDeptId): self |
1322
|
|
|
{ |
1323
|
|
|
$this->hrDeptId = $hrDeptId; |
1324
|
|
|
|
1325
|
|
|
return $this; |
1326
|
|
|
} |
1327
|
|
|
|
1328
|
|
|
public function getMemberSince(): DateTime |
1329
|
|
|
{ |
1330
|
|
|
return $this->registrationDate; |
1331
|
|
|
} |
1332
|
|
|
|
1333
|
|
|
public function isOnline(): bool |
1334
|
|
|
{ |
1335
|
|
|
return false; |
1336
|
|
|
} |
1337
|
|
|
|
1338
|
|
|
public function getIdentifier(): int |
1339
|
|
|
{ |
1340
|
|
|
return $this->getId(); |
|
|
|
|
1341
|
|
|
} |
1342
|
|
|
|
1343
|
|
|
public function getId(): ?int |
1344
|
|
|
{ |
1345
|
|
|
return $this->id; |
1346
|
|
|
} |
1347
|
|
|
|
1348
|
|
|
public function getIri(): ?string |
1349
|
|
|
{ |
1350
|
|
|
if (null === $this->id) { |
1351
|
|
|
return null; |
1352
|
|
|
} |
1353
|
|
|
|
1354
|
|
|
return '/api/users/'.$this->getId(); |
1355
|
|
|
} |
1356
|
|
|
|
1357
|
|
|
public function getSlug(): string |
1358
|
|
|
{ |
1359
|
|
|
return $this->getUsername(); |
1360
|
|
|
} |
1361
|
|
|
|
1362
|
|
|
public function getUsername(): string |
1363
|
|
|
{ |
1364
|
|
|
return $this->username; |
1365
|
|
|
} |
1366
|
|
|
|
1367
|
|
|
public function getUserIdentifier(): string |
1368
|
|
|
{ |
1369
|
|
|
return $this->username; |
1370
|
|
|
} |
1371
|
|
|
|
1372
|
|
|
public function setUsername(string $username): self |
1373
|
|
|
{ |
1374
|
|
|
$this->username = $username; |
1375
|
|
|
|
1376
|
|
|
return $this; |
1377
|
|
|
} |
1378
|
|
|
|
1379
|
|
|
public function setSlug(string $slug): self |
1380
|
|
|
{ |
1381
|
|
|
return $this->setUsername($slug); |
1382
|
|
|
} |
1383
|
|
|
|
1384
|
|
|
public function getLastLogin(): ?DateTime |
1385
|
|
|
{ |
1386
|
|
|
return $this->lastLogin; |
1387
|
|
|
} |
1388
|
|
|
|
1389
|
|
|
public function setLastLogin(DateTime $lastLogin = null): self |
1390
|
|
|
{ |
1391
|
|
|
$this->lastLogin = $lastLogin; |
1392
|
|
|
|
1393
|
|
|
return $this; |
1394
|
|
|
} |
1395
|
|
|
|
1396
|
|
|
public function getConfirmationToken(): ?string |
1397
|
|
|
{ |
1398
|
|
|
return $this->confirmationToken; |
1399
|
|
|
} |
1400
|
|
|
|
1401
|
|
|
public function setConfirmationToken(string $confirmationToken): self |
1402
|
|
|
{ |
1403
|
|
|
$this->confirmationToken = $confirmationToken; |
1404
|
|
|
|
1405
|
|
|
return $this; |
1406
|
|
|
} |
1407
|
|
|
|
1408
|
|
|
public function isPasswordRequestNonExpired(int $ttl): bool |
1409
|
|
|
{ |
1410
|
|
|
return $this->getPasswordRequestedAt() instanceof DateTime |
1411
|
|
|
&& $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); |
1412
|
|
|
} |
1413
|
|
|
|
1414
|
|
|
public function getPasswordRequestedAt(): ?DateTime |
1415
|
|
|
{ |
1416
|
|
|
return $this->passwordRequestedAt; |
1417
|
|
|
} |
1418
|
|
|
|
1419
|
|
|
public function setPasswordRequestedAt(DateTime $date = null): self |
1420
|
|
|
{ |
1421
|
|
|
$this->passwordRequestedAt = $date; |
1422
|
|
|
|
1423
|
|
|
return $this; |
1424
|
|
|
} |
1425
|
|
|
|
1426
|
|
|
public function getPlainPassword(): ?string |
1427
|
|
|
{ |
1428
|
|
|
return $this->plainPassword; |
1429
|
|
|
} |
1430
|
|
|
|
1431
|
|
|
public function setPlainPassword(string $password): self |
1432
|
|
|
{ |
1433
|
|
|
$this->plainPassword = $password; |
1434
|
|
|
|
1435
|
|
|
// forces the object to look "dirty" to Doctrine. Avoids |
1436
|
|
|
// Doctrine *not* saving this entity, if only plainPassword changes |
1437
|
|
|
$this->password = ''; |
1438
|
|
|
|
1439
|
|
|
return $this; |
1440
|
|
|
} |
1441
|
|
|
|
1442
|
|
|
/** |
1443
|
|
|
* Returns the expiration date. |
1444
|
|
|
*/ |
1445
|
|
|
public function getExpiresAt(): ?DateTime |
1446
|
|
|
{ |
1447
|
|
|
return $this->expiresAt; |
1448
|
|
|
} |
1449
|
|
|
|
1450
|
|
|
public function setExpiresAt(DateTime $date): self |
1451
|
|
|
{ |
1452
|
|
|
$this->expiresAt = $date; |
1453
|
|
|
|
1454
|
|
|
return $this; |
1455
|
|
|
} |
1456
|
|
|
|
1457
|
|
|
/** |
1458
|
|
|
* Returns the credentials expiration date. |
1459
|
|
|
*/ |
1460
|
|
|
public function getCredentialsExpireAt(): ?DateTime |
1461
|
|
|
{ |
1462
|
|
|
return $this->credentialsExpireAt; |
1463
|
|
|
} |
1464
|
|
|
|
1465
|
|
|
/** |
1466
|
|
|
* Sets the credentials expiration date. |
1467
|
|
|
*/ |
1468
|
|
|
public function setCredentialsExpireAt(DateTime $date = null): self |
1469
|
|
|
{ |
1470
|
|
|
$this->credentialsExpireAt = $date; |
1471
|
|
|
|
1472
|
|
|
return $this; |
1473
|
|
|
} |
1474
|
|
|
|
1475
|
|
|
public function getFullname(): string |
1476
|
|
|
{ |
1477
|
|
|
return sprintf('%s %s', $this->getFirstname(), $this->getLastname()); |
1478
|
|
|
} |
1479
|
|
|
|
1480
|
|
|
public function getFirstname(): ?string |
1481
|
|
|
{ |
1482
|
|
|
return $this->firstname; |
1483
|
|
|
} |
1484
|
|
|
|
1485
|
|
|
public function setFirstname(string $firstname): self |
1486
|
|
|
{ |
1487
|
|
|
$this->firstname = $firstname; |
1488
|
|
|
|
1489
|
|
|
return $this; |
1490
|
|
|
} |
1491
|
|
|
|
1492
|
|
|
public function getLastname(): ?string |
1493
|
|
|
{ |
1494
|
|
|
return $this->lastname; |
1495
|
|
|
} |
1496
|
|
|
|
1497
|
|
|
public function setLastname(string $lastname): self |
1498
|
|
|
{ |
1499
|
|
|
$this->lastname = $lastname; |
1500
|
|
|
|
1501
|
|
|
return $this; |
1502
|
|
|
} |
1503
|
|
|
|
1504
|
|
|
public function hasGroup(string $name): bool |
1505
|
|
|
{ |
1506
|
|
|
return \in_array($name, $this->getGroupNames(), true); |
1507
|
|
|
} |
1508
|
|
|
|
1509
|
|
|
public function getGroupNames(): array |
1510
|
|
|
{ |
1511
|
|
|
$names = []; |
1512
|
|
|
foreach ($this->getGroups() as $group) { |
1513
|
|
|
$names[] = $group->getName(); |
1514
|
|
|
} |
1515
|
|
|
|
1516
|
|
|
return $names; |
1517
|
|
|
} |
1518
|
|
|
|
1519
|
|
|
public function getGroups(): Collection |
1520
|
|
|
{ |
1521
|
|
|
return $this->groups; |
1522
|
|
|
} |
1523
|
|
|
|
1524
|
|
|
/** |
1525
|
|
|
* Sets the user groups. |
1526
|
|
|
*/ |
1527
|
|
|
public function setGroups(Collection $groups): self |
1528
|
|
|
{ |
1529
|
|
|
foreach ($groups as $group) { |
1530
|
|
|
$this->addGroup($group); |
1531
|
|
|
} |
1532
|
|
|
|
1533
|
|
|
return $this; |
1534
|
|
|
} |
1535
|
|
|
|
1536
|
|
|
public function addGroup(Group $group): self |
1537
|
|
|
{ |
1538
|
|
|
if (!$this->getGroups()->contains($group)) { |
1539
|
|
|
$this->getGroups()->add($group); |
1540
|
|
|
} |
1541
|
|
|
|
1542
|
|
|
return $this; |
1543
|
|
|
} |
1544
|
|
|
|
1545
|
|
|
public function removeGroup(Group $group): self |
1546
|
|
|
{ |
1547
|
|
|
if ($this->getGroups()->contains($group)) { |
1548
|
|
|
$this->getGroups()->removeElement($group); |
1549
|
|
|
} |
1550
|
|
|
|
1551
|
|
|
return $this; |
1552
|
|
|
} |
1553
|
|
|
|
1554
|
|
|
public function isAccountNonExpired(): bool |
1555
|
|
|
{ |
1556
|
|
|
/*if (true === $this->expired) { |
1557
|
|
|
return false; |
1558
|
|
|
} |
1559
|
|
|
|
1560
|
|
|
if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) { |
1561
|
|
|
return false; |
1562
|
|
|
}*/ |
1563
|
|
|
|
1564
|
|
|
return true; |
1565
|
|
|
} |
1566
|
|
|
|
1567
|
|
|
public function isAccountNonLocked(): bool |
1568
|
|
|
{ |
1569
|
|
|
return true; |
1570
|
|
|
//return !$this->locked; |
1571
|
|
|
} |
1572
|
|
|
|
1573
|
|
|
public function isCredentialsNonExpired(): bool |
1574
|
|
|
{ |
1575
|
|
|
/*if (true === $this->credentialsExpired) { |
1576
|
|
|
return false; |
1577
|
|
|
} |
1578
|
|
|
|
1579
|
|
|
if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) { |
1580
|
|
|
return false; |
1581
|
|
|
}*/ |
1582
|
|
|
|
1583
|
|
|
return true; |
1584
|
|
|
} |
1585
|
|
|
|
1586
|
|
|
public function getCredentialsExpired(): bool |
1587
|
|
|
{ |
1588
|
|
|
return $this->credentialsExpired; |
1589
|
|
|
} |
1590
|
|
|
|
1591
|
|
|
public function setCredentialsExpired(bool $boolean): self |
1592
|
|
|
{ |
1593
|
|
|
$this->credentialsExpired = $boolean; |
1594
|
|
|
|
1595
|
|
|
return $this; |
1596
|
|
|
} |
1597
|
|
|
|
1598
|
|
|
public function getExpired(): bool |
1599
|
|
|
{ |
1600
|
|
|
return $this->expired; |
1601
|
|
|
} |
1602
|
|
|
|
1603
|
|
|
/** |
1604
|
|
|
* Sets this user to expired. |
1605
|
|
|
*/ |
1606
|
|
|
public function setExpired(bool $boolean): self |
1607
|
|
|
{ |
1608
|
|
|
$this->expired = $boolean; |
1609
|
|
|
|
1610
|
|
|
return $this; |
1611
|
|
|
} |
1612
|
|
|
|
1613
|
|
|
public function getLocked(): bool |
1614
|
|
|
{ |
1615
|
|
|
return $this->locked; |
1616
|
|
|
} |
1617
|
|
|
|
1618
|
|
|
public function setLocked(bool $boolean): self |
1619
|
|
|
{ |
1620
|
|
|
$this->locked = $boolean; |
1621
|
|
|
|
1622
|
|
|
return $this; |
1623
|
|
|
} |
1624
|
|
|
|
1625
|
|
|
/** |
1626
|
|
|
* Check if the user has the skill. |
1627
|
|
|
* |
1628
|
|
|
* @param Skill $skill The skill |
1629
|
|
|
*/ |
1630
|
|
|
public function hasSkill(Skill $skill): bool |
1631
|
|
|
{ |
1632
|
|
|
$achievedSkills = $this->getAchievedSkills(); |
1633
|
|
|
|
1634
|
|
|
foreach ($achievedSkills as $userSkill) { |
1635
|
|
|
if ($userSkill->getSkill()->getId() !== $skill->getId()) { |
1636
|
|
|
continue; |
1637
|
|
|
} |
1638
|
|
|
|
1639
|
|
|
return true; |
1640
|
|
|
} |
1641
|
|
|
|
1642
|
|
|
return false; |
1643
|
|
|
} |
1644
|
|
|
|
1645
|
|
|
public function getAchievedSkills(): Collection |
1646
|
|
|
{ |
1647
|
|
|
return $this->achievedSkills; |
1648
|
|
|
} |
1649
|
|
|
|
1650
|
|
|
/** |
1651
|
|
|
* @param Collection<int, SkillRelUser>|SkillRelUser[] $value |
1652
|
|
|
*/ |
1653
|
|
|
public function setAchievedSkills(Collection $value): self |
1654
|
|
|
{ |
1655
|
|
|
$this->achievedSkills = $value; |
1656
|
|
|
|
1657
|
|
|
return $this; |
1658
|
|
|
} |
1659
|
|
|
|
1660
|
|
|
public function isProfileCompleted(): ?bool |
1661
|
|
|
{ |
1662
|
|
|
return $this->profileCompleted; |
1663
|
|
|
} |
1664
|
|
|
|
1665
|
|
|
public function setProfileCompleted(?bool $profileCompleted): self |
1666
|
|
|
{ |
1667
|
|
|
$this->profileCompleted = $profileCompleted; |
1668
|
|
|
|
1669
|
|
|
return $this; |
1670
|
|
|
} |
1671
|
|
|
|
1672
|
|
|
public function getCurrentUrl(): AccessUrl |
1673
|
|
|
{ |
1674
|
|
|
return $this->currentUrl; |
1675
|
|
|
} |
1676
|
|
|
|
1677
|
|
|
/** |
1678
|
|
|
* Sets the AccessUrl for the current user in memory. |
1679
|
|
|
*/ |
1680
|
|
|
public function setCurrentUrl(AccessUrl $url): self |
1681
|
|
|
{ |
1682
|
|
|
$urlList = $this->getPortals(); |
1683
|
|
|
/** @var AccessUrlRelUser $item */ |
1684
|
|
|
foreach ($urlList as $item) { |
1685
|
|
|
if ($item->getUrl()->getId() === $url->getId()) { |
1686
|
|
|
$this->currentUrl = $url; |
1687
|
|
|
|
1688
|
|
|
break; |
1689
|
|
|
} |
1690
|
|
|
} |
1691
|
|
|
|
1692
|
|
|
return $this; |
1693
|
|
|
} |
1694
|
|
|
|
1695
|
|
|
public function getPortals(): Collection |
1696
|
|
|
{ |
1697
|
|
|
return $this->portals; |
1698
|
|
|
} |
1699
|
|
|
|
1700
|
|
|
/** |
1701
|
|
|
* @param AccessUrlRelUser[]|Collection<int, AccessUrlRelUser> $value |
1702
|
|
|
*/ |
1703
|
|
|
public function setPortals(Collection $value): void |
1704
|
|
|
{ |
1705
|
|
|
$this->portals = $value; |
1706
|
|
|
} |
1707
|
|
|
|
1708
|
|
|
public function getSessionsAsGeneralCoach(): Collection |
1709
|
|
|
{ |
1710
|
|
|
return $this->sessionsAsGeneralCoach; |
1711
|
|
|
} |
1712
|
|
|
|
1713
|
|
|
/** |
1714
|
|
|
* @param Collection<int, Session>|Session[] $value |
1715
|
|
|
*/ |
1716
|
|
|
public function setSessionsAsGeneralCoach(Collection $value): self |
1717
|
|
|
{ |
1718
|
|
|
$this->sessionsAsGeneralCoach = $value; |
1719
|
|
|
|
1720
|
|
|
return $this; |
1721
|
|
|
} |
1722
|
|
|
|
1723
|
|
|
public function getCommentedUserSkills(): Collection |
1724
|
|
|
{ |
1725
|
|
|
return $this->commentedUserSkills; |
1726
|
|
|
} |
1727
|
|
|
|
1728
|
|
|
/** |
1729
|
|
|
* @param Collection<int, SkillRelUserComment>|SkillRelUserComment[] $commentedUserSkills |
1730
|
|
|
*/ |
1731
|
|
|
public function setCommentedUserSkills(Collection $commentedUserSkills): self |
1732
|
|
|
{ |
1733
|
|
|
$this->commentedUserSkills = $commentedUserSkills; |
1734
|
|
|
|
1735
|
|
|
return $this; |
1736
|
|
|
} |
1737
|
|
|
|
1738
|
|
|
public function isEqualTo(UserInterface $user): bool |
1739
|
|
|
{ |
1740
|
|
|
if ($this->password !== $user->getPassword()) { |
1741
|
|
|
return false; |
1742
|
|
|
} |
1743
|
|
|
|
1744
|
|
|
if ($this->salt !== $user->getSalt()) { |
1745
|
|
|
return false; |
1746
|
|
|
} |
1747
|
|
|
|
1748
|
|
|
if ($this->username !== $user->getUserIdentifier()) { |
1749
|
|
|
return false; |
1750
|
|
|
} |
1751
|
|
|
|
1752
|
|
|
return true; |
1753
|
|
|
} |
1754
|
|
|
|
1755
|
|
|
public function getSentMessages(): Collection |
1756
|
|
|
{ |
1757
|
|
|
return $this->sentMessages; |
1758
|
|
|
} |
1759
|
|
|
|
1760
|
|
|
public function getReceivedMessages(): Collection |
1761
|
|
|
{ |
1762
|
|
|
return $this->receivedMessages; |
1763
|
|
|
} |
1764
|
|
|
|
1765
|
|
|
public function getCourseGroupsAsMember(): Collection |
1766
|
|
|
{ |
1767
|
|
|
return $this->courseGroupsAsMember; |
1768
|
|
|
} |
1769
|
|
|
|
1770
|
|
|
public function getCourseGroupsAsTutor(): Collection |
1771
|
|
|
{ |
1772
|
|
|
return $this->courseGroupsAsTutor; |
1773
|
|
|
} |
1774
|
|
|
|
1775
|
|
|
public function getCourseGroupsAsMemberFromCourse(Course $course): Collection |
1776
|
|
|
{ |
1777
|
|
|
$criteria = Criteria::create(); |
1778
|
|
|
$criteria->where( |
1779
|
|
|
Criteria::expr()->eq('cId', $course) |
1780
|
|
|
); |
1781
|
|
|
|
1782
|
|
|
return $this->courseGroupsAsMember->matching($criteria); |
1783
|
|
|
} |
1784
|
|
|
|
1785
|
|
|
public function eraseCredentials(): void |
1786
|
|
|
{ |
1787
|
|
|
$this->plainPassword = null; |
1788
|
|
|
} |
1789
|
|
|
|
1790
|
|
|
public function isSuperAdmin(): bool |
1791
|
|
|
{ |
1792
|
|
|
return $this->hasRole('ROLE_SUPER_ADMIN'); |
1793
|
|
|
} |
1794
|
|
|
|
1795
|
|
|
public function setRoleFromStatus(int $status): void |
1796
|
|
|
{ |
1797
|
|
|
$role = match ($status) { |
1798
|
|
|
COURSEMANAGER => 'ROLE_TEACHER', |
1799
|
|
|
STUDENT => 'ROLE_STUDENT', |
1800
|
|
|
DRH => 'ROLE_RRHH', |
1801
|
|
|
SESSIONADMIN => 'ROLE_SESSION_MANAGER', |
1802
|
|
|
STUDENT_BOSS => 'ROLE_STUDENT_BOSS', |
1803
|
|
|
INVITEE => 'ROLE_INVITEE', |
1804
|
|
|
default => 'ROLE_USER', |
1805
|
|
|
}; |
1806
|
|
|
|
1807
|
|
|
$this->addRole($role); |
1808
|
|
|
} |
1809
|
|
|
|
1810
|
|
|
public function hasRole(string $role): bool |
1811
|
|
|
{ |
1812
|
|
|
return \in_array(strtoupper($role), $this->getRoles(), true); |
1813
|
|
|
} |
1814
|
|
|
|
1815
|
|
|
/** |
1816
|
|
|
* Returns the user roles. |
1817
|
|
|
* |
1818
|
|
|
* @return array The roles |
1819
|
|
|
*/ |
1820
|
|
|
public function getRoles(): array |
1821
|
|
|
{ |
1822
|
|
|
$roles = $this->roles; |
1823
|
|
|
|
1824
|
|
|
foreach ($this->getGroups() as $group) { |
1825
|
|
|
$roles = array_merge($roles, $group->getRoles()); |
1826
|
|
|
} |
1827
|
|
|
|
1828
|
|
|
// we need to make sure to have at least one role |
1829
|
|
|
$roles[] = 'ROLE_USER'; |
1830
|
|
|
|
1831
|
|
|
return array_unique($roles); |
1832
|
|
|
} |
1833
|
|
|
|
1834
|
|
|
public function setRoles(array $roles): self |
1835
|
|
|
{ |
1836
|
|
|
$this->roles = []; |
1837
|
|
|
|
1838
|
|
|
foreach ($roles as $role) { |
1839
|
|
|
$this->addRole($role); |
1840
|
|
|
} |
1841
|
|
|
|
1842
|
|
|
return $this; |
1843
|
|
|
} |
1844
|
|
|
|
1845
|
|
|
public function addRole(string $role): self |
1846
|
|
|
{ |
1847
|
|
|
$role = strtoupper($role); |
1848
|
|
|
if ($role === static::ROLE_DEFAULT) { |
1849
|
|
|
return $this; |
1850
|
|
|
} |
1851
|
|
|
|
1852
|
|
|
if (!\in_array($role, $this->roles, true)) { |
1853
|
|
|
$this->roles[] = $role; |
1854
|
|
|
} |
1855
|
|
|
|
1856
|
|
|
return $this; |
1857
|
|
|
} |
1858
|
|
|
|
1859
|
|
|
public function removeRole(string $role): self |
1860
|
|
|
{ |
1861
|
|
|
if (false !== $key = array_search(strtoupper($role), $this->roles, true)) { |
1862
|
|
|
unset($this->roles[$key]); |
1863
|
|
|
$this->roles = array_values($this->roles); |
1864
|
|
|
} |
1865
|
|
|
|
1866
|
|
|
return $this; |
1867
|
|
|
} |
1868
|
|
|
|
1869
|
|
|
public function getUsernameCanonical(): string |
1870
|
|
|
{ |
1871
|
|
|
return $this->usernameCanonical; |
1872
|
|
|
} |
1873
|
|
|
|
1874
|
|
|
public function setUsernameCanonical(string $usernameCanonical): self |
1875
|
|
|
{ |
1876
|
|
|
$this->usernameCanonical = $usernameCanonical; |
1877
|
|
|
|
1878
|
|
|
return $this; |
1879
|
|
|
} |
1880
|
|
|
|
1881
|
|
|
public function getEmailCanonical(): string |
1882
|
|
|
{ |
1883
|
|
|
return $this->emailCanonical; |
1884
|
|
|
} |
1885
|
|
|
|
1886
|
|
|
public function setEmailCanonical(string $emailCanonical): self |
1887
|
|
|
{ |
1888
|
|
|
$this->emailCanonical = $emailCanonical; |
1889
|
|
|
|
1890
|
|
|
return $this; |
1891
|
|
|
} |
1892
|
|
|
|
1893
|
|
|
public function getTimezone(): string |
1894
|
|
|
{ |
1895
|
|
|
return $this->timezone; |
1896
|
|
|
} |
1897
|
|
|
|
1898
|
|
|
public function setTimezone(string $timezone): self |
1899
|
|
|
{ |
1900
|
|
|
$this->timezone = $timezone; |
1901
|
|
|
|
1902
|
|
|
return $this; |
1903
|
|
|
} |
1904
|
|
|
|
1905
|
|
|
public function getLocale(): string |
1906
|
|
|
{ |
1907
|
|
|
return $this->locale; |
1908
|
|
|
} |
1909
|
|
|
|
1910
|
|
|
public function setLocale(string $locale): self |
1911
|
|
|
{ |
1912
|
|
|
$this->locale = $locale; |
1913
|
|
|
|
1914
|
|
|
return $this; |
1915
|
|
|
} |
1916
|
|
|
|
1917
|
|
|
public function getApiToken(): ?string |
1918
|
|
|
{ |
1919
|
|
|
return $this->apiToken; |
1920
|
|
|
} |
1921
|
|
|
|
1922
|
|
|
public function setApiToken(string $apiToken): self |
1923
|
|
|
{ |
1924
|
|
|
$this->apiToken = $apiToken; |
1925
|
|
|
|
1926
|
|
|
return $this; |
1927
|
|
|
} |
1928
|
|
|
|
1929
|
|
|
public function getWebsite(): ?string |
1930
|
|
|
{ |
1931
|
|
|
return $this->website; |
1932
|
|
|
} |
1933
|
|
|
|
1934
|
|
|
public function setWebsite(string $website): self |
1935
|
|
|
{ |
1936
|
|
|
$this->website = $website; |
1937
|
|
|
|
1938
|
|
|
return $this; |
1939
|
|
|
} |
1940
|
|
|
|
1941
|
|
|
public function getBiography(): ?string |
1942
|
|
|
{ |
1943
|
|
|
return $this->biography; |
1944
|
|
|
} |
1945
|
|
|
|
1946
|
|
|
public function setBiography(string $biography): self |
1947
|
|
|
{ |
1948
|
|
|
$this->biography = $biography; |
1949
|
|
|
|
1950
|
|
|
return $this; |
1951
|
|
|
} |
1952
|
|
|
|
1953
|
|
|
public function getDateOfBirth(): ?DateTime |
1954
|
|
|
{ |
1955
|
|
|
return $this->dateOfBirth; |
1956
|
|
|
} |
1957
|
|
|
|
1958
|
|
|
public function setDateOfBirth(DateTime $dateOfBirth = null): self |
1959
|
|
|
{ |
1960
|
|
|
$this->dateOfBirth = $dateOfBirth; |
1961
|
|
|
|
1962
|
|
|
return $this; |
1963
|
|
|
} |
1964
|
|
|
|
1965
|
|
|
public function getProfileUrl(): string |
1966
|
|
|
{ |
1967
|
|
|
return '/main/social/profile.php?u='.$this->id; |
1968
|
|
|
} |
1969
|
|
|
|
1970
|
|
|
public function getIconStatus(): string |
1971
|
|
|
{ |
1972
|
|
|
$hasCertificates = $this->getGradeBookCertificates()->count() > 0; |
1973
|
|
|
$urlImg = '/img/'; |
1974
|
|
|
|
1975
|
|
|
if ($this->isStudent()) { |
1976
|
|
|
$iconStatus = $urlImg.'icons/svg/identifier_student.svg'; |
1977
|
|
|
if ($hasCertificates) { |
1978
|
|
|
$iconStatus = $urlImg.'icons/svg/identifier_graduated.svg'; |
1979
|
|
|
} |
1980
|
|
|
|
1981
|
|
|
return $iconStatus; |
1982
|
|
|
} |
1983
|
|
|
|
1984
|
|
|
if ($this->isTeacher()) { |
1985
|
|
|
$iconStatus = $urlImg.'icons/svg/identifier_teacher.svg'; |
1986
|
|
|
if ($this->isAdmin()) { |
1987
|
|
|
$iconStatus = $urlImg.'icons/svg/identifier_admin.svg'; |
1988
|
|
|
} |
1989
|
|
|
|
1990
|
|
|
return $iconStatus; |
1991
|
|
|
} |
1992
|
|
|
|
1993
|
|
|
if ($this->isStudentBoss()) { |
1994
|
|
|
return $urlImg.'icons/svg/identifier_teacher.svg'; |
1995
|
|
|
} |
1996
|
|
|
|
1997
|
|
|
return ''; |
1998
|
|
|
} |
1999
|
|
|
|
2000
|
|
|
public function getStatus(): int |
2001
|
|
|
{ |
2002
|
|
|
return $this->status; |
2003
|
|
|
} |
2004
|
|
|
|
2005
|
|
|
public function setStatus(int $status): self |
2006
|
|
|
{ |
2007
|
|
|
$this->status = $status; |
2008
|
|
|
|
2009
|
|
|
return $this; |
2010
|
|
|
} |
2011
|
|
|
|
2012
|
|
|
public function getPictureUri(): ?string |
2013
|
|
|
{ |
2014
|
|
|
return $this->pictureUri; |
2015
|
|
|
} |
2016
|
|
|
|
2017
|
|
|
public function getGradeBookCertificates(): Collection |
2018
|
|
|
{ |
2019
|
|
|
return $this->gradeBookCertificates; |
2020
|
|
|
} |
2021
|
|
|
|
2022
|
|
|
/** |
2023
|
|
|
* @param Collection<int, GradebookCertificate>|GradebookCertificate[] $gradeBookCertificates |
2024
|
|
|
*/ |
2025
|
|
|
public function setGradeBookCertificates(Collection $gradeBookCertificates): self |
2026
|
|
|
{ |
2027
|
|
|
$this->gradeBookCertificates = $gradeBookCertificates; |
2028
|
|
|
|
2029
|
|
|
return $this; |
2030
|
|
|
} |
2031
|
|
|
|
2032
|
|
|
public function isStudent(): bool |
2033
|
|
|
{ |
2034
|
|
|
return $this->hasRole('ROLE_STUDENT'); |
2035
|
|
|
} |
2036
|
|
|
|
2037
|
|
|
public function isStudentBoss(): bool |
2038
|
|
|
{ |
2039
|
|
|
return $this->hasRole('ROLE_STUDENT_BOSS'); |
2040
|
|
|
} |
2041
|
|
|
|
2042
|
|
|
public function isTeacher(): bool |
2043
|
|
|
{ |
2044
|
|
|
return $this->hasRole('ROLE_TEACHER'); |
2045
|
|
|
} |
2046
|
|
|
|
2047
|
|
|
public function isAdmin(): bool |
2048
|
|
|
{ |
2049
|
|
|
return $this->hasRole('ROLE_ADMIN'); |
2050
|
|
|
} |
2051
|
|
|
|
2052
|
|
|
/** |
2053
|
|
|
* @return GradebookCategory[]|Collection |
2054
|
|
|
*/ |
2055
|
|
|
public function getGradeBookCategories() |
2056
|
|
|
{ |
2057
|
|
|
return $this->gradeBookCategories; |
2058
|
|
|
} |
2059
|
|
|
|
2060
|
|
|
/** |
2061
|
|
|
* @return GradebookComment[]|Collection |
2062
|
|
|
*/ |
2063
|
|
|
public function getGradeBookComments() |
2064
|
|
|
{ |
2065
|
|
|
return $this->gradeBookComments; |
2066
|
|
|
} |
2067
|
|
|
|
2068
|
|
|
/** |
2069
|
|
|
* @return GradebookEvaluation[]|Collection |
2070
|
|
|
*/ |
2071
|
|
|
public function getGradeBookEvaluations() |
2072
|
|
|
{ |
2073
|
|
|
return $this->gradeBookEvaluations; |
2074
|
|
|
} |
2075
|
|
|
|
2076
|
|
|
/** |
2077
|
|
|
* @return GradebookLink[]|Collection |
2078
|
|
|
*/ |
2079
|
|
|
public function getGradeBookLinks() |
2080
|
|
|
{ |
2081
|
|
|
return $this->gradeBookLinks; |
2082
|
|
|
} |
2083
|
|
|
|
2084
|
|
|
/** |
2085
|
|
|
* @return GradebookResult[]|Collection |
2086
|
|
|
*/ |
2087
|
|
|
public function getGradeBookResults() |
2088
|
|
|
{ |
2089
|
|
|
return $this->gradeBookResults; |
2090
|
|
|
} |
2091
|
|
|
|
2092
|
|
|
/** |
2093
|
|
|
* @return GradebookResultLog[]|Collection |
2094
|
|
|
*/ |
2095
|
|
|
public function getGradeBookResultLogs() |
2096
|
|
|
{ |
2097
|
|
|
return $this->gradeBookResultLogs; |
2098
|
|
|
} |
2099
|
|
|
|
2100
|
|
|
/** |
2101
|
|
|
* @return GradebookScoreLog[]|Collection |
2102
|
|
|
*/ |
2103
|
|
|
public function getGradeBookScoreLogs() |
2104
|
|
|
{ |
2105
|
|
|
return $this->gradeBookScoreLogs; |
2106
|
|
|
} |
2107
|
|
|
|
2108
|
|
|
/** |
2109
|
|
|
* @return GradebookLinkevalLog[]|Collection |
2110
|
|
|
*/ |
2111
|
|
|
public function getGradeBookLinkEvalLogs() |
2112
|
|
|
{ |
2113
|
|
|
return $this->gradeBookLinkEvalLogs; |
2114
|
|
|
} |
2115
|
|
|
|
2116
|
|
|
/** |
2117
|
|
|
* @return UserRelCourseVote[]|Collection |
2118
|
|
|
*/ |
2119
|
|
|
public function getUserRelCourseVotes() |
2120
|
|
|
{ |
2121
|
|
|
return $this->userRelCourseVotes; |
2122
|
|
|
} |
2123
|
|
|
|
2124
|
|
|
/** |
2125
|
|
|
* @return UserRelTag[]|Collection |
2126
|
|
|
*/ |
2127
|
|
|
public function getUserRelTags() |
2128
|
|
|
{ |
2129
|
|
|
return $this->userRelTags; |
2130
|
|
|
} |
2131
|
|
|
|
2132
|
|
|
/** |
2133
|
|
|
* @return PersonalAgenda[]|Collection |
2134
|
|
|
*/ |
2135
|
|
|
public function getPersonalAgendas() |
2136
|
|
|
{ |
2137
|
|
|
return $this->personalAgendas; |
2138
|
|
|
} |
2139
|
|
|
|
2140
|
|
|
/** |
2141
|
|
|
* @return Collection|mixed[] |
2142
|
|
|
*/ |
2143
|
|
|
public function getCurriculumItems() |
2144
|
|
|
{ |
2145
|
|
|
return $this->curriculumItems; |
2146
|
|
|
} |
2147
|
|
|
|
2148
|
|
|
/** |
2149
|
|
|
* @return UserRelUser[]|Collection |
2150
|
|
|
*/ |
2151
|
|
|
public function getFriends() |
2152
|
|
|
{ |
2153
|
|
|
return $this->friends; |
2154
|
|
|
} |
2155
|
|
|
|
2156
|
|
|
/** |
2157
|
|
|
* @param int $relationType Example: UserRelUser::USER_RELATION_TYPE_BOSS |
2158
|
|
|
* |
2159
|
|
|
* @return UserRelUser[]|Collection |
2160
|
|
|
*/ |
2161
|
|
|
public function getFriendsByRelationType(int $relationType) |
2162
|
|
|
{ |
2163
|
|
|
return $this->friends->filter(function (UserRelUser $userRelUser) use ($relationType) { |
2164
|
|
|
return $relationType === $userRelUser->getRelationType(); |
2165
|
|
|
}); |
2166
|
|
|
} |
2167
|
|
|
|
2168
|
|
|
/** |
2169
|
|
|
* @return UserRelUser[]|Collection |
2170
|
|
|
*/ |
2171
|
|
|
public function getFriendsWithMe() |
2172
|
|
|
{ |
2173
|
|
|
return $this->friendsWithMe; |
2174
|
|
|
} |
2175
|
|
|
|
2176
|
|
|
public function addFriend(self $friend): self |
2177
|
|
|
{ |
2178
|
|
|
return $this->addUserRelUser($friend, UserRelUser::USER_RELATION_TYPE_FRIEND); |
2179
|
|
|
} |
2180
|
|
|
|
2181
|
|
|
public function addUserRelUser(self $friend, int $relationType): self |
2182
|
|
|
{ |
2183
|
|
|
$userRelUser = (new UserRelUser()) |
2184
|
|
|
->setUser($this) |
2185
|
|
|
->setFriend($friend) |
2186
|
|
|
->setRelationType($relationType) |
2187
|
|
|
; |
2188
|
|
|
$this->friends->add($userRelUser); |
2189
|
|
|
|
2190
|
|
|
return $this; |
2191
|
|
|
} |
2192
|
|
|
|
2193
|
|
|
/** |
2194
|
|
|
* @return Templates[]|Collection |
2195
|
|
|
*/ |
2196
|
|
|
public function getTemplates() |
2197
|
|
|
{ |
2198
|
|
|
return $this->templates; |
2199
|
|
|
} |
2200
|
|
|
|
2201
|
|
|
/** |
2202
|
|
|
* @return ArrayCollection|Collection |
2203
|
|
|
*/ |
2204
|
|
|
public function getDropBoxReceivedFiles() |
2205
|
|
|
{ |
2206
|
|
|
return $this->dropBoxReceivedFiles; |
2207
|
|
|
} |
2208
|
|
|
|
2209
|
|
|
/** |
2210
|
|
|
* @return SequenceValue[]|Collection |
2211
|
|
|
*/ |
2212
|
|
|
public function getSequenceValues() |
2213
|
|
|
{ |
2214
|
|
|
return $this->sequenceValues; |
2215
|
|
|
} |
2216
|
|
|
|
2217
|
|
|
/** |
2218
|
|
|
* @return TrackEExerciseConfirmation[]|Collection |
2219
|
|
|
*/ |
2220
|
|
|
public function getTrackEExerciseConfirmations() |
2221
|
|
|
{ |
2222
|
|
|
return $this->trackEExerciseConfirmations; |
2223
|
|
|
} |
2224
|
|
|
|
2225
|
|
|
/** |
2226
|
|
|
* @return TrackEAttempt[]|Collection |
2227
|
|
|
*/ |
2228
|
|
|
public function getTrackEAccessCompleteList() |
2229
|
|
|
{ |
2230
|
|
|
return $this->trackEAccessCompleteList; |
2231
|
|
|
} |
2232
|
|
|
|
2233
|
|
|
/** |
2234
|
|
|
* @return TrackEAttempt[]|Collection |
2235
|
|
|
*/ |
2236
|
|
|
public function getTrackEAttempts() |
2237
|
|
|
{ |
2238
|
|
|
return $this->trackEAttempts; |
2239
|
|
|
} |
2240
|
|
|
|
2241
|
|
|
/** |
2242
|
|
|
* @return TrackECourseAccess[]|Collection |
2243
|
|
|
*/ |
2244
|
|
|
public function getTrackECourseAccess() |
2245
|
|
|
{ |
2246
|
|
|
return $this->trackECourseAccess; |
2247
|
|
|
} |
2248
|
|
|
|
2249
|
|
|
/** |
2250
|
|
|
* @return UserCourseCategory[]|Collection |
2251
|
|
|
*/ |
2252
|
|
|
public function getUserCourseCategories() |
2253
|
|
|
{ |
2254
|
|
|
return $this->userCourseCategories; |
2255
|
|
|
} |
2256
|
|
|
|
2257
|
|
|
public function getCourseGroupsAsTutorFromCourse(Course $course): Collection |
2258
|
|
|
{ |
2259
|
|
|
$criteria = Criteria::create(); |
2260
|
|
|
$criteria->where( |
2261
|
|
|
Criteria::expr()->eq('cId', $course->getId()) |
2262
|
|
|
); |
2263
|
|
|
|
2264
|
|
|
return $this->courseGroupsAsTutor->matching($criteria); |
2265
|
|
|
} |
2266
|
|
|
|
2267
|
|
|
/** |
2268
|
|
|
* Retrieves this user's related student sessions. |
2269
|
|
|
* |
2270
|
|
|
* @return Session[] |
2271
|
|
|
*/ |
2272
|
|
|
public function getStudentSessions(): array |
2273
|
|
|
{ |
2274
|
|
|
return $this->getSessions(0); |
2275
|
|
|
} |
2276
|
|
|
|
2277
|
|
|
/** |
2278
|
|
|
* @return SessionRelUser[]|Collection |
2279
|
|
|
*/ |
2280
|
|
|
public function getSessionsRelUser() |
2281
|
|
|
{ |
2282
|
|
|
return $this->sessionsRelUser; |
2283
|
|
|
} |
2284
|
|
|
|
2285
|
|
|
public function isSkipResourceNode(): bool |
2286
|
|
|
{ |
2287
|
|
|
return $this->skipResourceNode; |
2288
|
|
|
} |
2289
|
|
|
|
2290
|
|
|
public function setSkipResourceNode(bool $skipResourceNode): self |
2291
|
|
|
{ |
2292
|
|
|
$this->skipResourceNode = $skipResourceNode; |
2293
|
|
|
|
2294
|
|
|
return $this; |
2295
|
|
|
} |
2296
|
|
|
|
2297
|
|
|
/** |
2298
|
|
|
* Retrieves this user's related sessions. |
2299
|
|
|
* |
2300
|
|
|
* @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key |
2301
|
|
|
* |
2302
|
|
|
* @return Session[] |
2303
|
|
|
*/ |
2304
|
|
|
public function getSessions(int $relationType): array |
2305
|
|
|
{ |
2306
|
|
|
$sessions = []; |
2307
|
|
|
foreach ($this->getSessionsRelUser() as $sessionRelUser) { |
2308
|
|
|
if ($sessionRelUser->getRelationType() === $relationType) { |
2309
|
|
|
$sessions[] = $sessionRelUser->getSession(); |
2310
|
|
|
} |
2311
|
|
|
} |
2312
|
|
|
|
2313
|
|
|
return $sessions; |
2314
|
|
|
} |
2315
|
|
|
|
2316
|
|
|
/** |
2317
|
|
|
* Retrieves this user's related DRH sessions. |
2318
|
|
|
* |
2319
|
|
|
* @return Session[] |
2320
|
|
|
*/ |
2321
|
|
|
public function getDRHSessions(): array |
2322
|
|
|
{ |
2323
|
|
|
return $this->getSessions(1); |
2324
|
|
|
} |
2325
|
|
|
|
2326
|
|
|
/** |
2327
|
|
|
* Get this user's related accessible sessions of a type, student by default. |
2328
|
|
|
* |
2329
|
|
|
* @param int $relationType \Chamilo\CoreBundle\Entity\SessionRelUser::relationTypeList key |
2330
|
|
|
* |
2331
|
|
|
* @return Session[] |
2332
|
|
|
*/ |
2333
|
|
|
public function getCurrentlyAccessibleSessions(int $relationType = 0): array |
2334
|
|
|
{ |
2335
|
|
|
$sessions = []; |
2336
|
|
|
foreach ($this->getSessions($relationType) as $session) { |
2337
|
|
|
if ($session->isCurrentlyAccessible()) { |
2338
|
|
|
$sessions[] = $session; |
2339
|
|
|
} |
2340
|
|
|
} |
2341
|
|
|
|
2342
|
|
|
return $sessions; |
2343
|
|
|
} |
2344
|
|
|
|
2345
|
|
|
public function getResourceIdentifier(): int |
2346
|
|
|
{ |
2347
|
|
|
return $this->id; |
|
|
|
|
2348
|
|
|
} |
2349
|
|
|
|
2350
|
|
|
public function getResourceName(): string |
2351
|
|
|
{ |
2352
|
|
|
return $this->getUsername(); |
2353
|
|
|
} |
2354
|
|
|
|
2355
|
|
|
public function setResourceName(string $name): void |
2356
|
|
|
{ |
2357
|
|
|
$this->setUsername($name); |
2358
|
|
|
} |
2359
|
|
|
|
2360
|
|
|
public function setParent(AbstractResource $parent): void |
2361
|
|
|
{ |
2362
|
|
|
} |
2363
|
|
|
|
2364
|
|
|
public function getDefaultIllustration(int $size): string |
2365
|
|
|
{ |
2366
|
|
|
$size = empty($size) ? 32 : $size; |
2367
|
|
|
|
2368
|
|
|
return sprintf('/img/icons/%s/unknown.png', $size); |
2369
|
|
|
} |
2370
|
|
|
|
2371
|
|
|
public function getAdmin(): ?Admin |
2372
|
|
|
{ |
2373
|
|
|
return $this->admin; |
2374
|
|
|
} |
2375
|
|
|
|
2376
|
|
|
public function setAdmin(?Admin $admin): self |
2377
|
|
|
{ |
2378
|
|
|
$this->admin = $admin; |
2379
|
|
|
|
2380
|
|
|
return $this; |
2381
|
|
|
} |
2382
|
|
|
|
2383
|
|
|
public function addUserAsAdmin(): self |
2384
|
|
|
{ |
2385
|
|
|
if (null === $this->admin) { |
2386
|
|
|
$admin = new Admin(); |
2387
|
|
|
$admin->setUser($this); |
2388
|
|
|
$this->setAdmin($admin); |
2389
|
|
|
} |
2390
|
|
|
|
2391
|
|
|
return $this; |
2392
|
|
|
} |
2393
|
|
|
|
2394
|
|
|
/** |
2395
|
|
|
* @return SessionRelCourseRelUser[]|Collection |
2396
|
|
|
*/ |
2397
|
|
|
public function getSessionRelCourseRelUsers() |
2398
|
|
|
{ |
2399
|
|
|
return $this->sessionRelCourseRelUsers; |
2400
|
|
|
} |
2401
|
|
|
|
2402
|
|
|
/** |
2403
|
|
|
* @param SessionRelCourseRelUser[]|Collection $sessionRelCourseRelUsers |
2404
|
|
|
*/ |
2405
|
|
|
public function setSessionRelCourseRelUsers($sessionRelCourseRelUsers): self |
2406
|
|
|
{ |
2407
|
|
|
$this->sessionRelCourseRelUsers = $sessionRelCourseRelUsers; |
2408
|
|
|
|
2409
|
|
|
return $this; |
2410
|
|
|
} |
2411
|
|
|
|
2412
|
|
|
public function getGender(): ?string |
2413
|
|
|
{ |
2414
|
|
|
return $this->gender; |
2415
|
|
|
} |
2416
|
|
|
|
2417
|
|
|
public function setGender(?string $gender): self |
2418
|
|
|
{ |
2419
|
|
|
$this->gender = $gender; |
2420
|
|
|
|
2421
|
|
|
return $this; |
2422
|
|
|
} |
2423
|
|
|
|
2424
|
|
|
/** |
2425
|
|
|
* @return CSurveyInvitation[]|Collection |
2426
|
|
|
*/ |
2427
|
|
|
public function getSurveyInvitations() |
2428
|
|
|
{ |
2429
|
|
|
return $this->surveyInvitations; |
2430
|
|
|
} |
2431
|
|
|
|
2432
|
|
|
public function setSurveyInvitations(Collection $surveyInvitations): self |
2433
|
|
|
{ |
2434
|
|
|
$this->surveyInvitations = $surveyInvitations; |
2435
|
|
|
|
2436
|
|
|
return $this; |
2437
|
|
|
} |
2438
|
|
|
|
2439
|
|
|
/** |
2440
|
|
|
* @return TrackELogin[]|Collection |
2441
|
|
|
*/ |
2442
|
|
|
public function getLogins() |
2443
|
|
|
{ |
2444
|
|
|
return $this->logins; |
2445
|
|
|
} |
2446
|
|
|
|
2447
|
|
|
public function setLogins(Collection $logins): self |
2448
|
|
|
{ |
2449
|
|
|
$this->logins = $logins; |
2450
|
|
|
|
2451
|
|
|
return $this; |
2452
|
|
|
} |
2453
|
|
|
|
2454
|
|
|
/** |
2455
|
|
|
* @todo move in a repo |
2456
|
|
|
* Find the largest sort value in a given UserCourseCategory |
2457
|
|
|
* This method is used when we are moving a course to a different category |
2458
|
|
|
* and also when a user subscribes to courses (the new course is added at the end of the main category). |
2459
|
|
|
* |
2460
|
|
|
* Used to be implemented in global function \api_max_sort_value. |
2461
|
|
|
* Reimplemented using the ORM cache. |
2462
|
|
|
* |
2463
|
|
|
* @param null|UserCourseCategory $userCourseCategory the user_course_category |
2464
|
|
|
*/ |
2465
|
|
|
public function getMaxSortValue(?UserCourseCategory $userCourseCategory = null): int |
2466
|
|
|
{ |
2467
|
|
|
$categoryCourses = $this->courses->matching( |
2468
|
|
|
Criteria::create() |
2469
|
|
|
->where(Criteria::expr()->neq('relationType', COURSE_RELATION_TYPE_RRHH)) |
2470
|
|
|
->andWhere(Criteria::expr()->eq('userCourseCat', $userCourseCategory)) |
2471
|
|
|
); |
2472
|
|
|
|
2473
|
|
|
return $categoryCourses->isEmpty() |
2474
|
|
|
? 0 |
2475
|
|
|
: max( |
2476
|
|
|
$categoryCourses->map( |
2477
|
|
|
function ($courseRelUser) { |
2478
|
|
|
return $courseRelUser->getSort(); |
2479
|
|
|
} |
2480
|
|
|
)->toArray() |
2481
|
|
|
); |
2482
|
|
|
} |
2483
|
|
|
} |
2484
|
|
|
|