Passed
Push — master ( 577c0a...a84711 )
by Julito
08:53
created

User::getLastLogin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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