Passed
Push — master ( 30a646...7ef6af )
by Julito
29:23
created

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