| Total Complexity | 141 |
| Total Lines | 1896 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| 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 |
||
| 73 | class User extends BaseUser implements ThemeUser, EquatableInterface //implements ParticipantInterface, ThemeUser |
||
| 74 | { |
||
| 75 | public const COURSE_MANAGER = 1; |
||
| 76 | public const TEACHER = 1; |
||
| 77 | public const SESSION_ADMIN = 3; |
||
| 78 | public const DRH = 4; |
||
| 79 | public const STUDENT = 5; |
||
| 80 | public const ANONYMOUS = 6; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var int |
||
| 84 | * |
||
| 85 | * @ORM\Column(name="id", type="integer") |
||
| 86 | * @ORM\Id |
||
| 87 | * @ORM\GeneratedValue(strategy="AUTO") |
||
| 88 | */ |
||
| 89 | protected $id; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @var int |
||
| 93 | * |
||
| 94 | * @ORM\Column(name="user_id", type="integer", nullable=true) |
||
| 95 | */ |
||
| 96 | protected $userId; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var string |
||
| 100 | * |
||
| 101 | * @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true) |
||
| 102 | */ |
||
| 103 | //protected $username; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @var string |
||
| 107 | * |
||
| 108 | * @ORM\Column(name="username_canonical", type="string", length=100, nullable=false) |
||
| 109 | */ |
||
| 110 | //protected $usernameCanonical; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var string |
||
| 114 | * @ORM\Column(name="email_canonical", type="string", length=100, nullable=false, unique=false) |
||
| 115 | */ |
||
| 116 | //protected $emailCanonical; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @var string |
||
| 120 | * |
||
| 121 | * @ORM\Column(name="email", type="string", length=100, nullable=false, unique=false) |
||
| 122 | */ |
||
| 123 | //protected $email; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @var bool |
||
| 127 | * |
||
| 128 | * @ORM\Column(name="locked", type="boolean") |
||
| 129 | */ |
||
| 130 | protected $locked; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @var bool |
||
| 134 | * |
||
| 135 | * @ORM\Column(name="enabled", type="boolean") |
||
| 136 | */ |
||
| 137 | //protected $enabled; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @var bool |
||
| 141 | * |
||
| 142 | * @ORM\Column(name="expired", type="boolean") |
||
| 143 | */ |
||
| 144 | protected $expired; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @var bool |
||
| 148 | * |
||
| 149 | * @ORM\Column(name="credentials_expired", type="boolean") |
||
| 150 | */ |
||
| 151 | protected $credentialsExpired; |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @var \DateTime |
||
| 155 | * |
||
| 156 | * @ORM\Column(name="credentials_expire_at", type="datetime", nullable=true, unique=false) |
||
| 157 | */ |
||
| 158 | protected $credentialsExpireAt; |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @var \DateTime |
||
| 162 | * |
||
| 163 | * @ORM\Column(name="expires_at", type="datetime", nullable=true, unique=false) |
||
| 164 | */ |
||
| 165 | protected $expiresAt; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @var string |
||
| 169 | * |
||
| 170 | * @ORM\Column(name="phone", type="string", length=30, nullable=true, unique=false) |
||
| 171 | */ |
||
| 172 | //protected $phone; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @var string |
||
| 176 | * |
||
| 177 | * @ORM\Column(name="address", type="string", length=250, nullable=true, unique=false) |
||
| 178 | */ |
||
| 179 | protected $address; |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @var AccessUrl |
||
| 183 | */ |
||
| 184 | protected $currentUrl; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @ORM\Column(type="string", length=255) |
||
| 188 | */ |
||
| 189 | //protected $salt; |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @var \DateTime |
||
| 193 | * |
||
| 194 | * @ORM\Column(name="last_login", type="datetime", nullable=true, unique=false) |
||
| 195 | */ |
||
| 196 | //protected $lastLogin; |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Random string sent to the user email address in order to verify it. |
||
| 200 | * |
||
| 201 | * @var string |
||
| 202 | * @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true) |
||
| 203 | */ |
||
| 204 | //protected $confirmationToken; |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @var \DateTime |
||
| 208 | * |
||
| 209 | * @ORM\Column(name="password_requested_at", type="datetime", nullable=true, unique=false) |
||
| 210 | */ |
||
| 211 | //protected $passwordRequestedAt; |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user", orphanRemoval=true) |
||
| 215 | */ |
||
| 216 | protected $courses; |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="user") |
||
| 220 | */ |
||
| 221 | //protected $items; |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user") |
||
| 225 | */ |
||
| 226 | protected $classes; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user"). |
||
| 230 | */ |
||
| 231 | protected $dropBoxReceivedFiles; |
||
| 232 | |||
| 233 | /** |
||
| 234 | * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent"). |
||
| 235 | */ |
||
| 236 | protected $dropBoxSentFiles; |
||
| 237 | |||
| 238 | /** |
||
| 239 | * @ORM\Column(type="array") |
||
| 240 | */ |
||
| 241 | //protected $roles; |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @var bool |
||
| 245 | * |
||
| 246 | * @ORM\Column(name="profile_completed", type="boolean", nullable=true) |
||
| 247 | */ |
||
| 248 | protected $profileCompleted; |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user") |
||
| 252 | */ |
||
| 253 | //protected $jurySubscriptions; |
||
| 254 | |||
| 255 | /** |
||
| 256 | * @ORM\ManyToMany(targetEntity="Chamilo\UserBundle\Entity\Group", inversedBy="users") |
||
| 257 | * @ORM\JoinTable(name="fos_user_user_group", |
||
| 258 | * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}, |
||
| 259 | * inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")} |
||
| 260 | * ) |
||
| 261 | */ |
||
| 262 | protected $groups; |
||
| 263 | |||
| 264 | //private $isActive; |
||
| 265 | |||
| 266 | /** |
||
| 267 | * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user"). |
||
| 268 | */ |
||
| 269 | protected $curriculumItems; |
||
| 270 | |||
| 271 | /** |
||
| 272 | * @ORM\OneToMany( |
||
| 273 | * targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelUser", |
||
| 274 | * mappedBy="user", |
||
| 275 | * cascade={"persist", "remove"}, |
||
| 276 | * orphanRemoval=true |
||
| 277 | * ) |
||
| 278 | */ |
||
| 279 | protected $portals; |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @var ArrayCollection |
||
| 283 | * |
||
| 284 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach") |
||
| 285 | */ |
||
| 286 | protected $sessionAsGeneralCoach; |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="creator"). |
||
| 290 | */ |
||
| 291 | protected $resourceNodes; |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @ORM\OneToMany( |
||
| 295 | * targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", |
||
| 296 | * mappedBy="user", |
||
| 297 | * cascade={"persist"}, |
||
| 298 | * orphanRemoval=true |
||
| 299 | * ) |
||
| 300 | */ |
||
| 301 | protected $sessionCourseSubscriptions; |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @ORM\OneToMany( |
||
| 305 | * targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", |
||
| 306 | * mappedBy="user", |
||
| 307 | * cascade={"persist", "remove"}, |
||
| 308 | * orphanRemoval=true |
||
| 309 | * ) |
||
| 310 | */ |
||
| 311 | protected $achievedSkills; |
||
| 312 | |||
| 313 | /** |
||
| 314 | * @ORM\OneToMany( |
||
| 315 | * targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", |
||
| 316 | * mappedBy="feedbackGiver", |
||
| 317 | * cascade={"persist", "remove"}, |
||
| 318 | * orphanRemoval=true |
||
| 319 | * ) |
||
| 320 | */ |
||
| 321 | protected $commentedUserSkills; |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookCategory", mappedBy="user") |
||
| 325 | */ |
||
| 326 | protected $gradeBookCategories; |
||
| 327 | |||
| 328 | /** |
||
| 329 | * @ORM\OneToMany( |
||
| 330 | * targetEntity="Chamilo\CoreBundle\Entity\SessionRelUser", |
||
| 331 | * mappedBy="user", |
||
| 332 | * cascade={"persist", "remove"}, |
||
| 333 | * orphanRemoval=true |
||
| 334 | * ) |
||
| 335 | */ |
||
| 336 | protected $sessions; |
||
| 337 | |||
| 338 | /** |
||
| 339 | * @var Collection |
||
| 340 | * |
||
| 341 | * @ORM\OneToMany( |
||
| 342 | * targetEntity="Chamilo\CourseBundle\Entity\CGroupRelUser", |
||
| 343 | * mappedBy="user", |
||
| 344 | * cascade={"persist", "remove"}, |
||
| 345 | * orphanRemoval=true |
||
| 346 | * ) |
||
| 347 | */ |
||
| 348 | protected $courseGroupsAsMember; |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @var Collection |
||
| 352 | * |
||
| 353 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupRelTutor", mappedBy="user", orphanRemoval=true) |
||
| 354 | */ |
||
| 355 | protected $courseGroupsAsTutor; |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @var string |
||
| 359 | * |
||
| 360 | * @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false) |
||
| 361 | */ |
||
| 362 | protected $authSource; |
||
| 363 | |||
| 364 | /** |
||
| 365 | * @var int |
||
| 366 | * |
||
| 367 | * @ORM\Column(name="status", type="integer", nullable=false) |
||
| 368 | */ |
||
| 369 | protected $status; |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @var string |
||
| 373 | * |
||
| 374 | * @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false) |
||
| 375 | */ |
||
| 376 | protected $officialCode; |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @var string |
||
| 380 | * |
||
| 381 | * @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false) |
||
| 382 | */ |
||
| 383 | protected $pictureUri; |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @var int |
||
| 387 | * |
||
| 388 | * @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false) |
||
| 389 | */ |
||
| 390 | protected $creatorId; |
||
| 391 | |||
| 392 | /** |
||
| 393 | * @var string |
||
| 394 | * |
||
| 395 | * @ORM\Column(name="competences", type="text", nullable=true, unique=false) |
||
| 396 | */ |
||
| 397 | protected $competences; |
||
| 398 | |||
| 399 | /** |
||
| 400 | * @var string |
||
| 401 | * |
||
| 402 | * @ORM\Column(name="diplomas", type="text", nullable=true, unique=false) |
||
| 403 | */ |
||
| 404 | protected $diplomas; |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @var string |
||
| 408 | * |
||
| 409 | * @ORM\Column(name="openarea", type="text", nullable=true, unique=false) |
||
| 410 | */ |
||
| 411 | protected $openarea; |
||
| 412 | |||
| 413 | /** |
||
| 414 | * @var string |
||
| 415 | * |
||
| 416 | * @ORM\Column(name="teach", type="text", nullable=true, unique=false) |
||
| 417 | */ |
||
| 418 | protected $teach; |
||
| 419 | |||
| 420 | /** |
||
| 421 | * @var string |
||
| 422 | * |
||
| 423 | * @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false) |
||
| 424 | */ |
||
| 425 | protected $productions; |
||
| 426 | |||
| 427 | /** |
||
| 428 | * @var string |
||
| 429 | * |
||
| 430 | * @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false) |
||
| 431 | */ |
||
| 432 | protected $language; |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @var \DateTime |
||
| 436 | * |
||
| 437 | * @ORM\Column(name="registration_date", type="datetime", nullable=false, unique=false) |
||
| 438 | */ |
||
| 439 | protected $registrationDate; |
||
| 440 | |||
| 441 | /** |
||
| 442 | * @var \DateTime |
||
| 443 | * |
||
| 444 | * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false) |
||
| 445 | */ |
||
| 446 | protected $expirationDate; |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @var bool |
||
| 450 | * |
||
| 451 | * @ORM\Column(name="active", type="boolean", nullable=false, unique=false) |
||
| 452 | */ |
||
| 453 | protected $active; |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @var string |
||
| 457 | * |
||
| 458 | * @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false) |
||
| 459 | */ |
||
| 460 | protected $openid; |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @var string |
||
| 464 | * |
||
| 465 | * @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false) |
||
| 466 | */ |
||
| 467 | protected $theme; |
||
| 468 | |||
| 469 | /** |
||
| 470 | * @var int |
||
| 471 | * |
||
| 472 | * @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false) |
||
| 473 | */ |
||
| 474 | protected $hrDeptId; |
||
| 475 | |||
| 476 | /** |
||
| 477 | * @var ArrayCollection |
||
| 478 | * |
||
| 479 | * @ORM\OneToMany( |
||
| 480 | * targetEntity="Chamilo\CoreBundle\Entity\Message", |
||
| 481 | * mappedBy="userSender", |
||
| 482 | * cascade={"persist", "remove"}, |
||
| 483 | * orphanRemoval=true |
||
| 484 | * ) |
||
| 485 | */ |
||
| 486 | protected $sentMessages; |
||
| 487 | |||
| 488 | /** |
||
| 489 | * @var ArrayCollection |
||
| 490 | * |
||
| 491 | * @ORM\OneToMany( |
||
| 492 | * targetEntity="Chamilo\CoreBundle\Entity\Message", |
||
| 493 | * mappedBy="userReceiver", |
||
| 494 | * cascade={"persist", "remove"}, |
||
| 495 | * orphanRemoval=true |
||
| 496 | * ) |
||
| 497 | */ |
||
| 498 | protected $receivedMessages; |
||
| 499 | |||
| 500 | /** |
||
| 501 | * |
||
| 502 | * @ORM\OneToOne( |
||
| 503 | * targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", cascade={"remove"}, orphanRemoval=true |
||
| 504 | * ) |
||
| 505 | * @ORM\JoinColumn(name="resource_node_id", referencedColumnName="id", onDelete="CASCADE") |
||
| 506 | */ |
||
| 507 | public $resourceNode; |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @return $this |
||
| 511 | */ |
||
| 512 | public function setResourceNode(ResourceNode $resourceNode): self |
||
| 513 | { |
||
| 514 | $this->resourceNode = $resourceNode; |
||
| 515 | |||
| 516 | return $this; |
||
| 517 | } |
||
| 518 | |||
| 519 | public function getResourceNode(): ResourceNode |
||
| 520 | { |
||
| 521 | return $this->resourceNode; |
||
| 522 | } |
||
| 523 | |||
| 524 | /** |
||
| 525 | * Constructor. |
||
| 526 | */ |
||
| 527 | public function __construct() |
||
| 528 | { |
||
| 529 | parent::__construct(); |
||
| 530 | $this->status = self::STUDENT; |
||
| 531 | $this->salt = sha1(uniqid(null, true)); |
||
|
|
|||
| 532 | $this->active = true; |
||
| 533 | $this->registrationDate = new \DateTime(); |
||
| 534 | $this->authSource = 'platform'; |
||
| 535 | $this->courses = new ArrayCollection(); |
||
| 536 | //$this->items = new ArrayCollection(); |
||
| 537 | $this->classes = new ArrayCollection(); |
||
| 538 | $this->curriculumItems = new ArrayCollection(); |
||
| 539 | $this->portals = new ArrayCollection(); |
||
| 540 | $this->dropBoxSentFiles = new ArrayCollection(); |
||
| 541 | $this->dropBoxReceivedFiles = new ArrayCollection(); |
||
| 542 | //$this->extraFields = new ArrayCollection(); |
||
| 543 | //$this->userId = 0; |
||
| 544 | //$this->createdAt = new \DateTime(); |
||
| 545 | //$this->updatedAt = new \DateTime(); |
||
| 546 | |||
| 547 | $this->enabled = false; |
||
| 548 | $this->locked = false; |
||
| 549 | $this->expired = false; |
||
| 550 | $this->roles = []; |
||
| 551 | $this->credentialsExpired = false; |
||
| 552 | |||
| 553 | $this->courseGroupsAsMember = new ArrayCollection(); |
||
| 554 | $this->courseGroupsAsTutor = new ArrayCollection(); |
||
| 555 | } |
||
| 556 | |||
| 557 | /** |
||
| 558 | * @return string |
||
| 559 | */ |
||
| 560 | public function __toString() |
||
| 561 | { |
||
| 562 | return $this->username; |
||
| 563 | } |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Updates the id with the user_id. |
||
| 567 | * |
||
| 568 | * @ORM\PostPersist() |
||
| 569 | */ |
||
| 570 | public function postPersist(LifecycleEventArgs $args) |
||
| 571 | { |
||
| 572 | $user = $args->getEntity(); |
||
| 573 | $this->setUserId($user->getId()); |
||
| 574 | } |
||
| 575 | |||
| 576 | /** |
||
| 577 | * @param int $userId |
||
| 578 | */ |
||
| 579 | public function setId($userId) |
||
| 580 | { |
||
| 581 | $this->id = $userId; |
||
| 582 | } |
||
| 583 | |||
| 584 | /** |
||
| 585 | * @param int $userId |
||
| 586 | */ |
||
| 587 | public function setUserId($userId) |
||
| 588 | { |
||
| 589 | if (!empty($userId)) { |
||
| 590 | $this->userId = $userId; |
||
| 591 | } |
||
| 592 | } |
||
| 593 | |||
| 594 | /** |
||
| 595 | * @return int |
||
| 596 | */ |
||
| 597 | public function getId() |
||
| 598 | { |
||
| 599 | return $this->id; |
||
| 600 | } |
||
| 601 | |||
| 602 | /** |
||
| 603 | * @return ArrayCollection |
||
| 604 | */ |
||
| 605 | public function getDropBoxSentFiles() |
||
| 606 | { |
||
| 607 | return $this->dropBoxSentFiles; |
||
| 608 | } |
||
| 609 | |||
| 610 | /** |
||
| 611 | * @return ArrayCollection |
||
| 612 | */ |
||
| 613 | public function getDropBoxReceivedFiles() |
||
| 614 | { |
||
| 615 | return $this->dropBoxReceivedFiles; |
||
| 616 | } |
||
| 617 | |||
| 618 | /** |
||
| 619 | * @param ArrayCollection $value |
||
| 620 | */ |
||
| 621 | public function setDropBoxSentFiles($value) |
||
| 622 | { |
||
| 623 | $this->dropBoxSentFiles = $value; |
||
| 624 | } |
||
| 625 | |||
| 626 | /** |
||
| 627 | * @param ArrayCollection $value |
||
| 628 | */ |
||
| 629 | public function setDropBoxReceivedFiles($value) |
||
| 630 | { |
||
| 631 | $this->dropBoxReceivedFiles = $value; |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * @param ArrayCollection $courses |
||
| 636 | */ |
||
| 637 | public function setCourses($courses) |
||
| 638 | { |
||
| 639 | $this->courses = $courses; |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * @return ArrayCollection |
||
| 644 | */ |
||
| 645 | public function getCourses() |
||
| 646 | { |
||
| 647 | return $this->courses; |
||
| 648 | } |
||
| 649 | |||
| 650 | /** |
||
| 651 | * @return array |
||
| 652 | */ |
||
| 653 | public static function getPasswordConstraints() |
||
| 654 | { |
||
| 655 | return |
||
| 656 | [ |
||
| 657 | new Assert\Length(['min' => 5]), |
||
| 658 | // Alpha numeric + "_" or "-" |
||
| 659 | new Assert\Regex( |
||
| 660 | [ |
||
| 661 | 'pattern' => '/^[a-z\-_0-9]+$/i', |
||
| 662 | 'htmlPattern' => '/^[a-z\-_0-9]+$/i', ] |
||
| 663 | ), |
||
| 664 | // Min 3 letters - not needed |
||
| 665 | /*new Assert\Regex(array( |
||
| 666 | 'pattern' => '/[a-z]{3}/i', |
||
| 667 | 'htmlPattern' => '/[a-z]{3}/i') |
||
| 668 | ),*/ |
||
| 669 | // Min 2 numbers |
||
| 670 | new Assert\Regex( |
||
| 671 | [ |
||
| 672 | 'pattern' => '/[0-9]{2}/', |
||
| 673 | 'htmlPattern' => '/[0-9]{2}/', ] |
||
| 674 | ), |
||
| 675 | ] |
||
| 676 | ; |
||
| 677 | } |
||
| 678 | |||
| 679 | public static function loadValidatorMetadata(ClassMetadata $metadata) |
||
| 680 | { |
||
| 681 | //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank()); |
||
| 682 | //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank()); |
||
| 683 | //$metadata->addPropertyConstraint('email', new Assert\Email()); |
||
| 684 | /* |
||
| 685 | $metadata->addPropertyConstraint('password', |
||
| 686 | new Assert\Collection(self::getPasswordConstraints()) |
||
| 687 | );*/ |
||
| 688 | |||
| 689 | /*$metadata->addConstraint(new UniqueEntity(array( |
||
| 690 | 'fields' => 'username', |
||
| 691 | 'message' => 'This value is already used.', |
||
| 692 | )));*/ |
||
| 693 | |||
| 694 | /*$metadata->addPropertyConstraint( |
||
| 695 | 'username', |
||
| 696 | new Assert\Length(array( |
||
| 697 | 'min' => 2, |
||
| 698 | 'max' => 50, |
||
| 699 | '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.', |
||
| 700 | '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.', |
||
| 701 | )) |
||
| 702 | );*/ |
||
| 703 | } |
||
| 704 | |||
| 705 | /** |
||
| 706 | * @return ArrayCollection |
||
| 707 | */ |
||
| 708 | public function getPortals() |
||
| 709 | { |
||
| 710 | return $this->portals; |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * @param $portal |
||
| 715 | */ |
||
| 716 | public function setPortal($portal) |
||
| 717 | { |
||
| 718 | $this->portals->add($portal); |
||
| 719 | } |
||
| 720 | |||
| 721 | /** |
||
| 722 | * @param $value |
||
| 723 | */ |
||
| 724 | public function setPortals($value) |
||
| 725 | { |
||
| 726 | $this->portals = $value; |
||
| 727 | } |
||
| 728 | |||
| 729 | /** |
||
| 730 | * @return ArrayCollection |
||
| 731 | */ |
||
| 732 | public function getCurriculumItems() |
||
| 733 | { |
||
| 734 | return $this->curriculumItems; |
||
| 735 | } |
||
| 736 | |||
| 737 | /** |
||
| 738 | * @param $items |
||
| 739 | * |
||
| 740 | * @return $this |
||
| 741 | */ |
||
| 742 | public function setCurriculumItems($items) |
||
| 743 | { |
||
| 744 | $this->curriculumItems = $items; |
||
| 745 | |||
| 746 | return $this; |
||
| 747 | } |
||
| 748 | |||
| 749 | /** |
||
| 750 | * @return bool |
||
| 751 | */ |
||
| 752 | public function getIsActive() |
||
| 753 | { |
||
| 754 | return $this->active == 1; |
||
| 755 | } |
||
| 756 | |||
| 757 | /** |
||
| 758 | * @return bool |
||
| 759 | */ |
||
| 760 | public function isActive() |
||
| 761 | { |
||
| 762 | return $this->getIsActive(); |
||
| 763 | } |
||
| 764 | |||
| 765 | /** |
||
| 766 | * {@inheritdoc} |
||
| 767 | */ |
||
| 768 | public function isEnabled() |
||
| 769 | { |
||
| 770 | return $this->getActive() == 1; |
||
| 771 | } |
||
| 772 | |||
| 773 | /** |
||
| 774 | * @return ArrayCollection |
||
| 775 | */ |
||
| 776 | /*public function getRolesObj() |
||
| 777 | { |
||
| 778 | return $this->roles; |
||
| 779 | }*/ |
||
| 780 | |||
| 781 | /** |
||
| 782 | * Set salt. |
||
| 783 | * |
||
| 784 | * @param string $salt |
||
| 785 | * |
||
| 786 | * @return User |
||
| 787 | */ |
||
| 788 | public function setSalt($salt) |
||
| 789 | { |
||
| 790 | $this->salt = $salt; |
||
| 791 | |||
| 792 | return $this; |
||
| 793 | } |
||
| 794 | |||
| 795 | /** |
||
| 796 | * Get salt. |
||
| 797 | * |
||
| 798 | * @return string |
||
| 799 | */ |
||
| 800 | public function getSalt() |
||
| 801 | { |
||
| 802 | return $this->salt; |
||
| 803 | } |
||
| 804 | |||
| 805 | /** |
||
| 806 | * @param ArrayCollection $classes |
||
| 807 | * |
||
| 808 | * @return $this |
||
| 809 | */ |
||
| 810 | public function setClasses($classes) |
||
| 811 | { |
||
| 812 | $this->classes = $classes; |
||
| 813 | |||
| 814 | return $this; |
||
| 815 | } |
||
| 816 | |||
| 817 | /** |
||
| 818 | * @return ArrayCollection |
||
| 819 | */ |
||
| 820 | public function getClasses() |
||
| 821 | { |
||
| 822 | return $this->classes; |
||
| 823 | } |
||
| 824 | |||
| 825 | public function getLps() |
||
| 826 | { |
||
| 827 | //return $this->lps; |
||
| 828 | /*$criteria = Criteria::create() |
||
| 829 | ->where(Criteria::expr()->eq("id", "666")) |
||
| 830 | //->orderBy(array("username" => "ASC")) |
||
| 831 | //->setFirstResult(0) |
||
| 832 | //->setMaxResults(20) |
||
| 833 | ; |
||
| 834 | $lps = $this->lps->matching($criteria);*/ |
||
| 835 | /*return $this->lps->filter( |
||
| 836 | function($entry) use ($idsToFilter) { |
||
| 837 | return $entry->getId() == 1; |
||
| 838 | });*/ |
||
| 839 | } |
||
| 840 | |||
| 841 | /** |
||
| 842 | * Returns the list of classes for the user. |
||
| 843 | * |
||
| 844 | * @return string |
||
| 845 | */ |
||
| 846 | public function getCompleteNameWithClasses() |
||
| 847 | { |
||
| 848 | $classSubscription = $this->getClasses(); |
||
| 849 | $classList = []; |
||
| 850 | /** @var UsergroupRelUser $subscription */ |
||
| 851 | foreach ($classSubscription as $subscription) { |
||
| 852 | $class = $subscription->getUsergroup(); |
||
| 853 | $classList[] = $class->getName(); |
||
| 854 | } |
||
| 855 | $classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null; |
||
| 856 | |||
| 857 | return \UserManager::formatUserFullName($this).$classString; |
||
| 858 | } |
||
| 859 | |||
| 860 | /** |
||
| 861 | * Get userId. |
||
| 862 | * |
||
| 863 | * @return int |
||
| 864 | */ |
||
| 865 | public function getUserId() |
||
| 866 | { |
||
| 867 | return $this->userId; |
||
| 868 | } |
||
| 869 | |||
| 870 | /** |
||
| 871 | * Set lastname. |
||
| 872 | * |
||
| 873 | * @param string $lastname |
||
| 874 | * |
||
| 875 | * @return User |
||
| 876 | */ |
||
| 877 | public function setLastname($lastname) |
||
| 878 | { |
||
| 879 | $this->lastname = $lastname; |
||
| 880 | |||
| 881 | return $this; |
||
| 882 | } |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Set firstname. |
||
| 886 | * |
||
| 887 | * @param string $firstname |
||
| 888 | * |
||
| 889 | * @return User |
||
| 890 | */ |
||
| 891 | public function setFirstname($firstname) |
||
| 892 | { |
||
| 893 | $this->firstname = $firstname; |
||
| 894 | |||
| 895 | return $this; |
||
| 896 | } |
||
| 897 | |||
| 898 | /** |
||
| 899 | * Set password. |
||
| 900 | * |
||
| 901 | * @param string $password |
||
| 902 | * |
||
| 903 | * @return User |
||
| 904 | */ |
||
| 905 | public function setPassword($password) |
||
| 906 | { |
||
| 907 | $this->password = $password; |
||
| 908 | |||
| 909 | return $this; |
||
| 910 | } |
||
| 911 | |||
| 912 | /** |
||
| 913 | * Get password. |
||
| 914 | * |
||
| 915 | * @return string |
||
| 916 | */ |
||
| 917 | public function getPassword() |
||
| 918 | { |
||
| 919 | return $this->password; |
||
| 920 | } |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Set authSource. |
||
| 924 | * |
||
| 925 | * @param string $authSource |
||
| 926 | * |
||
| 927 | * @return User |
||
| 928 | */ |
||
| 929 | public function setAuthSource($authSource) |
||
| 930 | { |
||
| 931 | $this->authSource = $authSource; |
||
| 932 | |||
| 933 | return $this; |
||
| 934 | } |
||
| 935 | |||
| 936 | /** |
||
| 937 | * Get authSource. |
||
| 938 | * |
||
| 939 | * @return string |
||
| 940 | */ |
||
| 941 | public function getAuthSource() |
||
| 942 | { |
||
| 943 | return $this->authSource; |
||
| 944 | } |
||
| 945 | |||
| 946 | /** |
||
| 947 | * Set email. |
||
| 948 | * |
||
| 949 | * @param string $email |
||
| 950 | * |
||
| 951 | * @return User |
||
| 952 | */ |
||
| 953 | public function setEmail($email) |
||
| 954 | { |
||
| 955 | $this->email = $email; |
||
| 956 | |||
| 957 | return $this; |
||
| 958 | } |
||
| 959 | |||
| 960 | /** |
||
| 961 | * Get email. |
||
| 962 | * |
||
| 963 | * @return string |
||
| 964 | */ |
||
| 965 | public function getEmail() |
||
| 966 | { |
||
| 967 | return $this->email; |
||
| 968 | } |
||
| 969 | |||
| 970 | /** |
||
| 971 | * Set status. |
||
| 972 | * |
||
| 973 | * @param int $status |
||
| 974 | * |
||
| 975 | * @return User |
||
| 976 | */ |
||
| 977 | public function setStatus($status) |
||
| 978 | { |
||
| 979 | $this->status = $status; |
||
| 980 | |||
| 981 | return $this; |
||
| 982 | } |
||
| 983 | |||
| 984 | /** |
||
| 985 | * Get status. |
||
| 986 | * |
||
| 987 | * @return int |
||
| 988 | */ |
||
| 989 | public function getStatus() |
||
| 990 | { |
||
| 991 | return $this->status; |
||
| 992 | } |
||
| 993 | |||
| 994 | /** |
||
| 995 | * Set officialCode. |
||
| 996 | * |
||
| 997 | * @param string $officialCode |
||
| 998 | * |
||
| 999 | * @return User |
||
| 1000 | */ |
||
| 1001 | public function setOfficialCode($officialCode) |
||
| 1002 | { |
||
| 1003 | $this->officialCode = $officialCode; |
||
| 1004 | |||
| 1005 | return $this; |
||
| 1006 | } |
||
| 1007 | |||
| 1008 | /** |
||
| 1009 | * Get officialCode. |
||
| 1010 | * |
||
| 1011 | * @return string |
||
| 1012 | */ |
||
| 1013 | public function getOfficialCode() |
||
| 1014 | { |
||
| 1015 | return $this->officialCode; |
||
| 1016 | } |
||
| 1017 | |||
| 1018 | /** |
||
| 1019 | * Set phone. |
||
| 1020 | * |
||
| 1021 | * @param string $phone |
||
| 1022 | * |
||
| 1023 | * @return User |
||
| 1024 | */ |
||
| 1025 | public function setPhone($phone) |
||
| 1026 | { |
||
| 1027 | $this->phone = $phone; |
||
| 1028 | |||
| 1029 | return $this; |
||
| 1030 | } |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Get phone. |
||
| 1034 | * |
||
| 1035 | * @return string |
||
| 1036 | */ |
||
| 1037 | public function getPhone() |
||
| 1038 | { |
||
| 1039 | return $this->phone; |
||
| 1040 | } |
||
| 1041 | |||
| 1042 | /** |
||
| 1043 | * Set address. |
||
| 1044 | * |
||
| 1045 | * @param string $address |
||
| 1046 | * |
||
| 1047 | * @return User |
||
| 1048 | */ |
||
| 1049 | public function setAddress($address) |
||
| 1050 | { |
||
| 1051 | $this->address = $address; |
||
| 1052 | |||
| 1053 | return $this; |
||
| 1054 | } |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * Get address. |
||
| 1058 | * |
||
| 1059 | * @return string |
||
| 1060 | */ |
||
| 1061 | public function getAddress() |
||
| 1062 | { |
||
| 1063 | return $this->address; |
||
| 1064 | } |
||
| 1065 | |||
| 1066 | /** |
||
| 1067 | * Set pictureUri. |
||
| 1068 | * |
||
| 1069 | * @param string $pictureUri |
||
| 1070 | * |
||
| 1071 | * @return User |
||
| 1072 | */ |
||
| 1073 | public function setPictureUri($pictureUri) |
||
| 1074 | { |
||
| 1075 | $this->pictureUri = $pictureUri; |
||
| 1076 | |||
| 1077 | return $this; |
||
| 1078 | } |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Get pictureUri. |
||
| 1082 | * |
||
| 1083 | * @return string |
||
| 1084 | */ |
||
| 1085 | public function getPictureUri() |
||
| 1086 | { |
||
| 1087 | return $this->pictureUri; |
||
| 1088 | } |
||
| 1089 | |||
| 1090 | /** |
||
| 1091 | * Set creatorId. |
||
| 1092 | * |
||
| 1093 | * @param int $creatorId |
||
| 1094 | * |
||
| 1095 | * @return User |
||
| 1096 | */ |
||
| 1097 | public function setCreatorId($creatorId) |
||
| 1098 | { |
||
| 1099 | $this->creatorId = $creatorId; |
||
| 1100 | |||
| 1101 | return $this; |
||
| 1102 | } |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Get creatorId. |
||
| 1106 | * |
||
| 1107 | * @return int |
||
| 1108 | */ |
||
| 1109 | public function getCreatorId() |
||
| 1110 | { |
||
| 1111 | return $this->creatorId; |
||
| 1112 | } |
||
| 1113 | |||
| 1114 | /** |
||
| 1115 | * Set competences. |
||
| 1116 | * |
||
| 1117 | * @param string $competences |
||
| 1118 | * |
||
| 1119 | * @return User |
||
| 1120 | */ |
||
| 1121 | public function setCompetences($competences) |
||
| 1122 | { |
||
| 1123 | $this->competences = $competences; |
||
| 1124 | |||
| 1125 | return $this; |
||
| 1126 | } |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Get competences. |
||
| 1130 | * |
||
| 1131 | * @return string |
||
| 1132 | */ |
||
| 1133 | public function getCompetences() |
||
| 1134 | { |
||
| 1135 | return $this->competences; |
||
| 1136 | } |
||
| 1137 | |||
| 1138 | /** |
||
| 1139 | * Set diplomas. |
||
| 1140 | * |
||
| 1141 | * @param string $diplomas |
||
| 1142 | * |
||
| 1143 | * @return User |
||
| 1144 | */ |
||
| 1145 | public function setDiplomas($diplomas) |
||
| 1146 | { |
||
| 1147 | $this->diplomas = $diplomas; |
||
| 1148 | |||
| 1149 | return $this; |
||
| 1150 | } |
||
| 1151 | |||
| 1152 | /** |
||
| 1153 | * Get diplomas. |
||
| 1154 | * |
||
| 1155 | * @return string |
||
| 1156 | */ |
||
| 1157 | public function getDiplomas() |
||
| 1158 | { |
||
| 1159 | return $this->diplomas; |
||
| 1160 | } |
||
| 1161 | |||
| 1162 | /** |
||
| 1163 | * Set openarea. |
||
| 1164 | * |
||
| 1165 | * @param string $openarea |
||
| 1166 | * |
||
| 1167 | * @return User |
||
| 1168 | */ |
||
| 1169 | public function setOpenarea($openarea) |
||
| 1170 | { |
||
| 1171 | $this->openarea = $openarea; |
||
| 1172 | |||
| 1173 | return $this; |
||
| 1174 | } |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Get openarea. |
||
| 1178 | * |
||
| 1179 | * @return string |
||
| 1180 | */ |
||
| 1181 | public function getOpenarea() |
||
| 1182 | { |
||
| 1183 | return $this->openarea; |
||
| 1184 | } |
||
| 1185 | |||
| 1186 | /** |
||
| 1187 | * Set teach. |
||
| 1188 | * |
||
| 1189 | * @param string $teach |
||
| 1190 | * |
||
| 1191 | * @return User |
||
| 1192 | */ |
||
| 1193 | public function setTeach($teach) |
||
| 1194 | { |
||
| 1195 | $this->teach = $teach; |
||
| 1196 | |||
| 1197 | return $this; |
||
| 1198 | } |
||
| 1199 | |||
| 1200 | /** |
||
| 1201 | * Get teach. |
||
| 1202 | * |
||
| 1203 | * @return string |
||
| 1204 | */ |
||
| 1205 | public function getTeach() |
||
| 1206 | { |
||
| 1207 | return $this->teach; |
||
| 1208 | } |
||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * Set productions. |
||
| 1212 | * |
||
| 1213 | * @param string $productions |
||
| 1214 | * |
||
| 1215 | * @return User |
||
| 1216 | */ |
||
| 1217 | public function setProductions($productions) |
||
| 1218 | { |
||
| 1219 | $this->productions = $productions; |
||
| 1220 | |||
| 1221 | return $this; |
||
| 1222 | } |
||
| 1223 | |||
| 1224 | /** |
||
| 1225 | * Get productions. |
||
| 1226 | * |
||
| 1227 | * @return string |
||
| 1228 | */ |
||
| 1229 | public function getProductions() |
||
| 1230 | { |
||
| 1231 | return $this->productions; |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | /** |
||
| 1235 | * Set language. |
||
| 1236 | * |
||
| 1237 | * @param string $language |
||
| 1238 | * |
||
| 1239 | * @return User |
||
| 1240 | */ |
||
| 1241 | public function setLanguage($language) |
||
| 1242 | { |
||
| 1243 | $this->language = $language; |
||
| 1244 | |||
| 1245 | return $this; |
||
| 1246 | } |
||
| 1247 | |||
| 1248 | /** |
||
| 1249 | * Get language. |
||
| 1250 | * |
||
| 1251 | * @return string |
||
| 1252 | */ |
||
| 1253 | public function getLanguage() |
||
| 1254 | { |
||
| 1255 | return $this->language; |
||
| 1256 | } |
||
| 1257 | |||
| 1258 | /** |
||
| 1259 | * Set registrationDate. |
||
| 1260 | * |
||
| 1261 | * @param \DateTime $registrationDate |
||
| 1262 | * |
||
| 1263 | * @return User |
||
| 1264 | */ |
||
| 1265 | public function setRegistrationDate($registrationDate) |
||
| 1266 | { |
||
| 1267 | $this->registrationDate = $registrationDate; |
||
| 1268 | |||
| 1269 | return $this; |
||
| 1270 | } |
||
| 1271 | |||
| 1272 | /** |
||
| 1273 | * Get registrationDate. |
||
| 1274 | * |
||
| 1275 | * @return \DateTime |
||
| 1276 | */ |
||
| 1277 | public function getRegistrationDate() |
||
| 1278 | { |
||
| 1279 | return $this->registrationDate; |
||
| 1280 | } |
||
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Set expirationDate. |
||
| 1284 | * |
||
| 1285 | * @param \DateTime $expirationDate |
||
| 1286 | * |
||
| 1287 | * @return User |
||
| 1288 | */ |
||
| 1289 | public function setExpirationDate($expirationDate) |
||
| 1290 | { |
||
| 1291 | $this->expirationDate = $expirationDate; |
||
| 1292 | |||
| 1293 | return $this; |
||
| 1294 | } |
||
| 1295 | |||
| 1296 | /** |
||
| 1297 | * Get expirationDate. |
||
| 1298 | * |
||
| 1299 | * @return \DateTime |
||
| 1300 | */ |
||
| 1301 | public function getExpirationDate() |
||
| 1302 | { |
||
| 1303 | return $this->expirationDate; |
||
| 1304 | } |
||
| 1305 | |||
| 1306 | /** |
||
| 1307 | * Set active. |
||
| 1308 | * |
||
| 1309 | * @param bool $active |
||
| 1310 | * |
||
| 1311 | * @return User |
||
| 1312 | */ |
||
| 1313 | public function setActive($active) |
||
| 1314 | { |
||
| 1315 | $this->active = $active; |
||
| 1316 | |||
| 1317 | return $this; |
||
| 1318 | } |
||
| 1319 | |||
| 1320 | /** |
||
| 1321 | * Get active. |
||
| 1322 | * |
||
| 1323 | * @return bool |
||
| 1324 | */ |
||
| 1325 | public function getActive() |
||
| 1326 | { |
||
| 1327 | return $this->active; |
||
| 1328 | } |
||
| 1329 | |||
| 1330 | /** |
||
| 1331 | * Set openid. |
||
| 1332 | * |
||
| 1333 | * @param string $openid |
||
| 1334 | * |
||
| 1335 | * @return User |
||
| 1336 | */ |
||
| 1337 | public function setOpenid($openid) |
||
| 1338 | { |
||
| 1339 | $this->openid = $openid; |
||
| 1340 | |||
| 1341 | return $this; |
||
| 1342 | } |
||
| 1343 | |||
| 1344 | /** |
||
| 1345 | * Get openid. |
||
| 1346 | * |
||
| 1347 | * @return string |
||
| 1348 | */ |
||
| 1349 | public function getOpenid() |
||
| 1350 | { |
||
| 1351 | return $this->openid; |
||
| 1352 | } |
||
| 1353 | |||
| 1354 | /** |
||
| 1355 | * Set theme. |
||
| 1356 | * |
||
| 1357 | * @param string $theme |
||
| 1358 | * |
||
| 1359 | * @return User |
||
| 1360 | */ |
||
| 1361 | public function setTheme($theme) |
||
| 1362 | { |
||
| 1363 | $this->theme = $theme; |
||
| 1364 | |||
| 1365 | return $this; |
||
| 1366 | } |
||
| 1367 | |||
| 1368 | /** |
||
| 1369 | * Get theme. |
||
| 1370 | * |
||
| 1371 | * @return string |
||
| 1372 | */ |
||
| 1373 | public function getTheme() |
||
| 1374 | { |
||
| 1375 | return $this->theme; |
||
| 1376 | } |
||
| 1377 | |||
| 1378 | /** |
||
| 1379 | * Set hrDeptId. |
||
| 1380 | * |
||
| 1381 | * @param int $hrDeptId |
||
| 1382 | * |
||
| 1383 | * @return User |
||
| 1384 | */ |
||
| 1385 | public function setHrDeptId($hrDeptId) |
||
| 1386 | { |
||
| 1387 | $this->hrDeptId = $hrDeptId; |
||
| 1388 | |||
| 1389 | return $this; |
||
| 1390 | } |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Get hrDeptId. |
||
| 1394 | * |
||
| 1395 | * @return int |
||
| 1396 | */ |
||
| 1397 | public function getHrDeptId() |
||
| 1398 | { |
||
| 1399 | return $this->hrDeptId; |
||
| 1400 | } |
||
| 1401 | |||
| 1402 | /** |
||
| 1403 | * @return \DateTime |
||
| 1404 | */ |
||
| 1405 | public function getMemberSince() |
||
| 1406 | { |
||
| 1407 | return $this->registrationDate; |
||
| 1408 | } |
||
| 1409 | |||
| 1410 | /** |
||
| 1411 | * @return bool |
||
| 1412 | */ |
||
| 1413 | public function isOnline() |
||
| 1414 | { |
||
| 1415 | return false; |
||
| 1416 | } |
||
| 1417 | |||
| 1418 | /** |
||
| 1419 | * @return int |
||
| 1420 | */ |
||
| 1421 | public function getIdentifier() |
||
| 1422 | { |
||
| 1423 | return $this->getId(); |
||
| 1424 | } |
||
| 1425 | |||
| 1426 | /** |
||
| 1427 | * @return string |
||
| 1428 | */ |
||
| 1429 | public function getSlug() |
||
| 1430 | { |
||
| 1431 | return $this->getUsername(); |
||
| 1432 | } |
||
| 1433 | |||
| 1434 | /** |
||
| 1435 | * @param $slug |
||
| 1436 | * |
||
| 1437 | * @return User |
||
| 1438 | */ |
||
| 1439 | public function setSlug($slug) |
||
| 1440 | { |
||
| 1441 | return $this->setUsername($slug); |
||
| 1442 | } |
||
| 1443 | |||
| 1444 | /** |
||
| 1445 | * Set lastLogin. |
||
| 1446 | * |
||
| 1447 | * @param \DateTime $lastLogin |
||
| 1448 | * |
||
| 1449 | * @return User |
||
| 1450 | */ |
||
| 1451 | public function setLastLogin(\DateTime $lastLogin = null) |
||
| 1452 | { |
||
| 1453 | $this->lastLogin = $lastLogin; |
||
| 1454 | |||
| 1455 | return $this; |
||
| 1456 | } |
||
| 1457 | |||
| 1458 | /** |
||
| 1459 | * Get lastLogin. |
||
| 1460 | * |
||
| 1461 | * @return \DateTime |
||
| 1462 | */ |
||
| 1463 | public function getLastLogin() |
||
| 1464 | { |
||
| 1465 | return $this->lastLogin; |
||
| 1466 | } |
||
| 1467 | |||
| 1468 | /** |
||
| 1469 | * Get sessionCourseSubscription. |
||
| 1470 | * |
||
| 1471 | * @return ArrayCollection |
||
| 1472 | */ |
||
| 1473 | public function getSessionCourseSubscriptions() |
||
| 1474 | { |
||
| 1475 | return $this->sessionCourseSubscriptions; |
||
| 1476 | } |
||
| 1477 | |||
| 1478 | /** |
||
| 1479 | * @param $value |
||
| 1480 | * |
||
| 1481 | * @return $this |
||
| 1482 | */ |
||
| 1483 | public function setSessionCourseSubscriptions($value) |
||
| 1484 | { |
||
| 1485 | $this->sessionCourseSubscriptions = $value; |
||
| 1486 | |||
| 1487 | return $this; |
||
| 1488 | } |
||
| 1489 | |||
| 1490 | /** |
||
| 1491 | * @return string |
||
| 1492 | */ |
||
| 1493 | public function getConfirmationToken() |
||
| 1494 | { |
||
| 1495 | return $this->confirmationToken; |
||
| 1496 | } |
||
| 1497 | |||
| 1498 | /** |
||
| 1499 | * @param string $confirmationToken |
||
| 1500 | * |
||
| 1501 | * @return User |
||
| 1502 | */ |
||
| 1503 | public function setConfirmationToken($confirmationToken) |
||
| 1504 | { |
||
| 1505 | $this->confirmationToken = $confirmationToken; |
||
| 1506 | |||
| 1507 | return $this; |
||
| 1508 | } |
||
| 1509 | |||
| 1510 | /** |
||
| 1511 | * @return \DateTime |
||
| 1512 | */ |
||
| 1513 | public function getPasswordRequestedAt() |
||
| 1514 | { |
||
| 1515 | return $this->passwordRequestedAt; |
||
| 1516 | } |
||
| 1517 | |||
| 1518 | /** |
||
| 1519 | * @param int $ttl |
||
| 1520 | * |
||
| 1521 | * @return bool |
||
| 1522 | */ |
||
| 1523 | /*public function isPasswordRequestNonExpired($ttl) |
||
| 1524 | { |
||
| 1525 | return $this->getPasswordRequestedAt() instanceof \DateTime && |
||
| 1526 | $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); |
||
| 1527 | }*/ |
||
| 1528 | |||
| 1529 | public function getUsername(): string |
||
| 1530 | { |
||
| 1531 | return (string) $this->username; |
||
| 1532 | } |
||
| 1533 | |||
| 1534 | /** |
||
| 1535 | * Returns the expiration date. |
||
| 1536 | * |
||
| 1537 | * @return \DateTime|null |
||
| 1538 | */ |
||
| 1539 | public function getExpiresAt() |
||
| 1540 | { |
||
| 1541 | return $this->expiresAt; |
||
| 1542 | } |
||
| 1543 | |||
| 1544 | /** |
||
| 1545 | * Returns the credentials expiration date. |
||
| 1546 | * |
||
| 1547 | * @return \DateTime |
||
| 1548 | */ |
||
| 1549 | public function getCredentialsExpireAt() |
||
| 1550 | { |
||
| 1551 | return $this->credentialsExpireAt; |
||
| 1552 | } |
||
| 1553 | |||
| 1554 | /** |
||
| 1555 | * Sets the credentials expiration date. |
||
| 1556 | * |
||
| 1557 | * @return User |
||
| 1558 | */ |
||
| 1559 | public function setCredentialsExpireAt(\DateTime $date = null) |
||
| 1560 | { |
||
| 1561 | $this->credentialsExpireAt = $date; |
||
| 1562 | |||
| 1563 | return $this; |
||
| 1564 | } |
||
| 1565 | |||
| 1566 | /** |
||
| 1567 | * Sets the user groups. |
||
| 1568 | * |
||
| 1569 | * @param array $groups |
||
| 1570 | * |
||
| 1571 | * @return User |
||
| 1572 | */ |
||
| 1573 | public function setGroups($groups) |
||
| 1574 | { |
||
| 1575 | foreach ($groups as $group) { |
||
| 1576 | $this->addGroup($group); |
||
| 1577 | } |
||
| 1578 | |||
| 1579 | return $this; |
||
| 1580 | } |
||
| 1581 | |||
| 1582 | /** |
||
| 1583 | * @return string |
||
| 1584 | */ |
||
| 1585 | public function getFullname() |
||
| 1586 | { |
||
| 1587 | return sprintf('%s %s', $this->getFirstname(), $this->getLastname()); |
||
| 1588 | } |
||
| 1589 | |||
| 1590 | /** |
||
| 1591 | * Returns the user roles. |
||
| 1592 | * |
||
| 1593 | * @return array The roles |
||
| 1594 | */ |
||
| 1595 | public function getRoles() |
||
| 1596 | { |
||
| 1597 | $roles = $this->roles; |
||
| 1598 | |||
| 1599 | foreach ($this->getGroups() as $group) { |
||
| 1600 | $roles = array_merge($roles, $group->getRoles()); |
||
| 1601 | } |
||
| 1602 | |||
| 1603 | // we need to make sure to have at least one role |
||
| 1604 | $roles[] = static::ROLE_DEFAULT; |
||
| 1605 | |||
| 1606 | return array_unique($roles); |
||
| 1607 | } |
||
| 1608 | |||
| 1609 | public function isAccountNonExpired() |
||
| 1610 | { |
||
| 1611 | /*if (true === $this->expired) { |
||
| 1612 | return false; |
||
| 1613 | } |
||
| 1614 | |||
| 1615 | if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) { |
||
| 1616 | return false; |
||
| 1617 | }*/ |
||
| 1618 | |||
| 1619 | return true; |
||
| 1620 | } |
||
| 1621 | |||
| 1622 | public function isAccountNonLocked() |
||
| 1623 | { |
||
| 1624 | return true; |
||
| 1625 | //return !$this->locked; |
||
| 1626 | } |
||
| 1627 | |||
| 1628 | public function isCredentialsNonExpired() |
||
| 1639 | } |
||
| 1640 | |||
| 1641 | /** |
||
| 1642 | * @return bool |
||
| 1643 | */ |
||
| 1644 | public function getCredentialsExpired() |
||
| 1645 | { |
||
| 1646 | return $this->credentialsExpired; |
||
| 1647 | } |
||
| 1648 | |||
| 1649 | /** |
||
| 1650 | * @param bool $boolean |
||
| 1651 | * |
||
| 1652 | * @return User |
||
| 1653 | */ |
||
| 1654 | public function setCredentialsExpired($boolean) |
||
| 1659 | } |
||
| 1660 | |||
| 1661 | /** |
||
| 1662 | * @param $boolean |
||
| 1663 | * |
||
| 1664 | * @return $this|BaseUser |
||
| 1665 | */ |
||
| 1666 | public function setEnabled($boolean) |
||
| 1667 | { |
||
| 1668 | $this->enabled = (bool) $boolean; |
||
| 1669 | |||
| 1670 | return $this; |
||
| 1671 | } |
||
| 1672 | |||
| 1673 | /** |
||
| 1674 | * @return bool |
||
| 1675 | */ |
||
| 1676 | public function getExpired() |
||
| 1679 | } |
||
| 1680 | |||
| 1681 | /** |
||
| 1682 | * Sets this user to expired. |
||
| 1683 | * |
||
| 1684 | * @param bool $boolean |
||
| 1685 | * |
||
| 1686 | * @return User |
||
| 1687 | */ |
||
| 1688 | public function setExpired($boolean) |
||
| 1693 | } |
||
| 1694 | |||
| 1695 | /** |
||
| 1696 | * @return User |
||
| 1697 | */ |
||
| 1698 | public function setExpiresAt(\DateTime $date) |
||
| 1699 | { |
||
| 1700 | $this->expiresAt = $date; |
||
| 1701 | |||
| 1702 | return $this; |
||
| 1703 | } |
||
| 1704 | |||
| 1705 | public function getLocked(): bool |
||
| 1706 | { |
||
| 1707 | return $this->locked; |
||
| 1708 | } |
||
| 1709 | |||
| 1710 | /** |
||
| 1711 | * @param $boolean |
||
| 1712 | * |
||
| 1713 | * @return $this |
||
| 1714 | */ |
||
| 1715 | public function setLocked($boolean) |
||
| 1716 | { |
||
| 1717 | $this->locked = $boolean; |
||
| 1718 | |||
| 1719 | return $this; |
||
| 1720 | } |
||
| 1721 | |||
| 1722 | /** |
||
| 1723 | * @return $this |
||
| 1724 | */ |
||
| 1725 | public function setRoles(array $roles) |
||
| 1726 | { |
||
| 1727 | $this->roles = []; |
||
| 1728 | |||
| 1729 | foreach ($roles as $role) { |
||
| 1730 | $this->addRole($role); |
||
| 1731 | } |
||
| 1732 | |||
| 1733 | return $this; |
||
| 1734 | } |
||
| 1735 | |||
| 1736 | /** |
||
| 1737 | * Get achievedSkills. |
||
| 1738 | * |
||
| 1739 | * @return ArrayCollection |
||
| 1740 | */ |
||
| 1741 | public function getAchievedSkills() |
||
| 1742 | { |
||
| 1743 | return $this->achievedSkills; |
||
| 1744 | } |
||
| 1745 | |||
| 1746 | /** |
||
| 1747 | * @param $value |
||
| 1748 | * |
||
| 1749 | * @return $this |
||
| 1750 | */ |
||
| 1751 | public function setAchievedSkills($value) |
||
| 1752 | { |
||
| 1753 | $this->achievedSkills = $value; |
||
| 1754 | |||
| 1755 | return $this; |
||
| 1756 | } |
||
| 1757 | |||
| 1758 | /** |
||
| 1759 | * Check if the user has the skill. |
||
| 1760 | * |
||
| 1761 | * @param Skill $skill The skill |
||
| 1762 | * |
||
| 1763 | * @return bool |
||
| 1764 | */ |
||
| 1765 | public function hasSkill(Skill $skill) |
||
| 1766 | { |
||
| 1767 | $achievedSkills = $this->getAchievedSkills(); |
||
| 1768 | |||
| 1769 | foreach ($achievedSkills as $userSkill) { |
||
| 1770 | if ($userSkill->getSkill()->getId() !== $skill->getId()) { |
||
| 1771 | continue; |
||
| 1772 | } |
||
| 1773 | |||
| 1774 | return true; |
||
| 1775 | } |
||
| 1776 | } |
||
| 1777 | |||
| 1778 | /** |
||
| 1779 | * @return bool |
||
| 1780 | */ |
||
| 1781 | public function isProfileCompleted() |
||
| 1782 | { |
||
| 1783 | return $this->profileCompleted; |
||
| 1784 | } |
||
| 1785 | |||
| 1786 | /** |
||
| 1787 | * @param mixed $profileCompleted |
||
| 1788 | * |
||
| 1789 | * @return User |
||
| 1790 | */ |
||
| 1791 | public function setProfileCompleted($profileCompleted) |
||
| 1792 | { |
||
| 1793 | $this->profileCompleted = $profileCompleted; |
||
| 1794 | |||
| 1795 | return $this; |
||
| 1796 | } |
||
| 1797 | |||
| 1798 | /** |
||
| 1799 | * Sets the AccessUrl for the current user in memory. |
||
| 1800 | * |
||
| 1801 | * @return $this |
||
| 1802 | */ |
||
| 1803 | public function setCurrentUrl(AccessUrl $url) |
||
| 1804 | { |
||
| 1805 | $urlList = $this->getPortals(); |
||
| 1806 | /** @var AccessUrlRelUser $item */ |
||
| 1807 | foreach ($urlList as $item) { |
||
| 1808 | if ($item->getUrl()->getId() === $url->getId()) { |
||
| 1809 | $this->currentUrl = $url; |
||
| 1810 | break; |
||
| 1811 | } |
||
| 1812 | } |
||
| 1813 | |||
| 1814 | return $this; |
||
| 1815 | } |
||
| 1816 | |||
| 1817 | /** |
||
| 1818 | * @return AccessUrl |
||
| 1819 | */ |
||
| 1820 | public function getCurrentUrl() |
||
| 1821 | { |
||
| 1822 | return $this->currentUrl; |
||
| 1823 | } |
||
| 1824 | |||
| 1825 | /** |
||
| 1826 | * Get sessionAsGeneralCoach. |
||
| 1827 | * |
||
| 1828 | * @return ArrayCollection |
||
| 1829 | */ |
||
| 1830 | public function getSessionAsGeneralCoach() |
||
| 1831 | { |
||
| 1832 | return $this->sessionAsGeneralCoach; |
||
| 1833 | } |
||
| 1834 | |||
| 1835 | /** |
||
| 1836 | * Get sessionAsGeneralCoach. |
||
| 1837 | * |
||
| 1838 | * @param ArrayCollection $value |
||
| 1839 | * |
||
| 1840 | * @return $this |
||
| 1841 | */ |
||
| 1842 | public function setSessionAsGeneralCoach($value) |
||
| 1843 | { |
||
| 1844 | $this->sessionAsGeneralCoach = $value; |
||
| 1845 | |||
| 1846 | return $this; |
||
| 1847 | } |
||
| 1848 | |||
| 1849 | /** |
||
| 1850 | * @return mixed |
||
| 1851 | */ |
||
| 1852 | public function getCommentedUserSkills() |
||
| 1853 | { |
||
| 1854 | return $this->commentedUserSkills; |
||
| 1855 | } |
||
| 1856 | |||
| 1857 | /** |
||
| 1858 | * @param mixed $commentedUserSkills |
||
| 1859 | * |
||
| 1860 | * @return User |
||
| 1861 | */ |
||
| 1862 | public function setCommentedUserSkills($commentedUserSkills) |
||
| 1863 | { |
||
| 1864 | $this->commentedUserSkills = $commentedUserSkills; |
||
| 1865 | |||
| 1866 | return $this; |
||
| 1867 | } |
||
| 1868 | |||
| 1869 | /** |
||
| 1870 | * @return bool |
||
| 1871 | */ |
||
| 1872 | public function isEqualTo(UserInterface $user) |
||
| 1887 | } |
||
| 1888 | |||
| 1889 | public function getPictureLegacy(): string |
||
| 1890 | { |
||
| 1891 | $id = $this->id; |
||
| 1892 | $uri = $this->getPictureUri(); |
||
| 1893 | if ($uri) { |
||
| 1894 | return 'users/'.substr((string) $id, 0, 1).'/'.$id.'/'.'small_'.$uri; |
||
| 1895 | } |
||
| 1896 | |||
| 1897 | return ''; |
||
| 1898 | } |
||
| 1899 | |||
| 1900 | /** |
||
| 1901 | * Get sentMessages. |
||
| 1902 | * |
||
| 1903 | * @return ArrayCollection |
||
| 1904 | */ |
||
| 1905 | public function getSentMessages() |
||
| 1906 | { |
||
| 1907 | return $this->sentMessages; |
||
| 1908 | } |
||
| 1909 | |||
| 1910 | /** |
||
| 1911 | * Get receivedMessages. |
||
| 1912 | * |
||
| 1913 | * @return ArrayCollection |
||
| 1914 | */ |
||
| 1915 | public function getReceivedMessages() |
||
| 1916 | { |
||
| 1917 | return $this->receivedMessages; |
||
| 1918 | } |
||
| 1919 | |||
| 1920 | /** |
||
| 1921 | * @param int $lastId Optional. The ID of the last received message |
||
| 1922 | */ |
||
| 1923 | public function getUnreadReceivedMessages($lastId = 0): ArrayCollection |
||
| 1924 | { |
||
| 1925 | $criteria = Criteria::create(); |
||
| 1926 | $criteria->where( |
||
| 1927 | Criteria::expr()->eq('msgStatus', MESSAGE_STATUS_UNREAD) |
||
| 1928 | ); |
||
| 1929 | |||
| 1930 | if ($lastId > 0) { |
||
| 1931 | $criteria->andWhere( |
||
| 1932 | Criteria::expr()->gt('id', (int) $lastId) |
||
| 1933 | ); |
||
| 1934 | } |
||
| 1935 | |||
| 1936 | $criteria->orderBy(['sendDate' => Criteria::DESC]); |
||
| 1937 | |||
| 1938 | return $this->receivedMessages->matching($criteria); |
||
| 1939 | } |
||
| 1940 | |||
| 1941 | public function getCourseGroupsAsMember(): Collection |
||
| 1942 | { |
||
| 1943 | return $this->courseGroupsAsMember; |
||
| 1944 | } |
||
| 1945 | |||
| 1946 | public function getCourseGroupsAsTutor(): Collection |
||
| 1947 | { |
||
| 1948 | return $this->courseGroupsAsTutor; |
||
| 1949 | } |
||
| 1950 | |||
| 1951 | public function getCourseGroupsAsMemberFromCourse(Course $course): ArrayCollection |
||
| 1952 | { |
||
| 1953 | $criteria = Criteria::create(); |
||
| 1954 | $criteria->where( |
||
| 1955 | Criteria::expr()->eq('cId', $course) |
||
| 1956 | ); |
||
| 1957 | |||
| 1958 | return $this->courseGroupsAsMember->matching($criteria); |
||
| 1959 | } |
||
| 1960 | |||
| 1961 | public function getCourseGroupsAsTutorFromCourse(Course $course): ArrayCollection |
||
| 1969 | } |
||
| 1970 | } |
||
| 1971 |