Passed
Push — master ( 04ab64...41deee )
by Julito
09:36 queued 10s
created

User::getIsActive()   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\Skill;
10
use Chamilo\CoreBundle\Entity\UsergroupRelUser;
11
use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Doctrine\ORM\Event\LifecycleEventArgs;
14
use Doctrine\ORM\Mapping as ORM;
15
//use FOS\UserBundle\Model\GroupInterface;
16
use Sonata\UserBundle\Entity\BaseUser;
17
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
18
use Symfony\Component\HttpFoundation\File\File;
19
use Symfony\Component\Security\Core\User\EquatableInterface;
20
use Symfony\Component\Security\Core\User\UserInterface;
21
use Symfony\Component\Validator\Constraints as Assert;
22
use Symfony\Component\Validator\Mapping\ClassMetadata;
23
24
//use Chamilo\CoreBundle\Component\Auth;
25
//use FOS\MessageBundle\Model\ParticipantInterface;
26
//use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
27
//use Vich\UploaderBundle\Mapping\Annotation as Vich;
28
//use Application\Sonata\MediaBundle\Entity\Media;
29
//use Chamilo\UserBundle\Model\UserInterface as UserInterfaceModel;
30
//use Sylius\Component\Attribute\Model\AttributeValueInterface as BaseAttributeValueInterface;
31
//use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface;
32
//use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface;
33
34
/**
35
 * @ORM\HasLifecycleCallbacks
36
 * @ORM\Table(
37
 *  name="user",
38
 *  indexes={
39
 *      @ORM\Index(name="idx_user_uid", columns={"user_id"}),
40
 *      @ORM\Index(name="status", columns={"status"})
41
 *  }
42
 * )
43
 * @UniqueEntity("username")
44
 * @ORM\Entity(repositoryClass="Chamilo\UserBundle\Repository\UserRepository")
45
 *
46
 * @ORM\AttributeOverrides({
47
 *     @ORM\AttributeOverride(name="username",
48
 *         column=@ORM\Column(
49
 *             name="username",
50
 *             type="string",
51
 *             length=100,
52
 *             unique=true
53
 *         )
54
 *     ),
55
 *      @ORM\AttributeOverride(name="email",
56
 *         column=@ORM\Column(
57
 *             name="email",
58
 *             type="string",
59
 *             length=100,
60
 *             unique=false
61
 *         )
62
 *     ),
63
 *     @ORM\AttributeOverride(name="emailCanonical",
64
 *         column=@ORM\Column(
65
 *             name="email_canonical",
66
 *             type="string",
67
 *             length=100,
68
 *             unique=false
69
 *         )
70
 *     ),
71
 *     @ORM\AttributeOverride(name="usernameCanonical",
72
 *         column=@ORM\Column(
73
 *             name="username_canonical",
74
 *             type="string",
75
 *             length=180,
76
 *             unique=false
77
 *         )
78
 *     )
79
 * })
80
 */
81
class User extends BaseUser implements ThemeUser, EquatableInterface //implements ParticipantInterface, ThemeUser
82
{
83
    public const COURSE_MANAGER = 1;
84
    public const TEACHER = 1;
85
    public const SESSION_ADMIN = 3;
86
    public const DRH = 4;
87
    public const STUDENT = 5;
88
    public const ANONYMOUS = 6;
89
90
    /**
91
     * @var int
92
     *
93
     * @ORM\Column(name="id", type="integer")
94
     * @ORM\Id
95
     * @ORM\GeneratedValue(strategy="AUTO")
96
     */
97
    protected $id;
98
99
    /**
100
     * @var int
101
     *
102
     * @ORM\Column(name="user_id", type="integer", nullable=true)
103
     */
104
    protected $userId;
105
106
    /**
107
     * @var string
108
     *
109
     * @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true)
110
     */
111
    //protected $username;
112
113
    /**
114
     * @var string
115
     *
116
     * @ORM\Column(name="username_canonical", type="string", length=100, nullable=false)
117
     */
118
    //protected $usernameCanonical;
119
120
    /**
121
     * @var string
122
     * @ORM\Column(name="email_canonical", type="string", length=100, nullable=false, unique=false)
123
     */
124
    //protected $emailCanonical;
125
126
    /**
127
     * @var string
128
     *
129
     * @ORM\Column(name="email", type="string", length=100, nullable=false, unique=false)
130
     */
131
    //protected $email;
132
133
    /**
134
     * @var bool
135
     * @ORM\Column(name="locked", type="boolean")
136
     */
137
    protected $locked;
138
139
    /**
140
     * @var bool
141
     * @ORM\Column(name="enabled", type="boolean")
142
     */
143
    //protected $enabled;
144
145
    /**
146
     * @var bool
147
     * @ORM\Column(name="expired", type="boolean")
148
     */
149
    protected $expired;
150
151
    /**
152
     * @var bool
153
     * @ORM\Column(name="credentials_expired", type="boolean")
154
     */
155
    protected $credentialsExpired;
156
157
    /**
158
     * @var \DateTime
159
     * @ORM\Column(name="credentials_expire_at", type="datetime", nullable=true, unique=false)
160
     */
161
    protected $credentialsExpireAt;
162
163
    /**
164
     * @var \DateTime
165
     * @ORM\Column(name="expires_at", type="datetime", nullable=true, unique=false)
166
     */
167
    protected $expiresAt;
168
169
    /**
170
     * @var string
171
     *
172
     * @ORM\Column(name="phone", type="string", length=30, nullable=true, unique=false)
173
     */
174
    //protected $phone;
175
176
    /**
177
     * @var string
178
     *
179
     * @ORM\Column(name="address", type="string", length=250, nullable=true, unique=false)
180
     */
181
    protected $address;
182
183
    /**
184
     * Vich\UploadableField(mapping="user_image", fileNameProperty="picture_uri").
185
     *
186
     * note This is not a mapped field of entity metadata, just a simple property.
187
     *
188
     * @var File
189
     */
190
    protected $imageFile;
191
192
    /**
193
     * @var AccessUrl
194
     */
195
    protected $currentUrl;
196
197
    /**
198
     * @ORM\Column(type="string", length=255)
199
     */
200
    //protected $salt;
201
202
    /**
203
     * @var \DateTime
204
     *
205
     * @ORM\Column(name="last_login", type="datetime", nullable=true, unique=false)
206
     */
207
    //protected $lastLogin;
208
209
    /**
210
     * @var \DateTime
211
     * @ORM\Column(name="created_at", type="datetime", nullable=true, unique=false)
212
     */
213
    //protected $createdAt;
214
215
    /**
216
     * @var \DateTime
217
     * @ORM\Column(name="updated_at", type="datetime", nullable=true, unique=false)
218
     */
219
    //protected $updatedAt;
220
221
    /**
222
     * Random string sent to the user email address in order to verify it.
223
     *
224
     * @var string
225
     * @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true)
226
     */
227
    //protected $confirmationToken;
228
229
    /**
230
     * @var \DateTime
231
     *
232
     * @ORM\Column(name="password_requested_at", type="datetime", nullable=true, unique=false)
233
     */
234
    //protected $passwordRequestedAt;
235
236
    /**
237
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user")
238
     */
239
    protected $courses;
240
241
    /**
242
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="user")
243
     */
244
    //protected $items;
245
246
    /**
247
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user")
248
     */
249
    protected $classes;
250
251
    /**
252
     * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user").
253
     */
254
    protected $dropBoxReceivedFiles;
255
256
    /**
257
     * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent").
258
     */
259
    protected $dropBoxSentFiles;
260
261
    /**
262
     * @ORM\Column(type="array")
263
     */
264
    //protected $roles;
265
266
    /**
267
     * @var bool
268
     *
269
     * @ORM\Column(name="profile_completed", type="boolean", nullable=true)
270
     */
271
    protected $profileCompleted;
272
273
    /**
274
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user")
275
     */
276
    //protected $jurySubscriptions;
277
278
    /**
279
     * @ORM\ManyToMany(targetEntity="Chamilo\UserBundle\Entity\Group", inversedBy="users")
280
     * @ORM\JoinTable(name="fos_user_user_group",
281
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
282
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
283
     * )
284
     */
285
    protected $groups;
286
287
    //private $isActive;
288
289
    /**
290
     * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user").
291
     */
292
    protected $curriculumItems;
293
294
    /**
295
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelUser", mappedBy="user")
296
     */
297
    protected $portals;
298
299
    /**
300
     * @var ArrayCollection
301
     *
302
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach")
303
     */
304
    protected $sessionAsGeneralCoach;
305
306
    /**
307
     * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="creator").
308
     */
309
    protected $resourceNodes;
310
311
    /**
312
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", mappedBy="user", cascade={"persist"})
313
     */
314
    protected $sessionCourseSubscriptions;
315
316
    /**
317
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="user", cascade={"persist"})
318
     */
319
    protected $achievedSkills;
320
321
    /**
322
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", mappedBy="feedbackGiver")
323
     */
324
    protected $commentedUserSkills;
325
326
    /**
327
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookCategory", mappedBy="user")
328
     */
329
    protected $gradeBookCategories;
330
331
    /**
332
     * @var string
333
     *
334
     * @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false)
335
     */
336
    private $authSource;
337
338
    /**
339
     * @var int
340
     *
341
     * @ORM\Column(name="status", type="integer", nullable=false)
342
     */
343
    private $status;
344
345
    /**
346
     * @var string
347
     *
348
     * @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false)
349
     */
350
    private $officialCode;
351
352
    /**
353
     * @var string
354
     *
355
     * @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false)
356
     */
357
    private $pictureUri;
358
359
    /**
360
     * @var int
361
     *
362
     * @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false)
363
     */
364
    private $creatorId;
365
366
    /**
367
     * @var string
368
     *
369
     * @ORM\Column(name="competences", type="text", nullable=true, unique=false)
370
     */
371
    private $competences;
372
373
    /**
374
     * @var string
375
     *
376
     * @ORM\Column(name="diplomas", type="text", nullable=true, unique=false)
377
     */
378
    private $diplomas;
379
380
    /**
381
     * @var string
382
     *
383
     * @ORM\Column(name="openarea", type="text", nullable=true, unique=false)
384
     */
385
    private $openarea;
386
387
    /**
388
     * @var string
389
     *
390
     * @ORM\Column(name="teach", type="text", nullable=true, unique=false)
391
     */
392
    private $teach;
393
394
    /**
395
     * @var string
396
     *
397
     * @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false)
398
     */
399
    private $productions;
400
401
    /**
402
     * @var string
403
     *
404
     * @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false)
405
     */
406
    private $language;
407
408
    /**
409
     * @var \DateTime
410
     *
411
     * @ORM\Column(name="registration_date", type="datetime", nullable=false, unique=false)
412
     */
413
    private $registrationDate;
414
415
    /**
416
     * @var \DateTime
417
     *
418
     * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false)
419
     */
420
    private $expirationDate;
421
422
    /**
423
     * @var bool
424
     *
425
     * @ORM\Column(name="active", type="boolean", nullable=false, unique=false)
426
     */
427
    private $active;
428
429
    /**
430
     * @var string
431
     *
432
     * @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false)
433
     */
434
    private $openid;
435
436
    /**
437
     * @var string
438
     *
439
     * @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false)
440
     */
441
    private $theme;
442
443
    /**
444
     * @var int
445
     *
446
     * @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false)
447
     */
448
    private $hrDeptId;
449
450
    /**
451
     * @var ArrayCollection
452
     *
453
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Message", mappedBy="userSender")
454
     */
455
    private $sentMessages;
456
457
    /**
458
     * @var ArrayCollection
459
     *
460
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Message", mappedBy="userReceiver")
461
     */
462
    private $receivedMessages;
463
464
    /**
465
     * Constructor.
466
     */
467
    public function __construct()
468
    {
469
        parent::__construct();
470
        $this->status = self::STUDENT;
471
        $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...
472
        $this->active = true;
473
        $this->registrationDate = new \DateTime();
474
        $this->authSource = 'platform';
475
        $this->courses = new ArrayCollection();
476
        //$this->items = new ArrayCollection();
477
        $this->classes = new ArrayCollection();
478
        $this->curriculumItems = new ArrayCollection();
479
        $this->portals = new ArrayCollection();
480
        $this->dropBoxSentFiles = new ArrayCollection();
481
        $this->dropBoxReceivedFiles = new ArrayCollection();
482
        //$this->extraFields = new ArrayCollection();
483
        //$this->userId = 0;
484
        //$this->createdAt = new \DateTime();
485
        //$this->updatedAt = new \DateTime();
486
487
        $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...
488
        $this->locked = false;
489
        $this->expired = false;
490
        $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...
491
        $this->credentialsExpired = false;
492
    }
493
494
    /**
495
     * @return string
496
     */
497
    public function __toString()
498
    {
499
        return \UserManager::formatUserFullName();
0 ignored issues
show
Bug introduced by
The call to UserManager::formatUserFullName() has too few arguments starting with user. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

499
        return \UserManager::/** @scrutinizer ignore-call */ formatUserFullName();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
500
    }
501
502
    /**
503
     * Updates the id with the user_id.
504
     *
505
     * @ORM\PostPersist()
506
     *
507
     * @param LifecycleEventArgs $args
508
     */
509
    public function postPersist(LifecycleEventArgs $args)
510
    {
511
        $user = $args->getEntity();
512
        $this->setUserId($user->getId());
513
    }
514
515
    /**
516
     * @param int $userId
517
     */
518
    public function setId($userId)
519
    {
520
        $this->id = $userId;
521
    }
522
523
    /**
524
     * @param int $userId
525
     */
526
    public function setUserId($userId)
527
    {
528
        if (!empty($userId)) {
529
            $this->userId = $userId;
530
        }
531
    }
532
533
    /**
534
     * @return int
535
     */
536
    public function getId()
537
    {
538
        return $this->id;
539
    }
540
541
    /**
542
     * @return ArrayCollection
543
     */
544
    public function getDropBoxSentFiles()
545
    {
546
        return $this->dropBoxSentFiles;
547
    }
548
549
    /**
550
     * @return ArrayCollection
551
     */
552
    public function getDropBoxReceivedFiles()
553
    {
554
        return $this->dropBoxReceivedFiles;
555
    }
556
557
    /**
558
     * @param ArrayCollection $value
559
     */
560
    public function setDropBoxSentFiles($value)
561
    {
562
        $this->dropBoxSentFiles = $value;
563
    }
564
565
    /**
566
     * @param ArrayCollection $value
567
     */
568
    public function setDropBoxReceivedFiles($value)
569
    {
570
        $this->dropBoxReceivedFiles = $value;
571
    }
572
573
    /**
574
     * @param ArrayCollection $courses
575
     */
576
    public function setCourses($courses)
577
    {
578
        $this->courses = $courses;
579
    }
580
581
    /**
582
     * @return ArrayCollection
583
     */
584
    public function getCourses()
585
    {
586
        return $this->courses;
587
    }
588
589
    /**
590
     * @return array
591
     */
592
    public static function getPasswordConstraints()
593
    {
594
        return
595
            [
596
                new Assert\Length(['min' => 5]),
597
                // Alpha numeric + "_" or "-"
598
                new Assert\Regex(
599
                    [
600
                        'pattern' => '/^[a-z\-_0-9]+$/i',
601
                        'htmlPattern' => '/^[a-z\-_0-9]+$/i', ]
602
                ),
603
                // Min 3 letters - not needed
604
                /*new Assert\Regex(array(
605
                    'pattern' => '/[a-z]{3}/i',
606
                    'htmlPattern' => '/[a-z]{3}/i')
607
                ),*/
608
                // Min 2 numbers
609
                new Assert\Regex(
610
                    [
611
                        'pattern' => '/[0-9]{2}/',
612
                        'htmlPattern' => '/[0-9]{2}/', ]
613
                ),
614
            ]
615
            ;
616
    }
617
618
    /**
619
     * @param ClassMetadata $metadata
620
     */
621
    public static function loadValidatorMetadata(ClassMetadata $metadata)
622
    {
623
        //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank());
624
        //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank());
625
        //$metadata->addPropertyConstraint('email', new Assert\Email());
626
        /*
627
        $metadata->addPropertyConstraint('password',
628
            new Assert\Collection(self::getPasswordConstraints())
629
        );*/
630
631
        /*$metadata->addConstraint(new UniqueEntity(array(
632
            'fields'  => 'username',
633
            'message' => 'This value is already used.',
634
        )));*/
635
636
        /*$metadata->addPropertyConstraint(
637
            'username',
638
            new Assert\Length(array(
639
                'min'        => 2,
640
                'max'        => 50,
641
                '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.',
642
                '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.',
643
            ))
644
        );*/
645
    }
646
647
    /**
648
     * @return ArrayCollection
649
     */
650
    public function getPortals()
651
    {
652
        return $this->portals;
653
    }
654
655
    /**
656
     * @param $portal
657
     */
658
    public function setPortal($portal)
659
    {
660
        $this->portals->add($portal);
661
    }
662
663
    /**
664
     * @param $value
665
     */
666
    public function setPortals($value)
667
    {
668
        $this->portals = $value;
669
    }
670
671
    /**
672
     * @return ArrayCollection
673
     */
674
    public function getCurriculumItems()
675
    {
676
        return $this->curriculumItems;
677
    }
678
679
    /**
680
     * @param $items
681
     *
682
     * @return $this
683
     */
684
    public function setCurriculumItems($items)
685
    {
686
        $this->curriculumItems = $items;
687
688
        return $this;
689
    }
690
691
    /**
692
     * @return bool
693
     */
694
    public function getIsActive()
695
    {
696
        return $this->active == 1;
697
    }
698
699
    /**
700
     * @return bool
701
     */
702
    public function isActive()
703
    {
704
        return $this->getIsActive();
705
    }
706
707
    /**
708
     * {@inheritdoc}
709
     */
710
    public function isEnabled()
711
    {
712
        return $this->getActive() == 1;
713
    }
714
715
    /**
716
     * @return ArrayCollection
717
     */
718
    /*public function getRolesObj()
719
    {
720
        return $this->roles;
721
    }*/
722
723
    /**
724
     * Set salt.
725
     *
726
     * @param string $salt
727
     *
728
     * @return User
729
     */
730
    public function setSalt($salt)
731
    {
732
        $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...
733
734
        return $this;
735
    }
736
737
    /**
738
     * Get salt.
739
     *
740
     * @return string
741
     */
742
    public function getSalt()
743
    {
744
        return $this->salt;
745
    }
746
747
    /**
748
     * @param ArrayCollection $classes
749
     *
750
     * @return $this
751
     */
752
    public function setClasses($classes)
753
    {
754
        $this->classes = $classes;
755
756
        return $this;
757
    }
758
759
    /**
760
     * @return ArrayCollection
761
     */
762
    public function getClasses()
763
    {
764
        return $this->classes;
765
    }
766
767
    public function getLps()
768
    {
769
        //return $this->lps;
770
        /*$criteria = Criteria::create()
771
            ->where(Criteria::expr()->eq("id", "666"))
772
            //->orderBy(array("username" => "ASC"))
773
            //->setFirstResult(0)
774
            //->setMaxResults(20)
775
        ;
776
        $lps = $this->lps->matching($criteria);*/
777
        /*return $this->lps->filter(
778
            function($entry) use ($idsToFilter) {
779
                return $entry->getId() == 1;
780
        });*/
781
    }
782
783
    /**
784
     * Returns the list of classes for the user.
785
     *
786
     * @return string
787
     */
788
    public function getCompleteNameWithClasses()
789
    {
790
        $classSubscription = $this->getClasses();
791
        $classList = [];
792
        /** @var UsergroupRelUser $subscription */
793
        foreach ($classSubscription as $subscription) {
794
            $class = $subscription->getUsergroup();
795
            $classList[] = $class->getName();
796
        }
797
        $classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null;
798
799
        return \UserManager::formatUserFullName($this).$classString;
800
    }
801
802
    /**
803
     * Get userId.
804
     *
805
     * @return int
806
     */
807
    public function getUserId()
808
    {
809
        return $this->userId;
810
    }
811
812
    /**
813
     * Set lastname.
814
     *
815
     * @param string $lastname
816
     *
817
     * @return User
818
     */
819
    public function setLastname($lastname)
820
    {
821
        $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...
822
823
        return $this;
824
    }
825
826
    /**
827
     * Set firstname.
828
     *
829
     * @param string $firstname
830
     *
831
     * @return User
832
     */
833
    public function setFirstname($firstname)
834
    {
835
        $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...
836
837
        return $this;
838
    }
839
840
    /**
841
     * Set password.
842
     *
843
     * @param string $password
844
     *
845
     * @return User
846
     */
847
    public function setPassword($password)
848
    {
849
        $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...
850
851
        return $this;
852
    }
853
854
    /**
855
     * Get password.
856
     *
857
     * @return string
858
     */
859
    public function getPassword()
860
    {
861
        return $this->password;
862
    }
863
864
    /**
865
     * Set authSource.
866
     *
867
     * @param string $authSource
868
     *
869
     * @return User
870
     */
871
    public function setAuthSource($authSource)
872
    {
873
        $this->authSource = $authSource;
874
875
        return $this;
876
    }
877
878
    /**
879
     * Get authSource.
880
     *
881
     * @return string
882
     */
883
    public function getAuthSource()
884
    {
885
        return $this->authSource;
886
    }
887
888
    /**
889
     * Set email.
890
     *
891
     * @param string $email
892
     *
893
     * @return User
894
     */
895
    public function setEmail($email)
896
    {
897
        $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...
898
899
        return $this;
900
    }
901
902
    /**
903
     * Get email.
904
     *
905
     * @return string
906
     */
907
    public function getEmail()
908
    {
909
        return $this->email;
910
    }
911
912
    /**
913
     * Set status.
914
     *
915
     * @param int $status
916
     *
917
     * @return User
918
     */
919
    public function setStatus($status)
920
    {
921
        $this->status = $status;
922
923
        return $this;
924
    }
925
926
    /**
927
     * Get status.
928
     *
929
     * @return int
930
     */
931
    public function getStatus()
932
    {
933
        return $this->status;
934
    }
935
936
    /**
937
     * Set officialCode.
938
     *
939
     * @param string $officialCode
940
     *
941
     * @return User
942
     */
943
    public function setOfficialCode($officialCode)
944
    {
945
        $this->officialCode = $officialCode;
946
947
        return $this;
948
    }
949
950
    /**
951
     * Get officialCode.
952
     *
953
     * @return string
954
     */
955
    public function getOfficialCode()
956
    {
957
        return $this->officialCode;
958
    }
959
960
    /**
961
     * Set phone.
962
     *
963
     * @param string $phone
964
     *
965
     * @return User
966
     */
967
    public function setPhone($phone)
968
    {
969
        $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...
970
971
        return $this;
972
    }
973
974
    /**
975
     * Get phone.
976
     *
977
     * @return string
978
     */
979
    public function getPhone()
980
    {
981
        return $this->phone;
982
    }
983
984
    /**
985
     * Set address.
986
     *
987
     * @param string $address
988
     *
989
     * @return User
990
     */
991
    public function setAddress($address)
992
    {
993
        $this->address = $address;
994
995
        return $this;
996
    }
997
998
    /**
999
     * Get address.
1000
     *
1001
     * @return string
1002
     */
1003
    public function getAddress()
1004
    {
1005
        return $this->address;
1006
    }
1007
1008
    /**
1009
     * Set pictureUri.
1010
     *
1011
     * @param string $pictureUri
1012
     *
1013
     * @return User
1014
     */
1015
    public function setPictureUri($pictureUri)
1016
    {
1017
        $this->pictureUri = $pictureUri;
1018
1019
        return $this;
1020
    }
1021
1022
    /**
1023
     * Get pictureUri.
1024
     *
1025
     * @return Media
1026
     */
1027
    public function getPictureUri()
1028
    {
1029
        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...
1030
    }
1031
1032
    /**
1033
     * Set creatorId.
1034
     *
1035
     * @param int $creatorId
1036
     *
1037
     * @return User
1038
     */
1039
    public function setCreatorId($creatorId)
1040
    {
1041
        $this->creatorId = $creatorId;
1042
1043
        return $this;
1044
    }
1045
1046
    /**
1047
     * Get creatorId.
1048
     *
1049
     * @return int
1050
     */
1051
    public function getCreatorId()
1052
    {
1053
        return $this->creatorId;
1054
    }
1055
1056
    /**
1057
     * Set competences.
1058
     *
1059
     * @param string $competences
1060
     *
1061
     * @return User
1062
     */
1063
    public function setCompetences($competences)
1064
    {
1065
        $this->competences = $competences;
1066
1067
        return $this;
1068
    }
1069
1070
    /**
1071
     * Get competences.
1072
     *
1073
     * @return string
1074
     */
1075
    public function getCompetences()
1076
    {
1077
        return $this->competences;
1078
    }
1079
1080
    /**
1081
     * Set diplomas.
1082
     *
1083
     * @param string $diplomas
1084
     *
1085
     * @return User
1086
     */
1087
    public function setDiplomas($diplomas)
1088
    {
1089
        $this->diplomas = $diplomas;
1090
1091
        return $this;
1092
    }
1093
1094
    /**
1095
     * Get diplomas.
1096
     *
1097
     * @return string
1098
     */
1099
    public function getDiplomas()
1100
    {
1101
        return $this->diplomas;
1102
    }
1103
1104
    /**
1105
     * Set openarea.
1106
     *
1107
     * @param string $openarea
1108
     *
1109
     * @return User
1110
     */
1111
    public function setOpenarea($openarea)
1112
    {
1113
        $this->openarea = $openarea;
1114
1115
        return $this;
1116
    }
1117
1118
    /**
1119
     * Get openarea.
1120
     *
1121
     * @return string
1122
     */
1123
    public function getOpenarea()
1124
    {
1125
        return $this->openarea;
1126
    }
1127
1128
    /**
1129
     * Set teach.
1130
     *
1131
     * @param string $teach
1132
     *
1133
     * @return User
1134
     */
1135
    public function setTeach($teach)
1136
    {
1137
        $this->teach = $teach;
1138
1139
        return $this;
1140
    }
1141
1142
    /**
1143
     * Get teach.
1144
     *
1145
     * @return string
1146
     */
1147
    public function getTeach()
1148
    {
1149
        return $this->teach;
1150
    }
1151
1152
    /**
1153
     * Set productions.
1154
     *
1155
     * @param string $productions
1156
     *
1157
     * @return User
1158
     */
1159
    public function setProductions($productions)
1160
    {
1161
        $this->productions = $productions;
1162
1163
        return $this;
1164
    }
1165
1166
    /**
1167
     * Get productions.
1168
     *
1169
     * @return string
1170
     */
1171
    public function getProductions()
1172
    {
1173
        return $this->productions;
1174
    }
1175
1176
    /**
1177
     * Set language.
1178
     *
1179
     * @param string $language
1180
     *
1181
     * @return User
1182
     */
1183
    public function setLanguage($language)
1184
    {
1185
        $this->language = $language;
1186
1187
        return $this;
1188
    }
1189
1190
    /**
1191
     * Get language.
1192
     *
1193
     * @return string
1194
     */
1195
    public function getLanguage()
1196
    {
1197
        return $this->language;
1198
    }
1199
1200
    /**
1201
     * Set registrationDate.
1202
     *
1203
     * @param \DateTime $registrationDate
1204
     *
1205
     * @return User
1206
     */
1207
    public function setRegistrationDate($registrationDate)
1208
    {
1209
        $this->registrationDate = $registrationDate;
1210
1211
        return $this;
1212
    }
1213
1214
    /**
1215
     * Get registrationDate.
1216
     *
1217
     * @return \DateTime
1218
     */
1219
    public function getRegistrationDate()
1220
    {
1221
        return $this->registrationDate;
1222
    }
1223
1224
    /**
1225
     * Set expirationDate.
1226
     *
1227
     * @param \DateTime $expirationDate
1228
     *
1229
     * @return User
1230
     */
1231
    public function setExpirationDate($expirationDate)
1232
    {
1233
        $this->expirationDate = $expirationDate;
1234
1235
        return $this;
1236
    }
1237
1238
    /**
1239
     * Get expirationDate.
1240
     *
1241
     * @return \DateTime
1242
     */
1243
    public function getExpirationDate()
1244
    {
1245
        return $this->expirationDate;
1246
    }
1247
1248
    /**
1249
     * Set active.
1250
     *
1251
     * @param bool $active
1252
     *
1253
     * @return User
1254
     */
1255
    public function setActive($active)
1256
    {
1257
        $this->active = $active;
1258
1259
        return $this;
1260
    }
1261
1262
    /**
1263
     * Get active.
1264
     *
1265
     * @return bool
1266
     */
1267
    public function getActive()
1268
    {
1269
        return $this->active;
1270
    }
1271
1272
    /**
1273
     * Set openid.
1274
     *
1275
     * @param string $openid
1276
     *
1277
     * @return User
1278
     */
1279
    public function setOpenid($openid)
1280
    {
1281
        $this->openid = $openid;
1282
1283
        return $this;
1284
    }
1285
1286
    /**
1287
     * Get openid.
1288
     *
1289
     * @return string
1290
     */
1291
    public function getOpenid()
1292
    {
1293
        return $this->openid;
1294
    }
1295
1296
    /**
1297
     * Set theme.
1298
     *
1299
     * @param string $theme
1300
     *
1301
     * @return User
1302
     */
1303
    public function setTheme($theme)
1304
    {
1305
        $this->theme = $theme;
1306
1307
        return $this;
1308
    }
1309
1310
    /**
1311
     * Get theme.
1312
     *
1313
     * @return string
1314
     */
1315
    public function getTheme()
1316
    {
1317
        return $this->theme;
1318
    }
1319
1320
    /**
1321
     * Set hrDeptId.
1322
     *
1323
     * @param int $hrDeptId
1324
     *
1325
     * @return User
1326
     */
1327
    public function setHrDeptId($hrDeptId)
1328
    {
1329
        $this->hrDeptId = $hrDeptId;
1330
1331
        return $this;
1332
    }
1333
1334
    /**
1335
     * Get hrDeptId.
1336
     *
1337
     * @return int
1338
     */
1339
    public function getHrDeptId()
1340
    {
1341
        return $this->hrDeptId;
1342
    }
1343
1344
    /**
1345
     * @return Media
1346
     */
1347
    public function getAvatar()
1348
    {
1349
        return $this->getPictureUri();
1350
    }
1351
1352
    /**
1353
     * @param int $size
1354
     *
1355
     * @return string
1356
     */
1357
    public function getAvatarOrAnonymous($size = 22)
1358
    {
1359
        $avatar = $this->getAvatar();
1360
1361
        if (empty($avatar)) {
1362
            return "img/icons/$size/unknown.png";
1363
        }
1364
1365
        return $avatar;
1366
    }
1367
1368
    /**
1369
     * @return \DateTime
1370
     */
1371
    public function getMemberSince()
1372
    {
1373
        return $this->registrationDate;
1374
    }
1375
1376
    /**
1377
     * @return bool
1378
     */
1379
    public function isOnline()
1380
    {
1381
        return false;
1382
    }
1383
1384
    /**
1385
     * @return int
1386
     */
1387
    public function getIdentifier()
1388
    {
1389
        return $this->getId();
1390
    }
1391
1392
    /**
1393
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
1394
     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
1395
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
1396
     * must be able to accept an instance of 'File' as the bundle will inject one here
1397
     * during Doctrine hydration.
1398
     *
1399
     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
1400
     */
1401
    public function setImageFile(File $image)
1402
    {
1403
        $this->imageFile = $image;
1404
1405
        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...
1406
            // It is required that at least one field changes if you are using doctrine
1407
            // otherwise the event listeners won't be called and the file is lost
1408
            $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...
1409
        }
1410
    }
1411
1412
    /**
1413
     * @return File
1414
     */
1415
    public function getImageFile()
1416
    {
1417
        return $this->imageFile;
1418
    }
1419
1420
    /**
1421
     * @return string
1422
     */
1423
    public function getSlug()
1424
    {
1425
        return $this->getUsername();
1426
    }
1427
1428
    /**
1429
     * @param $slug
1430
     *
1431
     * @return User
1432
     */
1433
    public function setSlug($slug)
1434
    {
1435
        return $this->setUsername($slug);
1436
    }
1437
1438
    /**
1439
     * Set lastLogin.
1440
     *
1441
     * @param \DateTime $lastLogin
1442
     *
1443
     * @return User
1444
     */
1445
    public function setLastLogin(\DateTime $lastLogin = null)
1446
    {
1447
        $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...
1448
1449
        return $this;
1450
    }
1451
1452
    /**
1453
     * Get lastLogin.
1454
     *
1455
     * @return \DateTime
1456
     */
1457
    public function getLastLogin()
1458
    {
1459
        return $this->lastLogin;
1460
    }
1461
1462
    /**
1463
     * Get sessionCourseSubscription.
1464
     *
1465
     * @return ArrayCollection
1466
     */
1467
    public function getSessionCourseSubscriptions()
1468
    {
1469
        return $this->sessionCourseSubscriptions;
1470
    }
1471
1472
    /**
1473
     * @param $value
1474
     *
1475
     * @return $this
1476
     */
1477
    public function setSessionCourseSubscriptions($value)
1478
    {
1479
        $this->sessionCourseSubscriptions = $value;
1480
1481
        return $this;
1482
    }
1483
1484
    /**
1485
     * @return string
1486
     */
1487
    public function getConfirmationToken()
1488
    {
1489
        return $this->confirmationToken;
1490
    }
1491
1492
    /**
1493
     * @param string $confirmationToken
1494
     *
1495
     * @return User
1496
     */
1497
    public function setConfirmationToken($confirmationToken)
1498
    {
1499
        $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...
1500
1501
        return $this;
1502
    }
1503
1504
    /**
1505
     * @return \DateTime
1506
     */
1507
    public function getPasswordRequestedAt()
1508
    {
1509
        return $this->passwordRequestedAt;
1510
    }
1511
1512
    /**
1513
     * @param int $ttl
1514
     *
1515
     * @return bool
1516
     */
1517
    /*public function isPasswordRequestNonExpired($ttl)
1518
    {
1519
        return $this->getPasswordRequestedAt() instanceof \DateTime &&
1520
            $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time();
1521
    }*/
1522
1523
    public function getUsername()
1524
    {
1525
        return $this->username;
1526
    }
1527
1528
    /**
1529
     * Returns the expiration date.
1530
     *
1531
     * @return \DateTime|null
1532
     */
1533
    public function getExpiresAt()
1534
    {
1535
        return $this->expiresAt;
1536
    }
1537
1538
    /**
1539
     * Returns the credentials expiration date.
1540
     *
1541
     * @return \DateTime
1542
     */
1543
    public function getCredentialsExpireAt()
1544
    {
1545
        return $this->credentialsExpireAt;
1546
    }
1547
1548
    /**
1549
     * Sets the credentials expiration date.
1550
     *
1551
     * @param \DateTime|null $date
1552
     *
1553
     * @return User
1554
     */
1555
    public function setCredentialsExpireAt(\DateTime $date = null)
1556
    {
1557
        $this->credentialsExpireAt = $date;
1558
1559
        return $this;
1560
    }
1561
1562
    /**
1563
     * Sets the user groups.
1564
     *
1565
     * @param array $groups
1566
     *
1567
     * @return User
1568
     */
1569
    public function setGroups($groups)
1570
    {
1571
        foreach ($groups as $group) {
1572
            $this->addGroup($group);
1573
        }
1574
1575
        return $this;
1576
    }
1577
1578
    /**
1579
     * @return string
1580
     */
1581
    public function getFullname()
1582
    {
1583
        return sprintf('%s %s', $this->getFirstname(), $this->getLastname());
1584
    }
1585
1586
    /**
1587
     * Returns the user roles.
1588
     *
1589
     * @return array The roles
1590
     */
1591
    public function getRoles()
1592
    {
1593
        $roles = $this->roles;
1594
1595
        foreach ($this->getGroups() as $group) {
1596
            $roles = array_merge($roles, $group->getRoles());
1597
        }
1598
1599
        // we need to make sure to have at least one role
1600
        $roles[] = static::ROLE_DEFAULT;
1601
1602
        return array_unique($roles);
1603
    }
1604
1605
    public function isAccountNonExpired()
1606
    {
1607
        /*if (true === $this->expired) {
1608
            return false;
1609
        }
1610
1611
        if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) {
1612
            return false;
1613
        }*/
1614
1615
        return true;
1616
    }
1617
1618
    public function isAccountNonLocked()
1619
    {
1620
        return true;
1621
        //return !$this->locked;
1622
    }
1623
1624
    public function isCredentialsNonExpired()
1625
    {
1626
        /*if (true === $this->credentialsExpired) {
1627
            return false;
1628
        }
1629
1630
        if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) {
1631
            return false;
1632
        }*/
1633
1634
        return true;
1635
    }
1636
1637
    /**
1638
     * @return bool
1639
     */
1640
    public function getCredentialsExpired()
1641
    {
1642
        return $this->credentialsExpired;
1643
    }
1644
1645
    /**
1646
     * @param bool $boolean
1647
     *
1648
     * @return User
1649
     */
1650
    public function setCredentialsExpired($boolean)
1651
    {
1652
        $this->credentialsExpired = $boolean;
1653
1654
        return $this;
1655
    }
1656
1657
    /**
1658
     * @param $boolean
1659
     *
1660
     * @return $this|BaseUser
1661
     */
1662
    public function setEnabled($boolean)
1663
    {
1664
        $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...
1665
1666
        return $this;
1667
    }
1668
1669
    /**
1670
     * @return bool
1671
     */
1672
    public function getExpired()
1673
    {
1674
        return $this->expired;
1675
    }
1676
1677
    /**
1678
     * Sets this user to expired.
1679
     *
1680
     * @param bool $boolean
1681
     *
1682
     * @return User
1683
     */
1684
    public function setExpired($boolean)
1685
    {
1686
        $this->expired = (bool) $boolean;
1687
1688
        return $this;
1689
    }
1690
1691
    /**
1692
     * @param \DateTime $date
1693
     *
1694
     * @return User
1695
     */
1696
    public function setExpiresAt(\DateTime $date)
1697
    {
1698
        $this->expiresAt = $date;
1699
1700
        return $this;
1701
    }
1702
1703
    /**
1704
     * @return bool
1705
     */
1706
    public function getLocked(): bool
1707
    {
1708
        return $this->locked;
1709
    }
1710
1711
    /**
1712
     * @param $boolean
1713
     *
1714
     * @return $this
1715
     */
1716
    public function setLocked($boolean)
1717
    {
1718
        $this->locked = $boolean;
1719
1720
        return $this;
1721
    }
1722
1723
    /**
1724
     * @param array $roles
1725
     *
1726
     * @return $this
1727
     */
1728
    public function setRoles(array $roles)
1729
    {
1730
        $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...
1731
1732
        foreach ($roles as $role) {
1733
            $this->addRole($role);
1734
        }
1735
1736
        return $this;
1737
    }
1738
1739
    /**
1740
     * Get achievedSkills.
1741
     *
1742
     * @return ArrayCollection
1743
     */
1744
    public function getAchievedSkills()
1745
    {
1746
        return $this->achievedSkills;
1747
    }
1748
1749
    /**
1750
     * @param $value
1751
     *
1752
     * @return $this
1753
     */
1754
    public function setAchievedSkills($value)
1755
    {
1756
        $this->achievedSkills = $value;
1757
1758
        return $this;
1759
    }
1760
1761
    /**
1762
     * Check if the user has the skill.
1763
     *
1764
     * @param Skill $skill The skill
1765
     *
1766
     * @return bool
1767
     */
1768
    public function hasSkill(Skill $skill)
1769
    {
1770
        $achievedSkills = $this->getAchievedSkills();
1771
1772
        foreach ($achievedSkills as $userSkill) {
1773
            if ($userSkill->getSkill()->getId() !== $skill->getId()) {
1774
                continue;
1775
            }
1776
1777
            return true;
1778
        }
1779
    }
1780
1781
    /**
1782
     * @return bool
1783
     */
1784
    public function isProfileCompleted()
1785
    {
1786
        return $this->profileCompleted;
1787
    }
1788
1789
    /**
1790
     * @param mixed $profileCompleted
1791
     *
1792
     * @return User
1793
     */
1794
    public function setProfileCompleted($profileCompleted)
1795
    {
1796
        $this->profileCompleted = $profileCompleted;
1797
1798
        return $this;
1799
    }
1800
1801
    /**
1802
     * Sets the AccessUrl for the current user in memory.
1803
     *
1804
     * @param AccessUrl $url
1805
     *
1806
     * @return $this
1807
     */
1808
    public function setCurrentUrl(AccessUrl $url)
1809
    {
1810
        $urlList = $this->getPortals();
1811
        /** @var AccessUrlRelUser $item */
1812
        foreach ($urlList as $item) {
1813
            if ($item->getUrl()->getId() === $url->getId()) {
1814
                $this->currentUrl = $url;
1815
                break;
1816
            }
1817
        }
1818
1819
        return $this;
1820
    }
1821
1822
    /**
1823
     * @return AccessUrl
1824
     */
1825
    public function getCurrentUrl()
1826
    {
1827
        return $this->currentUrl;
1828
    }
1829
1830
    /**
1831
     * Get sessionAsGeneralCoach.
1832
     *
1833
     * @return ArrayCollection
1834
     */
1835
    public function getSessionAsGeneralCoach()
1836
    {
1837
        return $this->sessionAsGeneralCoach;
1838
    }
1839
1840
    /**
1841
     * Get sessionAsGeneralCoach.
1842
     *
1843
     * @param ArrayCollection $value
1844
     *
1845
     * @return $this
1846
     */
1847
    public function setSessionAsGeneralCoach($value)
1848
    {
1849
        $this->sessionAsGeneralCoach = $value;
1850
1851
        return $this;
1852
    }
1853
1854
    /**
1855
     * @return mixed
1856
     */
1857
    public function getCommentedUserSkills()
1858
    {
1859
        return $this->commentedUserSkills;
1860
    }
1861
1862
    /**
1863
     * @param mixed $commentedUserSkills
1864
     *
1865
     * @return User
1866
     */
1867
    public function setCommentedUserSkills($commentedUserSkills)
1868
    {
1869
        $this->commentedUserSkills = $commentedUserSkills;
1870
1871
        return $this;
1872
    }
1873
1874
    /**
1875
     * @param UserInterface $user
1876
     *
1877
     * @return bool
1878
     */
1879
    public function isEqualTo(UserInterface $user)
1880
    {
1881
        if ($this->password !== $user->getPassword()) {
1882
            return false;
1883
        }
1884
1885
        if ($this->salt !== $user->getSalt()) {
1886
            return false;
1887
        }
1888
1889
        if ($this->username !== $user->getUsername()) {
1890
            return false;
1891
        }
1892
1893
        return true;
1894
    }
1895
1896
    /**
1897
     * @return string
1898
     */
1899
    public function getPictureLegacy(): string
1900
    {
1901
        $id = $this->id;
1902
1903
        return 'users/'.substr((string) $id, 0, 1).'/'.$id.'/'.'small_'.$this->getPictureUri();
1904
    }
1905
1906
    /**
1907
     * Get sentMessages.
1908
     *
1909
     * @return ArrayCollection
1910
     */
1911
    public function getSentMessages()
1912
    {
1913
        return $this->sentMessages;
1914
    }
1915
1916
    /**
1917
     * Get receivedMessages.
1918
     *
1919
     * @return ArrayCollection
1920
     */
1921
    public function getReceivedMessages()
1922
    {
1923
        return $this->receivedMessages;
1924
    }
1925
}
1926