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