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