Passed
Push — master ( 5e8909...a4976f )
by Julito
12:52
created

User::postPersist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
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
    const COURSE_MANAGER = 1;
85
    const TEACHER = 1;
86
    const SESSION_ADMIN = 3;
87
    const DRH = 4;
88
    const STUDENT = 5;
89
    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
     */
299
    protected $portals;
300
301
    /**
302
     * @var ArrayCollection
303
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach")
304
     */
305
    protected $sessionAsGeneralCoach;
306
307
    /**
308
     * @var ArrayCollection
309
     *                      ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UserFieldValues", mappedBy="user", orphanRemoval=true, cascade={"persist"})
310
     */
311
    protected $extraFields;
312
313
    /**
314
     * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="creator").
315
     */
316
    protected $resourceNodes;
317
318
    /**
319
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", mappedBy="user", cascade={"persist"})
320
     */
321
    protected $sessionCourseSubscriptions;
322
323
    /**
324
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="user", cascade={"persist"})
325
     */
326
    protected $achievedSkills;
327
328
    /**
329
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", mappedBy="feedbackGiver")
330
     */
331
    protected $commentedUserSkills;
332
333
    /**
334
     * @var string
335
     *
336
     * @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false)
337
     */
338
    private $authSource;
339
340
    /**
341
     * @var int
342
     *
343
     * @ORM\Column(name="status", type="integer", nullable=false)
344
     */
345
    private $status;
346
347
    /**
348
     * @var string
349
     *
350
     * @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false)
351
     */
352
    private $officialCode;
353
354
    /**
355
     * @var string
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
     * Constructor.
453
     */
454
    public function __construct()
455
    {
456
        parent::__construct();
457
        $this->status = self::STUDENT;
458
        $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...
459
        $this->active = true;
460
        $this->registrationDate = new \DateTime();
461
        $this->authSource = 'platform';
462
        $this->courses = new ArrayCollection();
463
        //$this->items = new ArrayCollection();
464
        $this->classes = new ArrayCollection();
465
        $this->curriculumItems = new ArrayCollection();
466
        $this->portals = new ArrayCollection();
467
        $this->dropBoxSentFiles = new ArrayCollection();
468
        $this->dropBoxReceivedFiles = new ArrayCollection();
469
        //$this->extraFields = new ArrayCollection();
470
        //$this->userId = 0;
471
        //$this->createdAt = new \DateTime();
472
        //$this->updatedAt = new \DateTime();
473
474
        $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...
475
        $this->locked = false;
476
        $this->expired = false;
477
        $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...
478
        $this->credentialsExpired = false;
479
    }
480
481
    /**
482
     * @return string
483
     */
484
    public function __toString()
485
    {
486
        return $this->getCompleteName();
487
    }
488
489
    /**
490
     * Updates the id with the user_id.
491
     *
492
     * @ORM\PostPersist()
493
     *
494
     * @param LifecycleEventArgs $args
495
     */
496
    public function postPersist(LifecycleEventArgs $args)
497
    {
498
        $user = $args->getEntity();
499
        $this->setUserId($user->getId());
500
    }
501
502
    /**
503
     * @param int $userId
504
     */
505
    public function setId($userId)
506
    {
507
        $this->id = $userId;
508
    }
509
510
    /**
511
     * @param int $userId
512
     */
513
    public function setUserId($userId)
514
    {
515
        if (!empty($userId)) {
516
            $this->userId = $userId;
517
        }
518
    }
519
520
    /**
521
     * @return int
522
     */
523
    public function getId()
524
    {
525
        return $this->id;
526
    }
527
528
    /**
529
     * @return ArrayCollection
530
     */
531
    public function getDropBoxSentFiles()
532
    {
533
        return $this->dropBoxSentFiles;
534
    }
535
536
    /**
537
     * @return ArrayCollection
538
     */
539
    public function getDropBoxReceivedFiles()
540
    {
541
        return $this->dropBoxReceivedFiles;
542
    }
543
544
    /**
545
     * @return ArrayCollection
546
     */
547
    public function getCourses()
548
    {
549
        return $this->courses;
550
    }
551
552
    /**
553
     * @return array
554
     */
555
    public static function getPasswordConstraints()
556
    {
557
        return
558
            [
559
                new Assert\Length(['min' => 5]),
560
                // Alpha numeric + "_" or "-"
561
                new Assert\Regex(
562
                    [
563
                        'pattern' => '/^[a-z\-_0-9]+$/i',
564
                        'htmlPattern' => '/^[a-z\-_0-9]+$/i', ]
565
                ),
566
                // Min 3 letters - not needed
567
                /*new Assert\Regex(array(
568
                    'pattern' => '/[a-z]{3}/i',
569
                    'htmlPattern' => '/[a-z]{3}/i')
570
                ),*/
571
                // Min 2 numbers
572
                new Assert\Regex(
573
                    [
574
                        'pattern' => '/[0-9]{2}/',
575
                        'htmlPattern' => '/[0-9]{2}/', ]
576
                ),
577
            ]
578
            ;
579
    }
580
581
    /**
582
     * @param ClassMetadata $metadata
583
     */
584
    public static function loadValidatorMetadata(ClassMetadata $metadata)
585
    {
586
        //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank());
587
        //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank());
588
        //$metadata->addPropertyConstraint('email', new Assert\Email());
589
        /*
590
        $metadata->addPropertyConstraint('password',
591
            new Assert\Collection(self::getPasswordConstraints())
592
        );*/
593
594
        /*$metadata->addConstraint(new UniqueEntity(array(
595
            'fields'  => 'username',
596
            'message' => 'This value is already used.',
597
        )));*/
598
599
        /*$metadata->addPropertyConstraint(
600
            'username',
601
            new Assert\Length(array(
602
                'min'        => 2,
603
                'max'        => 50,
604
                '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.',
605
                '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.',
606
            ))
607
        );*/
608
    }
609
610
    /**
611
     * @return ArrayCollection
612
     */
613
    public function getPortals()
614
    {
615
        return $this->portals;
616
    }
617
618
    /**
619
     * @param $portal
620
     */
621
    public function setPortal($portal)
622
    {
623
        $this->portals->add($portal);
624
    }
625
626
    /**
627
     * @return ArrayCollection
628
     */
629
    public function getCurriculumItems()
630
    {
631
        return $this->curriculumItems;
632
    }
633
634
    /**
635
     * @param $items
636
     */
637
    public function setCurriculumItems($items)
638
    {
639
        $this->curriculumItems = $items;
640
    }
641
642
    /**
643
     * @return bool
644
     */
645
    public function getIsActive()
646
    {
647
        return $this->active == 1;
648
    }
649
650
    /**
651
     * @return bool
652
     */
653
    public function isActive()
654
    {
655
        return $this->getIsActive();
656
    }
657
658
    /**
659
     * {@inheritdoc}
660
     */
661
    public function isEnabled()
662
    {
663
        return $this->getActive() == 1;
664
    }
665
666
    /**
667
     * @return ArrayCollection
668
     */
669
    /*public function getRolesObj()
670
    {
671
        return $this->roles;
672
    }*/
673
674
    /**
675
     * Set salt.
676
     *
677
     * @param string $salt
678
     *
679
     * @return User
680
     */
681
    public function setSalt($salt)
682
    {
683
        $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...
684
685
        return $this;
686
    }
687
688
    /**
689
     * Get salt.
690
     *
691
     * @return string
692
     */
693
    public function getSalt()
694
    {
695
        return $this->salt;
696
    }
697
698
    /**
699
     * @return ArrayCollection
700
     */
701
    public function getClasses()
702
    {
703
        return $this->classes;
704
    }
705
706
    public function getLps()
707
    {
708
        //return $this->lps;
709
        /*$criteria = Criteria::create()
710
            ->where(Criteria::expr()->eq("id", "666"))
711
            //->orderBy(array("username" => "ASC"))
712
            //->setFirstResult(0)
713
            //->setMaxResults(20)
714
        ;
715
        $lps = $this->lps->matching($criteria);*/
716
        /*return $this->lps->filter(
717
            function($entry) use ($idsToFilter) {
718
                return $entry->getId() == 1;
719
        });*/
720
    }
721
722
    /**
723
     * Return Complete Name with the Username.
724
     *
725
     * @return string
726
     */
727
    public function getCompleteNameWithUsername()
728
    {
729
        return api_get_person_name($this->firstname, $this->lastname).' ('.$this->username.')';
730
    }
731
732
    /**
733
     * @todo don't use api_get_person_name
734
     *
735
     * @return string
736
     */
737
    public function getCompleteName()
738
    {
739
        return api_get_person_name($this->firstname, $this->lastname);
740
    }
741
742
    /**
743
     * Returns the list of classes for the user.
744
     *
745
     * @return string
746
     */
747
    public function getCompleteNameWithClasses()
748
    {
749
        $classSubscription = $this->getClasses();
750
        $classList = [];
751
        /** @var UsergroupRelUser $subscription */
752
        foreach ($classSubscription as $subscription) {
753
            $class = $subscription->getUsergroup();
754
            $classList[] = $class->getName();
755
        }
756
        $classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null;
757
758
        return $this->getCompleteName().$classString;
759
    }
760
761
    /**
762
     * Get userId.
763
     *
764
     * @return int
765
     */
766
    public function getUserId()
767
    {
768
        return $this->userId;
769
    }
770
771
    /**
772
     * Set lastname.
773
     *
774
     * @param string $lastname
775
     *
776
     * @return User
777
     */
778
    public function setLastname($lastname)
779
    {
780
        $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...
781
782
        return $this;
783
    }
784
785
    /**
786
     * Set firstname.
787
     *
788
     * @param string $firstname
789
     *
790
     * @return User
791
     */
792
    public function setFirstname($firstname)
793
    {
794
        $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...
795
796
        return $this;
797
    }
798
799
    /**
800
     * Set password.
801
     *
802
     * @param string $password
803
     *
804
     * @return User
805
     */
806
    public function setPassword($password)
807
    {
808
        $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...
809
810
        return $this;
811
    }
812
813
    /**
814
     * Get password.
815
     *
816
     * @return string
817
     */
818
    public function getPassword()
819
    {
820
        return $this->password;
821
    }
822
823
    /**
824
     * Set authSource.
825
     *
826
     * @param string $authSource
827
     *
828
     * @return User
829
     */
830
    public function setAuthSource($authSource)
831
    {
832
        $this->authSource = $authSource;
833
834
        return $this;
835
    }
836
837
    /**
838
     * Get authSource.
839
     *
840
     * @return string
841
     */
842
    public function getAuthSource()
843
    {
844
        return $this->authSource;
845
    }
846
847
    /**
848
     * Set email.
849
     *
850
     * @param string $email
851
     *
852
     * @return User
853
     */
854
    public function setEmail($email)
855
    {
856
        $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...
857
858
        return $this;
859
    }
860
861
    /**
862
     * Get email.
863
     *
864
     * @return string
865
     */
866
    public function getEmail()
867
    {
868
        return $this->email;
869
    }
870
871
    /**
872
     * Set status.
873
     *
874
     * @param int $status
875
     *
876
     * @return User
877
     */
878
    public function setStatus($status)
879
    {
880
        $this->status = $status;
881
882
        return $this;
883
    }
884
885
    /**
886
     * Get status.
887
     *
888
     * @return int
889
     */
890
    public function getStatus()
891
    {
892
        return $this->status;
893
    }
894
895
    /**
896
     * Set officialCode.
897
     *
898
     * @param string $officialCode
899
     *
900
     * @return User
901
     */
902
    public function setOfficialCode($officialCode)
903
    {
904
        $this->officialCode = $officialCode;
905
906
        return $this;
907
    }
908
909
    /**
910
     * Get officialCode.
911
     *
912
     * @return string
913
     */
914
    public function getOfficialCode()
915
    {
916
        return $this->officialCode;
917
    }
918
919
    /**
920
     * Set phone.
921
     *
922
     * @param string $phone
923
     *
924
     * @return User
925
     */
926
    public function setPhone($phone)
927
    {
928
        $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...
929
930
        return $this;
931
    }
932
933
    /**
934
     * Get phone.
935
     *
936
     * @return string
937
     */
938
    public function getPhone()
939
    {
940
        return $this->phone;
941
    }
942
943
    /**
944
     * Set address.
945
     *
946
     * @param string $address
947
     *
948
     * @return User
949
     */
950
    public function setAddress($address)
951
    {
952
        $this->address = $address;
953
954
        return $this;
955
    }
956
957
    /**
958
     * Get address.
959
     *
960
     * @return string
961
     */
962
    public function getAddress()
963
    {
964
        return $this->address;
965
    }
966
967
    /**
968
     * Set pictureUri.
969
     *
970
     * @param string $pictureUri
971
     *
972
     * @return User
973
     */
974
    public function setPictureUri($pictureUri)
975
    {
976
        $this->pictureUri = $pictureUri;
977
978
        return $this;
979
    }
980
981
    /**
982
     * Get pictureUri.
983
     *
984
     * @return Media
985
     */
986
    public function getPictureUri()
987
    {
988
        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...
989
    }
990
991
    /**
992
     * Set creatorId.
993
     *
994
     * @param int $creatorId
995
     *
996
     * @return User
997
     */
998
    public function setCreatorId($creatorId)
999
    {
1000
        $this->creatorId = $creatorId;
1001
1002
        return $this;
1003
    }
1004
1005
    /**
1006
     * Get creatorId.
1007
     *
1008
     * @return int
1009
     */
1010
    public function getCreatorId()
1011
    {
1012
        return $this->creatorId;
1013
    }
1014
1015
    /**
1016
     * Set competences.
1017
     *
1018
     * @param string $competences
1019
     *
1020
     * @return User
1021
     */
1022
    public function setCompetences($competences)
1023
    {
1024
        $this->competences = $competences;
1025
1026
        return $this;
1027
    }
1028
1029
    /**
1030
     * Get competences.
1031
     *
1032
     * @return string
1033
     */
1034
    public function getCompetences()
1035
    {
1036
        return $this->competences;
1037
    }
1038
1039
    /**
1040
     * Set diplomas.
1041
     *
1042
     * @param string $diplomas
1043
     *
1044
     * @return User
1045
     */
1046
    public function setDiplomas($diplomas)
1047
    {
1048
        $this->diplomas = $diplomas;
1049
1050
        return $this;
1051
    }
1052
1053
    /**
1054
     * Get diplomas.
1055
     *
1056
     * @return string
1057
     */
1058
    public function getDiplomas()
1059
    {
1060
        return $this->diplomas;
1061
    }
1062
1063
    /**
1064
     * Set openarea.
1065
     *
1066
     * @param string $openarea
1067
     *
1068
     * @return User
1069
     */
1070
    public function setOpenarea($openarea)
1071
    {
1072
        $this->openarea = $openarea;
1073
1074
        return $this;
1075
    }
1076
1077
    /**
1078
     * Get openarea.
1079
     *
1080
     * @return string
1081
     */
1082
    public function getOpenarea()
1083
    {
1084
        return $this->openarea;
1085
    }
1086
1087
    /**
1088
     * Set teach.
1089
     *
1090
     * @param string $teach
1091
     *
1092
     * @return User
1093
     */
1094
    public function setTeach($teach)
1095
    {
1096
        $this->teach = $teach;
1097
1098
        return $this;
1099
    }
1100
1101
    /**
1102
     * Get teach.
1103
     *
1104
     * @return string
1105
     */
1106
    public function getTeach()
1107
    {
1108
        return $this->teach;
1109
    }
1110
1111
    /**
1112
     * Set productions.
1113
     *
1114
     * @param string $productions
1115
     *
1116
     * @return User
1117
     */
1118
    public function setProductions($productions)
1119
    {
1120
        $this->productions = $productions;
1121
1122
        return $this;
1123
    }
1124
1125
    /**
1126
     * Get productions.
1127
     *
1128
     * @return string
1129
     */
1130
    public function getProductions()
1131
    {
1132
        return $this->productions;
1133
    }
1134
1135
    /**
1136
     * Set language.
1137
     *
1138
     * @param string $language
1139
     *
1140
     * @return User
1141
     */
1142
    public function setLanguage($language)
1143
    {
1144
        $this->language = $language;
1145
1146
        return $this;
1147
    }
1148
1149
    /**
1150
     * Get language.
1151
     *
1152
     * @return string
1153
     */
1154
    public function getLanguage()
1155
    {
1156
        return $this->language;
1157
    }
1158
1159
    /**
1160
     * Set registrationDate.
1161
     *
1162
     * @param \DateTime $registrationDate
1163
     *
1164
     * @return User
1165
     */
1166
    public function setRegistrationDate($registrationDate)
1167
    {
1168
        $this->registrationDate = $registrationDate;
1169
1170
        return $this;
1171
    }
1172
1173
    /**
1174
     * Get registrationDate.
1175
     *
1176
     * @return \DateTime
1177
     */
1178
    public function getRegistrationDate()
1179
    {
1180
        return $this->registrationDate;
1181
    }
1182
1183
    /**
1184
     * Set expirationDate.
1185
     *
1186
     * @param \DateTime $expirationDate
1187
     *
1188
     * @return User
1189
     */
1190
    public function setExpirationDate($expirationDate)
1191
    {
1192
        $this->expirationDate = $expirationDate;
1193
1194
        return $this;
1195
    }
1196
1197
    /**
1198
     * Get expirationDate.
1199
     *
1200
     * @return \DateTime
1201
     */
1202
    public function getExpirationDate()
1203
    {
1204
        return $this->expirationDate;
1205
    }
1206
1207
    /**
1208
     * Set active.
1209
     *
1210
     * @param bool $active
1211
     *
1212
     * @return User
1213
     */
1214
    public function setActive($active)
1215
    {
1216
        $this->active = $active;
1217
1218
        return $this;
1219
    }
1220
1221
    /**
1222
     * Get active.
1223
     *
1224
     * @return bool
1225
     */
1226
    public function getActive()
1227
    {
1228
        return $this->active;
1229
    }
1230
1231
    /**
1232
     * Set openid.
1233
     *
1234
     * @param string $openid
1235
     *
1236
     * @return User
1237
     */
1238
    public function setOpenid($openid)
1239
    {
1240
        $this->openid = $openid;
1241
1242
        return $this;
1243
    }
1244
1245
    /**
1246
     * Get openid.
1247
     *
1248
     * @return string
1249
     */
1250
    public function getOpenid()
1251
    {
1252
        return $this->openid;
1253
    }
1254
1255
    /**
1256
     * Set theme.
1257
     *
1258
     * @param string $theme
1259
     *
1260
     * @return User
1261
     */
1262
    public function setTheme($theme)
1263
    {
1264
        $this->theme = $theme;
1265
1266
        return $this;
1267
    }
1268
1269
    /**
1270
     * Get theme.
1271
     *
1272
     * @return string
1273
     */
1274
    public function getTheme()
1275
    {
1276
        return $this->theme;
1277
    }
1278
1279
    /**
1280
     * Set hrDeptId.
1281
     *
1282
     * @param int $hrDeptId
1283
     *
1284
     * @return User
1285
     */
1286
    public function setHrDeptId($hrDeptId)
1287
    {
1288
        $this->hrDeptId = $hrDeptId;
1289
1290
        return $this;
1291
    }
1292
1293
    /**
1294
     * Get hrDeptId.
1295
     *
1296
     * @return int
1297
     */
1298
    public function getHrDeptId()
1299
    {
1300
        return $this->hrDeptId;
1301
    }
1302
1303
    /**
1304
     * @return Media
1305
     */
1306
    public function getAvatar()
1307
    {
1308
        return $this->getPictureUri();
1309
    }
1310
1311
    /**
1312
     * @param int $size
1313
     *
1314
     * @return string
1315
     */
1316
    public function getAvatarOrAnonymous($size = 22)
1317
    {
1318
        $avatar = $this->getAvatar();
1319
1320
        if (empty($avatar)) {
1321
            return "img/icons/$size/unknown.png";
1322
        }
1323
1324
        return $avatar;
1325
    }
1326
1327
    /**
1328
     * @return \DateTime
1329
     */
1330
    public function getMemberSince()
1331
    {
1332
        return $this->registrationDate;
1333
    }
1334
1335
    /**
1336
     * @return bool
1337
     */
1338
    public function isOnline()
1339
    {
1340
        return false;
1341
    }
1342
1343
    /**
1344
     * @return int
1345
     */
1346
    public function getIdentifier()
1347
    {
1348
        return $this->getId();
1349
    }
1350
1351
    /**
1352
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
1353
     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
1354
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
1355
     * must be able to accept an instance of 'File' as the bundle will inject one here
1356
     * during Doctrine hydration.
1357
     *
1358
     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
1359
     */
1360
    public function setImageFile(File $image)
1361
    {
1362
        $this->imageFile = $image;
1363
1364
        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...
1365
            // It is required that at least one field changes if you are using doctrine
1366
            // otherwise the event listeners won't be called and the file is lost
1367
            $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...
1368
        }
1369
    }
1370
1371
    /**
1372
     * @return File
1373
     */
1374
    public function getImageFile()
1375
    {
1376
        return $this->imageFile;
1377
    }
1378
1379
    /**
1380
     * @param string $imageName
1381
     */
1382
    public function setImageName($imageName)
1383
    {
1384
        $this->imageName = $imageName;
0 ignored issues
show
Bug Best Practice introduced by
The property imageName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1385
    }
1386
1387
    /**
1388
     * @return string
1389
     */
1390
    public function getImageName()
1391
    {
1392
        return $this->imageName;
1393
    }
1394
1395
    /**
1396
     * @return string
1397
     */
1398
    public function getSlug()
1399
    {
1400
        return $this->getUsername();
1401
    }
1402
1403
    /**
1404
     * @param $slug
1405
     *
1406
     * @return User
1407
     */
1408
    public function setSlug($slug)
1409
    {
1410
        return $this->setUsername($slug);
1411
    }
1412
1413
    /**
1414
     * Set lastLogin.
1415
     *
1416
     * @param \DateTime $lastLogin
1417
     *
1418
     * @return User
1419
     */
1420
    public function setLastLogin(\DateTime $lastLogin = null)
1421
    {
1422
        $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...
1423
1424
        return $this;
1425
    }
1426
1427
    /**
1428
     * Get lastLogin.
1429
     *
1430
     * @return \DateTime
1431
     */
1432
    public function getLastLogin()
1433
    {
1434
        return $this->lastLogin;
1435
    }
1436
1437
    /**
1438
     * {@inheritdoc}
1439
     */
1440
    public function getExtraFields()
1441
    {
1442
        return $this->extraFields;
1443
    }
1444
1445
    /**
1446
     * {@inheritdoc}
1447
     */
1448
    public function setExtraFields($extraFields)
1449
    {
1450
        $this->extraFields = new ArrayCollection();
1451
        foreach ($extraFields as $extraField) {
1452
            $this->addExtraFields($extraField);
1453
        }
1454
1455
        return $this;
1456
    }
1457
1458
    /**
1459
     * {@inheritdoc}
1460
     */
1461
    /*public function addExtraFields(ExtraFieldValues $extraFieldValue)
1462
    {
1463
        $extraFieldValue->setUser($this);
1464
        $this->extraFields[] = $extraFieldValue;
1465
1466
        return $this;
1467
    }*/
1468
1469
    /**
1470
     * {@inheritdoc}
1471
     */
1472
    public function addExtraFields(ExtraFieldValues $extraFieldValue)
1473
    {
1474
        //if (!$this->hasExtraField($attribute)) {
1475
        $extraFieldValue->setUser($this);
0 ignored issues
show
Bug introduced by
The method setUser() does not exist on Chamilo\CoreBundle\Entity\ExtraFieldValues. ( Ignorable by Annotation )

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

1475
        $extraFieldValue->/** @scrutinizer ignore-call */ 
1476
                          setUser($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1476
        $this->extraFields[] = $extraFieldValue;
1477
        //}
1478
1479
        return $this;
1480
    }
1481
1482
    /**
1483
     * {@inheritdoc}
1484
     */
1485
    public function removeExtraField(ExtraFieldValues $attribute)
1486
    {
1487
        //if ($this->hasExtraField($attribute)) {
1488
        //$this->extraFields->removeElement($attribute);
1489
        //$attribute->setUser($this);
1490
        //}
1491
1492
        return $this;
1493
    }
1494
1495
    /**
1496
     * {@inheritdoc}
1497
     */
1498
    /*public function hasExtraField($attribute)
1499
    {
1500
        if (!$this->extraFields) {
1501
            return false;
1502
        }
1503
        return $this->extraFields->contains($attribute);
1504
    }*/
1505
1506
    /**
1507
     * {@inheritdoc}
1508
     */
1509
    public function hasExtraFieldByName($attributeName)
1510
    {
1511
        foreach ($this->extraFields as $attribute) {
1512
            if ($attribute->getName() === $attributeName) {
1513
                return true;
1514
            }
1515
        }
1516
1517
        return false;
1518
    }
1519
1520
    /**
1521
     * {@inheritdoc}
1522
     */
1523
    public function getExtraFieldByName($attributeName)
1524
    {
1525
        foreach ($this->extraFields as $attribute) {
1526
            if ($attribute->getName() === $attributeName) {
1527
                return $attribute;
1528
            }
1529
        }
1530
1531
        return null;
1532
    }
1533
1534
    /**
1535
     * Get sessionCourseSubscription.
1536
     *
1537
     * @return ArrayCollection
1538
     */
1539
    public function getSessionCourseSubscriptions()
1540
    {
1541
        return $this->sessionCourseSubscriptions;
1542
    }
1543
1544
    /**
1545
     * @return string
1546
     */
1547
    public function getConfirmationToken()
1548
    {
1549
        return $this->confirmationToken;
1550
    }
1551
1552
    /**
1553
     * @param string $confirmationToken
1554
     *
1555
     * @return User
1556
     */
1557
    public function setConfirmationToken($confirmationToken)
1558
    {
1559
        $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...
1560
1561
        return $this;
1562
    }
1563
1564
    /**
1565
     * @return \DateTime
1566
     */
1567
    public function getPasswordRequestedAt()
1568
    {
1569
        return $this->passwordRequestedAt;
1570
    }
1571
1572
    /**
1573
     * @param int $ttl
1574
     *
1575
     * @return bool
1576
     */
1577
    /*public function isPasswordRequestNonExpired($ttl)
1578
    {
1579
        return $this->getPasswordRequestedAt() instanceof \DateTime &&
1580
            $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time();
1581
    }*/
1582
1583
    public function getUsername()
1584
    {
1585
        return $this->username;
1586
    }
1587
1588
    /**
1589
     * Returns the expiration date.
1590
     *
1591
     * @return \DateTime|null
1592
     */
1593
    public function getExpiresAt()
1594
    {
1595
        return $this->expiresAt;
1596
    }
1597
1598
    /**
1599
     * Returns the credentials expiration date.
1600
     *
1601
     * @return \DateTime
1602
     */
1603
    public function getCredentialsExpireAt()
1604
    {
1605
        return $this->credentialsExpireAt;
1606
    }
1607
1608
    /**
1609
     * Sets the credentials expiration date.
1610
     *
1611
     * @param \DateTime|null $date
1612
     *
1613
     * @return User
1614
     */
1615
    public function setCredentialsExpireAt(\DateTime $date = null)
1616
    {
1617
        $this->credentialsExpireAt = $date;
1618
1619
        return $this;
1620
    }
1621
1622
    /**
1623
     * Sets the user groups.
1624
     *
1625
     * @param array $groups
1626
     *
1627
     * @return User
1628
     */
1629
    public function setGroups($groups)
1630
    {
1631
        foreach ($groups as $group) {
1632
            $this->addGroup($group);
1633
        }
1634
1635
        return $this;
1636
    }
1637
1638
    /**
1639
     * @return string
1640
     */
1641
    public function getFullname()
1642
    {
1643
        return sprintf('%s %s', $this->getFirstname(), $this->getLastname());
1644
    }
1645
1646
    /**
1647
     * Returns the user roles.
1648
     *
1649
     * @return array The roles
1650
     */
1651
    public function getRoles()
1652
    {
1653
        $roles = $this->roles;
1654
1655
        foreach ($this->getGroups() as $group) {
1656
            $roles = array_merge($roles, $group->getRoles());
1657
        }
1658
1659
        // we need to make sure to have at least one role
1660
        $roles[] = static::ROLE_DEFAULT;
1661
1662
        return array_unique($roles);
1663
    }
1664
1665
    public function isAccountNonExpired()
1666
    {
1667
        /*if (true === $this->expired) {
1668
            return false;
1669
        }
1670
1671
        if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) {
1672
            return false;
1673
        }*/
1674
1675
        return true;
1676
    }
1677
1678
    public function isAccountNonLocked()
1679
    {
1680
        return true;
1681
        //return !$this->locked;
1682
    }
1683
1684
    public function isCredentialsNonExpired()
1685
    {
1686
        /*if (true === $this->credentialsExpired) {
1687
            return false;
1688
        }
1689
1690
        if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) {
1691
            return false;
1692
        }*/
1693
1694
        return true;
1695
    }
1696
1697
    /**
1698
     * @param bool $boolean
1699
     *
1700
     * @return User
1701
     */
1702
    public function setCredentialsExpired($boolean)
1703
    {
1704
        $this->credentialsExpired = $boolean;
1705
1706
        return $this;
1707
    }
1708
1709
    public function setEnabled($boolean)
1710
    {
1711
        $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...
1712
1713
        return $this;
1714
    }
1715
1716
    /**
1717
     * Sets this user to expired.
1718
     *
1719
     * @param bool $boolean
1720
     *
1721
     * @return User
1722
     */
1723
    public function setExpired($boolean)
1724
    {
1725
        $this->expired = (bool) $boolean;
1726
1727
        return $this;
1728
    }
1729
1730
    /**
1731
     * @param \DateTime $date
1732
     *
1733
     * @return User
1734
     */
1735
    public function setExpiresAt(\DateTime $date)
1736
    {
1737
        $this->expiresAt = $date;
1738
1739
        return $this;
1740
    }
1741
1742
    public function setLocked($boolean)
1743
    {
1744
        $this->locked = $boolean;
1745
1746
        return $this;
1747
    }
1748
1749
    public function setRoles(array $roles)
1750
    {
1751
        $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...
1752
1753
        foreach ($roles as $role) {
1754
            $this->addRole($role);
1755
        }
1756
1757
        return $this;
1758
    }
1759
1760
    /**
1761
     * Get achievedSkills.
1762
     *
1763
     * @return ArrayCollection
1764
     */
1765
    public function getAchievedSkills()
1766
    {
1767
        return $this->achievedSkills;
1768
    }
1769
1770
    /**
1771
     * Check if the user has the skill.
1772
     *
1773
     * @param Skill $skill The skill
1774
     *
1775
     * @return bool
1776
     */
1777
    public function hasSkill(Skill $skill)
1778
    {
1779
        $achievedSkills = $this->getAchievedSkills();
1780
1781
        foreach ($achievedSkills as $userSkill) {
1782
            if ($userSkill->getSkill()->getId() !== $skill->getId()) {
1783
                continue;
1784
            }
1785
1786
            return true;
1787
        }
1788
    }
1789
1790
    /**
1791
     * @return bool
1792
     */
1793
    public function isProfileCompleted()
1794
    {
1795
        return $this->profileCompleted;
1796
    }
1797
1798
    /**
1799
     * @param mixed $profileCompleted
1800
     *
1801
     * @return User
1802
     */
1803
    public function setProfileCompleted($profileCompleted)
1804
    {
1805
        $this->profileCompleted = $profileCompleted;
1806
1807
        return $this;
1808
    }
1809
1810
    /**
1811
     * Sets the AccessUrl for the current user in memory.
1812
     *
1813
     * @param AccessUrl $url
1814
     *
1815
     * @return $this
1816
     */
1817
    public function setCurrentUrl(AccessUrl $url)
1818
    {
1819
        $urlList = $this->getPortals();
1820
        /** @var AccessUrlRelUser $item */
1821
        foreach ($urlList as $item) {
1822
            if ($item->getPortal()->getId() == $url->getId()) {
1823
                $this->currentUrl = $url;
1824
                break;
1825
            }
1826
        }
1827
1828
        return $this;
1829
    }
1830
1831
    /**
1832
     * @return AccessUrl
1833
     */
1834
    public function getCurrentUrl()
1835
    {
1836
        return $this->currentUrl;
1837
    }
1838
1839
    /**
1840
     * Get sessionAsGeneralCoach.
1841
     *
1842
     * @return ArrayCollection
1843
     */
1844
    public function getSessionAsGeneralCoach()
1845
    {
1846
        return $this->sessionAsGeneralCoach;
1847
    }
1848
1849
    /**
1850
     * @param UserInterface $user
1851
     *
1852
     * @return bool
1853
     */
1854
    public function isEqualTo(UserInterface $user)
1855
    {
1856
        if ($this->password !== $user->getPassword()) {
1857
            return false;
1858
        }
1859
1860
        if ($this->salt !== $user->getSalt()) {
1861
            return false;
1862
        }
1863
1864
        if ($this->username !== $user->getUsername()) {
1865
            return false;
1866
        }
1867
1868
        return true;
1869
    }
1870
1871
1872
    /**
1873
     * @return string
1874
     */
1875
    public function getPictureLegacy()
1876
    {
1877
        $id = $this->id;
1878
1879
        return 'users/'.substr((string) $id, 0, 1).'/'.$id.'/'.'small_'.$this->getPictureUri();
1880
    }
1881
}
1882